noop.isa revision 5222:bb733a878f85
1// -*- mode:c++ -*-
2
3// Copyright .AN) 2007 MIPS Technologies, Inc.  All Rights Reserved
4
5//  This software is part of the M5 simulator.
6
7//  THIS IS A LEGAL AGREEMENT.  BY DOWNLOADING, USING, COPYING, CREATING
8//  DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING
9//  TO THESE TERMS AND CONDITIONS.
10
11//  Permission is granted to use, copy, create derivative works and
12//  distribute this software and such derivative works for any purpose,
13//  so long as (1) the copyright notice above, this grant of permission,
14//  and the disclaimer below appear in all copies and derivative works
15//  made, (2) the copyright notice above is augmented as appropriate to
16//  reflect the addition of any new copyrightable work in a derivative
17//  work (e.g., Copyright .AN) <Publication Year> Copyright Owner), and (3)
18//  the name of MIPS Technologies, Inc. ($B!H(BMIPS$B!I(B) is not used in any
19//  advertising or publicity pertaining to the use or distribution of
20//  this software without specific, written prior authorization.
21
22//  THIS SOFTWARE IS PROVIDED $B!H(BAS IS.$B!I(B  MIPS MAKES NO WARRANTIES AND
23//  DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR
24//  OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25//  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
26//  NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE.
27//  IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT,
28//  INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF
29//  ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT,
30//  THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY
31//  IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR
32//  STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE
33//  POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE.
34
35//Authors: Korey L. Sewell
36
37////////////////////////////////////////////////////////////////////
38//
39// Nop
40//
41
42output header {{
43    /**
44     * Static instruction class for no-ops.  This is a leaf class.
45     */
46    class Nop : public MipsStaticInst
47    {
48        /// Disassembly of original instruction.
49        const std::string originalDisassembly;
50
51      public:
52        /// Constructor
53        Nop(const std::string _originalDisassembly, MachInst _machInst)
54            : MipsStaticInst("nop", _machInst, No_OpClass),
55              originalDisassembly(_originalDisassembly)
56        {
57            flags[IsNop] = true;
58        }
59
60        ~Nop() { }
61
62        std::string
63        generateDisassembly(Addr pc, const SymbolTable *symtab) const;
64
65        %(BasicExecDeclare)s
66    };
67}};
68
69output decoder {{
70    std::string Nop::generateDisassembly(Addr pc,
71                                         const SymbolTable *symtab) const
72    {
73        return csprintf("%-10s %s", "nop", originalDisassembly);
74    }
75
76    /// Helper function for decoding nops.  Substitute Nop object
77    /// for original inst passed in as arg (and delete latter).
78    inline
79    MipsStaticInst *
80    makeNop(MipsStaticInst *inst)
81    {
82        std::string nop_str = "(" + inst->disassemble(0) + ")";
83        MipsStaticInst *nop = new Nop(nop_str, inst->machInst);
84        delete inst;
85        return nop;
86    }
87}};
88
89output exec {{
90    Fault
91    Nop::execute(%(CPU_exec_context)s *, Trace::InstRecord *) const
92    {
93        return NoFault;
94    }
95}};
96
97// Int & FP operate instructions use RD as dest, so check for
98// RD == 0 to detect nops
99def template RegNopCheckDecode {{
100 {
101     MipsStaticInst *i = new %(class_name)s(machInst);
102     //if (RD == 0) {
103         //i = makeNop(i);
104         //}
105     return i;
106 }
107}};
108
109def template OperateNopCheckDecode {{
110 {
111     MipsStaticInst *i = new %(class_name)s(machInst);
112     //if (RD == 0) {
113     // i = makeNop(i);
114     //}
115     return i;
116 }
117}};
118
119// IntImm & Memory  instructions use Rt as dest, so check for
120// Rt == 0 to detect nops
121def template ImmNopCheckDecode {{
122 {
123     MipsStaticInst *i = new %(class_name)s(machInst);
124     //if (RT == 0) {
125     // i = makeNop(i);
126     // }
127     return i;
128 }
129}};
130
131
132// Like BasicOperate format, but generates NOP if RC/FC == 31
133def format BasicOperateWithNopCheck(code, *opt_args) {{
134    iop = InstObjParams(name, Name, 'MipsStaticInst', code,
135                        opt_args)
136    header_output = BasicDeclare.subst(iop)
137    decoder_output = BasicConstructor.subst(iop)
138    decode_block = OperateNopCheckDecode.subst(iop)
139    exec_output = BasicExecute.subst(iop)
140}};
141
142def format Nop() {{
143        decode_block = 'return new Nop(\"\",machInst);\n'
144}};
145
146