pred.isa revision 6271
12SN/A// -*- mode:c++ -*- 22188SN/A 32SN/A// Copyright (c) 2007-2008 The Florida State University 42SN/A// All rights reserved. 52SN/A// 62SN/A// Redistribution and use in source and binary forms, with or without 72SN/A// modification, are permitted provided that the following conditions are 82SN/A// met: redistributions of source code must retain the above copyright 92SN/A// notice, this list of conditions and the following disclaimer; 102SN/A// redistributions in binary form must reproduce the above copyright 112SN/A// notice, this list of conditions and the following disclaimer in the 122SN/A// documentation and/or other materials provided with the distribution; 132SN/A// neither the name of the copyright holders nor the names of its 142SN/A// contributors may be used to endorse or promote products derived from 152SN/A// this software without specific prior written permission. 162SN/A// 172SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272665SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665SN/A// 292665SN/A// Authors: Stephen Hines 302SN/A 312SN/A//////////////////////////////////////////////////////////////////// 322683Sktlim@umich.edu// 332683Sktlim@umich.edu// Predicated Instruction Execution 342SN/A// 356313Sgblack@eecs.umich.edu 362190SN/Alet {{ 376329Sgblack@eecs.umich.edu predicateTest = 'testPredicate(Cpsr, condCode)' 384997Sgblack@eecs.umich.edu}}; 396316Sgblack@eecs.umich.edu 406216Snate@binkert.orgdef template PredOpExecute {{ 411858SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 426658Snate@binkert.org { 438541Sgblack@eecs.umich.edu Fault fault = NoFault; 442680SN/A uint64_t resTemp = 0; 452683Sktlim@umich.edu resTemp = resTemp; 468232Snate@binkert.org %(op_decl)s; 478232Snate@binkert.org %(op_rd)s; 482395SN/A 492190SN/A if (%(predicate_test)s) 502188SN/A { 51217SN/A %(code)s; 522SN/A if (fault == NoFault) 532SN/A { 542SN/A %(op_wb)s; 551858SN/A } 562SN/A } 571070SN/A 581070SN/A return fault; 591917SN/A } 601917SN/A}}; 612521SN/A 622521SN/Adef template DataDecode {{ 632521SN/A if (machInst.opcode4 == 0) { 643548Sgblack@eecs.umich.edu if (machInst.sField == 0) 653548Sgblack@eecs.umich.edu return new %(class_name)sImm(machInst); 663548Sgblack@eecs.umich.edu else 673548Sgblack@eecs.umich.edu return new %(class_name)sImmCc(machInst); 682330SN/A } else { 692330SN/A if (machInst.sField == 0) 702SN/A return new %(class_name)s(machInst); 712SN/A else 728229Snate@binkert.org return new %(class_name)sCc(machInst); 73360SN/A } 742420SN/A}}; 752SN/A 762SN/Adef template DataImmDecode {{ 772SN/A if (machInst.sField == 0) 782683Sktlim@umich.edu return new %(class_name)s(machInst); 792683Sktlim@umich.edu else 802683Sktlim@umich.edu return new %(class_name)sCc(machInst); 812683Sktlim@umich.edu}}; 822683Sktlim@umich.edu 832683Sktlim@umich.edulet {{ 842683Sktlim@umich.edu 852683Sktlim@umich.edu calcCcCode = ''' 862683Sktlim@umich.edu uint16_t _ic, _iv, _iz, _in; 872683Sktlim@umich.edu 882683Sktlim@umich.edu _in = (resTemp >> 31) & 1; 892683Sktlim@umich.edu _iz = (resTemp == 0); 902683Sktlim@umich.edu _iv = %(ivValue)s & 1; 912683Sktlim@umich.edu _ic = %(icValue)s & 1; 922683Sktlim@umich.edu 932SN/A Cpsr = _in << 31 | _iz << 30 | _ic << 29 | _iv << 28 | 942683Sktlim@umich.edu (Cpsr & 0x0FFFFFFF); 952SN/A 962107SN/A DPRINTF(Arm, "in = %%d\\n", _in); 972107SN/A DPRINTF(Arm, "iz = %%d\\n", _iz); 982159SN/A DPRINTF(Arm, "ic = %%d\\n", _ic); 992455SN/A DPRINTF(Arm, "iv = %%d\\n", _iv); 1002455SN/A ''' 1012SN/A 1022680SN/A}}; 1032SN/A 1042190SN/Adef format DataOp(code, icValue, ivValue) {{ 1056315Sgblack@eecs.umich.edu regCode = re.sub(r'op2', 'shift_rm_rs(Rm, Rs, \ 1066315Sgblack@eecs.umich.edu shift, Cpsr<29:0>)', code) 1076315Sgblack@eecs.umich.edu immCode = re.sub(r'op2', 'shift_rm_imm(Rm, shift_size, \ 1086315Sgblack@eecs.umich.edu shift, Cpsr<29:0>)', code) 1096316Sgblack@eecs.umich.edu regIop = InstObjParams(name, Name, 'PredIntOp', 1106313Sgblack@eecs.umich.edu {"code": regCode, 1112SN/A "predicate_test": predicateTest}) 1127720Sgblack@eecs.umich.edu immIop = InstObjParams(name, Name + "Imm", 'PredIntOp', 1136324Sgblack@eecs.umich.edu {"code": immCode, 1147597Sminkyu.jeong@arm.com "predicate_test": predicateTest}) 1157597Sminkyu.jeong@arm.com regCcIop = InstObjParams(name, Name + "Cc", 'PredIntOp', 1167597Sminkyu.jeong@arm.com {"code": regCode + calcCcCode % vars(), 1172190SN/A "predicate_test": predicateTest}) 1188357Sksewell@umich.edu immCcIop = InstObjParams(name, Name + "ImmCc", 'PredIntOp', 1198357Sksewell@umich.edu {"code": immCode + calcCcCode % vars(), 1208357Sksewell@umich.edu "predicate_test": predicateTest}) 1218357Sksewell@umich.edu header_output = BasicDeclare.subst(regIop) + \ 1228357Sksewell@umich.edu BasicDeclare.subst(immIop) + \ 1232683Sktlim@umich.edu BasicDeclare.subst(regCcIop) + \ 1242SN/A BasicDeclare.subst(immCcIop) 1252SN/A decoder_output = BasicConstructor.subst(regIop) + \ 1262683Sktlim@umich.edu BasicConstructor.subst(immIop) + \ 1272188SN/A BasicConstructor.subst(regCcIop) + \ 1282378SN/A BasicConstructor.subst(immCcIop) 1292400SN/A exec_output = PredOpExecute.subst(regIop) + \ 1306022Sgblack@eecs.umich.edu PredOpExecute.subst(immIop) + \ 1316022Sgblack@eecs.umich.edu PredOpExecute.subst(regCcIop) + \ 1322SN/A PredOpExecute.subst(immCcIop) 1338541Sgblack@eecs.umich.edu decode_block = DataDecode.subst(regIop) 1348541Sgblack@eecs.umich.edu}}; 1352683Sktlim@umich.edu 1361858SN/Adef format DataImmOp(code, icValue, ivValue) {{ 1372683Sktlim@umich.edu code += "resTemp = resTemp;" 1386022Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'PredImmOp', 1392683Sktlim@umich.edu {"code": code, 1402SN/A "predicate_test": predicateTest}) 1414997Sgblack@eecs.umich.edu ccIop = InstObjParams(name, Name + "Cc", 'PredImmOp', 1426331Sgblack@eecs.umich.edu {"code": code + calcCcCode % vars(), 1432SN/A "predicate_test": predicateTest}) 1442862Sktlim@umich.edu header_output = BasicDeclare.subst(iop) + \ 1452864Sktlim@umich.edu BasicDeclare.subst(ccIop) 1462862Sktlim@umich.edu decoder_output = BasicConstructor.subst(iop) + \ 1472683Sktlim@umich.edu BasicConstructor.subst(ccIop) 1482SN/A exec_output = PredOpExecute.subst(iop) + \ 1492680SN/A PredOpExecute.subst(ccIop) 150180SN/A decode_block = DataImmDecode.subst(iop) 1512SN/A}}; 1522SN/A 1532864Sktlim@umich.edudef format PredOp(code, *opt_flags) {{ 1542864Sktlim@umich.edu iop = InstObjParams(name, Name, 'PredOp', 1552862Sktlim@umich.edu {"code": code, 1562862Sktlim@umich.edu "predicate_test": predicateTest}, 157217SN/A opt_flags) 158237SN/A header_output = BasicDeclare.subst(iop) 159217SN/A decoder_output = BasicConstructor.subst(iop) 1602683Sktlim@umich.edu decode_block = BasicDecode.subst(iop) 1612683Sktlim@umich.edu exec_output = PredOpExecute.subst(iop) 1625891Sgblack@eecs.umich.edu}}; 1632683Sktlim@umich.edu 1642190SN/Adef format PredImmOp(code, *opt_flags) {{ 1652683Sktlim@umich.edu iop = InstObjParams(name, Name, 'PredImmOp', 1662683Sktlim@umich.edu {"code": code, 1672683Sktlim@umich.edu "predicate_test": predicateTest}, 1682683Sktlim@umich.edu opt_flags) 1692680SN/A header_output = BasicDeclare.subst(iop) 1702190SN/A decoder_output = BasicConstructor.subst(iop) 1715358Sgblack@eecs.umich.edu decode_block = BasicDecode.subst(iop) 1725358Sgblack@eecs.umich.edu exec_output = PredOpExecute.subst(iop) 1735358Sgblack@eecs.umich.edu}}; 1745358Sgblack@eecs.umich.edu 1755358Sgblack@eecs.umich.edudef format PredImmOpCc(code, icValue, ivValue, *opt_flags) {{ 1765358Sgblack@eecs.umich.edu ccCode = calcCcCode % vars() 1775358Sgblack@eecs.umich.edu code += ccCode; 1785358Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'PredImmOp', 1795358Sgblack@eecs.umich.edu {"code": code, 1805358Sgblack@eecs.umich.edu "cc_code": ccCode, 1815358Sgblack@eecs.umich.edu "predicate_test": predicateTest}, 1825358Sgblack@eecs.umich.edu opt_flags) 1835358Sgblack@eecs.umich.edu header_output = BasicDeclare.subst(iop) 1845358Sgblack@eecs.umich.edu decoder_output = BasicConstructor.subst(iop) 1855358Sgblack@eecs.umich.edu decode_block = BasicDecode.subst(iop) 1865358Sgblack@eecs.umich.edu exec_output = PredOpExecute.subst(iop) 1874997Sgblack@eecs.umich.edu}}; 1882683Sktlim@umich.edu 1892521SN/Adef format PredIntOp(code, *opt_flags) {{ 1905702Ssaidi@eecs.umich.edu new_code = ArmGenericCodeSubs(code) 1915702Ssaidi@eecs.umich.edu iop = InstObjParams(name, Name, 'PredIntOp', 1925702Ssaidi@eecs.umich.edu {"code": new_code, 1935702Ssaidi@eecs.umich.edu "predicate_test": predicateTest}, 1942683Sktlim@umich.edu opt_flags) 1952SN/A header_output = BasicDeclare.subst(iop) 1962683Sktlim@umich.edu decoder_output = BasicConstructor.subst(iop) 1972683Sktlim@umich.edu decode_block = BasicDecode.subst(iop) 1982683Sktlim@umich.edu exec_output = PredOpExecute.subst(iop) 1992683Sktlim@umich.edu}}; 2002683Sktlim@umich.edu 2012683Sktlim@umich.edudef format PredIntOpCc(code, icValue, ivValue, *opt_flags) {{ 2026022Sgblack@eecs.umich.edu ccCode = calcCcCode % vars() 2032683Sktlim@umich.edu code += ccCode; 2046022Sgblack@eecs.umich.edu new_code = ArmGenericCodeSubs(code) 2052683Sktlim@umich.edu iop = InstObjParams(name, Name, 'PredIntOp', 2068541Sgblack@eecs.umich.edu {"code": new_code, 2078541Sgblack@eecs.umich.edu "cc_code": ccCode, 2084997Sgblack@eecs.umich.edu "predicate_test": predicateTest}, 2094997Sgblack@eecs.umich.edu opt_flags) 2105803Snate@binkert.org header_output = BasicDeclare.subst(iop) 2115499Ssaidi@eecs.umich.edu decoder_output = BasicConstructor.subst(iop) 2125499Ssaidi@eecs.umich.edu decode_block = BasicDecode.subst(iop) 2135499Ssaidi@eecs.umich.edu exec_output = PredOpExecute.subst(iop) 2145499Ssaidi@eecs.umich.edu}}; 2155499Ssaidi@eecs.umich.edu 2162SN/A