mem.isa revision 6303
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// Memory-format instructions 346019Shines@cs.fsu.edu// 356019Shines@cs.fsu.edu 366019Shines@cs.fsu.edudef template LoadStoreDeclare {{ 376019Shines@cs.fsu.edu /** 386019Shines@cs.fsu.edu * Static instruction class for "%(mnemonic)s". 396019Shines@cs.fsu.edu */ 406019Shines@cs.fsu.edu class %(class_name)s : public %(base_class)s 416019Shines@cs.fsu.edu { 426019Shines@cs.fsu.edu protected: 436019Shines@cs.fsu.edu 446019Shines@cs.fsu.edu /** 456019Shines@cs.fsu.edu * "Fake" effective address computation class for "%(mnemonic)s". 466019Shines@cs.fsu.edu */ 476019Shines@cs.fsu.edu class EAComp : public %(base_class)s 486019Shines@cs.fsu.edu { 496019Shines@cs.fsu.edu public: 506019Shines@cs.fsu.edu /// Constructor 516250Sgblack@eecs.umich.edu EAComp(ExtMachInst machInst); 526019Shines@cs.fsu.edu 536019Shines@cs.fsu.edu %(BasicExecDeclare)s 546019Shines@cs.fsu.edu }; 556019Shines@cs.fsu.edu 566019Shines@cs.fsu.edu /** 576019Shines@cs.fsu.edu * "Fake" memory access instruction class for "%(mnemonic)s". 586019Shines@cs.fsu.edu */ 596019Shines@cs.fsu.edu class MemAcc : public %(base_class)s 606019Shines@cs.fsu.edu { 616019Shines@cs.fsu.edu public: 626019Shines@cs.fsu.edu /// Constructor 636250Sgblack@eecs.umich.edu MemAcc(ExtMachInst machInst); 646019Shines@cs.fsu.edu 656019Shines@cs.fsu.edu %(BasicExecDeclare)s 666019Shines@cs.fsu.edu }; 676019Shines@cs.fsu.edu 686019Shines@cs.fsu.edu public: 696019Shines@cs.fsu.edu 706019Shines@cs.fsu.edu /// Constructor. 716250Sgblack@eecs.umich.edu %(class_name)s(ExtMachInst machInst); 726019Shines@cs.fsu.edu 736019Shines@cs.fsu.edu %(BasicExecDeclare)s 746019Shines@cs.fsu.edu 756019Shines@cs.fsu.edu %(InitiateAccDeclare)s 766019Shines@cs.fsu.edu 776019Shines@cs.fsu.edu %(CompleteAccDeclare)s 786019Shines@cs.fsu.edu }; 796019Shines@cs.fsu.edu}}; 806019Shines@cs.fsu.edu 816019Shines@cs.fsu.edu 826019Shines@cs.fsu.edudef template InitiateAccDeclare {{ 836019Shines@cs.fsu.edu Fault initiateAcc(%(CPU_exec_context)s *, Trace::InstRecord *) const; 846019Shines@cs.fsu.edu}}; 856019Shines@cs.fsu.edu 866019Shines@cs.fsu.edu 876019Shines@cs.fsu.edudef template CompleteAccDeclare {{ 886019Shines@cs.fsu.edu Fault completeAcc(PacketPtr, %(CPU_exec_context)s *, Trace::InstRecord *) const; 896019Shines@cs.fsu.edu}}; 906019Shines@cs.fsu.edu 916019Shines@cs.fsu.edu 926019Shines@cs.fsu.edudef template EACompConstructor {{ 936250Sgblack@eecs.umich.edu inline %(class_name)s::EAComp::EAComp(ExtMachInst machInst) 946019Shines@cs.fsu.edu : %(base_class)s("%(mnemonic)s (EAComp)", machInst, IntAluOp) 956019Shines@cs.fsu.edu { 966019Shines@cs.fsu.edu %(constructor)s; 976019Shines@cs.fsu.edu } 986019Shines@cs.fsu.edu}}; 996019Shines@cs.fsu.edu 1006019Shines@cs.fsu.edu 1016019Shines@cs.fsu.edudef template MemAccConstructor {{ 1026250Sgblack@eecs.umich.edu inline %(class_name)s::MemAcc::MemAcc(ExtMachInst machInst) 1036019Shines@cs.fsu.edu : %(base_class)s("%(mnemonic)s (MemAcc)", machInst, %(op_class)s) 1046019Shines@cs.fsu.edu { 1056019Shines@cs.fsu.edu %(constructor)s; 1066019Shines@cs.fsu.edu } 1076019Shines@cs.fsu.edu}}; 1086019Shines@cs.fsu.edu 1096019Shines@cs.fsu.edu 1106019Shines@cs.fsu.edudef template LoadStoreConstructor {{ 1116250Sgblack@eecs.umich.edu inline %(class_name)s::%(class_name)s(ExtMachInst machInst) 1126019Shines@cs.fsu.edu : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 1136019Shines@cs.fsu.edu new EAComp(machInst), new MemAcc(machInst)) 1146019Shines@cs.fsu.edu { 1156019Shines@cs.fsu.edu %(constructor)s; 1166019Shines@cs.fsu.edu } 1176019Shines@cs.fsu.edu}}; 1186019Shines@cs.fsu.edu 1196019Shines@cs.fsu.edu 1206019Shines@cs.fsu.edudef template EACompExecute {{ 1216019Shines@cs.fsu.edu Fault 1226019Shines@cs.fsu.edu %(class_name)s::EAComp::execute(%(CPU_exec_context)s *xc, 1236019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 1246019Shines@cs.fsu.edu { 1256019Shines@cs.fsu.edu Addr EA; 1266019Shines@cs.fsu.edu Fault fault = NoFault; 1276019Shines@cs.fsu.edu 1286019Shines@cs.fsu.edu %(op_decl)s; 1296019Shines@cs.fsu.edu %(op_rd)s; 1306019Shines@cs.fsu.edu %(ea_code)s; 1316019Shines@cs.fsu.edu 1326243Sgblack@eecs.umich.edu if (%(predicate_test)s) 1336019Shines@cs.fsu.edu { 1346019Shines@cs.fsu.edu if (fault == NoFault) { 1356019Shines@cs.fsu.edu %(op_wb)s; 1366019Shines@cs.fsu.edu xc->setEA(EA); 1376019Shines@cs.fsu.edu } 1386019Shines@cs.fsu.edu } 1396019Shines@cs.fsu.edu 1406019Shines@cs.fsu.edu return fault; 1416019Shines@cs.fsu.edu } 1426019Shines@cs.fsu.edu}}; 1436019Shines@cs.fsu.edu 1446019Shines@cs.fsu.edudef template LoadMemAccExecute {{ 1456019Shines@cs.fsu.edu Fault 1466019Shines@cs.fsu.edu %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 1476019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 1486019Shines@cs.fsu.edu { 1496019Shines@cs.fsu.edu Addr EA; 1506019Shines@cs.fsu.edu Fault fault = NoFault; 1516019Shines@cs.fsu.edu 1526019Shines@cs.fsu.edu %(op_decl)s; 1536019Shines@cs.fsu.edu %(op_rd)s; 1546019Shines@cs.fsu.edu EA = xc->getEA(); 1556019Shines@cs.fsu.edu 1566243Sgblack@eecs.umich.edu if (%(predicate_test)s) 1576019Shines@cs.fsu.edu { 1586019Shines@cs.fsu.edu if (fault == NoFault) { 1596019Shines@cs.fsu.edu fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags); 1606019Shines@cs.fsu.edu %(memacc_code)s; 1616019Shines@cs.fsu.edu } 1626019Shines@cs.fsu.edu 1636019Shines@cs.fsu.edu if (fault == NoFault) { 1646019Shines@cs.fsu.edu %(op_wb)s; 1656019Shines@cs.fsu.edu } 1666019Shines@cs.fsu.edu } 1676019Shines@cs.fsu.edu 1686019Shines@cs.fsu.edu return fault; 1696019Shines@cs.fsu.edu } 1706019Shines@cs.fsu.edu}}; 1716019Shines@cs.fsu.edu 1726019Shines@cs.fsu.edu 1736019Shines@cs.fsu.edudef template LoadExecute {{ 1746019Shines@cs.fsu.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 1756019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 1766019Shines@cs.fsu.edu { 1776019Shines@cs.fsu.edu Addr EA; 1786019Shines@cs.fsu.edu Fault fault = NoFault; 1796019Shines@cs.fsu.edu 1806019Shines@cs.fsu.edu %(op_decl)s; 1816019Shines@cs.fsu.edu %(op_rd)s; 1826019Shines@cs.fsu.edu %(ea_code)s; 1836019Shines@cs.fsu.edu 1846243Sgblack@eecs.umich.edu if (%(predicate_test)s) 1856019Shines@cs.fsu.edu { 1866019Shines@cs.fsu.edu if (fault == NoFault) { 1876019Shines@cs.fsu.edu fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags); 1886019Shines@cs.fsu.edu %(memacc_code)s; 1896019Shines@cs.fsu.edu } 1906019Shines@cs.fsu.edu 1916019Shines@cs.fsu.edu if (fault == NoFault) { 1926019Shines@cs.fsu.edu %(op_wb)s; 1936019Shines@cs.fsu.edu } 1946019Shines@cs.fsu.edu } 1956019Shines@cs.fsu.edu 1966019Shines@cs.fsu.edu return fault; 1976019Shines@cs.fsu.edu } 1986019Shines@cs.fsu.edu}}; 1996019Shines@cs.fsu.edu 2006019Shines@cs.fsu.edu 2016019Shines@cs.fsu.edudef template LoadInitiateAcc {{ 2026019Shines@cs.fsu.edu Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 2036019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 2046019Shines@cs.fsu.edu { 2056019Shines@cs.fsu.edu Addr EA; 2066019Shines@cs.fsu.edu Fault fault = NoFault; 2076019Shines@cs.fsu.edu 2086019Shines@cs.fsu.edu %(op_src_decl)s; 2096019Shines@cs.fsu.edu %(op_rd)s; 2106019Shines@cs.fsu.edu %(ea_code)s; 2116019Shines@cs.fsu.edu 2126243Sgblack@eecs.umich.edu if (%(predicate_test)s) 2136019Shines@cs.fsu.edu { 2146019Shines@cs.fsu.edu if (fault == NoFault) { 2156019Shines@cs.fsu.edu fault = xc->read(EA, (uint%(mem_acc_size)d_t &)Mem, memAccessFlags); 2166019Shines@cs.fsu.edu } 2176019Shines@cs.fsu.edu } 2186019Shines@cs.fsu.edu 2196019Shines@cs.fsu.edu return fault; 2206019Shines@cs.fsu.edu } 2216019Shines@cs.fsu.edu}}; 2226019Shines@cs.fsu.edu 2236019Shines@cs.fsu.edu 2246019Shines@cs.fsu.edudef template LoadCompleteAcc {{ 2256019Shines@cs.fsu.edu Fault %(class_name)s::completeAcc(PacketPtr pkt, 2266019Shines@cs.fsu.edu %(CPU_exec_context)s *xc, 2276019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 2286019Shines@cs.fsu.edu { 2296019Shines@cs.fsu.edu Fault fault = NoFault; 2306019Shines@cs.fsu.edu 2316019Shines@cs.fsu.edu %(op_decl)s; 2326019Shines@cs.fsu.edu %(op_rd)s; 2336019Shines@cs.fsu.edu 2346243Sgblack@eecs.umich.edu if (%(predicate_test)s) 2356019Shines@cs.fsu.edu { 2366019Shines@cs.fsu.edu // ARM instructions will not have a pkt if the predicate is false 2376019Shines@cs.fsu.edu Mem = pkt->get<typeof(Mem)>(); 2386019Shines@cs.fsu.edu 2396019Shines@cs.fsu.edu if (fault == NoFault) { 2406019Shines@cs.fsu.edu %(memacc_code)s; 2416019Shines@cs.fsu.edu } 2426019Shines@cs.fsu.edu 2436019Shines@cs.fsu.edu if (fault == NoFault) { 2446019Shines@cs.fsu.edu %(op_wb)s; 2456019Shines@cs.fsu.edu } 2466019Shines@cs.fsu.edu } 2476019Shines@cs.fsu.edu 2486019Shines@cs.fsu.edu return fault; 2496019Shines@cs.fsu.edu } 2506019Shines@cs.fsu.edu}}; 2516019Shines@cs.fsu.edu 2526019Shines@cs.fsu.edu 2536019Shines@cs.fsu.edudef template StoreMemAccExecute {{ 2546019Shines@cs.fsu.edu Fault 2556019Shines@cs.fsu.edu %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 2566019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 2576019Shines@cs.fsu.edu { 2586019Shines@cs.fsu.edu Addr EA; 2596019Shines@cs.fsu.edu Fault fault = NoFault; 2606019Shines@cs.fsu.edu 2616019Shines@cs.fsu.edu %(op_decl)s; 2626019Shines@cs.fsu.edu %(op_rd)s; 2636019Shines@cs.fsu.edu 2646243Sgblack@eecs.umich.edu if (%(predicate_test)s) 2656019Shines@cs.fsu.edu { 2666019Shines@cs.fsu.edu EA = xc->getEA(); 2676019Shines@cs.fsu.edu 2686019Shines@cs.fsu.edu if (fault == NoFault) { 2696019Shines@cs.fsu.edu fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 2706019Shines@cs.fsu.edu memAccessFlags, NULL); 2716019Shines@cs.fsu.edu if (traceData) { traceData->setData(Mem); } 2726019Shines@cs.fsu.edu } 2736019Shines@cs.fsu.edu 2746019Shines@cs.fsu.edu if (fault == NoFault) { 2756019Shines@cs.fsu.edu %(op_wb)s; 2766019Shines@cs.fsu.edu } 2776019Shines@cs.fsu.edu } 2786019Shines@cs.fsu.edu 2796019Shines@cs.fsu.edu return fault; 2806019Shines@cs.fsu.edu } 2816019Shines@cs.fsu.edu}}; 2826019Shines@cs.fsu.edu 2836019Shines@cs.fsu.edu 2846019Shines@cs.fsu.edudef template StoreExecute {{ 2856019Shines@cs.fsu.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 2866019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 2876019Shines@cs.fsu.edu { 2886019Shines@cs.fsu.edu Addr EA; 2896019Shines@cs.fsu.edu Fault fault = NoFault; 2906019Shines@cs.fsu.edu 2916019Shines@cs.fsu.edu %(op_decl)s; 2926019Shines@cs.fsu.edu %(op_rd)s; 2936019Shines@cs.fsu.edu %(ea_code)s; 2946019Shines@cs.fsu.edu 2956243Sgblack@eecs.umich.edu if (%(predicate_test)s) 2966019Shines@cs.fsu.edu { 2976019Shines@cs.fsu.edu if (fault == NoFault) { 2986019Shines@cs.fsu.edu %(memacc_code)s; 2996019Shines@cs.fsu.edu } 3006019Shines@cs.fsu.edu 3016019Shines@cs.fsu.edu if (fault == NoFault) { 3026019Shines@cs.fsu.edu fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 3036019Shines@cs.fsu.edu memAccessFlags, NULL); 3046019Shines@cs.fsu.edu if (traceData) { traceData->setData(Mem); } 3056019Shines@cs.fsu.edu } 3066019Shines@cs.fsu.edu 3076019Shines@cs.fsu.edu if (fault == NoFault) { 3086019Shines@cs.fsu.edu %(op_wb)s; 3096019Shines@cs.fsu.edu } 3106019Shines@cs.fsu.edu } 3116019Shines@cs.fsu.edu 3126019Shines@cs.fsu.edu return fault; 3136019Shines@cs.fsu.edu } 3146019Shines@cs.fsu.edu}}; 3156019Shines@cs.fsu.edu 3166019Shines@cs.fsu.edudef template StoreInitiateAcc {{ 3176019Shines@cs.fsu.edu Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 3186019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 3196019Shines@cs.fsu.edu { 3206019Shines@cs.fsu.edu Addr EA; 3216019Shines@cs.fsu.edu Fault fault = NoFault; 3226019Shines@cs.fsu.edu 3236019Shines@cs.fsu.edu %(op_decl)s; 3246019Shines@cs.fsu.edu %(op_rd)s; 3256019Shines@cs.fsu.edu %(ea_code)s; 3266019Shines@cs.fsu.edu 3276243Sgblack@eecs.umich.edu if (%(predicate_test)s) 3286019Shines@cs.fsu.edu { 3296019Shines@cs.fsu.edu if (fault == NoFault) { 3306019Shines@cs.fsu.edu %(memacc_code)s; 3316019Shines@cs.fsu.edu } 3326019Shines@cs.fsu.edu 3336019Shines@cs.fsu.edu if (fault == NoFault) { 3346019Shines@cs.fsu.edu fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 3356019Shines@cs.fsu.edu memAccessFlags, NULL); 3366019Shines@cs.fsu.edu if (traceData) { traceData->setData(Mem); } 3376019Shines@cs.fsu.edu } 3386019Shines@cs.fsu.edu 3396019Shines@cs.fsu.edu // Need to write back any potential address register update 3406019Shines@cs.fsu.edu if (fault == NoFault) { 3416019Shines@cs.fsu.edu %(op_wb)s; 3426019Shines@cs.fsu.edu } 3436019Shines@cs.fsu.edu } 3446019Shines@cs.fsu.edu 3456019Shines@cs.fsu.edu return fault; 3466019Shines@cs.fsu.edu } 3476019Shines@cs.fsu.edu}}; 3486019Shines@cs.fsu.edu 3496019Shines@cs.fsu.edu 3506019Shines@cs.fsu.edudef template StoreCompleteAcc {{ 3516019Shines@cs.fsu.edu Fault %(class_name)s::completeAcc(PacketPtr pkt, 3526019Shines@cs.fsu.edu %(CPU_exec_context)s *xc, 3536019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 3546019Shines@cs.fsu.edu { 3556019Shines@cs.fsu.edu Fault fault = NoFault; 3566019Shines@cs.fsu.edu 3576302Sgblack@eecs.umich.edu %(op_decl)s; 3586302Sgblack@eecs.umich.edu %(op_rd)s; 3596019Shines@cs.fsu.edu 3606243Sgblack@eecs.umich.edu if (%(predicate_test)s) 3616019Shines@cs.fsu.edu { 3626019Shines@cs.fsu.edu if (fault == NoFault) { 3636019Shines@cs.fsu.edu %(op_wb)s; 3646019Shines@cs.fsu.edu } 3656019Shines@cs.fsu.edu } 3666019Shines@cs.fsu.edu 3676019Shines@cs.fsu.edu return fault; 3686019Shines@cs.fsu.edu } 3696019Shines@cs.fsu.edu}}; 3706019Shines@cs.fsu.edu 3716019Shines@cs.fsu.edudef template StoreCondCompleteAcc {{ 3726019Shines@cs.fsu.edu Fault %(class_name)s::completeAcc(PacketPtr pkt, 3736019Shines@cs.fsu.edu %(CPU_exec_context)s *xc, 3746019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 3756019Shines@cs.fsu.edu { 3766019Shines@cs.fsu.edu Fault fault = NoFault; 3776019Shines@cs.fsu.edu 3786019Shines@cs.fsu.edu %(op_dest_decl)s; 3796019Shines@cs.fsu.edu 3806243Sgblack@eecs.umich.edu if (%(predicate_test)s) 3816019Shines@cs.fsu.edu { 3826019Shines@cs.fsu.edu if (fault == NoFault) { 3836019Shines@cs.fsu.edu %(op_wb)s; 3846019Shines@cs.fsu.edu } 3856019Shines@cs.fsu.edu } 3866019Shines@cs.fsu.edu 3876019Shines@cs.fsu.edu return fault; 3886019Shines@cs.fsu.edu } 3896019Shines@cs.fsu.edu}}; 3906019Shines@cs.fsu.edu 3916019Shines@cs.fsu.edu 3926019Shines@cs.fsu.edudef template MiscMemAccExecute {{ 3936019Shines@cs.fsu.edu Fault %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 3946019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 3956019Shines@cs.fsu.edu { 3966019Shines@cs.fsu.edu Addr EA; 3976019Shines@cs.fsu.edu Fault fault = NoFault; 3986019Shines@cs.fsu.edu 3996019Shines@cs.fsu.edu %(op_decl)s; 4006019Shines@cs.fsu.edu %(op_rd)s; 4016019Shines@cs.fsu.edu 4026243Sgblack@eecs.umich.edu if (%(predicate_test)s) 4036019Shines@cs.fsu.edu { 4046019Shines@cs.fsu.edu EA = xc->getEA(); 4056019Shines@cs.fsu.edu 4066019Shines@cs.fsu.edu if (fault == NoFault) { 4076019Shines@cs.fsu.edu %(memacc_code)s; 4086019Shines@cs.fsu.edu } 4096019Shines@cs.fsu.edu } 4106019Shines@cs.fsu.edu 4116019Shines@cs.fsu.edu return NoFault; 4126019Shines@cs.fsu.edu } 4136019Shines@cs.fsu.edu}}; 4146019Shines@cs.fsu.edu 4156019Shines@cs.fsu.edudef template MiscExecute {{ 4166019Shines@cs.fsu.edu Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, 4176019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 4186019Shines@cs.fsu.edu { 4196019Shines@cs.fsu.edu Addr EA; 4206019Shines@cs.fsu.edu Fault fault = NoFault; 4216019Shines@cs.fsu.edu 4226019Shines@cs.fsu.edu %(op_decl)s; 4236019Shines@cs.fsu.edu %(op_rd)s; 4246019Shines@cs.fsu.edu %(ea_code)s; 4256019Shines@cs.fsu.edu 4266243Sgblack@eecs.umich.edu if (%(predicate_test)s) 4276019Shines@cs.fsu.edu { 4286019Shines@cs.fsu.edu if (fault == NoFault) { 4296019Shines@cs.fsu.edu %(memacc_code)s; 4306019Shines@cs.fsu.edu } 4316019Shines@cs.fsu.edu } 4326019Shines@cs.fsu.edu 4336019Shines@cs.fsu.edu return NoFault; 4346019Shines@cs.fsu.edu } 4356019Shines@cs.fsu.edu}}; 4366019Shines@cs.fsu.edu 4376019Shines@cs.fsu.edudef template MiscInitiateAcc {{ 4386019Shines@cs.fsu.edu Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 4396019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 4406019Shines@cs.fsu.edu { 4416019Shines@cs.fsu.edu panic("Misc instruction does not support split access method!"); 4426019Shines@cs.fsu.edu return NoFault; 4436019Shines@cs.fsu.edu } 4446019Shines@cs.fsu.edu}}; 4456019Shines@cs.fsu.edu 4466019Shines@cs.fsu.edu 4476019Shines@cs.fsu.edudef template MiscCompleteAcc {{ 4486019Shines@cs.fsu.edu Fault %(class_name)s::completeAcc(PacketPtr pkt, 4496019Shines@cs.fsu.edu %(CPU_exec_context)s *xc, 4506019Shines@cs.fsu.edu Trace::InstRecord *traceData) const 4516019Shines@cs.fsu.edu { 4526019Shines@cs.fsu.edu panic("Misc instruction does not support split access method!"); 4536019Shines@cs.fsu.edu 4546019Shines@cs.fsu.edu return NoFault; 4556019Shines@cs.fsu.edu } 4566019Shines@cs.fsu.edu}}; 4576019Shines@cs.fsu.edu 4586301Sgblack@eecs.umich.edulet {{ 4596301Sgblack@eecs.umich.edu def buildPUBWLCase(p, u, b, w, l): 4606301Sgblack@eecs.umich.edu return (p << 4) + (u << 3) + (b << 2) + (w << 1) + (l << 0) 4616301Sgblack@eecs.umich.edu 4626303Sgblack@eecs.umich.edu def buildMode2Inst(p, u, b, w, l, suffix, offset): 4636303Sgblack@eecs.umich.edu mnem = ("str", "ldr")[l] 4646303Sgblack@eecs.umich.edu op = ("-", "+")[u] 4656303Sgblack@eecs.umich.edu offset = op + ArmGenericCodeSubs(offset); 4666303Sgblack@eecs.umich.edu mem = ("Mem", "Mem.ub")[b] 4676303Sgblack@eecs.umich.edu code = ("%s = Rd;", "Rd = %s;")[l] % mem 4686303Sgblack@eecs.umich.edu ea_code = "EA = Rn %s;" % ("", offset)[p] 4696303Sgblack@eecs.umich.edu if p == 0 or w == 1: 4706303Sgblack@eecs.umich.edu code += "Rn = Rn %s;" % offset 4716303Sgblack@eecs.umich.edu if p == 0 and w == 0: 4726303Sgblack@eecs.umich.edu # Here's where we'll tack on a flag to make this a usermode access. 4736303Sgblack@eecs.umich.edu mnem += "t" 4746303Sgblack@eecs.umich.edu type = ("Store", "Load")[l] 4756303Sgblack@eecs.umich.edu suffix = "_%s_P%dU%dB%dW%d" % (suffix, p, u, b, w) 4766303Sgblack@eecs.umich.edu if b == 1: 4776303Sgblack@eecs.umich.edu mnem += "b" 4786303Sgblack@eecs.umich.edu return LoadStoreBase(mnem, mnem.capitalize() + suffix, 4796303Sgblack@eecs.umich.edu ea_code, code, mem_flags = [], inst_flags = [], 4806303Sgblack@eecs.umich.edu exec_template_base = type.capitalize()) 4816303Sgblack@eecs.umich.edu 4826301Sgblack@eecs.umich.edu def buildMode3Inst(p, u, i, w, type, code, mnem): 4836301Sgblack@eecs.umich.edu op = ("-", "+")[u] 4846301Sgblack@eecs.umich.edu offset = ("%s Rm", "%s hilo")[i] % op 4856301Sgblack@eecs.umich.edu ea_code = "EA = Rn %s;" % ("", offset)[p] 4866301Sgblack@eecs.umich.edu if p == 0 or w == 1: 4876301Sgblack@eecs.umich.edu code += "Rn = Rn %s;" % offset 4886301Sgblack@eecs.umich.edu suffix = "_P%dU%dI%dW%d" % (p, u, i, w) 4896301Sgblack@eecs.umich.edu return LoadStoreBase(mnem, mnem.capitalize() + suffix, 4906301Sgblack@eecs.umich.edu ea_code, code, mem_flags = [], inst_flags = [], 4916301Sgblack@eecs.umich.edu exec_template_base = type.capitalize()) 4926301Sgblack@eecs.umich.edu}}; 4936301Sgblack@eecs.umich.edu 4946303Sgblack@eecs.umich.edudef format AddrMode2(suffix, offset) {{ 4956303Sgblack@eecs.umich.edu header_output = decoder_output = exec_output = "" 4966303Sgblack@eecs.umich.edu decode_block = "switch(PUBWL) {\n" 4976303Sgblack@eecs.umich.edu 4986303Sgblack@eecs.umich.edu # Loop over all the values of p, u, b, w and l and build instructions and 4996303Sgblack@eecs.umich.edu # a decode block for them. 5006303Sgblack@eecs.umich.edu for p in (0, 1): 5016303Sgblack@eecs.umich.edu for u in (0, 1): 5026303Sgblack@eecs.umich.edu for b in (0, 1): 5036303Sgblack@eecs.umich.edu for w in (0, 1): 5046303Sgblack@eecs.umich.edu for l in (0, 1): 5056303Sgblack@eecs.umich.edu (new_header_output, 5066303Sgblack@eecs.umich.edu new_decoder_output, 5076303Sgblack@eecs.umich.edu new_decode_block, 5086303Sgblack@eecs.umich.edu new_exec_output) = buildMode2Inst(p, u, b, w, l, 5096303Sgblack@eecs.umich.edu suffix, offset) 5106303Sgblack@eecs.umich.edu header_output += new_header_output 5116303Sgblack@eecs.umich.edu decoder_output += new_decoder_output 5126303Sgblack@eecs.umich.edu exec_output += new_exec_output 5136303Sgblack@eecs.umich.edu decode_block += ''' 5146303Sgblack@eecs.umich.edu case %#x: 5156303Sgblack@eecs.umich.edu {%s} 5166303Sgblack@eecs.umich.edu break; 5176303Sgblack@eecs.umich.edu ''' % (buildPUBWLCase(p,u,b,w,l), new_decode_block) 5186303Sgblack@eecs.umich.edu decode_block += ''' 5196303Sgblack@eecs.umich.edu default: 5206303Sgblack@eecs.umich.edu return new Unknown(machInst); 5216303Sgblack@eecs.umich.edu break; 5226303Sgblack@eecs.umich.edu }''' 5236303Sgblack@eecs.umich.edu}}; 5246303Sgblack@eecs.umich.edu 5256301Sgblack@eecs.umich.edudef format AddrMode3(l0Type, l0Code, l1Type, l1Code) {{ 5266301Sgblack@eecs.umich.edu l0Code = ArmGenericCodeSubs(l0Code); 5276301Sgblack@eecs.umich.edu l1Code = ArmGenericCodeSubs(l1Code); 5286301Sgblack@eecs.umich.edu 5296301Sgblack@eecs.umich.edu header_output = decoder_output = exec_output = "" 5306301Sgblack@eecs.umich.edu decode_block = "switch(PUBWL) {\n" 5316301Sgblack@eecs.umich.edu (l0Mnem, l1Mnem) = name.split("_"); 5326301Sgblack@eecs.umich.edu 5336301Sgblack@eecs.umich.edu # Loop over all the values of p, u, i, w and l and build instructions and 5346301Sgblack@eecs.umich.edu # a decode block for them. 5356301Sgblack@eecs.umich.edu for (l, type, code, mnem) in ((0, l0Type, l0Code, l0Mnem), 5366301Sgblack@eecs.umich.edu (1, l1Type, l1Code, l1Mnem)): 5376301Sgblack@eecs.umich.edu for p in (0, 1): 5386301Sgblack@eecs.umich.edu wset = (0, 1) 5396301Sgblack@eecs.umich.edu if (p == 0): 5406301Sgblack@eecs.umich.edu wset = (0,) 5416301Sgblack@eecs.umich.edu for u in (0, 1): 5426301Sgblack@eecs.umich.edu for i in (0, 1): 5436301Sgblack@eecs.umich.edu for w in wset: 5446301Sgblack@eecs.umich.edu (new_header_output, 5456301Sgblack@eecs.umich.edu new_decoder_output, 5466301Sgblack@eecs.umich.edu new_decode_block, 5476301Sgblack@eecs.umich.edu new_exec_output) = buildMode3Inst(p, u, i, w, 5486301Sgblack@eecs.umich.edu type, code, mnem) 5496301Sgblack@eecs.umich.edu header_output += new_header_output 5506301Sgblack@eecs.umich.edu decoder_output += new_decoder_output 5516301Sgblack@eecs.umich.edu exec_output += new_exec_output 5526301Sgblack@eecs.umich.edu decode_block += ''' 5536301Sgblack@eecs.umich.edu case %#x: 5546301Sgblack@eecs.umich.edu {%s} 5556301Sgblack@eecs.umich.edu break; 5566301Sgblack@eecs.umich.edu ''' % (buildPUBWLCase(p,u,i,w,l), new_decode_block) 5576301Sgblack@eecs.umich.edu 5586301Sgblack@eecs.umich.edu decode_block += ''' 5596301Sgblack@eecs.umich.edu default: 5606301Sgblack@eecs.umich.edu return new Unknown(machInst); 5616301Sgblack@eecs.umich.edu break; 5626301Sgblack@eecs.umich.edu }''' 5636301Sgblack@eecs.umich.edu}}; 5646301Sgblack@eecs.umich.edu 5656019Shines@cs.fsu.edudef format ArmLoadMemory(memacc_code, ea_code = {{ EA = Rn + disp; }}, 5666019Shines@cs.fsu.edu mem_flags = [], inst_flags = []) {{ 5676019Shines@cs.fsu.edu ea_code = ArmGenericCodeSubs(ea_code) 5686019Shines@cs.fsu.edu memacc_code = ArmGenericCodeSubs(memacc_code) 5696019Shines@cs.fsu.edu (header_output, decoder_output, decode_block, exec_output) = \ 5706019Shines@cs.fsu.edu LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 5716019Shines@cs.fsu.edu decode_template = BasicDecode, 5726019Shines@cs.fsu.edu exec_template_base = 'Load') 5736019Shines@cs.fsu.edu}}; 5746019Shines@cs.fsu.edu 5756019Shines@cs.fsu.edudef format ArmStoreMemory(memacc_code, ea_code = {{ EA = Rn + disp; }}, 5766019Shines@cs.fsu.edu mem_flags = [], inst_flags = []) {{ 5776019Shines@cs.fsu.edu ea_code = ArmGenericCodeSubs(ea_code) 5786019Shines@cs.fsu.edu memacc_code = ArmGenericCodeSubs(memacc_code) 5796019Shines@cs.fsu.edu (header_output, decoder_output, decode_block, exec_output) = \ 5806019Shines@cs.fsu.edu LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 5816019Shines@cs.fsu.edu exec_template_base = 'Store') 5826019Shines@cs.fsu.edu}}; 5836019Shines@cs.fsu.edu 584