pred.isa revision 6265
12330SN/A// -*- mode:c++ -*- 28733Sgeoffrey.blake@arm.com 38733Sgeoffrey.blake@arm.com// Copyright (c) 2007-2008 The Florida State University 48733Sgeoffrey.blake@arm.com// All rights reserved. 58733Sgeoffrey.blake@arm.com// 68733Sgeoffrey.blake@arm.com// Redistribution and use in source and binary forms, with or without 78733Sgeoffrey.blake@arm.com// modification, are permitted provided that the following conditions are 88733Sgeoffrey.blake@arm.com// met: redistributions of source code must retain the above copyright 98733Sgeoffrey.blake@arm.com// notice, this list of conditions and the following disclaimer; 108733Sgeoffrey.blake@arm.com// redistributions in binary form must reproduce the above copyright 118733Sgeoffrey.blake@arm.com// notice, this list of conditions and the following disclaimer in the 128733Sgeoffrey.blake@arm.com// documentation and/or other materials provided with the distribution; 138733Sgeoffrey.blake@arm.com// neither the name of the copyright holders nor the names of its 142330SN/A// contributors may be used to endorse or promote products derived from 152330SN/A// this software without specific prior written permission. 162330SN/A// 172330SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182330SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192330SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202330SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212330SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222330SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232330SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242330SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252330SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262330SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272330SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282330SN/A// 292330SN/A// Authors: Stephen Hines 302330SN/A 312330SN/A//////////////////////////////////////////////////////////////////// 322330SN/A// 332330SN/A// Predicated Instruction Execution 342330SN/A// 352330SN/A 362330SN/Alet {{ 372330SN/A predicateTest = 'testPredicate(Cpsr, condCode)' 382330SN/A}}; 392689Sktlim@umich.edu 402689Sktlim@umich.edudef template PredOpExecute {{ 412330SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 422330SN/A { 432683Sktlim@umich.edu Fault fault = NoFault; 442683Sktlim@umich.edu %(op_decl)s; 452315SN/A %(op_rd)s; 462972Sgblack@eecs.umich.edu 476658Snate@binkert.org if (%(predicate_test)s) 482315SN/A { 492683Sktlim@umich.edu %(code)s; 502680SN/A if (fault == NoFault) 518733Sgeoffrey.blake@arm.com { 522315SN/A %(op_wb)s; 532315SN/A } 543548Sgblack@eecs.umich.edu } 553548Sgblack@eecs.umich.edu 563548Sgblack@eecs.umich.edu return fault; 573548Sgblack@eecs.umich.edu } 589020Sgblack@eecs.umich.edu}}; 592330SN/A 602315SN/Adef template DataDecode {{ 612350SN/A if (machInst.opcode4 == 0) { 622680SN/A if (machInst.sField == 0) 632680SN/A return new %(class_name)sImm(machInst); 642683Sktlim@umich.edu else 652683Sktlim@umich.edu return new %(class_name)sImmCc(machInst); 662683Sktlim@umich.edu } else { 672683Sktlim@umich.edu if (machInst.sField == 0) 682350SN/A return new %(class_name)s(machInst); 692680SN/A else 702680SN/A return new %(class_name)sCc(machInst); 712315SN/A } 722315SN/A}}; 732680SN/A 742683Sktlim@umich.edulet {{ 752683Sktlim@umich.edu 762330SN/A calcCcCode = ''' 772315SN/A uint16_t _ic, _iv, _iz, _in; 782315SN/A 792315SN/A _in = (resTemp >> 31) & 1; 802683Sktlim@umich.edu _iz = (resTemp == 0); 812683Sktlim@umich.edu _iv = %(ivValue)s & 1; 822680SN/A _ic = %(icValue)s & 1; 832683Sktlim@umich.edu 842683Sktlim@umich.edu Cpsr = _in << 31 | _iz << 30 | _ic << 29 | _iv << 28 | 852683Sktlim@umich.edu (Cpsr & 0x0FFFFFFF); 862683Sktlim@umich.edu 872683Sktlim@umich.edu DPRINTF(Arm, "in = %%d\\n", _in); 882315SN/A DPRINTF(Arm, "iz = %%d\\n", _iz); 892315SN/A DPRINTF(Arm, "ic = %%d\\n", _ic); 902315SN/A DPRINTF(Arm, "iv = %%d\\n", _iv); 912315SN/A ''' 922680SN/A 932315SN/A}}; 948733Sgeoffrey.blake@arm.com 958733Sgeoffrey.blake@arm.comdef format DataOp(code, icValue, ivValue) {{ 968733Sgeoffrey.blake@arm.com code += "resTemp = resTemp;" 978733Sgeoffrey.blake@arm.com regCode = re.sub(r'op2', 'shift_rm_rs(Rm, Rs, \ 988733Sgeoffrey.blake@arm.com shift, Cpsr<29:0>)', code) 992315SN/A immCode = re.sub(r'op2', 'shift_rm_imm(Rm, shift_size, \ 1008733Sgeoffrey.blake@arm.com shift, Cpsr<29:0>)', code) 1018733Sgeoffrey.blake@arm.com regIop = InstObjParams(name, Name, 'PredIntOp', 1022315SN/A {"code": regCode, 1032315SN/A "predicate_test": predicateTest}) 1048733Sgeoffrey.blake@arm.com immIop = InstObjParams(name, Name + "Imm", 'PredIntOp', 1058733Sgeoffrey.blake@arm.com {"code": immCode, 1068733Sgeoffrey.blake@arm.com "predicate_test": predicateTest}) 1078733Sgeoffrey.blake@arm.com regCcIop = InstObjParams(name, Name + "Cc", 'PredIntOp', 1088733Sgeoffrey.blake@arm.com {"code": regCode + calcCcCode % vars(), 1098733Sgeoffrey.blake@arm.com "predicate_test": predicateTest}) 1108733Sgeoffrey.blake@arm.com immCcIop = InstObjParams(name, Name + "ImmCc", 'PredIntOp', 1112315SN/A {"code": immCode + calcCcCode % vars(), 1126022Sgblack@eecs.umich.edu "predicate_test": predicateTest}) 1134997Sgblack@eecs.umich.edu header_output = BasicDeclare.subst(regIop) + \ 1146022Sgblack@eecs.umich.edu BasicDeclare.subst(immIop) + \ 1154997Sgblack@eecs.umich.edu BasicDeclare.subst(regCcIop) + \ 1168887Sgeoffrey.blake@arm.com BasicDeclare.subst(immCcIop) 1178887Sgeoffrey.blake@arm.com decoder_output = BasicConstructor.subst(regIop) + \ 1188887Sgeoffrey.blake@arm.com BasicConstructor.subst(immIop) + \ 1198887Sgeoffrey.blake@arm.com BasicConstructor.subst(regCcIop) + \ 1208733Sgeoffrey.blake@arm.com BasicConstructor.subst(immCcIop) 1219020Sgblack@eecs.umich.edu exec_output = PredOpExecute.subst(regIop) + \ 1228733Sgeoffrey.blake@arm.com PredOpExecute.subst(immIop) + \ 1232680SN/A PredOpExecute.subst(regCcIop) + \ 1242315SN/A PredOpExecute.subst(immCcIop) 1253548Sgblack@eecs.umich.edu decode_block = DataDecode.subst(regIop) 1263548Sgblack@eecs.umich.edu}}; 1272690Sktlim@umich.edu 1287679Sgblack@eecs.umich.edudef format PredOp(code, *opt_flags) {{ 1297679Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'PredOp', 1308852Sandreas.hansson@arm.com {"code": code, 1312690Sktlim@umich.edu "predicate_test": predicateTest}, 1328852Sandreas.hansson@arm.com opt_flags) 1338706Sandreas.hansson@arm.com header_output = BasicDeclare.subst(iop) 1348733Sgeoffrey.blake@arm.com decoder_output = BasicConstructor.subst(iop) 1358733Sgeoffrey.blake@arm.com decode_block = BasicDecode.subst(iop) 1368733Sgeoffrey.blake@arm.com exec_output = PredOpExecute.subst(iop) 1378733Sgeoffrey.blake@arm.com}}; 1388733Sgeoffrey.blake@arm.com 1398733Sgeoffrey.blake@arm.comdef format PredImmOp(code, *opt_flags) {{ 1408733Sgeoffrey.blake@arm.com iop = InstObjParams(name, Name, 'PredImmOp', 1418733Sgeoffrey.blake@arm.com {"code": code, 1428809Sgblack@eecs.umich.edu "predicate_test": predicateTest}, 1438852Sandreas.hansson@arm.com opt_flags) 1442690Sktlim@umich.edu header_output = BasicDeclare.subst(iop) 1458733Sgeoffrey.blake@arm.com decoder_output = BasicConstructor.subst(iop) 1468733Sgeoffrey.blake@arm.com decode_block = BasicDecode.subst(iop) 1478733Sgeoffrey.blake@arm.com exec_output = PredOpExecute.subst(iop) 1482315SN/A}}; 1492680SN/A 1502315SN/Adef format PredImmOpCc(code, icValue, ivValue, *opt_flags) {{ 1512315SN/A ccCode = calcCcCode % vars() 1522330SN/A code += ccCode; 1532680SN/A iop = InstObjParams(name, Name, 'PredImmOp', 1542680SN/A {"code": code, 1552330SN/A "cc_code": ccCode, 1562315SN/A "predicate_test": predicateTest}, 1572315SN/A opt_flags) 1582315SN/A header_output = BasicDeclare.subst(iop) 1599180Sandreas.hansson@arm.com decoder_output = BasicConstructor.subst(iop) 1609180Sandreas.hansson@arm.com decode_block = BasicDecode.subst(iop) 1612315SN/A exec_output = PredOpExecute.subst(iop) 1622315SN/A}}; 1639180Sandreas.hansson@arm.com 1642315SN/Adef format PredIntOp(code, *opt_flags) {{ 1652315SN/A new_code = ArmGenericCodeSubs(code) 1669180Sandreas.hansson@arm.com iop = InstObjParams(name, Name, 'PredIntOp', 1672315SN/A {"code": new_code, 1682680SN/A "predicate_test": predicateTest}, 1692315SN/A opt_flags) 1702680SN/A header_output = BasicDeclare.subst(iop) 1712315SN/A decoder_output = BasicConstructor.subst(iop) 1722680SN/A decode_block = BasicDecode.subst(iop) 1733225Sktlim@umich.edu exec_output = PredOpExecute.subst(iop) 1742315SN/A}}; 1752315SN/A 1768733Sgeoffrey.blake@arm.comdef format PredIntOpCc(code, icValue, ivValue, *opt_flags) {{ 1778733Sgeoffrey.blake@arm.com ccCode = calcCcCode % vars() 1788733Sgeoffrey.blake@arm.com code += ccCode; 1798733Sgeoffrey.blake@arm.com new_code = ArmGenericCodeSubs(code) 1808733Sgeoffrey.blake@arm.com iop = InstObjParams(name, Name, 'PredIntOp', 1812315SN/A {"code": new_code, 1822680SN/A "cc_code": ccCode, 1832315SN/A "predicate_test": predicateTest}, 1842680SN/A opt_flags) 1852315SN/A header_output = BasicDeclare.subst(iop) 1862680SN/A decoder_output = BasicConstructor.subst(iop) 1872315SN/A decode_block = BasicDecode.subst(iop) 1882680SN/A exec_output = PredOpExecute.subst(iop) 1892680SN/A}}; 1902315SN/A 1912680SN/A