compressed.isa revision 13931
16145Snate@binkert.org// -*- mode:c++ -*- 26145Snate@binkert.org 36145Snate@binkert.org// Copyright (c) 2015 RISC-V Foundation 46145Snate@binkert.org// Copyright (c) 2017 The University of Virginia 56145Snate@binkert.org// All rights reserved. 66145Snate@binkert.org// 76145Snate@binkert.org// Redistribution and use in source and binary forms, with or without 86145Snate@binkert.org// modification, are permitted provided that the following conditions are 96145Snate@binkert.org// met: redistributions of source code must retain the above copyright 106145Snate@binkert.org// notice, this list of conditions and the following disclaimer; 116145Snate@binkert.org// redistributions in binary form must reproduce the above copyright 126145Snate@binkert.org// notice, this list of conditions and the following disclaimer in the 136145Snate@binkert.org// documentation and/or other materials provided with the distribution; 146145Snate@binkert.org// neither the name of the copyright holders nor the names of its 156145Snate@binkert.org// contributors may be used to endorse or promote products derived from 166145Snate@binkert.org// this software without specific prior written permission. 176145Snate@binkert.org// 186145Snate@binkert.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 196145Snate@binkert.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 206145Snate@binkert.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 216145Snate@binkert.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 226145Snate@binkert.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 236145Snate@binkert.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 246145Snate@binkert.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 256145Snate@binkert.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 266145Snate@binkert.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 276145Snate@binkert.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 286145Snate@binkert.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 296145Snate@binkert.org// 307039Snate@binkert.org// Authors: Alec Roelke 317039Snate@binkert.orgdef format CROp(code, *opt_flags) {{ 327039Snate@binkert.org iop = InstObjParams(name, Name, 'CompRegOp', code, opt_flags) 336145Snate@binkert.org header_output = BasicDeclare.subst(iop) 346145Snate@binkert.org decoder_output = BasicConstructor.subst(iop) 357039Snate@binkert.org decode_block = BasicDecode.subst(iop) 367039Snate@binkert.org exec_output = BasicExecute.subst(iop) 376145Snate@binkert.org}}; 387002Snate@binkert.org 397021Stushar@csail.mit.edudef format CIOp(imm_code, code, imm_type='int64_t', *opt_flags) {{ 407002Snate@binkert.org regs = ['_destRegIdx[0]','_srcRegIdx[0]'] 416154Snate@binkert.org iop = InstObjParams(name, Name, 'ImmOp<%s>' % imm_type, 426154Snate@binkert.org {'code': code, 'imm_code': imm_code, 436145Snate@binkert.org 'regs': ','.join(regs)}, opt_flags) 446145Snate@binkert.org header_output = ImmDeclare.subst(iop) 456145Snate@binkert.org decoder_output = ImmConstructor.subst(iop) 467039Snate@binkert.org decode_block = BasicDecode.subst(iop) 477039Snate@binkert.org exec_output = ImmExecute.subst(iop) 487039Snate@binkert.org}}; 497039Snate@binkert.org 507039Snate@binkert.orgdef format CJOp(code, *opt_flags) {{ 517039Snate@binkert.org regs = ['_destRegIdx[0]', '_srcRegIdx[0]'] 527039Snate@binkert.org imm_code = """ 536145Snate@binkert.org imm = CJUMPIMM3TO1 << 1 | 547039Snate@binkert.org CJUMPIMM4TO4 << 4 | 557039Snate@binkert.org CJUMPIMM5TO5 << 5 | 567039Snate@binkert.org CJUMPIMM6TO6 << 6 | 576145Snate@binkert.org CJUMPIMM7TO7 << 7 | 587039Snate@binkert.org CJUMPIMM9TO8 << 8 | 597039Snate@binkert.org CJUMPIMM10TO10 << 10; 607039Snate@binkert.org if (CJUMPIMMSIGN) 617039Snate@binkert.org imm |= ~((int64_t)0x7FF); 627039Snate@binkert.org """ 637039Snate@binkert.org iop = InstObjParams(name, Name, 'ImmOp<int64_t>', 647039Snate@binkert.org {'code': code, 'imm_code': imm_code, 657039Snate@binkert.org 'regs': ','.join(regs)}, opt_flags) 667039Snate@binkert.org header_output = BranchDeclare.subst(iop) 676145Snate@binkert.org decoder_output = ImmConstructor.subst(iop) 687039Snate@binkert.org decode_block = BasicDecode.subst(iop) 697039Snate@binkert.org exec_output = BranchExecute.subst(iop) 706145Snate@binkert.org}}; 717039Snate@binkert.org 727039Snate@binkert.orgdef format CBOp(code, *opt_flags) {{ 737039Snate@binkert.org imm_code = """ 747039Snate@binkert.org imm = CIMM5<2:1> << 1 | 757039Snate@binkert.org CIMM3<1:0> << 3 | 767039Snate@binkert.org CIMM5<0:0> << 5 | 777039Snate@binkert.org CIMM5<4:3> << 6; 787039Snate@binkert.org if (CIMM3<2:2> > 0) 797039Snate@binkert.org imm |= ~((int64_t)0xFF); 807039Snate@binkert.org """ 817039Snate@binkert.org regs = ['_srcRegIdx[0]','_srcRegIdx[1]'] 827039Snate@binkert.org iop = InstObjParams(name, Name, 'ImmOp<int64_t>', 837039Snate@binkert.org {'code': code, 'imm_code': imm_code, 847039Snate@binkert.org 'regs': ','.join(regs)}, opt_flags) 857039Snate@binkert.org header_output = BranchDeclare.subst(iop) 867039Snate@binkert.org decoder_output = ImmConstructor.subst(iop) 877039Snate@binkert.org decode_block = BasicDecode.subst(iop) 887039Snate@binkert.org exec_output = BranchExecute.subst(iop) 897039Snate@binkert.org}}; 907039Snate@binkert.org 917039Snate@binkert.orgdef format CompressedLoad(ldisp_code, memacc_code, 927039Snate@binkert.org ea_code, mem_flags=[], inst_flags=[]) {{ 937039Snate@binkert.org (header_output, decoder_output, decode_block, exec_output) = \ 947039Snate@binkert.org LoadStoreBase(name, Name, ldisp_code, ea_code, memacc_code, mem_flags, 957039Snate@binkert.org inst_flags, 'Load', exec_template_base='Load') 967039Snate@binkert.org}}; 977039Snate@binkert.org 987039Snate@binkert.orgdef format CompressedStore(sdisp_code, memacc_code, 997039Snate@binkert.org ea_code, mem_flags=[], inst_flags=[]) {{ 1007039Snate@binkert.org (header_output, decoder_output, decode_block, exec_output) = \ 1017039Snate@binkert.org LoadStoreBase(name, Name, sdisp_code, ea_code, memacc_code, mem_flags, 1027039Snate@binkert.org inst_flags, 'Store', exec_template_base='Store') 1037039Snate@binkert.org}}; 1047039Snate@binkert.org