mem.isa revision 4056
12124SN/A// -*- mode:c++ -*- 22124SN/A 32754Sksewell@umich.edu// Copyright (c) 2006 The Regents of The University of Michigan 42124SN/A// All rights reserved. 52022SN/A// 62124SN/A// Redistribution and use in source and binary forms, with or without 72124SN/A// modification, are permitted provided that the following conditions are 82124SN/A// met: redistributions of source code must retain the above copyright 92124SN/A// notice, this list of conditions and the following disclaimer; 102124SN/A// redistributions in binary form must reproduce the above copyright 112124SN/A// notice, this list of conditions and the following disclaimer in the 122124SN/A// documentation and/or other materials provided with the distribution; 132124SN/A// neither the name of the copyright holders nor the names of its 142124SN/A// contributors may be used to endorse or promote products derived from 152124SN/A// this software without specific prior written permission. 162022SN/A// 172124SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182124SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192124SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202124SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212124SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222124SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232124SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242124SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252124SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262124SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272124SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu// 292935Sksewell@umich.edu// Authors: Steve Reinhardt 302665Ssaidi@eecs.umich.edu// Korey Sewell 312022SN/A 322649Ssaidi@eecs.umich.edu//////////////////////////////////////////////////////////////////// 332649Ssaidi@eecs.umich.edu// 342706Sksewell@umich.edu// Memory-format instructions 352649Ssaidi@eecs.umich.edu// 362649Ssaidi@eecs.umich.edu 372022SN/Aoutput header {{ 382124SN/A /** 392124SN/A * Base class for general Mips memory-format instructions. 402124SN/A */ 412124SN/A class Memory : public MipsStaticInst 422124SN/A { 432124SN/A protected: 442124SN/A 452124SN/A /// Memory request flags. See mem_req_base.hh. 462124SN/A unsigned memAccessFlags; 472124SN/A /// Pointer to EAComp object. 482124SN/A const StaticInstPtr eaCompPtr; 492124SN/A /// Pointer to MemAcc object. 502124SN/A const StaticInstPtr memAccPtr; 512239SN/A 522124SN/A /// Displacement for EA calculation (signed). 532124SN/A int32_t disp; 542124SN/A 552124SN/A /// Constructor 562124SN/A Memory(const char *mnem, MachInst _machInst, OpClass __opClass, 572124SN/A StaticInstPtr _eaCompPtr = nullStaticInstPtr, 582124SN/A StaticInstPtr _memAccPtr = nullStaticInstPtr) 592124SN/A : MipsStaticInst(mnem, _machInst, __opClass), 602124SN/A memAccessFlags(0), eaCompPtr(_eaCompPtr), memAccPtr(_memAccPtr), 612742Sksewell@umich.edu disp(sext<16>(OFFSET)) 622022SN/A { 632124SN/A } 642022SN/A 652124SN/A std::string 662124SN/A generateDisassembly(Addr pc, const SymbolTable *symtab) const; 672022SN/A 682124SN/A public: 692124SN/A 702124SN/A const StaticInstPtr &eaCompInst() const { return eaCompPtr; } 712124SN/A const StaticInstPtr &memAccInst() const { return memAccPtr; } 722124SN/A }; 732124SN/A 742742Sksewell@umich.edu /** 752742Sksewell@umich.edu * Base class for a few miscellaneous memory-format insts 762742Sksewell@umich.edu * that don't interpret the disp field 772742Sksewell@umich.edu */ 782742Sksewell@umich.edu class MemoryNoDisp : public Memory 792742Sksewell@umich.edu { 802742Sksewell@umich.edu protected: 812742Sksewell@umich.edu /// Constructor 822742Sksewell@umich.edu MemoryNoDisp(const char *mnem, ExtMachInst _machInst, OpClass __opClass, 832742Sksewell@umich.edu StaticInstPtr _eaCompPtr = nullStaticInstPtr, 842742Sksewell@umich.edu StaticInstPtr _memAccPtr = nullStaticInstPtr) 852742Sksewell@umich.edu : Memory(mnem, _machInst, __opClass, _eaCompPtr, _memAccPtr) 862742Sksewell@umich.edu { 872742Sksewell@umich.edu } 882742Sksewell@umich.edu 892742Sksewell@umich.edu std::string 902742Sksewell@umich.edu generateDisassembly(Addr pc, const SymbolTable *symtab) const; 912742Sksewell@umich.edu }; 922022SN/A}}; 932022SN/A 942124SN/A 952022SN/Aoutput decoder {{ 962124SN/A std::string 972124SN/A Memory::generateDisassembly(Addr pc, const SymbolTable *symtab) const 982124SN/A { 992742Sksewell@umich.edu return csprintf("%-10s %c%d, %d(r%d)", mnemonic, 1002239SN/A flags[IsFloating] ? 'f' : 'r', RT, disp, RS); 1012124SN/A } 1022124SN/A 1032742Sksewell@umich.edu std::string 1042742Sksewell@umich.edu MemoryNoDisp::generateDisassembly(Addr pc, const SymbolTable *symtab) const 1052742Sksewell@umich.edu { 1062742Sksewell@umich.edu return csprintf("%-10s %c%d, r%d(r%d)", mnemonic, 1072742Sksewell@umich.edu flags[IsFloating] ? 'f' : 'r', 1082742Sksewell@umich.edu flags[IsFloating] ? FD : RD, 1092742Sksewell@umich.edu RS, RT); 1102742Sksewell@umich.edu } 1112022SN/A}}; 1122022SN/A 1132124SN/Adef template LoadStoreDeclare {{ 1142124SN/A /** 1152124SN/A * Static instruction class for "%(mnemonic)s". 1162124SN/A */ 1172124SN/A class %(class_name)s : public %(base_class)s 1182124SN/A { 1192124SN/A protected: 1202124SN/A 1212124SN/A /** 1222124SN/A * "Fake" effective address computation class for "%(mnemonic)s". 1232124SN/A */ 1242124SN/A class EAComp : public %(base_class)s 1252124SN/A { 1262124SN/A public: 1272124SN/A /// Constructor 1282124SN/A EAComp(MachInst machInst); 1292124SN/A 1302124SN/A %(BasicExecDeclare)s 1312124SN/A }; 1322124SN/A 1332124SN/A /** 1342124SN/A * "Fake" memory access instruction class for "%(mnemonic)s". 1352124SN/A */ 1362124SN/A class MemAcc : public %(base_class)s 1372124SN/A { 1382124SN/A public: 1392124SN/A /// Constructor 1402124SN/A MemAcc(MachInst machInst); 1412124SN/A 1422124SN/A %(BasicExecDeclare)s 1432124SN/A }; 1442124SN/A 1452124SN/A public: 1462124SN/A 1472124SN/A /// Constructor. 1482124SN/A %(class_name)s(MachInst machInst); 1492124SN/A 1502124SN/A %(BasicExecDeclare)s 1512124SN/A 1522124SN/A %(InitiateAccDeclare)s 1532124SN/A 1542124SN/A %(CompleteAccDeclare)s 1552124SN/A }; 1562022SN/A}}; 1572022SN/A 1582124SN/A 1592124SN/Adef template InitiateAccDeclare {{ 1602132SN/A Fault initiateAcc(%(CPU_exec_context)s *, Trace::InstRecord *) const; 1612022SN/A}}; 1622124SN/A 1632124SN/A 1642124SN/Adef template CompleteAccDeclare {{ 1653349Sbinkertn@umich.edu Fault completeAcc(PacketPtr, %(CPU_exec_context)s *, Trace::InstRecord *) const; 1662124SN/A}}; 1672124SN/A 1682124SN/A 1693953Sstever@eecs.umich.edudef template EACompConstructor {{ 1702124SN/A /** TODO: change op_class to AddrGenOp or something (requires 1712124SN/A * creating new member of OpClass enum in op_class.hh, updating 1722124SN/A * config files, etc.). */ 1732124SN/A inline %(class_name)s::EAComp::EAComp(MachInst machInst) 1742124SN/A : %(base_class)s("%(mnemonic)s (EAComp)", machInst, IntAluOp) 1752124SN/A { 1763953Sstever@eecs.umich.edu %(constructor)s; 1772124SN/A } 1783953Sstever@eecs.umich.edu}}; 1792124SN/A 1803953Sstever@eecs.umich.edu 1813953Sstever@eecs.umich.edudef template MemAccConstructor {{ 1822124SN/A inline %(class_name)s::MemAcc::MemAcc(MachInst machInst) 1832124SN/A : %(base_class)s("%(mnemonic)s (MemAcc)", machInst, %(op_class)s) 1842124SN/A { 1853953Sstever@eecs.umich.edu %(constructor)s; 1862124SN/A } 1873953Sstever@eecs.umich.edu}}; 1882124SN/A 1893953Sstever@eecs.umich.edu 1903953Sstever@eecs.umich.edudef template LoadStoreConstructor {{ 1912124SN/A inline %(class_name)s::%(class_name)s(MachInst machInst) 1922124SN/A : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 1932124SN/A new EAComp(machInst), new MemAcc(machInst)) 1942124SN/A { 1952124SN/A %(constructor)s; 1962124SN/A } 1972124SN/A}}; 1982124SN/A 1992124SN/A 2002124SN/Adef template EACompExecute {{ 2012132SN/A Fault 2022124SN/A %(class_name)s::EAComp::execute(%(CPU_exec_context)s *xc, 2032124SN/A Trace::InstRecord *traceData) const 2042124SN/A { 2052124SN/A Addr EA; 2062132SN/A Fault fault = NoFault; 2072124SN/A 2082124SN/A %(fp_enable_check)s; 2092124SN/A %(op_decl)s; 2102124SN/A %(op_rd)s; 2113953Sstever@eecs.umich.edu %(ea_code)s; 2122124SN/A 2132124SN/A if (fault == NoFault) { 2142124SN/A %(op_wb)s; 2152124SN/A xc->setEA(EA); 2162124SN/A } 2172124SN/A 2182124SN/A return fault; 2192124SN/A } 2202124SN/A}}; 2212124SN/A 2222124SN/Adef template LoadMemAccExecute {{ 2232132SN/A Fault 2242124SN/A %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 2252124SN/A Trace::InstRecord *traceData) const 2262124SN/A { 2272239SN/A Addr EA; 2282132SN/A Fault fault = NoFault; 2292239SN/A 2302239SN/A %(fp_enable_check)s; 2312239SN/A %(op_decl)s; 2322239SN/A %(op_rd)s; 2332239SN/A EA = xc->getEA(); 2342239SN/A 2352239SN/A if (fault == NoFault) { 2362239SN/A fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags); 2373953Sstever@eecs.umich.edu %(memacc_code)s; 2382239SN/A } 2392239SN/A 2402239SN/A if (fault == NoFault) { 2412239SN/A %(op_wb)s; 2422239SN/A } 2432239SN/A 2442124SN/A return fault; 2452124SN/A } 2462124SN/A}}; 2472124SN/A 2482124SN/A 2492124SN/Adef template LoadExecute {{ 2502132SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 2512124SN/A Trace::InstRecord *traceData) const 2522124SN/A { 2532124SN/A Addr EA; 2542132SN/A Fault fault = NoFault; 2552124SN/A 2562124SN/A %(fp_enable_check)s; 2572124SN/A %(op_decl)s; 2582124SN/A %(op_rd)s; 2592124SN/A %(ea_code)s; 2602124SN/A 2612124SN/A if (fault == NoFault) { 2622124SN/A fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags); 2632124SN/A %(memacc_code)s; 2642124SN/A } 2652124SN/A 2662124SN/A if (fault == NoFault) { 2672124SN/A %(op_wb)s; 2682124SN/A } 2692124SN/A 2702124SN/A return fault; 2712124SN/A } 2722124SN/A}}; 2732124SN/A 2742124SN/A 2752124SN/Adef template LoadInitiateAcc {{ 2762132SN/A Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 2772124SN/A Trace::InstRecord *traceData) const 2782124SN/A { 2792239SN/A Addr EA; 2802132SN/A Fault fault = NoFault; 2812239SN/A 2822239SN/A %(fp_enable_check)s; 2832239SN/A %(op_src_decl)s; 2842239SN/A %(op_rd)s; 2852239SN/A %(ea_code)s; 2862239SN/A 2872239SN/A if (fault == NoFault) { 2882239SN/A fault = xc->read(EA, (uint%(mem_acc_size)d_t &)Mem, memAccessFlags); 2892239SN/A } 2902239SN/A 2912124SN/A return fault; 2922124SN/A } 2932124SN/A}}; 2942124SN/A 2952124SN/A 2962124SN/Adef template LoadCompleteAcc {{ 2973349Sbinkertn@umich.edu Fault %(class_name)s::completeAcc(PacketPtr pkt, 2982124SN/A %(CPU_exec_context)s *xc, 2992124SN/A Trace::InstRecord *traceData) const 3002124SN/A { 3012132SN/A Fault fault = NoFault; 3022239SN/A 3032239SN/A %(fp_enable_check)s; 3042506SN/A %(op_decl)s; 3052239SN/A 3062935Sksewell@umich.edu Mem = pkt->get<typeof(Mem)>(); 3072239SN/A 3082239SN/A if (fault == NoFault) { 3092239SN/A %(memacc_code)s; 3102239SN/A } 3112239SN/A 3122239SN/A if (fault == NoFault) { 3132239SN/A %(op_wb)s; 3142239SN/A } 3152239SN/A 3162124SN/A return fault; 3172124SN/A } 3182124SN/A}}; 3192124SN/A 3202124SN/A 3212124SN/Adef template StoreMemAccExecute {{ 3222132SN/A Fault 3232124SN/A %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 3242124SN/A Trace::InstRecord *traceData) const 3252124SN/A { 3262239SN/A Addr EA; 3272132SN/A Fault fault = NoFault; 3284056Sstever@eecs.umich.edu 3294056Sstever@eecs.umich.edu %(fp_enable_check)s; 3304056Sstever@eecs.umich.edu %(op_decl)s; 3314056Sstever@eecs.umich.edu %(op_rd)s; 3324056Sstever@eecs.umich.edu EA = xc->getEA(); 3334056Sstever@eecs.umich.edu 3344056Sstever@eecs.umich.edu if (fault == NoFault) { 3354056Sstever@eecs.umich.edu %(memacc_code)s; 3364056Sstever@eecs.umich.edu } 3374056Sstever@eecs.umich.edu 3384056Sstever@eecs.umich.edu if (fault == NoFault) { 3394056Sstever@eecs.umich.edu fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 3404056Sstever@eecs.umich.edu memAccessFlags, NULL); 3414056Sstever@eecs.umich.edu if (traceData) { traceData->setData(Mem); } 3424056Sstever@eecs.umich.edu } 3434056Sstever@eecs.umich.edu 3444056Sstever@eecs.umich.edu if (fault == NoFault) { 3454056Sstever@eecs.umich.edu %(postacc_code)s; 3464056Sstever@eecs.umich.edu } 3474056Sstever@eecs.umich.edu 3484056Sstever@eecs.umich.edu if (fault == NoFault) { 3494056Sstever@eecs.umich.edu %(op_wb)s; 3504056Sstever@eecs.umich.edu } 3514056Sstever@eecs.umich.edu 3524056Sstever@eecs.umich.edu return fault; 3534056Sstever@eecs.umich.edu } 3544056Sstever@eecs.umich.edu}}; 3554056Sstever@eecs.umich.edu 3564056Sstever@eecs.umich.edudef template StoreCondMemAccExecute {{ 3574056Sstever@eecs.umich.edu Fault 3584056Sstever@eecs.umich.edu %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 3594056Sstever@eecs.umich.edu Trace::InstRecord *traceData) const 3604056Sstever@eecs.umich.edu { 3614056Sstever@eecs.umich.edu Addr EA; 3624056Sstever@eecs.umich.edu Fault fault = NoFault; 3632239SN/A uint64_t write_result = 0; 3642239SN/A 3652239SN/A %(fp_enable_check)s; 3662239SN/A %(op_decl)s; 3672239SN/A %(op_rd)s; 3682239SN/A EA = xc->getEA(); 3692239SN/A 3702239SN/A if (fault == NoFault) { 3713953Sstever@eecs.umich.edu %(memacc_code)s; 3722239SN/A } 3732239SN/A 3742239SN/A if (fault == NoFault) { 3752239SN/A fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 3762239SN/A memAccessFlags, &write_result); 3772239SN/A if (traceData) { traceData->setData(Mem); } 3782239SN/A } 3792239SN/A 3802239SN/A if (fault == NoFault) { 3812239SN/A %(postacc_code)s; 3822239SN/A } 3832239SN/A 3842239SN/A if (fault == NoFault) { 3852239SN/A %(op_wb)s; 3862239SN/A } 3872239SN/A 3882124SN/A return fault; 3892124SN/A } 3902124SN/A}}; 3912124SN/A 3922124SN/A 3932124SN/Adef template StoreExecute {{ 3942132SN/A Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 3952124SN/A Trace::InstRecord *traceData) const 3962124SN/A { 3972124SN/A Addr EA; 3982132SN/A Fault fault = NoFault; 3994056Sstever@eecs.umich.edu 4004056Sstever@eecs.umich.edu %(fp_enable_check)s; 4014056Sstever@eecs.umich.edu %(op_decl)s; 4024056Sstever@eecs.umich.edu %(op_rd)s; 4034056Sstever@eecs.umich.edu %(ea_code)s; 4044056Sstever@eecs.umich.edu 4054056Sstever@eecs.umich.edu if (fault == NoFault) { 4064056Sstever@eecs.umich.edu %(memacc_code)s; 4074056Sstever@eecs.umich.edu } 4084056Sstever@eecs.umich.edu 4094056Sstever@eecs.umich.edu if (fault == NoFault) { 4104056Sstever@eecs.umich.edu fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 4114056Sstever@eecs.umich.edu memAccessFlags, NULL); 4124056Sstever@eecs.umich.edu if (traceData) { traceData->setData(Mem); } 4134056Sstever@eecs.umich.edu } 4144056Sstever@eecs.umich.edu 4154056Sstever@eecs.umich.edu if (fault == NoFault) { 4164056Sstever@eecs.umich.edu %(postacc_code)s; 4174056Sstever@eecs.umich.edu } 4184056Sstever@eecs.umich.edu 4194056Sstever@eecs.umich.edu if (fault == NoFault) { 4204056Sstever@eecs.umich.edu %(op_wb)s; 4214056Sstever@eecs.umich.edu } 4224056Sstever@eecs.umich.edu 4234056Sstever@eecs.umich.edu return fault; 4244056Sstever@eecs.umich.edu } 4254056Sstever@eecs.umich.edu}}; 4264056Sstever@eecs.umich.edu 4274056Sstever@eecs.umich.edudef template StoreCondExecute {{ 4284056Sstever@eecs.umich.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 4294056Sstever@eecs.umich.edu Trace::InstRecord *traceData) const 4304056Sstever@eecs.umich.edu { 4314056Sstever@eecs.umich.edu Addr EA; 4324056Sstever@eecs.umich.edu Fault fault = NoFault; 4332124SN/A uint64_t write_result = 0; 4342124SN/A 4352124SN/A %(fp_enable_check)s; 4362124SN/A %(op_decl)s; 4372124SN/A %(op_rd)s; 4382124SN/A %(ea_code)s; 4392124SN/A 4402124SN/A if (fault == NoFault) { 4412124SN/A %(memacc_code)s; 4422124SN/A } 4432124SN/A 4442124SN/A if (fault == NoFault) { 4452124SN/A fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 4462124SN/A memAccessFlags, &write_result); 4472124SN/A if (traceData) { traceData->setData(Mem); } 4482124SN/A } 4492124SN/A 4502124SN/A if (fault == NoFault) { 4512124SN/A %(postacc_code)s; 4522124SN/A } 4532124SN/A 4542124SN/A if (fault == NoFault) { 4552124SN/A %(op_wb)s; 4562124SN/A } 4572124SN/A 4582124SN/A return fault; 4592124SN/A } 4602124SN/A}}; 4612124SN/A 4622124SN/Adef template StoreInitiateAcc {{ 4632132SN/A Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 4642124SN/A Trace::InstRecord *traceData) const 4652124SN/A { 4662239SN/A Addr EA; 4672132SN/A Fault fault = NoFault; 4682239SN/A 4692239SN/A %(fp_enable_check)s; 4702506SN/A %(op_decl)s; 4712239SN/A %(op_rd)s; 4722239SN/A %(ea_code)s; 4732239SN/A 4742239SN/A if (fault == NoFault) { 4752239SN/A %(memacc_code)s; 4762239SN/A } 4772239SN/A 4782239SN/A if (fault == NoFault) { 4792239SN/A fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 4802935Sksewell@umich.edu memAccessFlags, NULL); 4812239SN/A if (traceData) { traceData->setData(Mem); } 4822239SN/A } 4832239SN/A 4842124SN/A return fault; 4852124SN/A } 4862124SN/A}}; 4872124SN/A 4882124SN/A 4892124SN/Adef template StoreCompleteAcc {{ 4903349Sbinkertn@umich.edu Fault %(class_name)s::completeAcc(PacketPtr pkt, 4912124SN/A %(CPU_exec_context)s *xc, 4922124SN/A Trace::InstRecord *traceData) const 4932124SN/A { 4942132SN/A Fault fault = NoFault; 4952239SN/A 4962239SN/A %(fp_enable_check)s; 4972239SN/A %(op_dest_decl)s; 4982239SN/A 4992935Sksewell@umich.edu if (fault == NoFault) { 5002935Sksewell@umich.edu %(postacc_code)s; 5012935Sksewell@umich.edu } 5022935Sksewell@umich.edu 5032935Sksewell@umich.edu if (fault == NoFault) { 5042935Sksewell@umich.edu %(op_wb)s; 5052935Sksewell@umich.edu } 5062935Sksewell@umich.edu 5072935Sksewell@umich.edu return fault; 5082935Sksewell@umich.edu } 5092935Sksewell@umich.edu}}; 5102935Sksewell@umich.edu 5112935Sksewell@umich.edudef template StoreCondCompleteAcc {{ 5123349Sbinkertn@umich.edu Fault %(class_name)s::completeAcc(PacketPtr pkt, 5132935Sksewell@umich.edu %(CPU_exec_context)s *xc, 5142935Sksewell@umich.edu Trace::InstRecord *traceData) const 5152935Sksewell@umich.edu { 5162935Sksewell@umich.edu Fault fault = NoFault; 5172935Sksewell@umich.edu 5182935Sksewell@umich.edu %(fp_enable_check)s; 5192935Sksewell@umich.edu %(op_dest_decl)s; 5202935Sksewell@umich.edu 5214055Ssaidi@eecs.umich.edu uint64_t write_result = pkt->req->getExtraData(); 5222239SN/A 5232239SN/A if (fault == NoFault) { 5242239SN/A %(postacc_code)s; 5252239SN/A } 5262239SN/A 5272239SN/A if (fault == NoFault) { 5282239SN/A %(op_wb)s; 5292239SN/A } 5302239SN/A 5312124SN/A return fault; 5322124SN/A } 5332124SN/A}}; 5342124SN/A 5352686Sksewell@umich.edu 5362686Sksewell@umich.edudef template MiscMemAccExecute {{ 5372686Sksewell@umich.edu Fault %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 5382686Sksewell@umich.edu Trace::InstRecord *traceData) const 5392686Sksewell@umich.edu { 5402686Sksewell@umich.edu Addr EA; 5412686Sksewell@umich.edu Fault fault = NoFault; 5422686Sksewell@umich.edu 5432686Sksewell@umich.edu %(fp_enable_check)s; 5442686Sksewell@umich.edu %(op_decl)s; 5452686Sksewell@umich.edu %(op_rd)s; 5462686Sksewell@umich.edu EA = xc->getEA(); 5472686Sksewell@umich.edu 5482686Sksewell@umich.edu if (fault == NoFault) { 5493953Sstever@eecs.umich.edu %(memacc_code)s; 5502686Sksewell@umich.edu } 5512686Sksewell@umich.edu 5522686Sksewell@umich.edu return NoFault; 5532686Sksewell@umich.edu } 5542686Sksewell@umich.edu}}; 5552686Sksewell@umich.edu 5562686Sksewell@umich.edudef template MiscExecute {{ 5572686Sksewell@umich.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 5582686Sksewell@umich.edu Trace::InstRecord *traceData) const 5592686Sksewell@umich.edu { 5602686Sksewell@umich.edu Addr EA; 5612686Sksewell@umich.edu Fault fault = NoFault; 5622686Sksewell@umich.edu 5632686Sksewell@umich.edu %(fp_enable_check)s; 5642686Sksewell@umich.edu %(op_decl)s; 5652686Sksewell@umich.edu %(op_rd)s; 5662686Sksewell@umich.edu %(ea_code)s; 5672686Sksewell@umich.edu 5682686Sksewell@umich.edu if (fault == NoFault) { 5692686Sksewell@umich.edu %(memacc_code)s; 5702686Sksewell@umich.edu } 5712686Sksewell@umich.edu 5722686Sksewell@umich.edu return NoFault; 5732686Sksewell@umich.edu } 5742686Sksewell@umich.edu}}; 5752686Sksewell@umich.edu 5762686Sksewell@umich.edudef template MiscInitiateAcc {{ 5772686Sksewell@umich.edu Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 5782686Sksewell@umich.edu Trace::InstRecord *traceData) const 5792686Sksewell@umich.edu { 5802686Sksewell@umich.edu panic("Misc instruction does not support split access method!"); 5812686Sksewell@umich.edu return NoFault; 5822686Sksewell@umich.edu } 5832686Sksewell@umich.edu}}; 5842686Sksewell@umich.edu 5852686Sksewell@umich.edu 5862686Sksewell@umich.edudef template MiscCompleteAcc {{ 5873349Sbinkertn@umich.edu Fault %(class_name)s::completeAcc(PacketPtr pkt, 5882686Sksewell@umich.edu %(CPU_exec_context)s *xc, 5892686Sksewell@umich.edu Trace::InstRecord *traceData) const 5902686Sksewell@umich.edu { 5912686Sksewell@umich.edu panic("Misc instruction does not support split access method!"); 5922686Sksewell@umich.edu 5932686Sksewell@umich.edu return NoFault; 5942686Sksewell@umich.edu } 5952686Sksewell@umich.edu}}; 5962686Sksewell@umich.edu 5972124SN/Adef format LoadMemory(memacc_code, ea_code = {{ EA = Rs + disp; }}, 5982124SN/A mem_flags = [], inst_flags = []) {{ 5992124SN/A (header_output, decoder_output, decode_block, exec_output) = \ 6002124SN/A LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 6012750Sksewell@umich.edu decode_template = ImmNopCheckDecode, 6022124SN/A exec_template_base = 'Load') 6032124SN/A}}; 6042124SN/A 6052124SN/Adef format StoreMemory(memacc_code, ea_code = {{ EA = Rs + disp; }}, 6062124SN/A mem_flags = [], inst_flags = []) {{ 6072124SN/A (header_output, decoder_output, decode_block, exec_output) = \ 6082124SN/A LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 6092124SN/A exec_template_base = 'Store') 6102124SN/A}}; 6112124SN/A 6122686Sksewell@umich.edudef format LoadIndexedMemory(memacc_code, ea_code = {{ EA = Rs + Rt; }}, 6132573SN/A mem_flags = [], inst_flags = []) {{ 6142573SN/A (header_output, decoder_output, decode_block, exec_output) = \ 6152573SN/A LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 6162750Sksewell@umich.edu decode_template = ImmNopCheckDecode, 6172573SN/A exec_template_base = 'Load') 6182573SN/A}}; 6192573SN/A 6202686Sksewell@umich.edudef format StoreIndexedMemory(memacc_code, ea_code = {{ EA = Rs + Rt; }}, 6212573SN/A mem_flags = [], inst_flags = []) {{ 6222573SN/A (header_output, decoder_output, decode_block, exec_output) = \ 6232573SN/A LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 6242573SN/A exec_template_base = 'Store') 6252573SN/A}}; 6262573SN/A 6272686Sksewell@umich.edudef format LoadUnalignedMemory(memacc_code, ea_code = {{ EA = (Rs + disp) & ~3; }}, 6282686Sksewell@umich.edu mem_flags = [], inst_flags = []) {{ 6292686Sksewell@umich.edu decl_code = 'uint32_t mem_word = Mem.uw;\n' 6302686Sksewell@umich.edu decl_code += 'uint32_t unalign_addr = Rs + disp;\n' 6312686Sksewell@umich.edu decl_code += 'uint32_t byte_offset = unalign_addr & 3;\n' 6322686Sksewell@umich.edu decl_code += '#if BYTE_ORDER == BIG_ENDIAN\n' 6332686Sksewell@umich.edu decl_code += '\tbyte_offset ^= 3;\n' 6342686Sksewell@umich.edu decl_code += '#endif\n' 6352573SN/A 6362686Sksewell@umich.edu memacc_code = decl_code + memacc_code 6372686Sksewell@umich.edu 6382686Sksewell@umich.edu (header_output, decoder_output, decode_block, exec_output) = \ 6392686Sksewell@umich.edu LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 6402750Sksewell@umich.edu decode_template = ImmNopCheckDecode, 6412686Sksewell@umich.edu exec_template_base = 'Load') 6422686Sksewell@umich.edu}}; 6432686Sksewell@umich.edu 6442686Sksewell@umich.edudef format StoreUnalignedMemory(memacc_code, ea_code = {{ EA = (Rs + disp) & ~3; }}, 6452686Sksewell@umich.edu mem_flags = [], inst_flags = []) {{ 6462686Sksewell@umich.edu decl_code = 'uint32_t mem_word = 0;\n' 6472686Sksewell@umich.edu decl_code += 'uint32_t unaligned_addr = Rs + disp;\n' 6482686Sksewell@umich.edu decl_code += 'uint32_t byte_offset = unaligned_addr & 3;\n' 6492686Sksewell@umich.edu decl_code += '#if BYTE_ORDER == BIG_ENDIAN\n' 6502686Sksewell@umich.edu decl_code += '\tbyte_offset ^= 3;\n' 6512686Sksewell@umich.edu decl_code += '#endif\n' 6522686Sksewell@umich.edu decl_code += 'fault = xc->read(EA, (uint32_t&)mem_word, memAccessFlags);\n' 6532686Sksewell@umich.edu memacc_code = decl_code + memacc_code + '\nMem = mem_word;\n' 6542686Sksewell@umich.edu 6552686Sksewell@umich.edu (header_output, decoder_output, decode_block, exec_output) = \ 6562686Sksewell@umich.edu LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 6572686Sksewell@umich.edu exec_template_base = 'Store') 6582686Sksewell@umich.edu}}; 6592686Sksewell@umich.edu 6602686Sksewell@umich.edudef format Prefetch(ea_code = {{ EA = Rs + disp; }}, 6612686Sksewell@umich.edu mem_flags = [], pf_flags = [], inst_flags = []) {{ 6622686Sksewell@umich.edu pf_mem_flags = mem_flags + pf_flags + ['NO_FAULT'] 6632686Sksewell@umich.edu pf_inst_flags = inst_flags + ['IsMemRef', 'IsLoad', 6642686Sksewell@umich.edu 'IsDataPrefetch', 'MemReadOp'] 6652686Sksewell@umich.edu 6662686Sksewell@umich.edu (header_output, decoder_output, decode_block, exec_output) = \ 6672686Sksewell@umich.edu LoadStoreBase(name, Name, ea_code, 6682686Sksewell@umich.edu 'xc->prefetch(EA, memAccessFlags);', 6692686Sksewell@umich.edu pf_mem_flags, pf_inst_flags, exec_template_base = 'Misc') 6702686Sksewell@umich.edu 6712686Sksewell@umich.edu}}; 6722686Sksewell@umich.edu 6732686Sksewell@umich.edudef format StoreCond(memacc_code, postacc_code, 6742686Sksewell@umich.edu ea_code = {{ EA = Rs + disp; }}, 6752495SN/A mem_flags = [], inst_flags = []) {{ 6762495SN/A (header_output, decoder_output, decode_block, exec_output) = \ 6772495SN/A LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 6782935Sksewell@umich.edu postacc_code, exec_template_base = 'StoreCond') 6792495SN/A}}; 680