pred.isa revision 6270
16019Shines@cs.fsu.edu// -*- mode:c++ -*- 26019Shines@cs.fsu.edu 36019Shines@cs.fsu.edu// Copyright (c) 2007-2008 The Florida State University 46019Shines@cs.fsu.edu// All rights reserved. 56019Shines@cs.fsu.edu// 66019Shines@cs.fsu.edu// Redistribution and use in source and binary forms, with or without 76019Shines@cs.fsu.edu// modification, are permitted provided that the following conditions are 86019Shines@cs.fsu.edu// met: redistributions of source code must retain the above copyright 96019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer; 106019Shines@cs.fsu.edu// redistributions in binary form must reproduce the above copyright 116019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer in the 126019Shines@cs.fsu.edu// documentation and/or other materials provided with the distribution; 136019Shines@cs.fsu.edu// neither the name of the copyright holders nor the names of its 146019Shines@cs.fsu.edu// contributors may be used to endorse or promote products derived from 156019Shines@cs.fsu.edu// this software without specific prior written permission. 166019Shines@cs.fsu.edu// 176019Shines@cs.fsu.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186019Shines@cs.fsu.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196019Shines@cs.fsu.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206019Shines@cs.fsu.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216019Shines@cs.fsu.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226019Shines@cs.fsu.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236019Shines@cs.fsu.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246019Shines@cs.fsu.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256019Shines@cs.fsu.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266019Shines@cs.fsu.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276019Shines@cs.fsu.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286019Shines@cs.fsu.edu// 296019Shines@cs.fsu.edu// Authors: Stephen Hines 306019Shines@cs.fsu.edu 316019Shines@cs.fsu.edu//////////////////////////////////////////////////////////////////// 326019Shines@cs.fsu.edu// 336019Shines@cs.fsu.edu// Predicated Instruction Execution 346019Shines@cs.fsu.edu// 356019Shines@cs.fsu.edu 366243Sgblack@eecs.umich.edulet {{ 376243Sgblack@eecs.umich.edu predicateTest = 'testPredicate(Cpsr, condCode)' 386243Sgblack@eecs.umich.edu}}; 396243Sgblack@eecs.umich.edu 406019Shines@cs.fsu.edudef template PredOpExecute {{ 416019Shines@cs.fsu.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 426019Shines@cs.fsu.edu { 436019Shines@cs.fsu.edu Fault fault = NoFault; 446019Shines@cs.fsu.edu %(op_decl)s; 456019Shines@cs.fsu.edu %(op_rd)s; 466019Shines@cs.fsu.edu 476243Sgblack@eecs.umich.edu if (%(predicate_test)s) 486019Shines@cs.fsu.edu { 496243Sgblack@eecs.umich.edu %(code)s; 506019Shines@cs.fsu.edu if (fault == NoFault) 516019Shines@cs.fsu.edu { 526019Shines@cs.fsu.edu %(op_wb)s; 536019Shines@cs.fsu.edu } 546019Shines@cs.fsu.edu } 556019Shines@cs.fsu.edu 566019Shines@cs.fsu.edu return fault; 576019Shines@cs.fsu.edu } 586019Shines@cs.fsu.edu}}; 596019Shines@cs.fsu.edu 606265Sgblack@eecs.umich.edudef template DataDecode {{ 616265Sgblack@eecs.umich.edu if (machInst.opcode4 == 0) { 626265Sgblack@eecs.umich.edu if (machInst.sField == 0) 636265Sgblack@eecs.umich.edu return new %(class_name)sImm(machInst); 646265Sgblack@eecs.umich.edu else 656265Sgblack@eecs.umich.edu return new %(class_name)sImmCc(machInst); 666265Sgblack@eecs.umich.edu } else { 676265Sgblack@eecs.umich.edu if (machInst.sField == 0) 686265Sgblack@eecs.umich.edu return new %(class_name)s(machInst); 696265Sgblack@eecs.umich.edu else 706265Sgblack@eecs.umich.edu return new %(class_name)sCc(machInst); 716265Sgblack@eecs.umich.edu } 726265Sgblack@eecs.umich.edu}}; 736265Sgblack@eecs.umich.edu 746270Sgblack@eecs.umich.edudef template DataImmDecode {{ 756270Sgblack@eecs.umich.edu if (machInst.sField == 0) 766270Sgblack@eecs.umich.edu return new %(class_name)s(machInst); 776270Sgblack@eecs.umich.edu else 786270Sgblack@eecs.umich.edu return new %(class_name)sCc(machInst); 796270Sgblack@eecs.umich.edu}}; 806270Sgblack@eecs.umich.edu 816019Shines@cs.fsu.edulet {{ 826019Shines@cs.fsu.edu 836019Shines@cs.fsu.edu calcCcCode = ''' 846019Shines@cs.fsu.edu uint16_t _ic, _iv, _iz, _in; 856019Shines@cs.fsu.edu 866019Shines@cs.fsu.edu _in = (resTemp >> 31) & 1; 876019Shines@cs.fsu.edu _iz = (resTemp == 0); 886019Shines@cs.fsu.edu _iv = %(ivValue)s & 1; 896019Shines@cs.fsu.edu _ic = %(icValue)s & 1; 906019Shines@cs.fsu.edu 916019Shines@cs.fsu.edu Cpsr = _in << 31 | _iz << 30 | _ic << 29 | _iv << 28 | 926019Shines@cs.fsu.edu (Cpsr & 0x0FFFFFFF); 936019Shines@cs.fsu.edu 946019Shines@cs.fsu.edu DPRINTF(Arm, "in = %%d\\n", _in); 956019Shines@cs.fsu.edu DPRINTF(Arm, "iz = %%d\\n", _iz); 966019Shines@cs.fsu.edu DPRINTF(Arm, "ic = %%d\\n", _ic); 976019Shines@cs.fsu.edu DPRINTF(Arm, "iv = %%d\\n", _iv); 986019Shines@cs.fsu.edu ''' 996019Shines@cs.fsu.edu 1006019Shines@cs.fsu.edu}}; 1016019Shines@cs.fsu.edu 1026265Sgblack@eecs.umich.edudef format DataOp(code, icValue, ivValue) {{ 1036265Sgblack@eecs.umich.edu code += "resTemp = resTemp;" 1046265Sgblack@eecs.umich.edu regCode = re.sub(r'op2', 'shift_rm_rs(Rm, Rs, \ 1056265Sgblack@eecs.umich.edu shift, Cpsr<29:0>)', code) 1066265Sgblack@eecs.umich.edu immCode = re.sub(r'op2', 'shift_rm_imm(Rm, shift_size, \ 1076265Sgblack@eecs.umich.edu shift, Cpsr<29:0>)', code) 1086265Sgblack@eecs.umich.edu regIop = InstObjParams(name, Name, 'PredIntOp', 1096265Sgblack@eecs.umich.edu {"code": regCode, 1106265Sgblack@eecs.umich.edu "predicate_test": predicateTest}) 1116265Sgblack@eecs.umich.edu immIop = InstObjParams(name, Name + "Imm", 'PredIntOp', 1126265Sgblack@eecs.umich.edu {"code": immCode, 1136265Sgblack@eecs.umich.edu "predicate_test": predicateTest}) 1146265Sgblack@eecs.umich.edu regCcIop = InstObjParams(name, Name + "Cc", 'PredIntOp', 1156265Sgblack@eecs.umich.edu {"code": regCode + calcCcCode % vars(), 1166265Sgblack@eecs.umich.edu "predicate_test": predicateTest}) 1176265Sgblack@eecs.umich.edu immCcIop = InstObjParams(name, Name + "ImmCc", 'PredIntOp', 1186265Sgblack@eecs.umich.edu {"code": immCode + calcCcCode % vars(), 1196265Sgblack@eecs.umich.edu "predicate_test": predicateTest}) 1206265Sgblack@eecs.umich.edu header_output = BasicDeclare.subst(regIop) + \ 1216265Sgblack@eecs.umich.edu BasicDeclare.subst(immIop) + \ 1226265Sgblack@eecs.umich.edu BasicDeclare.subst(regCcIop) + \ 1236265Sgblack@eecs.umich.edu BasicDeclare.subst(immCcIop) 1246265Sgblack@eecs.umich.edu decoder_output = BasicConstructor.subst(regIop) + \ 1256265Sgblack@eecs.umich.edu BasicConstructor.subst(immIop) + \ 1266265Sgblack@eecs.umich.edu BasicConstructor.subst(regCcIop) + \ 1276265Sgblack@eecs.umich.edu BasicConstructor.subst(immCcIop) 1286265Sgblack@eecs.umich.edu exec_output = PredOpExecute.subst(regIop) + \ 1296265Sgblack@eecs.umich.edu PredOpExecute.subst(immIop) + \ 1306265Sgblack@eecs.umich.edu PredOpExecute.subst(regCcIop) + \ 1316265Sgblack@eecs.umich.edu PredOpExecute.subst(immCcIop) 1326265Sgblack@eecs.umich.edu decode_block = DataDecode.subst(regIop) 1336265Sgblack@eecs.umich.edu}}; 1346265Sgblack@eecs.umich.edu 1356270Sgblack@eecs.umich.edudef format DataImmOp(code, icValue, ivValue) {{ 1366270Sgblack@eecs.umich.edu code += "resTemp = resTemp;" 1376270Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'PredImmOp', 1386270Sgblack@eecs.umich.edu {"code": code, 1396270Sgblack@eecs.umich.edu "predicate_test": predicateTest}) 1406270Sgblack@eecs.umich.edu ccIop = InstObjParams(name, Name + "Cc", 'PredImmOp', 1416270Sgblack@eecs.umich.edu {"code": code + calcCcCode % vars(), 1426270Sgblack@eecs.umich.edu "predicate_test": predicateTest}) 1436270Sgblack@eecs.umich.edu header_output = BasicDeclare.subst(iop) + \ 1446270Sgblack@eecs.umich.edu BasicDeclare.subst(ccIop) 1456270Sgblack@eecs.umich.edu decoder_output = BasicConstructor.subst(iop) + \ 1466270Sgblack@eecs.umich.edu BasicConstructor.subst(ccIop) 1476270Sgblack@eecs.umich.edu exec_output = PredOpExecute.subst(iop) + \ 1486270Sgblack@eecs.umich.edu PredOpExecute.subst(ccIop) 1496270Sgblack@eecs.umich.edu decode_block = DataImmDecode.subst(iop) 1506270Sgblack@eecs.umich.edu}}; 1516270Sgblack@eecs.umich.edu 1526019Shines@cs.fsu.edudef format PredOp(code, *opt_flags) {{ 1536243Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'PredOp', 1546243Sgblack@eecs.umich.edu {"code": code, 1556243Sgblack@eecs.umich.edu "predicate_test": predicateTest}, 1566243Sgblack@eecs.umich.edu opt_flags) 1576019Shines@cs.fsu.edu header_output = BasicDeclare.subst(iop) 1586019Shines@cs.fsu.edu decoder_output = BasicConstructor.subst(iop) 1596019Shines@cs.fsu.edu decode_block = BasicDecode.subst(iop) 1606019Shines@cs.fsu.edu exec_output = PredOpExecute.subst(iop) 1616019Shines@cs.fsu.edu}}; 1626019Shines@cs.fsu.edu 1636019Shines@cs.fsu.edudef format PredImmOp(code, *opt_flags) {{ 1646243Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'PredImmOp', 1656243Sgblack@eecs.umich.edu {"code": code, 1666243Sgblack@eecs.umich.edu "predicate_test": predicateTest}, 1676243Sgblack@eecs.umich.edu opt_flags) 1686019Shines@cs.fsu.edu header_output = BasicDeclare.subst(iop) 1696019Shines@cs.fsu.edu decoder_output = BasicConstructor.subst(iop) 1706019Shines@cs.fsu.edu decode_block = BasicDecode.subst(iop) 1716019Shines@cs.fsu.edu exec_output = PredOpExecute.subst(iop) 1726019Shines@cs.fsu.edu}}; 1736019Shines@cs.fsu.edu 1746019Shines@cs.fsu.edudef format PredImmOpCc(code, icValue, ivValue, *opt_flags) {{ 1756019Shines@cs.fsu.edu ccCode = calcCcCode % vars() 1766019Shines@cs.fsu.edu code += ccCode; 1776019Shines@cs.fsu.edu iop = InstObjParams(name, Name, 'PredImmOp', 1786243Sgblack@eecs.umich.edu {"code": code, 1796243Sgblack@eecs.umich.edu "cc_code": ccCode, 1806243Sgblack@eecs.umich.edu "predicate_test": predicateTest}, 1816243Sgblack@eecs.umich.edu opt_flags) 1826019Shines@cs.fsu.edu header_output = BasicDeclare.subst(iop) 1836019Shines@cs.fsu.edu decoder_output = BasicConstructor.subst(iop) 1846019Shines@cs.fsu.edu decode_block = BasicDecode.subst(iop) 1856019Shines@cs.fsu.edu exec_output = PredOpExecute.subst(iop) 1866019Shines@cs.fsu.edu}}; 1876019Shines@cs.fsu.edu 1886019Shines@cs.fsu.edudef format PredIntOp(code, *opt_flags) {{ 1896019Shines@cs.fsu.edu new_code = ArmGenericCodeSubs(code) 1906243Sgblack@eecs.umich.edu iop = InstObjParams(name, Name, 'PredIntOp', 1916243Sgblack@eecs.umich.edu {"code": new_code, 1926243Sgblack@eecs.umich.edu "predicate_test": predicateTest}, 1936243Sgblack@eecs.umich.edu opt_flags) 1946019Shines@cs.fsu.edu header_output = BasicDeclare.subst(iop) 1956019Shines@cs.fsu.edu decoder_output = BasicConstructor.subst(iop) 1966019Shines@cs.fsu.edu decode_block = BasicDecode.subst(iop) 1976019Shines@cs.fsu.edu exec_output = PredOpExecute.subst(iop) 1986019Shines@cs.fsu.edu}}; 1996019Shines@cs.fsu.edu 2006019Shines@cs.fsu.edudef format PredIntOpCc(code, icValue, ivValue, *opt_flags) {{ 2016019Shines@cs.fsu.edu ccCode = calcCcCode % vars() 2026019Shines@cs.fsu.edu code += ccCode; 2036019Shines@cs.fsu.edu new_code = ArmGenericCodeSubs(code) 2046019Shines@cs.fsu.edu iop = InstObjParams(name, Name, 'PredIntOp', 2056243Sgblack@eecs.umich.edu {"code": new_code, 2066243Sgblack@eecs.umich.edu "cc_code": ccCode, 2076243Sgblack@eecs.umich.edu "predicate_test": predicateTest}, 2086243Sgblack@eecs.umich.edu opt_flags) 2096019Shines@cs.fsu.edu header_output = BasicDeclare.subst(iop) 2106019Shines@cs.fsu.edu decoder_output = BasicConstructor.subst(iop) 2116019Shines@cs.fsu.edu decode_block = BasicDecode.subst(iop) 2126019Shines@cs.fsu.edu exec_output = PredOpExecute.subst(iop) 2136019Shines@cs.fsu.edu}}; 2146019Shines@cs.fsu.edu 215