mem.isa revision 6250
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.eduoutput header {{
376019Shines@cs.fsu.edu    /**
386019Shines@cs.fsu.edu     * Base class for general Arm memory-format instructions.
396019Shines@cs.fsu.edu     */
406019Shines@cs.fsu.edu    class Memory : public PredOp
416019Shines@cs.fsu.edu    {
426019Shines@cs.fsu.edu      protected:
436019Shines@cs.fsu.edu
446019Shines@cs.fsu.edu        /// Memory request flags.  See mem_req_base.hh.
456019Shines@cs.fsu.edu        unsigned memAccessFlags;
466019Shines@cs.fsu.edu        /// Pointer to EAComp object.
476019Shines@cs.fsu.edu        const StaticInstPtr eaCompPtr;
486019Shines@cs.fsu.edu        /// Pointer to MemAcc object.
496019Shines@cs.fsu.edu        const StaticInstPtr memAccPtr;
506019Shines@cs.fsu.edu
516019Shines@cs.fsu.edu        /// Displacement for EA calculation (signed).
526019Shines@cs.fsu.edu        int32_t disp;
536019Shines@cs.fsu.edu        int32_t disp8;
546019Shines@cs.fsu.edu        int32_t up;
556019Shines@cs.fsu.edu        int32_t hilo,
566019Shines@cs.fsu.edu                shift_size,
576019Shines@cs.fsu.edu                shift;
586019Shines@cs.fsu.edu
596019Shines@cs.fsu.edu        /// Constructor
606250Sgblack@eecs.umich.edu        Memory(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
616019Shines@cs.fsu.edu               StaticInstPtr _eaCompPtr = nullStaticInstPtr,
626019Shines@cs.fsu.edu               StaticInstPtr _memAccPtr = nullStaticInstPtr)
636019Shines@cs.fsu.edu            : PredOp(mnem, _machInst, __opClass),
646019Shines@cs.fsu.edu              memAccessFlags(0), eaCompPtr(_eaCompPtr), memAccPtr(_memAccPtr),
656019Shines@cs.fsu.edu              disp(IMMED_11_0), disp8(IMMED_7_0 << 2), up(UP),
666019Shines@cs.fsu.edu              hilo((IMMED_HI_11_8 << 4) | IMMED_LO_3_0),
676019Shines@cs.fsu.edu              shift_size(SHIFT_SIZE), shift(SHIFT)
686019Shines@cs.fsu.edu        {
696019Shines@cs.fsu.edu            // When Up is not set, then we must subtract by the displacement
706019Shines@cs.fsu.edu            if (!up)
716019Shines@cs.fsu.edu            {
726019Shines@cs.fsu.edu                disp = -disp;
736019Shines@cs.fsu.edu                disp8 = -disp8;
746019Shines@cs.fsu.edu                hilo = -hilo;
756019Shines@cs.fsu.edu            }
766019Shines@cs.fsu.edu        }
776019Shines@cs.fsu.edu
786019Shines@cs.fsu.edu        std::string
796019Shines@cs.fsu.edu        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
806019Shines@cs.fsu.edu
816019Shines@cs.fsu.edu      public:
826019Shines@cs.fsu.edu
836019Shines@cs.fsu.edu        const StaticInstPtr &eaCompInst() const { return eaCompPtr; }
846019Shines@cs.fsu.edu        const StaticInstPtr &memAccInst() const { return memAccPtr; }
856019Shines@cs.fsu.edu    };
866019Shines@cs.fsu.edu
876019Shines@cs.fsu.edu     /**
886019Shines@cs.fsu.edu     * Base class for a few miscellaneous memory-format insts
896019Shines@cs.fsu.edu     * that don't interpret the disp field
906019Shines@cs.fsu.edu     */
916019Shines@cs.fsu.edu    class MemoryNoDisp : public Memory
926019Shines@cs.fsu.edu    {
936019Shines@cs.fsu.edu      protected:
946019Shines@cs.fsu.edu        /// Constructor
956019Shines@cs.fsu.edu        MemoryNoDisp(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
966019Shines@cs.fsu.edu                     StaticInstPtr _eaCompPtr = nullStaticInstPtr,
976019Shines@cs.fsu.edu                     StaticInstPtr _memAccPtr = nullStaticInstPtr)
986019Shines@cs.fsu.edu            : Memory(mnem, _machInst, __opClass, _eaCompPtr, _memAccPtr)
996019Shines@cs.fsu.edu        {
1006019Shines@cs.fsu.edu        }
1016019Shines@cs.fsu.edu
1026019Shines@cs.fsu.edu        std::string
1036019Shines@cs.fsu.edu        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
1046019Shines@cs.fsu.edu    };
1056019Shines@cs.fsu.edu}};
1066019Shines@cs.fsu.edu
1076019Shines@cs.fsu.edu
1086019Shines@cs.fsu.eduoutput decoder {{
1096019Shines@cs.fsu.edu    std::string
1106019Shines@cs.fsu.edu    Memory::generateDisassembly(Addr pc, const SymbolTable *symtab) const
1116019Shines@cs.fsu.edu    {
1126019Shines@cs.fsu.edu        return csprintf("%-10s", mnemonic);
1136019Shines@cs.fsu.edu    }
1146019Shines@cs.fsu.edu
1156019Shines@cs.fsu.edu    std::string
1166019Shines@cs.fsu.edu    MemoryNoDisp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
1176019Shines@cs.fsu.edu    {
1186019Shines@cs.fsu.edu        return csprintf("%-10s", mnemonic);
1196019Shines@cs.fsu.edu    }
1206019Shines@cs.fsu.edu}};
1216019Shines@cs.fsu.edu
1226019Shines@cs.fsu.edudef template LoadStoreDeclare {{
1236019Shines@cs.fsu.edu    /**
1246019Shines@cs.fsu.edu     * Static instruction class for "%(mnemonic)s".
1256019Shines@cs.fsu.edu     */
1266019Shines@cs.fsu.edu    class %(class_name)s : public %(base_class)s
1276019Shines@cs.fsu.edu    {
1286019Shines@cs.fsu.edu      protected:
1296019Shines@cs.fsu.edu
1306019Shines@cs.fsu.edu        /**
1316019Shines@cs.fsu.edu         * "Fake" effective address computation class for "%(mnemonic)s".
1326019Shines@cs.fsu.edu         */
1336019Shines@cs.fsu.edu        class EAComp : public %(base_class)s
1346019Shines@cs.fsu.edu        {
1356019Shines@cs.fsu.edu          public:
1366019Shines@cs.fsu.edu            /// Constructor
1376250Sgblack@eecs.umich.edu            EAComp(ExtMachInst machInst);
1386019Shines@cs.fsu.edu
1396019Shines@cs.fsu.edu            %(BasicExecDeclare)s
1406019Shines@cs.fsu.edu        };
1416019Shines@cs.fsu.edu
1426019Shines@cs.fsu.edu        /**
1436019Shines@cs.fsu.edu         * "Fake" memory access instruction class for "%(mnemonic)s".
1446019Shines@cs.fsu.edu         */
1456019Shines@cs.fsu.edu        class MemAcc : public %(base_class)s
1466019Shines@cs.fsu.edu        {
1476019Shines@cs.fsu.edu          public:
1486019Shines@cs.fsu.edu            /// Constructor
1496250Sgblack@eecs.umich.edu            MemAcc(ExtMachInst machInst);
1506019Shines@cs.fsu.edu
1516019Shines@cs.fsu.edu            %(BasicExecDeclare)s
1526019Shines@cs.fsu.edu        };
1536019Shines@cs.fsu.edu
1546019Shines@cs.fsu.edu      public:
1556019Shines@cs.fsu.edu
1566019Shines@cs.fsu.edu        /// Constructor.
1576250Sgblack@eecs.umich.edu        %(class_name)s(ExtMachInst machInst);
1586019Shines@cs.fsu.edu
1596019Shines@cs.fsu.edu        %(BasicExecDeclare)s
1606019Shines@cs.fsu.edu
1616019Shines@cs.fsu.edu        %(InitiateAccDeclare)s
1626019Shines@cs.fsu.edu
1636019Shines@cs.fsu.edu        %(CompleteAccDeclare)s
1646019Shines@cs.fsu.edu    };
1656019Shines@cs.fsu.edu}};
1666019Shines@cs.fsu.edu
1676019Shines@cs.fsu.edu
1686019Shines@cs.fsu.edudef template InitiateAccDeclare {{
1696019Shines@cs.fsu.edu    Fault initiateAcc(%(CPU_exec_context)s *, Trace::InstRecord *) const;
1706019Shines@cs.fsu.edu}};
1716019Shines@cs.fsu.edu
1726019Shines@cs.fsu.edu
1736019Shines@cs.fsu.edudef template CompleteAccDeclare {{
1746019Shines@cs.fsu.edu    Fault completeAcc(PacketPtr,  %(CPU_exec_context)s *, Trace::InstRecord *) const;
1756019Shines@cs.fsu.edu}};
1766019Shines@cs.fsu.edu
1776019Shines@cs.fsu.edu
1786019Shines@cs.fsu.edudef template EACompConstructor {{
1796250Sgblack@eecs.umich.edu    inline %(class_name)s::EAComp::EAComp(ExtMachInst machInst)
1806019Shines@cs.fsu.edu        : %(base_class)s("%(mnemonic)s (EAComp)", machInst, IntAluOp)
1816019Shines@cs.fsu.edu    {
1826019Shines@cs.fsu.edu        %(constructor)s;
1836019Shines@cs.fsu.edu    }
1846019Shines@cs.fsu.edu}};
1856019Shines@cs.fsu.edu
1866019Shines@cs.fsu.edu
1876019Shines@cs.fsu.edudef template MemAccConstructor {{
1886250Sgblack@eecs.umich.edu    inline %(class_name)s::MemAcc::MemAcc(ExtMachInst machInst)
1896019Shines@cs.fsu.edu        : %(base_class)s("%(mnemonic)s (MemAcc)", machInst, %(op_class)s)
1906019Shines@cs.fsu.edu    {
1916019Shines@cs.fsu.edu        %(constructor)s;
1926019Shines@cs.fsu.edu    }
1936019Shines@cs.fsu.edu}};
1946019Shines@cs.fsu.edu
1956019Shines@cs.fsu.edu
1966019Shines@cs.fsu.edudef template LoadStoreConstructor {{
1976250Sgblack@eecs.umich.edu    inline %(class_name)s::%(class_name)s(ExtMachInst machInst)
1986019Shines@cs.fsu.edu         : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
1996019Shines@cs.fsu.edu                          new EAComp(machInst), new MemAcc(machInst))
2006019Shines@cs.fsu.edu    {
2016019Shines@cs.fsu.edu        %(constructor)s;
2026019Shines@cs.fsu.edu    }
2036019Shines@cs.fsu.edu}};
2046019Shines@cs.fsu.edu
2056019Shines@cs.fsu.edu
2066019Shines@cs.fsu.edudef template EACompExecute {{
2076019Shines@cs.fsu.edu    Fault
2086019Shines@cs.fsu.edu    %(class_name)s::EAComp::execute(%(CPU_exec_context)s *xc,
2096019Shines@cs.fsu.edu                                   Trace::InstRecord *traceData) const
2106019Shines@cs.fsu.edu    {
2116019Shines@cs.fsu.edu        Addr EA;
2126019Shines@cs.fsu.edu        Fault fault = NoFault;
2136019Shines@cs.fsu.edu
2146019Shines@cs.fsu.edu        %(op_decl)s;
2156019Shines@cs.fsu.edu        %(op_rd)s;
2166019Shines@cs.fsu.edu        %(ea_code)s;
2176019Shines@cs.fsu.edu
2186243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
2196019Shines@cs.fsu.edu        {
2206019Shines@cs.fsu.edu            if (fault == NoFault) {
2216019Shines@cs.fsu.edu                %(op_wb)s;
2226019Shines@cs.fsu.edu                xc->setEA(EA);
2236019Shines@cs.fsu.edu            }
2246019Shines@cs.fsu.edu        }
2256019Shines@cs.fsu.edu
2266019Shines@cs.fsu.edu        return fault;
2276019Shines@cs.fsu.edu    }
2286019Shines@cs.fsu.edu}};
2296019Shines@cs.fsu.edu
2306019Shines@cs.fsu.edudef template LoadMemAccExecute {{
2316019Shines@cs.fsu.edu    Fault
2326019Shines@cs.fsu.edu    %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc,
2336019Shines@cs.fsu.edu                                   Trace::InstRecord *traceData) const
2346019Shines@cs.fsu.edu    {
2356019Shines@cs.fsu.edu        Addr EA;
2366019Shines@cs.fsu.edu        Fault fault = NoFault;
2376019Shines@cs.fsu.edu
2386019Shines@cs.fsu.edu        %(op_decl)s;
2396019Shines@cs.fsu.edu        %(op_rd)s;
2406019Shines@cs.fsu.edu        EA = xc->getEA();
2416019Shines@cs.fsu.edu
2426243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
2436019Shines@cs.fsu.edu        {
2446019Shines@cs.fsu.edu            if (fault == NoFault) {
2456019Shines@cs.fsu.edu                fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags);
2466019Shines@cs.fsu.edu                %(memacc_code)s;
2476019Shines@cs.fsu.edu            }
2486019Shines@cs.fsu.edu
2496019Shines@cs.fsu.edu            if (fault == NoFault) {
2506019Shines@cs.fsu.edu                %(op_wb)s;
2516019Shines@cs.fsu.edu            }
2526019Shines@cs.fsu.edu        }
2536019Shines@cs.fsu.edu
2546019Shines@cs.fsu.edu        return fault;
2556019Shines@cs.fsu.edu    }
2566019Shines@cs.fsu.edu}};
2576019Shines@cs.fsu.edu
2586019Shines@cs.fsu.edu
2596019Shines@cs.fsu.edudef template LoadExecute {{
2606019Shines@cs.fsu.edu    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
2616019Shines@cs.fsu.edu                                  Trace::InstRecord *traceData) const
2626019Shines@cs.fsu.edu    {
2636019Shines@cs.fsu.edu        Addr EA;
2646019Shines@cs.fsu.edu        Fault fault = NoFault;
2656019Shines@cs.fsu.edu
2666019Shines@cs.fsu.edu        %(op_decl)s;
2676019Shines@cs.fsu.edu        %(op_rd)s;
2686019Shines@cs.fsu.edu        %(ea_code)s;
2696019Shines@cs.fsu.edu
2706243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
2716019Shines@cs.fsu.edu        {
2726019Shines@cs.fsu.edu            if (fault == NoFault) {
2736019Shines@cs.fsu.edu                fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags);
2746019Shines@cs.fsu.edu                %(memacc_code)s;
2756019Shines@cs.fsu.edu            }
2766019Shines@cs.fsu.edu
2776019Shines@cs.fsu.edu            if (fault == NoFault) {
2786019Shines@cs.fsu.edu                %(op_wb)s;
2796019Shines@cs.fsu.edu            }
2806019Shines@cs.fsu.edu        }
2816019Shines@cs.fsu.edu
2826019Shines@cs.fsu.edu        return fault;
2836019Shines@cs.fsu.edu    }
2846019Shines@cs.fsu.edu}};
2856019Shines@cs.fsu.edu
2866019Shines@cs.fsu.edu
2876019Shines@cs.fsu.edudef template LoadInitiateAcc {{
2886019Shines@cs.fsu.edu    Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
2896019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
2906019Shines@cs.fsu.edu    {
2916019Shines@cs.fsu.edu        Addr EA;
2926019Shines@cs.fsu.edu        Fault fault = NoFault;
2936019Shines@cs.fsu.edu
2946019Shines@cs.fsu.edu        %(op_src_decl)s;
2956019Shines@cs.fsu.edu        %(op_rd)s;
2966019Shines@cs.fsu.edu        %(ea_code)s;
2976019Shines@cs.fsu.edu
2986243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
2996019Shines@cs.fsu.edu        {
3006019Shines@cs.fsu.edu            if (fault == NoFault) {
3016019Shines@cs.fsu.edu                fault = xc->read(EA, (uint%(mem_acc_size)d_t &)Mem, memAccessFlags);
3026019Shines@cs.fsu.edu            }
3036019Shines@cs.fsu.edu        }
3046019Shines@cs.fsu.edu
3056019Shines@cs.fsu.edu        return fault;
3066019Shines@cs.fsu.edu    }
3076019Shines@cs.fsu.edu}};
3086019Shines@cs.fsu.edu
3096019Shines@cs.fsu.edu
3106019Shines@cs.fsu.edudef template LoadCompleteAcc {{
3116019Shines@cs.fsu.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
3126019Shines@cs.fsu.edu                                      %(CPU_exec_context)s *xc,
3136019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
3146019Shines@cs.fsu.edu    {
3156019Shines@cs.fsu.edu        Fault fault = NoFault;
3166019Shines@cs.fsu.edu
3176019Shines@cs.fsu.edu        %(op_decl)s;
3186019Shines@cs.fsu.edu        %(op_rd)s;
3196019Shines@cs.fsu.edu
3206243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
3216019Shines@cs.fsu.edu        {
3226019Shines@cs.fsu.edu            // ARM instructions will not have a pkt if the predicate is false
3236019Shines@cs.fsu.edu            Mem = pkt->get<typeof(Mem)>();
3246019Shines@cs.fsu.edu
3256019Shines@cs.fsu.edu            if (fault == NoFault) {
3266019Shines@cs.fsu.edu                %(memacc_code)s;
3276019Shines@cs.fsu.edu            }
3286019Shines@cs.fsu.edu
3296019Shines@cs.fsu.edu            if (fault == NoFault) {
3306019Shines@cs.fsu.edu                %(op_wb)s;
3316019Shines@cs.fsu.edu            }
3326019Shines@cs.fsu.edu        }
3336019Shines@cs.fsu.edu
3346019Shines@cs.fsu.edu        return fault;
3356019Shines@cs.fsu.edu    }
3366019Shines@cs.fsu.edu}};
3376019Shines@cs.fsu.edu
3386019Shines@cs.fsu.edu
3396019Shines@cs.fsu.edudef template StoreMemAccExecute {{
3406019Shines@cs.fsu.edu    Fault
3416019Shines@cs.fsu.edu    %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc,
3426019Shines@cs.fsu.edu                                   Trace::InstRecord *traceData) const
3436019Shines@cs.fsu.edu    {
3446019Shines@cs.fsu.edu        Addr EA;
3456019Shines@cs.fsu.edu        Fault fault = NoFault;
3466019Shines@cs.fsu.edu
3476019Shines@cs.fsu.edu        %(op_decl)s;
3486019Shines@cs.fsu.edu        %(op_rd)s;
3496019Shines@cs.fsu.edu
3506243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
3516019Shines@cs.fsu.edu        {
3526019Shines@cs.fsu.edu            EA = xc->getEA();
3536019Shines@cs.fsu.edu
3546019Shines@cs.fsu.edu            if (fault == NoFault) {
3556019Shines@cs.fsu.edu                fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA,
3566019Shines@cs.fsu.edu                                  memAccessFlags, NULL);
3576019Shines@cs.fsu.edu                if (traceData) { traceData->setData(Mem); }
3586019Shines@cs.fsu.edu            }
3596019Shines@cs.fsu.edu
3606019Shines@cs.fsu.edu            if (fault == NoFault) {
3616019Shines@cs.fsu.edu                %(op_wb)s;
3626019Shines@cs.fsu.edu            }
3636019Shines@cs.fsu.edu        }
3646019Shines@cs.fsu.edu
3656019Shines@cs.fsu.edu        return fault;
3666019Shines@cs.fsu.edu    }
3676019Shines@cs.fsu.edu}};
3686019Shines@cs.fsu.edu
3696019Shines@cs.fsu.edu
3706019Shines@cs.fsu.edudef template StoreExecute {{
3716019Shines@cs.fsu.edu    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
3726019Shines@cs.fsu.edu                                  Trace::InstRecord *traceData) const
3736019Shines@cs.fsu.edu    {
3746019Shines@cs.fsu.edu        Addr EA;
3756019Shines@cs.fsu.edu        Fault fault = NoFault;
3766019Shines@cs.fsu.edu
3776019Shines@cs.fsu.edu        %(op_decl)s;
3786019Shines@cs.fsu.edu        %(op_rd)s;
3796019Shines@cs.fsu.edu        %(ea_code)s;
3806019Shines@cs.fsu.edu
3816243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
3826019Shines@cs.fsu.edu        {
3836019Shines@cs.fsu.edu            if (fault == NoFault) {
3846019Shines@cs.fsu.edu                %(memacc_code)s;
3856019Shines@cs.fsu.edu            }
3866019Shines@cs.fsu.edu
3876019Shines@cs.fsu.edu            if (fault == NoFault) {
3886019Shines@cs.fsu.edu                fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA,
3896019Shines@cs.fsu.edu                                  memAccessFlags, NULL);
3906019Shines@cs.fsu.edu                if (traceData) { traceData->setData(Mem); }
3916019Shines@cs.fsu.edu            }
3926019Shines@cs.fsu.edu
3936019Shines@cs.fsu.edu            if (fault == NoFault) {
3946019Shines@cs.fsu.edu                %(op_wb)s;
3956019Shines@cs.fsu.edu            }
3966019Shines@cs.fsu.edu        }
3976019Shines@cs.fsu.edu
3986019Shines@cs.fsu.edu        return fault;
3996019Shines@cs.fsu.edu    }
4006019Shines@cs.fsu.edu}};
4016019Shines@cs.fsu.edu
4026019Shines@cs.fsu.edudef template StoreInitiateAcc {{
4036019Shines@cs.fsu.edu    Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
4046019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
4056019Shines@cs.fsu.edu    {
4066019Shines@cs.fsu.edu        Addr EA;
4076019Shines@cs.fsu.edu        Fault fault = NoFault;
4086019Shines@cs.fsu.edu
4096019Shines@cs.fsu.edu        %(op_decl)s;
4106019Shines@cs.fsu.edu        %(op_rd)s;
4116019Shines@cs.fsu.edu        %(ea_code)s;
4126019Shines@cs.fsu.edu
4136243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
4146019Shines@cs.fsu.edu        {
4156019Shines@cs.fsu.edu            if (fault == NoFault) {
4166019Shines@cs.fsu.edu                %(memacc_code)s;
4176019Shines@cs.fsu.edu            }
4186019Shines@cs.fsu.edu
4196019Shines@cs.fsu.edu            if (fault == NoFault) {
4206019Shines@cs.fsu.edu                fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA,
4216019Shines@cs.fsu.edu                                  memAccessFlags, NULL);
4226019Shines@cs.fsu.edu                if (traceData) { traceData->setData(Mem); }
4236019Shines@cs.fsu.edu            }
4246019Shines@cs.fsu.edu
4256019Shines@cs.fsu.edu            // Need to write back any potential address register update
4266019Shines@cs.fsu.edu            if (fault == NoFault) {
4276019Shines@cs.fsu.edu                %(op_wb)s;
4286019Shines@cs.fsu.edu            }
4296019Shines@cs.fsu.edu        }
4306019Shines@cs.fsu.edu
4316019Shines@cs.fsu.edu        return fault;
4326019Shines@cs.fsu.edu    }
4336019Shines@cs.fsu.edu}};
4346019Shines@cs.fsu.edu
4356019Shines@cs.fsu.edu
4366019Shines@cs.fsu.edudef template StoreCompleteAcc {{
4376019Shines@cs.fsu.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
4386019Shines@cs.fsu.edu                                      %(CPU_exec_context)s *xc,
4396019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
4406019Shines@cs.fsu.edu    {
4416019Shines@cs.fsu.edu        Fault fault = NoFault;
4426019Shines@cs.fsu.edu
4436019Shines@cs.fsu.edu        %(op_dest_decl)s;
4446019Shines@cs.fsu.edu
4456243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
4466019Shines@cs.fsu.edu        {
4476019Shines@cs.fsu.edu            if (fault == NoFault) {
4486019Shines@cs.fsu.edu                %(op_wb)s;
4496019Shines@cs.fsu.edu            }
4506019Shines@cs.fsu.edu        }
4516019Shines@cs.fsu.edu
4526019Shines@cs.fsu.edu        return fault;
4536019Shines@cs.fsu.edu    }
4546019Shines@cs.fsu.edu}};
4556019Shines@cs.fsu.edu
4566019Shines@cs.fsu.edudef template StoreCondCompleteAcc {{
4576019Shines@cs.fsu.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
4586019Shines@cs.fsu.edu                                      %(CPU_exec_context)s *xc,
4596019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
4606019Shines@cs.fsu.edu    {
4616019Shines@cs.fsu.edu        Fault fault = NoFault;
4626019Shines@cs.fsu.edu
4636019Shines@cs.fsu.edu        %(op_dest_decl)s;
4646019Shines@cs.fsu.edu
4656243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
4666019Shines@cs.fsu.edu        {
4676019Shines@cs.fsu.edu            if (fault == NoFault) {
4686019Shines@cs.fsu.edu                %(op_wb)s;
4696019Shines@cs.fsu.edu            }
4706019Shines@cs.fsu.edu        }
4716019Shines@cs.fsu.edu
4726019Shines@cs.fsu.edu        return fault;
4736019Shines@cs.fsu.edu    }
4746019Shines@cs.fsu.edu}};
4756019Shines@cs.fsu.edu
4766019Shines@cs.fsu.edu
4776019Shines@cs.fsu.edudef template MiscMemAccExecute {{
4786019Shines@cs.fsu.edu    Fault %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc,
4796019Shines@cs.fsu.edu                                          Trace::InstRecord *traceData) const
4806019Shines@cs.fsu.edu    {
4816019Shines@cs.fsu.edu        Addr EA;
4826019Shines@cs.fsu.edu        Fault fault = NoFault;
4836019Shines@cs.fsu.edu
4846019Shines@cs.fsu.edu        %(op_decl)s;
4856019Shines@cs.fsu.edu        %(op_rd)s;
4866019Shines@cs.fsu.edu
4876243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
4886019Shines@cs.fsu.edu        {
4896019Shines@cs.fsu.edu            EA = xc->getEA();
4906019Shines@cs.fsu.edu
4916019Shines@cs.fsu.edu            if (fault == NoFault) {
4926019Shines@cs.fsu.edu                %(memacc_code)s;
4936019Shines@cs.fsu.edu            }
4946019Shines@cs.fsu.edu        }
4956019Shines@cs.fsu.edu
4966019Shines@cs.fsu.edu        return NoFault;
4976019Shines@cs.fsu.edu    }
4986019Shines@cs.fsu.edu}};
4996019Shines@cs.fsu.edu
5006019Shines@cs.fsu.edudef template MiscExecute {{
5016019Shines@cs.fsu.edu    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
5026019Shines@cs.fsu.edu                                  Trace::InstRecord *traceData) const
5036019Shines@cs.fsu.edu    {
5046019Shines@cs.fsu.edu        Addr EA;
5056019Shines@cs.fsu.edu        Fault fault = NoFault;
5066019Shines@cs.fsu.edu
5076019Shines@cs.fsu.edu        %(op_decl)s;
5086019Shines@cs.fsu.edu        %(op_rd)s;
5096019Shines@cs.fsu.edu        %(ea_code)s;
5106019Shines@cs.fsu.edu
5116243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
5126019Shines@cs.fsu.edu        {
5136019Shines@cs.fsu.edu            if (fault == NoFault) {
5146019Shines@cs.fsu.edu                %(memacc_code)s;
5156019Shines@cs.fsu.edu            }
5166019Shines@cs.fsu.edu        }
5176019Shines@cs.fsu.edu
5186019Shines@cs.fsu.edu        return NoFault;
5196019Shines@cs.fsu.edu    }
5206019Shines@cs.fsu.edu}};
5216019Shines@cs.fsu.edu
5226019Shines@cs.fsu.edudef template MiscInitiateAcc {{
5236019Shines@cs.fsu.edu    Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
5246019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
5256019Shines@cs.fsu.edu    {
5266019Shines@cs.fsu.edu        panic("Misc instruction does not support split access method!");
5276019Shines@cs.fsu.edu        return NoFault;
5286019Shines@cs.fsu.edu    }
5296019Shines@cs.fsu.edu}};
5306019Shines@cs.fsu.edu
5316019Shines@cs.fsu.edu
5326019Shines@cs.fsu.edudef template MiscCompleteAcc {{
5336019Shines@cs.fsu.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
5346019Shines@cs.fsu.edu                                      %(CPU_exec_context)s *xc,
5356019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
5366019Shines@cs.fsu.edu    {
5376019Shines@cs.fsu.edu        panic("Misc instruction does not support split access method!");
5386019Shines@cs.fsu.edu
5396019Shines@cs.fsu.edu        return NoFault;
5406019Shines@cs.fsu.edu    }
5416019Shines@cs.fsu.edu}};
5426019Shines@cs.fsu.edu
5436019Shines@cs.fsu.edudef format ArmLoadMemory(memacc_code, ea_code = {{ EA = Rn + disp; }},
5446019Shines@cs.fsu.edu                     mem_flags = [], inst_flags = []) {{
5456019Shines@cs.fsu.edu    ea_code = ArmGenericCodeSubs(ea_code)
5466019Shines@cs.fsu.edu    memacc_code = ArmGenericCodeSubs(memacc_code)
5476019Shines@cs.fsu.edu    (header_output, decoder_output, decode_block, exec_output) = \
5486019Shines@cs.fsu.edu        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5496019Shines@cs.fsu.edu                      decode_template = BasicDecode,
5506019Shines@cs.fsu.edu                      exec_template_base = 'Load')
5516019Shines@cs.fsu.edu}};
5526019Shines@cs.fsu.edu
5536019Shines@cs.fsu.edudef format ArmStoreMemory(memacc_code, ea_code = {{ EA = Rn + disp; }},
5546019Shines@cs.fsu.edu                     mem_flags = [], inst_flags = []) {{
5556019Shines@cs.fsu.edu    ea_code = ArmGenericCodeSubs(ea_code)
5566019Shines@cs.fsu.edu    memacc_code = ArmGenericCodeSubs(memacc_code)
5576019Shines@cs.fsu.edu    (header_output, decoder_output, decode_block, exec_output) = \
5586019Shines@cs.fsu.edu        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5596019Shines@cs.fsu.edu                      exec_template_base = 'Store')
5606019Shines@cs.fsu.edu}};
5616019Shines@cs.fsu.edu
562