noop.isa revision 2084
1////////////////////////////////////////////////////////////////////
2//
3// Noop instruction
4//
5
6output header {{
7        /**
8         * Base class for integer operations.
9         */
10        class Noop : public MipsStaticInst
11        {
12                protected:
13
14                /// Constructor
15                Noop(const char *mnem, MachInst _machInst, OpClass __opClass) : MipsStaticInst(mnem, _machInst, __opClass)
16                {
17                }
18
19                std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
20        };
21}};
22
23output decoder {{
24        std::string Noop::generateDisassembly(Addr pc, const SymbolTable *symtab) const
25        {
26                return "Disassembly of integer instruction\n";
27        }
28}};
29
30def template NoopExecute {{
31        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
32        {
33                //Nothing to see here, move along
34                return No_Fault;
35        }
36}};
37
38// Primary format for integer operate instructions:
39def format Noop(code, *opt_flags) {{
40        orig_code = code
41        cblk = CodeBlock(code)
42        iop = InstObjParams(name, Name, 'MipsStaticInst', cblk, opt_flags)
43        header_output = BasicDeclare.subst(iop)
44        decoder_output = BasicConstructor.subst(iop)
45        decode_block = BasicDecodeWithMnemonic.subst(iop)
46        exec_output = NoopExecute.subst(iop)
47}};
48
49////////////////////////////////////////////////////////////////////
50//
51// Nop
52//
53
54output header {{
55    /**
56     * Static instruction class for no-ops.  This is a leaf class.
57     */
58    class Nop : public AlphaStaticInst
59    {
60        /// Disassembly of original instruction.
61        const std::string originalDisassembly;
62
63      public:
64        /// Constructor
65        Nop(const std::string _originalDisassembly, MachInst _machInst)
66            : AlphaStaticInst("nop", _machInst, No_OpClass),
67              originalDisassembly(_originalDisassembly)
68        {
69            flags[IsNop] = true;
70        }
71
72        ~Nop() { }
73
74        std::string
75        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
76
77        %(BasicExecDeclare)s
78    };
79}};
80
81output decoder {{
82    std::string Nop::generateDisassembly(Addr pc,
83                                         const SymbolTable *symtab) const
84    {
85#ifdef SS_COMPATIBLE_DISASSEMBLY
86        return originalDisassembly;
87#else
88        return csprintf("%-10s (%s)", "nop", originalDisassembly);
89#endif
90    }
91
92    /// Helper function for decoding nops.  Substitute Nop object
93    /// for original inst passed in as arg (and delete latter).
94    inline
95    AlphaStaticInst *
96    makeNop(AlphaStaticInst *inst)
97    {
98        AlphaStaticInst *nop = new Nop(inst->disassemble(0), inst->machInst);
99        delete inst;
100        return nop;
101    }
102}};
103
104output exec {{
105    Fault
106    Nop::execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
107    {
108        return No_Fault;
109    }
110}};
111
112// integer & FP operate instructions use Rc as dest, so check for
113// Rc == 31 to detect nops
114def template OperateNopCheckDecode {{
115 {
116     AlphaStaticInst *i = new %(class_name)s(machInst);
117     if (RC == 31) {
118         i = makeNop(i);
119     }
120     return i;
121 }
122}};
123
124
125// Like BasicOperate format, but generates NOP if RC/FC == 31
126def format BasicOperateWithNopCheck(code, *opt_args) {{
127    iop = InstObjParams(name, Name, 'AlphaStaticInst', CodeBlock(code),
128                        opt_args)
129    header_output = BasicDeclare.subst(iop)
130    decoder_output = BasicConstructor.subst(iop)
131    decode_block = OperateNopCheckDecode.subst(iop)
132    exec_output = BasicExecute.subst(iop)
133}};
134
135