mem.isa revision 6301
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
3576019Shines@cs.fsu.edu        %(op_dest_decl)s;
3586019Shines@cs.fsu.edu
3596243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
3606019Shines@cs.fsu.edu        {
3616019Shines@cs.fsu.edu            if (fault == NoFault) {
3626019Shines@cs.fsu.edu                %(op_wb)s;
3636019Shines@cs.fsu.edu            }
3646019Shines@cs.fsu.edu        }
3656019Shines@cs.fsu.edu
3666019Shines@cs.fsu.edu        return fault;
3676019Shines@cs.fsu.edu    }
3686019Shines@cs.fsu.edu}};
3696019Shines@cs.fsu.edu
3706019Shines@cs.fsu.edudef template StoreCondCompleteAcc {{
3716019Shines@cs.fsu.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
3726019Shines@cs.fsu.edu                                      %(CPU_exec_context)s *xc,
3736019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
3746019Shines@cs.fsu.edu    {
3756019Shines@cs.fsu.edu        Fault fault = NoFault;
3766019Shines@cs.fsu.edu
3776019Shines@cs.fsu.edu        %(op_dest_decl)s;
3786019Shines@cs.fsu.edu
3796243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
3806019Shines@cs.fsu.edu        {
3816019Shines@cs.fsu.edu            if (fault == NoFault) {
3826019Shines@cs.fsu.edu                %(op_wb)s;
3836019Shines@cs.fsu.edu            }
3846019Shines@cs.fsu.edu        }
3856019Shines@cs.fsu.edu
3866019Shines@cs.fsu.edu        return fault;
3876019Shines@cs.fsu.edu    }
3886019Shines@cs.fsu.edu}};
3896019Shines@cs.fsu.edu
3906019Shines@cs.fsu.edu
3916019Shines@cs.fsu.edudef template MiscMemAccExecute {{
3926019Shines@cs.fsu.edu    Fault %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc,
3936019Shines@cs.fsu.edu                                          Trace::InstRecord *traceData) const
3946019Shines@cs.fsu.edu    {
3956019Shines@cs.fsu.edu        Addr EA;
3966019Shines@cs.fsu.edu        Fault fault = NoFault;
3976019Shines@cs.fsu.edu
3986019Shines@cs.fsu.edu        %(op_decl)s;
3996019Shines@cs.fsu.edu        %(op_rd)s;
4006019Shines@cs.fsu.edu
4016243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
4026019Shines@cs.fsu.edu        {
4036019Shines@cs.fsu.edu            EA = xc->getEA();
4046019Shines@cs.fsu.edu
4056019Shines@cs.fsu.edu            if (fault == NoFault) {
4066019Shines@cs.fsu.edu                %(memacc_code)s;
4076019Shines@cs.fsu.edu            }
4086019Shines@cs.fsu.edu        }
4096019Shines@cs.fsu.edu
4106019Shines@cs.fsu.edu        return NoFault;
4116019Shines@cs.fsu.edu    }
4126019Shines@cs.fsu.edu}};
4136019Shines@cs.fsu.edu
4146019Shines@cs.fsu.edudef template MiscExecute {{
4156019Shines@cs.fsu.edu    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
4166019Shines@cs.fsu.edu                                  Trace::InstRecord *traceData) const
4176019Shines@cs.fsu.edu    {
4186019Shines@cs.fsu.edu        Addr EA;
4196019Shines@cs.fsu.edu        Fault fault = NoFault;
4206019Shines@cs.fsu.edu
4216019Shines@cs.fsu.edu        %(op_decl)s;
4226019Shines@cs.fsu.edu        %(op_rd)s;
4236019Shines@cs.fsu.edu        %(ea_code)s;
4246019Shines@cs.fsu.edu
4256243Sgblack@eecs.umich.edu        if (%(predicate_test)s)
4266019Shines@cs.fsu.edu        {
4276019Shines@cs.fsu.edu            if (fault == NoFault) {
4286019Shines@cs.fsu.edu                %(memacc_code)s;
4296019Shines@cs.fsu.edu            }
4306019Shines@cs.fsu.edu        }
4316019Shines@cs.fsu.edu
4326019Shines@cs.fsu.edu        return NoFault;
4336019Shines@cs.fsu.edu    }
4346019Shines@cs.fsu.edu}};
4356019Shines@cs.fsu.edu
4366019Shines@cs.fsu.edudef template MiscInitiateAcc {{
4376019Shines@cs.fsu.edu    Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
4386019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
4396019Shines@cs.fsu.edu    {
4406019Shines@cs.fsu.edu        panic("Misc instruction does not support split access method!");
4416019Shines@cs.fsu.edu        return NoFault;
4426019Shines@cs.fsu.edu    }
4436019Shines@cs.fsu.edu}};
4446019Shines@cs.fsu.edu
4456019Shines@cs.fsu.edu
4466019Shines@cs.fsu.edudef template MiscCompleteAcc {{
4476019Shines@cs.fsu.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
4486019Shines@cs.fsu.edu                                      %(CPU_exec_context)s *xc,
4496019Shines@cs.fsu.edu                                      Trace::InstRecord *traceData) const
4506019Shines@cs.fsu.edu    {
4516019Shines@cs.fsu.edu        panic("Misc instruction does not support split access method!");
4526019Shines@cs.fsu.edu
4536019Shines@cs.fsu.edu        return NoFault;
4546019Shines@cs.fsu.edu    }
4556019Shines@cs.fsu.edu}};
4566019Shines@cs.fsu.edu
4576301Sgblack@eecs.umich.edulet {{
4586301Sgblack@eecs.umich.edu    def buildPUBWLCase(p, u, b, w, l):
4596301Sgblack@eecs.umich.edu        return (p << 4) + (u << 3) + (b << 2) + (w << 1) + (l << 0)
4606301Sgblack@eecs.umich.edu
4616301Sgblack@eecs.umich.edu    def buildMode3Inst(p, u, i, w, type, code, mnem):
4626301Sgblack@eecs.umich.edu        op = ("-", "+")[u]
4636301Sgblack@eecs.umich.edu        offset = ("%s Rm", "%s hilo")[i] % op
4646301Sgblack@eecs.umich.edu        ea_code = "EA = Rn %s;" % ("", offset)[p]
4656301Sgblack@eecs.umich.edu        if p == 0 or w == 1:
4666301Sgblack@eecs.umich.edu            code += "Rn = Rn %s;" % offset
4676301Sgblack@eecs.umich.edu        suffix = "_P%dU%dI%dW%d" % (p, u, i, w)
4686301Sgblack@eecs.umich.edu        return LoadStoreBase(mnem, mnem.capitalize() + suffix,
4696301Sgblack@eecs.umich.edu                ea_code, code, mem_flags = [], inst_flags = [],
4706301Sgblack@eecs.umich.edu                exec_template_base = type.capitalize())
4716301Sgblack@eecs.umich.edu}};
4726301Sgblack@eecs.umich.edu
4736301Sgblack@eecs.umich.edudef format AddrMode3(l0Type, l0Code, l1Type, l1Code) {{
4746301Sgblack@eecs.umich.edu    l0Code = ArmGenericCodeSubs(l0Code);
4756301Sgblack@eecs.umich.edu    l1Code = ArmGenericCodeSubs(l1Code);
4766301Sgblack@eecs.umich.edu
4776301Sgblack@eecs.umich.edu    header_output = decoder_output = exec_output = ""
4786301Sgblack@eecs.umich.edu    decode_block = "switch(PUBWL) {\n"
4796301Sgblack@eecs.umich.edu    (l0Mnem, l1Mnem) = name.split("_");
4806301Sgblack@eecs.umich.edu
4816301Sgblack@eecs.umich.edu    # Loop over all the values of p, u, i, w and l and build instructions and
4826301Sgblack@eecs.umich.edu    # a decode block for them.
4836301Sgblack@eecs.umich.edu    for (l, type, code, mnem) in ((0, l0Type, l0Code, l0Mnem),
4846301Sgblack@eecs.umich.edu                                  (1, l1Type, l1Code, l1Mnem)):
4856301Sgblack@eecs.umich.edu        for p in (0, 1):
4866301Sgblack@eecs.umich.edu            wset = (0, 1)
4876301Sgblack@eecs.umich.edu            if (p == 0):
4886301Sgblack@eecs.umich.edu                wset = (0,)
4896301Sgblack@eecs.umich.edu            for u in (0, 1):
4906301Sgblack@eecs.umich.edu                for i in (0, 1):
4916301Sgblack@eecs.umich.edu                    for w in wset:
4926301Sgblack@eecs.umich.edu                        (new_header_output,
4936301Sgblack@eecs.umich.edu                         new_decoder_output,
4946301Sgblack@eecs.umich.edu                         new_decode_block,
4956301Sgblack@eecs.umich.edu                         new_exec_output) = buildMode3Inst(p, u, i, w,
4966301Sgblack@eecs.umich.edu                                                           type, code, mnem)
4976301Sgblack@eecs.umich.edu                        header_output += new_header_output
4986301Sgblack@eecs.umich.edu                        decoder_output += new_decoder_output
4996301Sgblack@eecs.umich.edu                        exec_output += new_exec_output
5006301Sgblack@eecs.umich.edu                        decode_block += '''
5016301Sgblack@eecs.umich.edu                            case %#x:
5026301Sgblack@eecs.umich.edu                              {%s}
5036301Sgblack@eecs.umich.edu                              break;
5046301Sgblack@eecs.umich.edu                        ''' % (buildPUBWLCase(p,u,i,w,l), new_decode_block)
5056301Sgblack@eecs.umich.edu
5066301Sgblack@eecs.umich.edu    decode_block += '''
5076301Sgblack@eecs.umich.edu        default:
5086301Sgblack@eecs.umich.edu          return new Unknown(machInst);
5096301Sgblack@eecs.umich.edu        break;
5106301Sgblack@eecs.umich.edu    }'''
5116301Sgblack@eecs.umich.edu}};
5126301Sgblack@eecs.umich.edu
5136019Shines@cs.fsu.edudef format ArmLoadMemory(memacc_code, ea_code = {{ EA = Rn + disp; }},
5146019Shines@cs.fsu.edu                     mem_flags = [], inst_flags = []) {{
5156019Shines@cs.fsu.edu    ea_code = ArmGenericCodeSubs(ea_code)
5166019Shines@cs.fsu.edu    memacc_code = ArmGenericCodeSubs(memacc_code)
5176019Shines@cs.fsu.edu    (header_output, decoder_output, decode_block, exec_output) = \
5186019Shines@cs.fsu.edu        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5196019Shines@cs.fsu.edu                      decode_template = BasicDecode,
5206019Shines@cs.fsu.edu                      exec_template_base = 'Load')
5216019Shines@cs.fsu.edu}};
5226019Shines@cs.fsu.edu
5236019Shines@cs.fsu.edudef format ArmStoreMemory(memacc_code, ea_code = {{ EA = Rn + disp; }},
5246019Shines@cs.fsu.edu                     mem_flags = [], inst_flags = []) {{
5256019Shines@cs.fsu.edu    ea_code = ArmGenericCodeSubs(ea_code)
5266019Shines@cs.fsu.edu    memacc_code = ArmGenericCodeSubs(memacc_code)
5276019Shines@cs.fsu.edu    (header_output, decoder_output, decode_block, exec_output) = \
5286019Shines@cs.fsu.edu        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5296019Shines@cs.fsu.edu                      exec_template_base = 'Store')
5306019Shines@cs.fsu.edu}};
5316019Shines@cs.fsu.edu
532