main.isa revision 7720:65d338a8dba4
1278Sbinkertn@umich.edu// -*- mode:c++ -*-
212003Sandreas.sandberg@arm.com
38659SAli.Saidi@ARM.com// Copyright (c) 2003-2005 The Regents of The University of Michigan
48659SAli.Saidi@ARM.com// All rights reserved.
58659SAli.Saidi@ARM.com//
68659SAli.Saidi@ARM.com// Redistribution and use in source and binary forms, with or without
78659SAli.Saidi@ARM.com// modification, are permitted provided that the following conditions are
88659SAli.Saidi@ARM.com// met: redistributions of source code must retain the above copyright
98659SAli.Saidi@ARM.com// notice, this list of conditions and the following disclaimer;
108659SAli.Saidi@ARM.com// redistributions in binary form must reproduce the above copyright
118659SAli.Saidi@ARM.com// notice, this list of conditions and the following disclaimer in the
128659SAli.Saidi@ARM.com// documentation and/or other materials provided with the distribution;
138659SAli.Saidi@ARM.com// neither the name of the copyright holders nor the names of its
141762Sstever@eecs.umich.edu// contributors may be used to endorse or promote products derived from
15278Sbinkertn@umich.edu// this software without specific prior written permission.
16278Sbinkertn@umich.edu//
17278Sbinkertn@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18278Sbinkertn@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19278Sbinkertn@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20278Sbinkertn@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21278Sbinkertn@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22278Sbinkertn@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23278Sbinkertn@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24278Sbinkertn@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25278Sbinkertn@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26278Sbinkertn@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27278Sbinkertn@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28278Sbinkertn@umich.edu//
29278Sbinkertn@umich.edu// Authors: Steve Reinhardt
30278Sbinkertn@umich.edu
31278Sbinkertn@umich.edu////////////////////////////////////////////////////////////////////
32278Sbinkertn@umich.edu//
33278Sbinkertn@umich.edu// Alpha ISA description file.
34278Sbinkertn@umich.edu//
35278Sbinkertn@umich.edu////////////////////////////////////////////////////////////////////
36278Sbinkertn@umich.edu
37278Sbinkertn@umich.edu
38278Sbinkertn@umich.edu////////////////////////////////////////////////////////////////////
392665Ssaidi@eecs.umich.edu//
402665Ssaidi@eecs.umich.edu// Output include file directives.
41278Sbinkertn@umich.edu//
42278Sbinkertn@umich.edu
435755Snate@binkert.orgoutput header {{
445755Snate@binkert.org#include <sstream>
455755Snate@binkert.org#include <iostream>
4612023Sbrandon.potter@amd.com#include <iomanip>
475755Snate@binkert.org
485755Snate@binkert.org#include "arch/alpha/faults.hh"
495754Snate@binkert.org#include "arch/alpha/types.hh"
505754Snate@binkert.org#include "config/ss_compatible_fp.hh"
518229Snate@binkert.org#include "cpu/static_inst.hh"
52275Sbinkertn@umich.edu#include "mem/request.hh"  // some constructors use MemReq flags
53275Sbinkertn@umich.edu#include "mem/packet.hh"
54275Sbinkertn@umich.edu}};
559898Sandreas@sandberg.pp.se
569898Sandreas@sandberg.pp.seoutput decoder {{
579898Sandreas@sandberg.pp.se#include <cmath>
582358Sktlim@umich.edu
59275Sbinkertn@umich.edu#include "arch/alpha/registers.hh"
6012161Sandreas.sandberg@arm.com#include "arch/alpha/regredir.hh"
6112464Sjang.hanhwi@gmail.com#include "base/cprintf.hh"
629898Sandreas@sandberg.pp.se#include "base/fenv.hh"
63275Sbinkertn@umich.edu#include "base/loader/symtab.hh"
645754Snate@binkert.org#include "config/ss_compatible_fp.hh"
655754Snate@binkert.org#include "cpu/thread_context.hh"  // for Jump::branchTarget()
665754Snate@binkert.org#include "mem/packet.hh"
675754Snate@binkert.org
685754Snate@binkert.orgusing namespace AlphaISA;
695754Snate@binkert.org}};
705754Snate@binkert.org
715754Snate@binkert.orgoutput exec {{
725754Snate@binkert.org#include <math.h>
739191SAli.Saidi@ARM.com
749191SAli.Saidi@ARM.com#include "arch/alpha/regredir.hh"
759191SAli.Saidi@ARM.com#include "base/cp_annotate.hh"
769191SAli.Saidi@ARM.com#include "sim/pseudo_inst.hh"
779191SAli.Saidi@ARM.com#include "arch/alpha/registers.hh"
789191SAli.Saidi@ARM.com#include "base/fenv.hh"
795754Snate@binkert.org#include "config/ss_compatible_fp.hh"
805754Snate@binkert.org#include "cpu/base.hh"
819191SAli.Saidi@ARM.com#include "cpu/exetrace.hh"
829191SAli.Saidi@ARM.com#include "mem/packet.hh"
839191SAli.Saidi@ARM.com#include "mem/packet_access.hh"
845754Snate@binkert.org#include "sim/sim_exit.hh"
855754Snate@binkert.org
8611289Sgabor.dozsa@arm.comusing namespace AlphaISA;
8711289Sgabor.dozsa@arm.com}};
8811289Sgabor.dozsa@arm.com
8911372Sgabor.dozsa@arm.com////////////////////////////////////////////////////////////////////
9011289Sgabor.dozsa@arm.com//
9111289Sgabor.dozsa@arm.com// Namespace statement.  Everything below this line will be in the
9211289Sgabor.dozsa@arm.com// AlphaISAInst namespace.
9311289Sgabor.dozsa@arm.com//
9411289Sgabor.dozsa@arm.com
9511289Sgabor.dozsa@arm.com
9611289Sgabor.dozsa@arm.comnamespace AlphaISA;
9711289Sgabor.dozsa@arm.com
9811289Sgabor.dozsa@arm.com////////////////////////////////////////////////////////////////////
9911289Sgabor.dozsa@arm.com//
10011289Sgabor.dozsa@arm.com// Bitfield definitions.
10111289Sgabor.dozsa@arm.com//
10211289Sgabor.dozsa@arm.com
10311289Sgabor.dozsa@arm.com// Universal (format-independent) fields
10411289Sgabor.dozsa@arm.comdef bitfield PALMODE    <32:32>;
10511289Sgabor.dozsa@arm.comdef bitfield OPCODE	<31:26>;
10611289Sgabor.dozsa@arm.comdef bitfield RA		<25:21>;
1075754Snate@binkert.orgdef bitfield RB		<20:16>;
1085754Snate@binkert.org
1095754Snate@binkert.org// Memory format
11012003Sandreas.sandberg@arm.comdef signed bitfield MEMDISP <15: 0>; // displacement
1115754Snate@binkert.orgdef        bitfield MEMFUNC <15: 0>; // function code (same field, unsigned)
11212003Sandreas.sandberg@arm.com
1135754Snate@binkert.org// Memory-format jumps
1147517Shestness@cs.utexas.edudef bitfield JMPFUNC	<15:14>; // function code (disp<15:14>)
1157517Shestness@cs.utexas.edudef bitfield JMPHINT	<13: 0>; // tgt Icache idx hint (disp<13:0>)
1167517Shestness@cs.utexas.edu
1177517Shestness@cs.utexas.edu// Branch format
1187517Shestness@cs.utexas.edudef signed bitfield BRDISP <20: 0>; // displacement
11912160Sandreas.sandberg@arm.com
12012003Sandreas.sandberg@arm.com// Integer operate format(s>;
1215754Snate@binkert.orgdef bitfield INTIMM	<20:13>; // integer immediate (literal)
12212003Sandreas.sandberg@arm.comdef bitfield IMM	<12:12>; // immediate flag
12312003Sandreas.sandberg@arm.comdef bitfield INTFUNC	<11: 5>; // function code
12412003Sandreas.sandberg@arm.comdef bitfield RC		< 4: 0>; // dest reg
12512003Sandreas.sandberg@arm.com
12612003Sandreas.sandberg@arm.com// Floating-point operate format
12712003Sandreas.sandberg@arm.comdef bitfield FA		  <25:21>;
12812003Sandreas.sandberg@arm.comdef bitfield FB		  <20:16>;
12912003Sandreas.sandberg@arm.comdef bitfield FP_FULLFUNC  <15: 5>; // complete function code
13012003Sandreas.sandberg@arm.com    def bitfield FP_TRAPMODE  <15:13>; // trapping mode
13112003Sandreas.sandberg@arm.com    def bitfield FP_ROUNDMODE <12:11>; // rounding mode
13212003Sandreas.sandberg@arm.com    def bitfield FP_TYPEFUNC  <10: 5>; // type+func: handiest for decoding
13312003Sandreas.sandberg@arm.com        def bitfield FP_SRCTYPE   <10: 9>; // source reg type
13412003Sandreas.sandberg@arm.com        def bitfield FP_SHORTFUNC < 8: 5>; // short function code
13512003Sandreas.sandberg@arm.com        def bitfield FP_SHORTFUNC_TOP2 <8:7>; // top 2 bits of short func code
1365754Snate@binkert.orgdef bitfield FC		  < 4: 0>; // dest reg
13712003Sandreas.sandberg@arm.com
13812003Sandreas.sandberg@arm.com// PALcode format
1395754Snate@binkert.orgdef bitfield PALFUNC	<25: 0>; // function code
1405754Snate@binkert.org
14111998Sandreas.sandberg@arm.com// EV5 PAL instructions:
14212198Sgabeblack@google.com// HW_LD/HW_ST
1438734Sdam.sunwoo@arm.comdef bitfield HW_LDST_PHYS  <15>; // address is physical
1448734Sdam.sunwoo@arm.comdef bitfield HW_LDST_ALT   <14>; // use ALT_MODE IPR
1458734Sdam.sunwoo@arm.comdef bitfield HW_LDST_WRTCK <13>; // HW_LD only: fault if no write acc
1468734Sdam.sunwoo@arm.comdef bitfield HW_LDST_QUAD  <12>; // size: 0=32b, 1=64b
1478734Sdam.sunwoo@arm.comdef bitfield HW_LDST_VPTE  <11>; // HW_LD only: is PTE fetch
1488734Sdam.sunwoo@arm.comdef bitfield HW_LDST_LOCK  <10>; // HW_LD only: is load locked
1498734Sdam.sunwoo@arm.comdef bitfield HW_LDST_COND  <10>; // HW_ST only: is store conditional
1508734Sdam.sunwoo@arm.comdef signed bitfield HW_LDST_DISP  <9:0>; // signed displacement
1518734Sdam.sunwoo@arm.com
1528734Sdam.sunwoo@arm.com// HW_REI
1538734Sdam.sunwoo@arm.comdef bitfield HW_REI_TYP <15:14>; // type: stalling vs. non-stallingk
1548734Sdam.sunwoo@arm.comdef bitfield HW_REI_MBZ <13: 0>; // must be zero
1558734Sdam.sunwoo@arm.com
1568734Sdam.sunwoo@arm.com// HW_MTPR/MW_MFPR
1578734Sdam.sunwoo@arm.comdef bitfield HW_IPR_IDX <15:0>;	 // IPR index
1588734Sdam.sunwoo@arm.com
1598734Sdam.sunwoo@arm.com// M5 instructions
16012198Sgabeblack@google.comdef bitfield M5FUNC <7:0>;
1618734Sdam.sunwoo@arm.com
1628734Sdam.sunwoo@arm.comdef operand_types {{
1638734Sdam.sunwoo@arm.com    'sb' : ('signed int', 8),
1648734Sdam.sunwoo@arm.com    'ub' : ('unsigned int', 8),
1658734Sdam.sunwoo@arm.com    'sw' : ('signed int', 16),
1668734Sdam.sunwoo@arm.com    'uw' : ('unsigned int', 16),
1678734Sdam.sunwoo@arm.com    'sl' : ('signed int', 32),
1685754Snate@binkert.org    'ul' : ('unsigned int', 32),
1695754Snate@binkert.org    'sq' : ('signed int', 64),
1705754Snate@binkert.org    'uq' : ('unsigned int', 64),
1715754Snate@binkert.org    'sf' : ('float', 32),
1725754Snate@binkert.org    'df' : ('float', 64)
1735754Snate@binkert.org}};
1749191SAli.Saidi@ARM.com
1759451SAndreas.Sandberg@ARM.comdef operands {{
1769191SAli.Saidi@ARM.com    # Int regs default to unsigned, but code should not count on this.
1775754Snate@binkert.org    # For clarity, descriptions that depend on unsigned behavior should
1785754Snate@binkert.org    # explicitly specify '.uq'.
1795754Snate@binkert.org    'Ra': ('IntReg', 'uq', 'PALMODE ? reg_redir[RA] : RA',
1809457Svilanova@ac.upc.edu           'IsInteger', 1),
1819457Svilanova@ac.upc.edu    'Rb': ('IntReg', 'uq', 'PALMODE ? reg_redir[RB] : RB',
1829457Svilanova@ac.upc.edu           'IsInteger', 2),
1839457Svilanova@ac.upc.edu    'Rc': ('IntReg', 'uq', 'PALMODE ? reg_redir[RC] : RC',
1849457Svilanova@ac.upc.edu           'IsInteger', 3),
1859949SAli.Saidi@ARM.com    'Fa': ('FloatReg', 'df', 'FA', 'IsFloating', 1),
1869949SAli.Saidi@ARM.com    'Fb': ('FloatReg', 'df', 'FB', 'IsFloating', 2),
1879949SAli.Saidi@ARM.com    'Fc': ('FloatReg', 'df', 'FC', 'IsFloating', 3),
1889457Svilanova@ac.upc.edu    'Mem': ('Mem', 'uq', None, ('IsMemRef', 'IsLoad', 'IsStore'), 4),
1899457Svilanova@ac.upc.edu    'PCS': ('PCState', 'uq', None, ( None, None, 'IsControl' ), 4),
1909457Svilanova@ac.upc.edu    'Runiq': ('ControlReg', 'uq', 'MISCREG_UNIQ', None, 1),
1915754Snate@binkert.org    'FPCR':  ('ControlReg', 'uq', 'MISCREG_FPCR', None, 1),
1925754Snate@binkert.org    'IntrFlag': ('ControlReg', 'uq', 'MISCREG_INTR', None, 1),
1935754Snate@binkert.org    # The next two are hacks for non-full-system call-pal emulation
1945754Snate@binkert.org    'R0':  ('IntReg', 'uq', '0', None, 1),
1955754Snate@binkert.org    'R16': ('IntReg', 'uq', '16', None, 1),
1965754Snate@binkert.org    'R17': ('IntReg', 'uq', '17', None, 1),
1975754Snate@binkert.org    'R18': ('IntReg', 'uq', '18', None, 1)
1985754Snate@binkert.org}};
1995754Snate@binkert.org
2005754Snate@binkert.org////////////////////////////////////////////////////////////////////
2015754Snate@binkert.org//
2025754Snate@binkert.org// Basic instruction classes/templates/formats etc.
2035754Snate@binkert.org//
2045754Snate@binkert.org
2055754Snate@binkert.orgoutput header {{
2065754Snate@binkert.org// uncomment the following to get SimpleScalar-compatible disassembly
2075754Snate@binkert.org// (useful for diffing output traces).
2085754Snate@binkert.org// #define SS_COMPATIBLE_DISASSEMBLY
2095754Snate@binkert.org
2105754Snate@binkert.org    /**
21112160Sandreas.sandberg@arm.com     * Base class for all Alpha static instructions.
2125754Snate@binkert.org     */
2135754Snate@binkert.org    class AlphaStaticInst : public StaticInst
2145754Snate@binkert.org    {
2155754Snate@binkert.org      protected:
2165754Snate@binkert.org
2175754Snate@binkert.org        /// Make AlphaISA register dependence tags directly visible in
2185754Snate@binkert.org        /// this class and derived classes.  Maybe these should really
2195754Snate@binkert.org        /// live here and not in the AlphaISA namespace.
2205754Snate@binkert.org        enum DependenceTags {
2215754Snate@binkert.org            FP_Base_DepTag = AlphaISA::FP_Base_DepTag,
2225754Snate@binkert.org        };
2235754Snate@binkert.org
2248734Sdam.sunwoo@arm.com        /// Constructor.
2258734Sdam.sunwoo@arm.com        AlphaStaticInst(const char *mnem, ExtMachInst _machInst,
22612198Sgabeblack@google.com                        OpClass __opClass)
2278734Sdam.sunwoo@arm.com            : StaticInst(mnem, _machInst, __opClass)
2288734Sdam.sunwoo@arm.com        {
2298734Sdam.sunwoo@arm.com        }
23012198Sgabeblack@google.com
2318734Sdam.sunwoo@arm.com        /// Print a register name for disassembly given the unique
23212198Sgabeblack@google.com        /// dependence tag number (FP or int).
2338734Sdam.sunwoo@arm.com        void printReg(std::ostream &os, int reg) const;
2348734Sdam.sunwoo@arm.com
2358734Sdam.sunwoo@arm.com        std::string
2365754Snate@binkert.org        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
2375754Snate@binkert.org
2385754Snate@binkert.org        void
2395754Snate@binkert.org        advancePC(AlphaISA::PCState &pcState) const
2405754Snate@binkert.org        {
2415754Snate@binkert.org            pcState.advance();
2425754Snate@binkert.org        }
2435754Snate@binkert.org    };
2445754Snate@binkert.org}};
2455754Snate@binkert.org
2465754Snate@binkert.orgoutput decoder {{
2475754Snate@binkert.org    void
2485754Snate@binkert.org    AlphaStaticInst::printReg(std::ostream &os, int reg) const
2495754Snate@binkert.org    {
2505754Snate@binkert.org        if (reg < FP_Base_DepTag) {
2515754Snate@binkert.org            ccprintf(os, "r%d", reg);
2525754Snate@binkert.org        }
2535754Snate@binkert.org        else {
2545754Snate@binkert.org            ccprintf(os, "f%d", reg - FP_Base_DepTag);
2555754Snate@binkert.org        }
2565754Snate@binkert.org    }
2575754Snate@binkert.org
2585754Snate@binkert.org    std::string
2595754Snate@binkert.org    AlphaStaticInst::generateDisassembly(Addr pc,
2605754Snate@binkert.org                                         const SymbolTable *symtab) const
26112001Sandreas.sandberg@arm.com    {
2625754Snate@binkert.org        std::stringstream ss;
2635754Snate@binkert.org
2645754Snate@binkert.org        ccprintf(ss, "%-10s ", mnemonic);
2655754Snate@binkert.org
2665754Snate@binkert.org        // just print the first two source regs... if there's
2675754Snate@binkert.org        // a third one, it's a read-modify-write dest (Rc),
26812160Sandreas.sandberg@arm.com        // e.g. for CMOVxx
2695754Snate@binkert.org        if (_numSrcRegs > 0) {
2705754Snate@binkert.org            printReg(ss, _srcRegIdx[0]);
27112002Sandreas.sandberg@arm.com        }
27212002Sandreas.sandberg@arm.com        if (_numSrcRegs > 1) {
27312002Sandreas.sandberg@arm.com            ss << ",";
27412002Sandreas.sandberg@arm.com            printReg(ss, _srcRegIdx[1]);
27512002Sandreas.sandberg@arm.com        }
27612002Sandreas.sandberg@arm.com
27712002Sandreas.sandberg@arm.com        // just print the first dest... if there's a second one,
27812160Sandreas.sandberg@arm.com        // it's generally implicit
27912002Sandreas.sandberg@arm.com        if (_numDestRegs > 0) {
28012002Sandreas.sandberg@arm.com            if (_numSrcRegs > 0)
2815754Snate@binkert.org                ss << ",";
2825754Snate@binkert.org            printReg(ss, _destRegIdx[0]);
2835754Snate@binkert.org        }
28411289Sgabor.dozsa@arm.com
2855754Snate@binkert.org        return ss.str();
2865754Snate@binkert.org    }
28711289Sgabor.dozsa@arm.com}};
28811289Sgabor.dozsa@arm.com
28912160Sandreas.sandberg@arm.com// Declarations for execute() methods.
2908659SAli.Saidi@ARM.comdef template BasicExecDeclare {{
2915754Snate@binkert.org    Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
2925754Snate@binkert.org}};
2935754Snate@binkert.org
2945754Snate@binkert.org// Basic instruction class declaration template.
2955754Snate@binkert.orgdef template BasicDeclare {{
2965754Snate@binkert.org    /**
2975754Snate@binkert.org     * Static instruction class for "%(mnemonic)s".
2985754Snate@binkert.org     */
29912160Sandreas.sandberg@arm.com    class %(class_name)s : public %(base_class)s
3005754Snate@binkert.org    {
3015754Snate@binkert.org      public:
3029191SAli.Saidi@ARM.com        /// Constructor.
3039191SAli.Saidi@ARM.com        %(class_name)s(ExtMachInst machInst);
3045754Snate@binkert.org
3055754Snate@binkert.org        %(BasicExecDeclare)s
3065754Snate@binkert.org    };
3075754Snate@binkert.org}};
3085755Snate@binkert.org
3095755Snate@binkert.org// Basic instruction class constructor template.
3105755Snate@binkert.orgdef template BasicConstructor {{
3115755Snate@binkert.org    inline %(class_name)s::%(class_name)s(ExtMachInst machInst)
3125755Snate@binkert.org         : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
3135755Snate@binkert.org    {
3145755Snate@binkert.org        %(constructor)s;
31511320Ssteve.reinhardt@amd.com    }
3165755Snate@binkert.org}};
3175755Snate@binkert.org
3185755Snate@binkert.org// Basic instruction class execute method template.
3195755Snate@binkert.orgdef template BasicExecute {{
3205755Snate@binkert.org    Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
3215755Snate@binkert.org                                  Trace::InstRecord *traceData) const
3225755Snate@binkert.org    {
32311320Ssteve.reinhardt@amd.com        Fault fault = NoFault;
3245755Snate@binkert.org
3255755Snate@binkert.org        %(fp_enable_check)s;
3265755Snate@binkert.org        %(op_decl)s;
3275755Snate@binkert.org        %(op_rd)s;
3285755Snate@binkert.org        %(code)s;
3295755Snate@binkert.org
3305755Snate@binkert.org        if (fault == NoFault) {
3315755Snate@binkert.org            %(op_wb)s;
3325755Snate@binkert.org        }
3335754Snate@binkert.org
3345754Snate@binkert.org        return fault;
3355754Snate@binkert.org    }
3365754Snate@binkert.org}};
3375754Snate@binkert.org
3385754Snate@binkert.org// Basic decode template.
3395754Snate@binkert.orgdef template BasicDecode {{
3405754Snate@binkert.org    return new %(class_name)s(machInst);
3415754Snate@binkert.org}};
3429457Svilanova@ac.upc.edu
3435754Snate@binkert.org// Basic decode template, passing mnemonic in as string arg to constructor.
3445754Snate@binkert.orgdef template BasicDecodeWithMnemonic {{
3455754Snate@binkert.org    return new %(class_name)s("%(mnemonic)s", machInst);
3468734Sdam.sunwoo@arm.com}};
34712198Sgabeblack@google.com
3488734Sdam.sunwoo@arm.com// The most basic instruction format... used only for a few misc. insts
3495754Snate@binkert.orgdef format BasicOperate(code, *flags) {{
35012001Sandreas.sandberg@arm.com    iop = InstObjParams(name, Name, 'AlphaStaticInst', code, flags)
35112002Sandreas.sandberg@arm.com    header_output = BasicDeclare.subst(iop)
35212023Sbrandon.potter@amd.com    decoder_output = BasicConstructor.subst(iop)
35312023Sbrandon.potter@amd.com    decode_block = BasicDecode.subst(iop)
3545754Snate@binkert.org    exec_output = BasicExecute.subst(iop)
3555755Snate@binkert.org}};
3565755Snate@binkert.org
3575755Snate@binkert.org
3585754Snate@binkert.org
3595754Snate@binkert.org////////////////////////////////////////////////////////////////////
360275Sbinkertn@umich.edu//
361275Sbinkertn@umich.edu// Nop
362275Sbinkertn@umich.edu//
363275Sbinkertn@umich.edu
3645754Snate@binkert.orgoutput header {{
3655754Snate@binkert.org    /**
3665754Snate@binkert.org     * Static instruction class for no-ops.  This is a leaf class.
3675754Snate@binkert.org     */
3685754Snate@binkert.org    class Nop : public AlphaStaticInst
3695754Snate@binkert.org    {
3705754Snate@binkert.org        /// Disassembly of original instruction.
3715754Snate@binkert.org        const std::string originalDisassembly;
3725754Snate@binkert.org
3735754Snate@binkert.org      public:
374275Sbinkertn@umich.edu        /// Constructor
375275Sbinkertn@umich.edu        Nop(const std::string _originalDisassembly, ExtMachInst _machInst)
376275Sbinkertn@umich.edu            : AlphaStaticInst("nop", _machInst, No_OpClass),
377275Sbinkertn@umich.edu              originalDisassembly(_originalDisassembly)
378275Sbinkertn@umich.edu        {
379275Sbinkertn@umich.edu            flags[IsNop] = true;
380275Sbinkertn@umich.edu        }
381275Sbinkertn@umich.edu
3825754Snate@binkert.org        ~Nop() { }
383275Sbinkertn@umich.edu
3849898Sandreas@sandberg.pp.se        std::string
3859898Sandreas@sandberg.pp.se        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
386287Sbinkertn@umich.edu
387287Sbinkertn@umich.edu        %(BasicExecDeclare)s
3885754Snate@binkert.org    };
3895754Snate@binkert.org
390287Sbinkertn@umich.edu    /// Helper function for decoding nops.  Substitute Nop object
3915754Snate@binkert.org    /// for original inst passed in as arg (and delete latter).
3925754Snate@binkert.org    static inline
3935754Snate@binkert.org    AlphaStaticInst *
3945754Snate@binkert.org    makeNop(AlphaStaticInst *inst)
3955754Snate@binkert.org    {
3965754Snate@binkert.org        AlphaStaticInst *nop = new Nop(inst->disassemble(0), inst->machInst);
3975754Snate@binkert.org        delete inst;
398287Sbinkertn@umich.edu        return nop;
399287Sbinkertn@umich.edu    }
4005754Snate@binkert.org}};
401275Sbinkertn@umich.edu
402output decoder {{
403    std::string Nop::generateDisassembly(Addr pc,
404                                         const SymbolTable *symtab) const
405    {
406#ifdef SS_COMPATIBLE_DISASSEMBLY
407        return originalDisassembly;
408#else
409        return csprintf("%-10s (%s)", "nop", originalDisassembly);
410#endif
411    }
412}};
413
414output exec {{
415    Fault
416    Nop::execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
417    {
418        return NoFault;
419    }
420}};
421
422// integer & FP operate instructions use Rc as dest, so check for
423// Rc == 31 to detect nops
424def template OperateNopCheckDecode {{
425 {
426     AlphaStaticInst *i = new %(class_name)s(machInst);
427     if (RC == 31) {
428         i = makeNop(i);
429     }
430     return i;
431 }
432}};
433
434// Like BasicOperate format, but generates NOP if RC/FC == 31
435def format BasicOperateWithNopCheck(code, *opt_args) {{
436    iop = InstObjParams(name, Name, 'AlphaStaticInst', code, opt_args)
437    header_output = BasicDeclare.subst(iop)
438    decoder_output = BasicConstructor.subst(iop)
439    decode_block = OperateNopCheckDecode.subst(iop)
440    exec_output = BasicExecute.subst(iop)
441}};
442
443// Integer instruction templates, formats, etc.
444##include "int.isa"
445
446// Floating-point instruction templates, formats, etc.
447##include "fp.isa"
448
449// Memory instruction templates, formats, etc.
450##include "mem.isa"
451
452// Branch/jump instruction templates, formats, etc.
453##include "branch.isa"
454
455// PAL instruction templates, formats, etc.
456##include "pal.isa"
457
458// Opcdec fault instruction templates, formats, etc.
459##include "opcdec.isa"
460
461// Unimplemented instruction templates, formats, etc.
462##include "unimp.isa"
463
464// Unknown instruction templates, formats, etc.
465##include "unknown.isa"
466
467// Execution utility functions
468##include "util.isa"
469
470// The actual decoder
471##include "decoder.isa"
472