mem.isa revision 6739
12068SN/A// -*- mode:c++ -*-
22068SN/A
32068SN/A// Copyright (c) 2003-2005 The Regents of The University of Michigan
42068SN/A// All rights reserved.
52068SN/A//
62068SN/A// Redistribution and use in source and binary forms, with or without
72068SN/A// modification, are permitted provided that the following conditions are
82068SN/A// met: redistributions of source code must retain the above copyright
92068SN/A// notice, this list of conditions and the following disclaimer;
102068SN/A// redistributions in binary form must reproduce the above copyright
112068SN/A// notice, this list of conditions and the following disclaimer in the
122068SN/A// documentation and/or other materials provided with the distribution;
132068SN/A// neither the name of the copyright holders nor the names of its
142068SN/A// contributors may be used to endorse or promote products derived from
152068SN/A// this software without specific prior written permission.
162068SN/A//
172068SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182068SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192068SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202068SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212068SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222068SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232068SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242068SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252068SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262068SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272068SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu//
292665Ssaidi@eecs.umich.edu// Authors: Steve Reinhardt
302665Ssaidi@eecs.umich.edu//          Kevin Lim
312068SN/A
322649Ssaidi@eecs.umich.edu////////////////////////////////////////////////////////////////////
332649Ssaidi@eecs.umich.edu//
342649Ssaidi@eecs.umich.edu// Memory-format instructions: LoadAddress, Load, Store
352649Ssaidi@eecs.umich.edu//
362649Ssaidi@eecs.umich.edu
372068SN/Aoutput header {{
382068SN/A    /**
392068SN/A     * Base class for general Alpha memory-format instructions.
402068SN/A     */
412068SN/A    class Memory : public AlphaStaticInst
422068SN/A    {
432068SN/A      protected:
442068SN/A
452068SN/A        /// Memory request flags.  See mem_req_base.hh.
465736Snate@binkert.org        Request::Flags memAccessFlags;
472068SN/A
482068SN/A        /// Constructor
496181Sksewell@umich.edu        Memory(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
506181Sksewell@umich.edu            : AlphaStaticInst(mnem, _machInst, __opClass)
512068SN/A        {
522068SN/A        }
532068SN/A
542068SN/A        std::string
552068SN/A        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
562068SN/A    };
572068SN/A
582068SN/A    /**
592068SN/A     * Base class for memory-format instructions using a 32-bit
602068SN/A     * displacement (i.e. most of them).
612068SN/A     */
622068SN/A    class MemoryDisp32 : public Memory
632068SN/A    {
642068SN/A      protected:
652068SN/A        /// Displacement for EA calculation (signed).
662068SN/A        int32_t disp;
672068SN/A
682068SN/A        /// Constructor.
696181Sksewell@umich.edu        MemoryDisp32(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
706181Sksewell@umich.edu            : Memory(mnem, _machInst, __opClass),
712068SN/A              disp(MEMDISP)
722068SN/A        {
732068SN/A        }
742068SN/A    };
752068SN/A
762068SN/A
772068SN/A    /**
782068SN/A     * Base class for a few miscellaneous memory-format insts
792068SN/A     * that don't interpret the disp field: wh64, fetch, fetch_m, ecb.
802068SN/A     * None of these instructions has a destination register either.
812068SN/A     */
822068SN/A    class MemoryNoDisp : public Memory
832068SN/A    {
842068SN/A      protected:
852068SN/A        /// Constructor
866181Sksewell@umich.edu        MemoryNoDisp(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
876181Sksewell@umich.edu            : Memory(mnem, _machInst, __opClass)
882068SN/A        {
892068SN/A        }
902068SN/A
912068SN/A        std::string
922068SN/A        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
932068SN/A    };
942068SN/A}};
952068SN/A
962068SN/A
972068SN/Aoutput decoder {{
982068SN/A    std::string
992068SN/A    Memory::generateDisassembly(Addr pc, const SymbolTable *symtab) const
1002068SN/A    {
1012068SN/A        return csprintf("%-10s %c%d,%d(r%d)", mnemonic,
1022068SN/A                        flags[IsFloating] ? 'f' : 'r', RA, MEMDISP, RB);
1032068SN/A    }
1042068SN/A
1052068SN/A    std::string
1062068SN/A    MemoryNoDisp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
1072068SN/A    {
1082068SN/A        return csprintf("%-10s (r%d)", mnemonic, RB);
1092068SN/A    }
1102068SN/A}};
1112068SN/A
1122068SN/Adef format LoadAddress(code) {{
1133953Sstever@eecs.umich.edu    iop = InstObjParams(name, Name, 'MemoryDisp32', code)
1142068SN/A    header_output = BasicDeclare.subst(iop)
1152068SN/A    decoder_output = BasicConstructor.subst(iop)
1162068SN/A    decode_block = BasicDecode.subst(iop)
1172068SN/A    exec_output = BasicExecute.subst(iop)
1182068SN/A}};
1192068SN/A
1202068SN/A
1212068SN/Adef template LoadStoreDeclare {{
1222068SN/A    /**
1232068SN/A     * Static instruction class for "%(mnemonic)s".
1242068SN/A     */
1252068SN/A    class %(class_name)s : public %(base_class)s
1262068SN/A    {
1272068SN/A      public:
1282068SN/A
1292068SN/A        /// Constructor.
1302227SN/A        %(class_name)s(ExtMachInst machInst);
1312068SN/A
1322068SN/A        %(BasicExecDeclare)s
1332095SN/A
1346181Sksewell@umich.edu        %(EACompDeclare)s
1356181Sksewell@umich.edu
1362095SN/A        %(InitiateAccDeclare)s
1372095SN/A
1382095SN/A        %(CompleteAccDeclare)s
1392068SN/A    };
1402068SN/A}};
1412068SN/A
1422095SN/A
1436181Sksewell@umich.edudef template EACompDeclare {{
1446181Sksewell@umich.edu    Fault eaComp(%(CPU_exec_context)s *, Trace::InstRecord *) const;
1456181Sksewell@umich.edu}};
1466181Sksewell@umich.edu
1472095SN/Adef template InitiateAccDeclare {{
1482132SN/A    Fault initiateAcc(%(CPU_exec_context)s *, Trace::InstRecord *) const;
1492095SN/A}};
1502095SN/A
1512095SN/A
1522095SN/Adef template CompleteAccDeclare {{
1533349Sbinkertn@umich.edu    Fault completeAcc(PacketPtr, %(CPU_exec_context)s *,
1542623SN/A                      Trace::InstRecord *) const;
1552095SN/A}};
1562095SN/A
1576181Sksewell@umich.edudef template LoadStoreConstructor {{
1586181Sksewell@umich.edu    inline %(class_name)s::%(class_name)s(ExtMachInst machInst)
1596181Sksewell@umich.edu         : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
1602068SN/A    {
1613953Sstever@eecs.umich.edu        %(constructor)s;
1622068SN/A    }
1633953Sstever@eecs.umich.edu}};
1642068SN/A
1652068SN/Adef template EACompExecute {{
1666181Sksewell@umich.edu    Fault %(class_name)s::eaComp(%(CPU_exec_context)s *xc,
1676181Sksewell@umich.edu                                  Trace::InstRecord *traceData) const
1682068SN/A    {
1692068SN/A        Addr EA;
1702132SN/A        Fault fault = NoFault;
1712068SN/A
1722068SN/A        %(fp_enable_check)s;
1732068SN/A        %(op_decl)s;
1742068SN/A        %(op_rd)s;
1753953Sstever@eecs.umich.edu        %(ea_code)s;
1762068SN/A
1772090SN/A        if (fault == NoFault) {
1782068SN/A            %(op_wb)s;
1792068SN/A            xc->setEA(EA);
1802068SN/A        }
1812068SN/A
1822068SN/A        return fault;
1832068SN/A    }
1842068SN/A}};
1852068SN/A
1862068SN/A
1872069SN/Adef template LoadExecute {{
1882132SN/A    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
1892068SN/A                                  Trace::InstRecord *traceData) const
1902068SN/A    {
1912068SN/A        Addr EA;
1922132SN/A        Fault fault = NoFault;
1932068SN/A
1942068SN/A        %(fp_enable_check)s;
1952068SN/A        %(op_decl)s;
1962069SN/A        %(op_rd)s;
1972068SN/A        %(ea_code)s;
1982068SN/A
1992090SN/A        if (fault == NoFault) {
2002069SN/A            fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags);
2012068SN/A            %(memacc_code)s;
2022068SN/A        }
2032068SN/A
2042090SN/A        if (fault == NoFault) {
2052069SN/A            %(op_wb)s;
2062069SN/A        }
2072069SN/A
2082069SN/A        return fault;
2092069SN/A    }
2102069SN/A}};
2112069SN/A
2122069SN/A
2132095SN/Adef template LoadInitiateAcc {{
2142132SN/A    Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
2152095SN/A                                      Trace::InstRecord *traceData) const
2162095SN/A    {
2172095SN/A        Addr EA;
2182132SN/A        Fault fault = NoFault;
2192095SN/A
2202095SN/A        %(fp_enable_check)s;
2212095SN/A        %(op_src_decl)s;
2222095SN/A        %(op_rd)s;
2232095SN/A        %(ea_code)s;
2242095SN/A
2252098SN/A        if (fault == NoFault) {
2262095SN/A            fault = xc->read(EA, (uint%(mem_acc_size)d_t &)Mem, memAccessFlags);
2272095SN/A        }
2282095SN/A
2292095SN/A        return fault;
2302095SN/A    }
2312095SN/A}};
2322095SN/A
2332095SN/A
2342095SN/Adef template LoadCompleteAcc {{
2353349Sbinkertn@umich.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
2362095SN/A                                      %(CPU_exec_context)s *xc,
2372095SN/A                                      Trace::InstRecord *traceData) const
2382095SN/A    {
2392132SN/A        Fault fault = NoFault;
2402095SN/A
2412095SN/A        %(fp_enable_check)s;
2422506SN/A        %(op_decl)s;
2432095SN/A
2442623SN/A        Mem = pkt->get<typeof(Mem)>();
2452095SN/A
2462098SN/A        if (fault == NoFault) {
2472095SN/A            %(memacc_code)s;
2482095SN/A        }
2492095SN/A
2502098SN/A        if (fault == NoFault) {
2512095SN/A            %(op_wb)s;
2522095SN/A        }
2532095SN/A
2542095SN/A        return fault;
2552095SN/A    }
2562095SN/A}};
2572095SN/A
2582095SN/A
2592069SN/Adef template StoreExecute {{
2602132SN/A    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
2612069SN/A                                  Trace::InstRecord *traceData) const
2622069SN/A    {
2632069SN/A        Addr EA;
2642132SN/A        Fault fault = NoFault;
2654027Sstever@eecs.umich.edu
2664027Sstever@eecs.umich.edu        %(fp_enable_check)s;
2674027Sstever@eecs.umich.edu        %(op_decl)s;
2684027Sstever@eecs.umich.edu        %(op_rd)s;
2694027Sstever@eecs.umich.edu        %(ea_code)s;
2704027Sstever@eecs.umich.edu
2714027Sstever@eecs.umich.edu        if (fault == NoFault) {
2724027Sstever@eecs.umich.edu            %(memacc_code)s;
2734027Sstever@eecs.umich.edu        }
2744027Sstever@eecs.umich.edu
2754027Sstever@eecs.umich.edu        if (fault == NoFault) {
2764027Sstever@eecs.umich.edu            fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA,
2774027Sstever@eecs.umich.edu                              memAccessFlags, NULL);
2784027Sstever@eecs.umich.edu            if (traceData) { traceData->setData(Mem); }
2794027Sstever@eecs.umich.edu        }
2804027Sstever@eecs.umich.edu
2814027Sstever@eecs.umich.edu        if (fault == NoFault) {
2824027Sstever@eecs.umich.edu            %(postacc_code)s;
2834027Sstever@eecs.umich.edu        }
2844027Sstever@eecs.umich.edu
2854027Sstever@eecs.umich.edu        if (fault == NoFault) {
2864027Sstever@eecs.umich.edu            %(op_wb)s;
2874027Sstever@eecs.umich.edu        }
2884027Sstever@eecs.umich.edu
2894027Sstever@eecs.umich.edu        return fault;
2904027Sstever@eecs.umich.edu    }
2914027Sstever@eecs.umich.edu}};
2924027Sstever@eecs.umich.edu
2934027Sstever@eecs.umich.edudef template StoreCondExecute {{
2944027Sstever@eecs.umich.edu    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
2954027Sstever@eecs.umich.edu                                  Trace::InstRecord *traceData) const
2964027Sstever@eecs.umich.edu    {
2974027Sstever@eecs.umich.edu        Addr EA;
2984027Sstever@eecs.umich.edu        Fault fault = NoFault;
2992069SN/A        uint64_t write_result = 0;
3002069SN/A
3012069SN/A        %(fp_enable_check)s;
3022069SN/A        %(op_decl)s;
3032069SN/A        %(op_rd)s;
3042069SN/A        %(ea_code)s;
3052069SN/A
3062090SN/A        if (fault == NoFault) {
3072069SN/A            %(memacc_code)s;
3082069SN/A        }
3092069SN/A
3102090SN/A        if (fault == NoFault) {
3112069SN/A            fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA,
3122069SN/A                              memAccessFlags, &write_result);
3132069SN/A            if (traceData) { traceData->setData(Mem); }
3142069SN/A        }
3152069SN/A
3162090SN/A        if (fault == NoFault) {
3172069SN/A            %(postacc_code)s;
3182069SN/A        }
3192069SN/A
3202090SN/A        if (fault == NoFault) {
3212069SN/A            %(op_wb)s;
3222069SN/A        }
3232069SN/A
3242069SN/A        return fault;
3252069SN/A    }
3262069SN/A}};
3272069SN/A
3282095SN/Adef template StoreInitiateAcc {{
3292132SN/A    Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
3302095SN/A                                      Trace::InstRecord *traceData) const
3312095SN/A    {
3322095SN/A        Addr EA;
3332132SN/A        Fault fault = NoFault;
3342095SN/A
3352095SN/A        %(fp_enable_check)s;
3362506SN/A        %(op_decl)s;
3372095SN/A        %(op_rd)s;
3382095SN/A        %(ea_code)s;
3392095SN/A
3402098SN/A        if (fault == NoFault) {
3412095SN/A            %(memacc_code)s;
3422095SN/A        }
3432095SN/A
3442098SN/A        if (fault == NoFault) {
3452095SN/A            fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA,
3462623SN/A                              memAccessFlags, NULL);
3472095SN/A            if (traceData) { traceData->setData(Mem); }
3482095SN/A        }
3492095SN/A
3502095SN/A        return fault;
3512095SN/A    }
3522095SN/A}};
3532095SN/A
3542095SN/A
3552095SN/Adef template StoreCompleteAcc {{
3563349Sbinkertn@umich.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
3572095SN/A                                      %(CPU_exec_context)s *xc,
3582095SN/A                                      Trace::InstRecord *traceData) const
3592095SN/A    {
3602132SN/A        Fault fault = NoFault;
3612095SN/A
3622095SN/A        %(fp_enable_check)s;
3632095SN/A        %(op_dest_decl)s;
3642095SN/A
3652623SN/A        if (fault == NoFault) {
3662623SN/A            %(postacc_code)s;
3672623SN/A        }
3682623SN/A
3692623SN/A        if (fault == NoFault) {
3702623SN/A            %(op_wb)s;
3712623SN/A        }
3722623SN/A
3732623SN/A        return fault;
3742623SN/A    }
3752623SN/A}};
3762623SN/A
3772623SN/A
3782623SN/Adef template StoreCondCompleteAcc {{
3793349Sbinkertn@umich.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
3802623SN/A                                      %(CPU_exec_context)s *xc,
3812623SN/A                                      Trace::InstRecord *traceData) const
3822623SN/A    {
3832623SN/A        Fault fault = NoFault;
3842623SN/A
3852623SN/A        %(fp_enable_check)s;
3862623SN/A        %(op_dest_decl)s;
3872623SN/A
3884040Ssaidi@eecs.umich.edu        uint64_t write_result = pkt->req->getExtraData();
3892095SN/A
3902098SN/A        if (fault == NoFault) {
3912095SN/A            %(postacc_code)s;
3922095SN/A        }
3932095SN/A
3942098SN/A        if (fault == NoFault) {
3952095SN/A            %(op_wb)s;
3962095SN/A        }
3972095SN/A
3982095SN/A        return fault;
3992095SN/A    }
4002095SN/A}};
4012095SN/A
4022069SN/A
4032069SN/Adef template MiscExecute {{
4042132SN/A    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
4052068SN/A                                  Trace::InstRecord *traceData) const
4062068SN/A    {
4072068SN/A        Addr EA;
4082132SN/A        Fault fault = NoFault;
4092068SN/A
4102068SN/A        %(fp_enable_check)s;
4112068SN/A        %(op_decl)s;
4122069SN/A        %(op_rd)s;
4132068SN/A        %(ea_code)s;
4142068SN/A
4152090SN/A        if (fault == NoFault) {
4162069SN/A            %(memacc_code)s;
4172068SN/A        }
4182068SN/A
4192090SN/A        return NoFault;
4202068SN/A    }
4212068SN/A}};
4222068SN/A
4232095SN/Adef template MiscInitiateAcc {{
4242132SN/A    Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc,
4252095SN/A                                      Trace::InstRecord *traceData) const
4262095SN/A    {
4276185Sksewell@umich.edu        warn("initiateAcc undefined: Misc instruction does not support split "
4286185Sksewell@umich.edu             "access method!");
4292098SN/A        return NoFault;
4302095SN/A    }
4312095SN/A}};
4322095SN/A
4332095SN/A
4342095SN/Adef template MiscCompleteAcc {{
4353349Sbinkertn@umich.edu    Fault %(class_name)s::completeAcc(PacketPtr pkt,
4362095SN/A                                      %(CPU_exec_context)s *xc,
4372095SN/A                                      Trace::InstRecord *traceData) const
4382095SN/A    {
4396185Sksewell@umich.edu        warn("completeAcc undefined: Misc instruction does not support split "
4406185Sksewell@umich.edu             "access method!");
4412110SN/A
4422098SN/A        return NoFault;
4432095SN/A    }
4442095SN/A}};
4452095SN/A
4466179Sksewell@umich.edu
4472068SN/A// load instructions use Ra as dest, so check for
4482068SN/A// Ra == 31 to detect nops
4492068SN/Adef template LoadNopCheckDecode {{
4502068SN/A {
4512068SN/A     AlphaStaticInst *i = new %(class_name)s(machInst);
4522068SN/A     if (RA == 31) {
4532068SN/A         i = makeNop(i);
4542068SN/A     }
4552068SN/A     return i;
4562068SN/A }
4572068SN/A}};
4582068SN/A
4592068SN/A
4602068SN/A// for some load instructions, Ra == 31 indicates a prefetch (not a nop)
4612068SN/Adef template LoadPrefetchCheckDecode {{
4622068SN/A {
4632068SN/A     if (RA != 31) {
4642068SN/A         return new %(class_name)s(machInst);
4652068SN/A     }
4662068SN/A     else {
4672068SN/A         return new %(class_name)sPrefetch(machInst);
4682068SN/A     }
4692068SN/A }
4702068SN/A}};
4712068SN/A
4722068SN/A
4732068SN/Alet {{
4742075SN/Adef LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
4752075SN/A                  postacc_code = '', base_class = 'MemoryDisp32',
4762069SN/A                  decode_template = BasicDecode, exec_template_base = ''):
4772075SN/A    # Make sure flags are in lists (convert to lists if not).
4782075SN/A    mem_flags = makeList(mem_flags)
4792075SN/A    inst_flags = makeList(inst_flags)
4802068SN/A
4812068SN/A    # add hook to get effective addresses into execution trace output.
4822068SN/A    ea_code += '\nif (traceData) { traceData->setAddr(EA); }\n'
4832068SN/A
4842068SN/A    # Some CPU models execute the memory operation as an atomic unit,
4852068SN/A    # while others want to separate them into an effective address
4862068SN/A    # computation and a memory access operation.  As a result, we need
4872068SN/A    # to generate three StaticInst objects.  Note that the latter two
4882068SN/A    # are nested inside the larger "atomic" one.
4892068SN/A
4903953Sstever@eecs.umich.edu    # Generate InstObjParams for each of the three objects.  Note that
4913953Sstever@eecs.umich.edu    # they differ only in the set of code objects contained (which in
4923953Sstever@eecs.umich.edu    # turn affects the object's overall operand list).
4933953Sstever@eecs.umich.edu    iop = InstObjParams(name, Name, base_class,
4943953Sstever@eecs.umich.edu                        { 'ea_code':ea_code, 'memacc_code':memacc_code, 'postacc_code':postacc_code },
4953953Sstever@eecs.umich.edu                        inst_flags)
4963953Sstever@eecs.umich.edu    memacc_iop = InstObjParams(name, Name, base_class,
4973953Sstever@eecs.umich.edu                        { 'memacc_code':memacc_code, 'postacc_code':postacc_code },
4983953Sstever@eecs.umich.edu                        inst_flags)
4992068SN/A
5002068SN/A    if mem_flags:
5015736Snate@binkert.org        mem_flags = [ 'Request::%s' % flag for flag in mem_flags ]
5025745Snate@binkert.org        s = '\n\tmemAccessFlags = ' + string.join(mem_flags, '|') + ';'
5032068SN/A        iop.constructor += s
5042068SN/A        memacc_iop.constructor += s
5052068SN/A
5062069SN/A    # select templates
5072623SN/A
5084027Sstever@eecs.umich.edu    # The InitiateAcc template is the same for StoreCond templates as the
5094027Sstever@eecs.umich.edu    # corresponding Store template..
5102623SN/A    StoreCondInitiateAcc = StoreInitiateAcc
5112623SN/A
5122069SN/A    fullExecTemplate = eval(exec_template_base + 'Execute')
5132095SN/A    initiateAccTemplate = eval(exec_template_base + 'InitiateAcc')
5142095SN/A    completeAccTemplate = eval(exec_template_base + 'CompleteAcc')
5152069SN/A
5162068SN/A    # (header_output, decoder_output, decode_block, exec_output)
5173953Sstever@eecs.umich.edu    return (LoadStoreDeclare.subst(iop),
5186181Sksewell@umich.edu            LoadStoreConstructor.subst(iop),
5192068SN/A            decode_template.subst(iop),
5206181Sksewell@umich.edu            fullExecTemplate.subst(iop)
5216181Sksewell@umich.edu            + EACompExecute.subst(iop)
5223953Sstever@eecs.umich.edu            + initiateAccTemplate.subst(iop)
5236192Sksewell@umich.edu            + completeAccTemplate.subst(iop))
5242068SN/A}};
5252068SN/A
5262075SN/Adef format LoadOrNop(memacc_code, ea_code = {{ EA = Rb + disp; }},
5272075SN/A                     mem_flags = [], inst_flags = []) {{
5282068SN/A    (header_output, decoder_output, decode_block, exec_output) = \
5292075SN/A        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5302069SN/A                      decode_template = LoadNopCheckDecode,
5312069SN/A                      exec_template_base = 'Load')
5322068SN/A}};
5332068SN/A
5342068SN/A
5352068SN/A// Note that the flags passed in apply only to the prefetch version
5362075SN/Adef format LoadOrPrefetch(memacc_code, ea_code = {{ EA = Rb + disp; }},
5372075SN/A                          mem_flags = [], pf_flags = [], inst_flags = []) {{
5382068SN/A    # declare the load instruction object and generate the decode block
5392068SN/A    (header_output, decoder_output, decode_block, exec_output) = \
5402075SN/A        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5412069SN/A                      decode_template = LoadPrefetchCheckDecode,
5422069SN/A                      exec_template_base = 'Load')
5432068SN/A
5442068SN/A    # Declare the prefetch instruction object.
5452068SN/A
5462075SN/A    # Make sure flag args are lists so we can mess with them.
5472075SN/A    mem_flags = makeList(mem_flags)
5482075SN/A    pf_flags = makeList(pf_flags)
5492075SN/A    inst_flags = makeList(inst_flags)
5502075SN/A
5516739Sgblack@eecs.umich.edu    pf_mem_flags = mem_flags + pf_flags + ['PREFETCH']
5522075SN/A    pf_inst_flags = inst_flags + ['IsMemRef', 'IsLoad',
5532075SN/A                                  'IsDataPrefetch', 'MemReadOp']
5542068SN/A
5552068SN/A    (pf_header_output, pf_decoder_output, _, pf_exec_output) = \
5562069SN/A        LoadStoreBase(name, Name + 'Prefetch', ea_code,
5572069SN/A                      'xc->prefetch(EA, memAccessFlags);',
5582075SN/A                      pf_mem_flags, pf_inst_flags, exec_template_base = 'Misc')
5592068SN/A
5602068SN/A    header_output += pf_header_output
5612068SN/A    decoder_output += pf_decoder_output
5622068SN/A    exec_output += pf_exec_output
5632068SN/A}};
5642068SN/A
5652068SN/A
5662075SN/Adef format Store(memacc_code, ea_code = {{ EA = Rb + disp; }},
5672075SN/A                 mem_flags = [], inst_flags = []) {{
5682068SN/A    (header_output, decoder_output, decode_block, exec_output) = \
5692075SN/A        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5702069SN/A                      exec_template_base = 'Store')
5712068SN/A}};
5722068SN/A
5732068SN/A
5742075SN/Adef format StoreCond(memacc_code, postacc_code,
5752075SN/A                     ea_code = {{ EA = Rb + disp; }},
5762075SN/A                     mem_flags = [], inst_flags = []) {{
5772068SN/A    (header_output, decoder_output, decode_block, exec_output) = \
5782075SN/A        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5792623SN/A                      postacc_code, exec_template_base = 'StoreCond')
5802068SN/A}};
5812068SN/A
5822068SN/A
5832068SN/A// Use 'MemoryNoDisp' as base: for wh64, fetch, ecb
5842075SN/Adef format MiscPrefetch(ea_code, memacc_code,
5852075SN/A                        mem_flags = [], inst_flags = []) {{
5862068SN/A    (header_output, decoder_output, decode_block, exec_output) = \
5872075SN/A        LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
5882069SN/A                      base_class = 'MemoryNoDisp', exec_template_base = 'Misc')
5892068SN/A}};
5902068SN/A
5912068SN/A
592