pred.isa revision 8910
16019SN/A// -*- mode:c++ -*- 26019SN/A 37110SN/A// Copyright (c) 2010 ARM Limited 47110SN/A// All rights reserved 57110SN/A// 67110SN/A// The license below extends only to copyright in the software and shall 77110SN/A// not be construed as granting a license to any other intellectual 87110SN/A// property including but not limited to intellectual property relating 97110SN/A// to a hardware implementation of the functionality of the software 107110SN/A// licensed hereunder. You may use the software subject to the license 117110SN/A// terms below provided that you ensure that this notice is replicated 127110SN/A// unmodified and in its entirety in all distributions of the software, 137110SN/A// modified or unmodified, in source code or in binary form. 147110SN/A// 156019SN/A// Copyright (c) 2007-2008 The Florida State University 166019SN/A// All rights reserved. 176019SN/A// 186019SN/A// Redistribution and use in source and binary forms, with or without 196019SN/A// modification, are permitted provided that the following conditions are 206019SN/A// met: redistributions of source code must retain the above copyright 216019SN/A// notice, this list of conditions and the following disclaimer; 226019SN/A// redistributions in binary form must reproduce the above copyright 236019SN/A// notice, this list of conditions and the following disclaimer in the 246019SN/A// documentation and/or other materials provided with the distribution; 256019SN/A// neither the name of the copyright holders nor the names of its 266019SN/A// contributors may be used to endorse or promote products derived from 276019SN/A// this software without specific prior written permission. 286019SN/A// 296019SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 306019SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 316019SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 326019SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 336019SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 346019SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 356019SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 366019SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 376019SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 386019SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 396019SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 406019SN/A// 416019SN/A// Authors: Stephen Hines 426019SN/A 436019SN/A//////////////////////////////////////////////////////////////////// 446019SN/A// 456019SN/A// Predicated Instruction Execution 466019SN/A// 476019SN/A 486243SN/Alet {{ 498303SAli.Saidi@ARM.com predicateTest = 'testPredicate(OptCondCodesNZ, OptCondCodesC, OptCondCodesV, condCode)' 508303SAli.Saidi@ARM.com condPredicateTest = 'testPredicate(CondCodesNZ, CondCodesC, CondCodesV, condCode)' 516243SN/A}}; 526243SN/A 537138Sgblack@eecs.umich.edudef template DataImmDeclare {{ 547138Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s 557138Sgblack@eecs.umich.edu{ 567138Sgblack@eecs.umich.edu public: 577138Sgblack@eecs.umich.edu // Constructor 587138Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst machInst, IntRegIndex _dest, 597138Sgblack@eecs.umich.edu IntRegIndex _op1, uint32_t _imm, bool _rotC=true); 607138Sgblack@eecs.umich.edu %(BasicExecDeclare)s 617138Sgblack@eecs.umich.edu}; 627138Sgblack@eecs.umich.edu}}; 637138Sgblack@eecs.umich.edu 647138Sgblack@eecs.umich.edudef template DataImmConstructor {{ 657138Sgblack@eecs.umich.edu inline %(class_name)s::%(class_name)s(ExtMachInst machInst, 667138Sgblack@eecs.umich.edu IntRegIndex _dest, 677138Sgblack@eecs.umich.edu IntRegIndex _op1, 687138Sgblack@eecs.umich.edu uint32_t _imm, 697138Sgblack@eecs.umich.edu bool _rotC) 707138Sgblack@eecs.umich.edu : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 717138Sgblack@eecs.umich.edu _dest, _op1, _imm, _rotC) 727138Sgblack@eecs.umich.edu { 737138Sgblack@eecs.umich.edu %(constructor)s; 747848SAli.Saidi@ARM.com if (!(condCode == COND_AL || condCode == COND_UC)) { 757848SAli.Saidi@ARM.com for (int x = 0; x < _numDestRegs; x++) { 767848SAli.Saidi@ARM.com _srcRegIdx[_numSrcRegs++] = _destRegIdx[x]; 777848SAli.Saidi@ARM.com } 787848SAli.Saidi@ARM.com } 797138Sgblack@eecs.umich.edu } 807138Sgblack@eecs.umich.edu}}; 817138Sgblack@eecs.umich.edu 827138Sgblack@eecs.umich.edudef template DataRegDeclare {{ 837138Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s 847138Sgblack@eecs.umich.edu{ 857138Sgblack@eecs.umich.edu public: 867138Sgblack@eecs.umich.edu // Constructor 877138Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst machInst, IntRegIndex _dest, 887138Sgblack@eecs.umich.edu IntRegIndex _op1, IntRegIndex _op2, 897138Sgblack@eecs.umich.edu int32_t _shiftAmt, ArmShiftType _shiftType); 907138Sgblack@eecs.umich.edu %(BasicExecDeclare)s 917138Sgblack@eecs.umich.edu}; 927138Sgblack@eecs.umich.edu}}; 937138Sgblack@eecs.umich.edu 947138Sgblack@eecs.umich.edudef template DataRegConstructor {{ 957138Sgblack@eecs.umich.edu inline %(class_name)s::%(class_name)s(ExtMachInst machInst, 967138Sgblack@eecs.umich.edu IntRegIndex _dest, 977138Sgblack@eecs.umich.edu IntRegIndex _op1, 987138Sgblack@eecs.umich.edu IntRegIndex _op2, 997138Sgblack@eecs.umich.edu int32_t _shiftAmt, 1007138Sgblack@eecs.umich.edu ArmShiftType _shiftType) 1017138Sgblack@eecs.umich.edu : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 1027138Sgblack@eecs.umich.edu _dest, _op1, _op2, _shiftAmt, _shiftType) 1037138Sgblack@eecs.umich.edu { 1047138Sgblack@eecs.umich.edu %(constructor)s; 1057848SAli.Saidi@ARM.com if (!(condCode == COND_AL || condCode == COND_UC)) { 1067848SAli.Saidi@ARM.com for (int x = 0; x < _numDestRegs; x++) { 1077848SAli.Saidi@ARM.com _srcRegIdx[_numSrcRegs++] = _destRegIdx[x]; 1087848SAli.Saidi@ARM.com } 1097848SAli.Saidi@ARM.com } 1108203SAli.Saidi@ARM.com 1118203SAli.Saidi@ARM.com if (%(is_branch)s){ 1128203SAli.Saidi@ARM.com flags[IsControl] = true; 1138203SAli.Saidi@ARM.com flags[IsIndirectControl] = true; 1148203SAli.Saidi@ARM.com if (condCode == COND_AL || condCode == COND_UC) 1158910Snpremill@irisa.fr flags[IsUncondControl] = true; 1168910Snpremill@irisa.fr else 1178203SAli.Saidi@ARM.com flags[IsCondControl] = true; 1188203SAli.Saidi@ARM.com } 1198203SAli.Saidi@ARM.com 1208203SAli.Saidi@ARM.com if (%(is_ras_pop)s) { 1218203SAli.Saidi@ARM.com flags[IsReturn] = true; 1228203SAli.Saidi@ARM.com } 1237138Sgblack@eecs.umich.edu } 1247138Sgblack@eecs.umich.edu}}; 1257138Sgblack@eecs.umich.edu 1267138Sgblack@eecs.umich.edudef template DataRegRegDeclare {{ 1277138Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s 1287138Sgblack@eecs.umich.edu{ 1297138Sgblack@eecs.umich.edu public: 1307138Sgblack@eecs.umich.edu // Constructor 1317138Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst machInst, IntRegIndex _dest, 1327138Sgblack@eecs.umich.edu IntRegIndex _op1, IntRegIndex _op2, IntRegIndex _shift, 1337138Sgblack@eecs.umich.edu ArmShiftType _shiftType); 1347138Sgblack@eecs.umich.edu %(BasicExecDeclare)s 1357138Sgblack@eecs.umich.edu}; 1367138Sgblack@eecs.umich.edu}}; 1377138Sgblack@eecs.umich.edu 1387138Sgblack@eecs.umich.edudef template DataRegRegConstructor {{ 1397138Sgblack@eecs.umich.edu inline %(class_name)s::%(class_name)s(ExtMachInst machInst, 1407138Sgblack@eecs.umich.edu IntRegIndex _dest, 1417138Sgblack@eecs.umich.edu IntRegIndex _op1, 1427138Sgblack@eecs.umich.edu IntRegIndex _op2, 1437138Sgblack@eecs.umich.edu IntRegIndex _shift, 1447138Sgblack@eecs.umich.edu ArmShiftType _shiftType) 1457138Sgblack@eecs.umich.edu : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 1467138Sgblack@eecs.umich.edu _dest, _op1, _op2, _shift, _shiftType) 1477138Sgblack@eecs.umich.edu { 1487138Sgblack@eecs.umich.edu %(constructor)s; 1497848SAli.Saidi@ARM.com if (!(condCode == COND_AL || condCode == COND_UC)) { 1507848SAli.Saidi@ARM.com for (int x = 0; x < _numDestRegs; x++) { 1517848SAli.Saidi@ARM.com _srcRegIdx[_numSrcRegs++] = _destRegIdx[x]; 1527848SAli.Saidi@ARM.com } 1537848SAli.Saidi@ARM.com } 1547138Sgblack@eecs.umich.edu } 1557138Sgblack@eecs.umich.edu}}; 1567138Sgblack@eecs.umich.edu 1576019SN/Adef template PredOpExecute {{ 1586019SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 1596019SN/A { 1606019SN/A Fault fault = NoFault; 1616271SN/A uint64_t resTemp = 0; 1626271SN/A resTemp = resTemp; 1636019SN/A %(op_decl)s; 1646019SN/A %(op_rd)s; 1656019SN/A 1666243SN/A if (%(predicate_test)s) 1676019SN/A { 1686243SN/A %(code)s; 1696019SN/A if (fault == NoFault) 1706019SN/A { 1716019SN/A %(op_wb)s; 1726019SN/A } 1737597Sminkyu.jeong@arm.com } else { 1747597Sminkyu.jeong@arm.com xc->setPredicate(false); 1756019SN/A } 1766019SN/A 1776019SN/A return fault; 1786019SN/A } 1796019SN/A}}; 1806019SN/A 1818142SAli.Saidi@ARM.comdef template QuiescePredOpExecute {{ 1828142SAli.Saidi@ARM.com Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 1838142SAli.Saidi@ARM.com { 1848142SAli.Saidi@ARM.com Fault fault = NoFault; 1858142SAli.Saidi@ARM.com uint64_t resTemp = 0; 1868142SAli.Saidi@ARM.com resTemp = resTemp; 1878142SAli.Saidi@ARM.com %(op_decl)s; 1888142SAli.Saidi@ARM.com %(op_rd)s; 1898142SAli.Saidi@ARM.com 1908142SAli.Saidi@ARM.com if (%(predicate_test)s) 1918142SAli.Saidi@ARM.com { 1928142SAli.Saidi@ARM.com %(code)s; 1938142SAli.Saidi@ARM.com if (fault == NoFault) 1948142SAli.Saidi@ARM.com { 1958142SAli.Saidi@ARM.com %(op_wb)s; 1968142SAli.Saidi@ARM.com } 1978142SAli.Saidi@ARM.com } else { 1988142SAli.Saidi@ARM.com xc->setPredicate(false); 1998142SAli.Saidi@ARM.com PseudoInst::quiesceSkip(xc->tcBase()); 2008142SAli.Saidi@ARM.com } 2018142SAli.Saidi@ARM.com 2028142SAli.Saidi@ARM.com return fault; 2038142SAli.Saidi@ARM.com } 2048142SAli.Saidi@ARM.com}}; 2058142SAli.Saidi@ARM.com 2068518Sgeoffrey.blake@arm.comdef template QuiescePredOpExecuteWithFixup {{ 2078518Sgeoffrey.blake@arm.com Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 2088518Sgeoffrey.blake@arm.com { 2098518Sgeoffrey.blake@arm.com Fault fault = NoFault; 2108518Sgeoffrey.blake@arm.com uint64_t resTemp = 0; 2118518Sgeoffrey.blake@arm.com resTemp = resTemp; 2128518Sgeoffrey.blake@arm.com %(op_decl)s; 2138518Sgeoffrey.blake@arm.com %(op_rd)s; 2148518Sgeoffrey.blake@arm.com 2158518Sgeoffrey.blake@arm.com if (%(predicate_test)s) 2168518Sgeoffrey.blake@arm.com { 2178518Sgeoffrey.blake@arm.com %(code)s; 2188518Sgeoffrey.blake@arm.com if (fault == NoFault) 2198518Sgeoffrey.blake@arm.com { 2208518Sgeoffrey.blake@arm.com %(op_wb)s; 2218518Sgeoffrey.blake@arm.com } 2228518Sgeoffrey.blake@arm.com } else { 2238518Sgeoffrey.blake@arm.com xc->setPredicate(false); 2248518Sgeoffrey.blake@arm.com %(pred_fixup)s; 2258518Sgeoffrey.blake@arm.com PseudoInst::quiesceSkip(xc->tcBase()); 2268518Sgeoffrey.blake@arm.com } 2278518Sgeoffrey.blake@arm.com 2288518Sgeoffrey.blake@arm.com return fault; 2298518Sgeoffrey.blake@arm.com } 2308518Sgeoffrey.blake@arm.com}}; 2318518Sgeoffrey.blake@arm.com 2326265SN/Adef template DataDecode {{ 2336265SN/A if (machInst.opcode4 == 0) { 2346265SN/A if (machInst.sField == 0) 2356265SN/A return new %(class_name)sImm(machInst); 2366265SN/A else 2376265SN/A return new %(class_name)sImmCc(machInst); 2386265SN/A } else { 2396265SN/A if (machInst.sField == 0) 2406265SN/A return new %(class_name)s(machInst); 2416265SN/A else 2426265SN/A return new %(class_name)sCc(machInst); 2436265SN/A } 2446265SN/A}}; 2456265SN/A 2466270SN/Adef template DataImmDecode {{ 2476270SN/A if (machInst.sField == 0) 2486270SN/A return new %(class_name)s(machInst); 2496270SN/A else 2506270SN/A return new %(class_name)sCc(machInst); 2516270SN/A}}; 252