3 // Copyright
\e.A
\eN) 2007 MIPS Technologies, Inc. All Rights Reserved
5 // This software is part of the M5 simulator.
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.
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
\e.A
\eN) <Publication Year> Copyright Owner), and (3)
18 // the name of MIPS Technologies, Inc. (
\e$B!H
\e(BMIPS
\e$B!I
\e(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.
22 // THIS SOFTWARE IS PROVIDED
\e$B!H
\e(BAS IS.
\e$B!I
\e(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.
35 //Authors: Korey L. Sewell
37 ////////////////////////////////////////////////////////////////////
39 // Integer operate instructions
45 * Base class for integer operations.
47 class IntOp : public MipsStaticInst
52 IntOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
53 MipsStaticInst(mnem, _machInst, __opClass)
57 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
61 class HiLoOp: public IntOp
66 HiLoOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
67 IntOp(mnem, _machInst, __opClass)
71 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
74 class HiLoRsSelOp: public HiLoOp
79 HiLoRsSelOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
80 HiLoOp(mnem, _machInst, __opClass)
84 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
87 class HiLoRdSelOp: public HiLoOp
92 HiLoRdSelOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
93 HiLoOp(mnem, _machInst, __opClass)
97 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
100 class HiLoRdSelValOp: public HiLoOp
105 HiLoRdSelValOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
106 HiLoOp(mnem, _machInst, __opClass)
110 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
113 class IntImmOp : public MipsStaticInst
122 IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
123 MipsStaticInst(mnem, _machInst, __opClass),imm(INTIMM),
124 sextImm(INTIMM),zextImm(0x0000FFFF & INTIMM)
126 //If Bit 15 is 1 then Sign Extend
127 int32_t temp = sextImm & 0x00008000;
128 if (temp > 0 && mnemonic != "lui") {
129 sextImm |= 0xFFFF0000;
133 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
140 // HiLo instruction class execute method template.
141 def template HiLoExecute {{
142 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
144 Fault fault = NoFault;
159 // HiLoRsSel instruction class execute method template.
160 def template HiLoRsSelExecute {{
161 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
163 Fault fault = NoFault;
167 if( ACSRC > 0 && !isDspEnabled(xc) )
169 fault = new DspStateDisabledFault();
185 // HiLoRdSel instruction class execute method template.
186 def template HiLoRdSelExecute {{
187 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
189 Fault fault = NoFault;
193 if( ACDST > 0 && !isDspEnabled(xc) )
195 fault = new DspStateDisabledFault();
211 //Outputs to decoder.cc
213 std::string IntOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
215 std::stringstream ss;
217 ccprintf(ss, "%-10s ", mnemonic);
219 // just print the first dest... if there's a second one,
220 // it's generally implicit
221 if (_numDestRegs > 0) {
222 printReg(ss, _destRegIdx[0]);
226 // just print the first two source regs... if there's
227 // a third one, it's a read-modify-write dest (Rc),
229 if (_numSrcRegs > 0) {
230 printReg(ss, _srcRegIdx[0]);
233 if (_numSrcRegs > 1) {
235 printReg(ss, _srcRegIdx[1]);
241 std::string HiLoOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
243 std::stringstream ss;
245 ccprintf(ss, "%-10s ", mnemonic);
247 //Destination Registers are implicit for HI/LO ops
248 if (_numSrcRegs > 0) {
249 printReg(ss, _srcRegIdx[0]);
252 if (_numSrcRegs > 1) {
254 printReg(ss, _srcRegIdx[1]);
260 std::string HiLoRsSelOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
262 std::stringstream ss;
264 ccprintf(ss, "%-10s ", mnemonic);
266 if (_numDestRegs > 0 && _destRegIdx[0] < 32) {
267 printReg(ss, _destRegIdx[0]);
268 } else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) {
269 printReg(ss, _srcRegIdx[0]);
275 std::string HiLoRdSelOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
277 std::stringstream ss;
279 ccprintf(ss, "%-10s ", mnemonic);
281 if (_numDestRegs > 0 && _destRegIdx[0] < 32) {
282 printReg(ss, _destRegIdx[0]);
283 } else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) {
284 printReg(ss, _srcRegIdx[0]);
290 std::string HiLoRdSelValOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
292 std::stringstream ss;
294 ccprintf(ss, "%-10s ", mnemonic);
296 if (_numDestRegs > 0 && _destRegIdx[0] < 32) {
297 printReg(ss, _destRegIdx[0]);
298 } else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) {
299 printReg(ss, _srcRegIdx[0]);
305 std::string IntImmOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
307 std::stringstream ss;
309 ccprintf(ss, "%-10s ", mnemonic);
311 if (_numDestRegs > 0) {
312 printReg(ss, _destRegIdx[0]);
317 if (_numSrcRegs > 0) {
318 printReg(ss, _srcRegIdx[0]);
322 if( mnemonic == "lui")
323 ccprintf(ss, "0x%x ", sextImm);
332 def format IntOp(code, *opt_flags) {{
333 iop = InstObjParams(name, Name, 'IntOp', code, opt_flags)
334 header_output = BasicDeclare.subst(iop)
335 decoder_output = BasicConstructor.subst(iop)
336 decode_block = RegNopCheckDecode.subst(iop)
337 exec_output = BasicExecute.subst(iop)
340 def format IntImmOp(code, *opt_flags) {{
341 iop = InstObjParams(name, Name, 'IntImmOp', code, opt_flags)
342 header_output = BasicDeclare.subst(iop)
343 decoder_output = BasicConstructor.subst(iop)
344 decode_block = ImmNopCheckDecode.subst(iop)
345 exec_output = BasicExecute.subst(iop)
348 def format HiLoRsSelOp(code, *opt_flags) {{
349 iop = InstObjParams(name, Name, 'HiLoRsSelOp', code, opt_flags)
350 header_output = BasicDeclare.subst(iop)
351 decoder_output = BasicConstructor.subst(iop)
352 decode_block = BasicDecode.subst(iop)
353 exec_output = HiLoRsSelExecute.subst(iop)
356 def format HiLoRdSelOp(code, *opt_flags) {{
357 iop = InstObjParams(name, Name, 'HiLoRdSelOp', code, opt_flags)
358 header_output = BasicDeclare.subst(iop)
359 decoder_output = BasicConstructor.subst(iop)
360 decode_block = BasicDecode.subst(iop)
361 exec_output = HiLoRdSelExecute.subst(iop)
364 def format HiLoRdSelValOp(code, *opt_flags) {{
367 code = 'int64_t ' + code
369 code = 'uint64_t ' + code
371 code += 'HI_RD_SEL = val<63:32>;\n'
372 code += 'LO_RD_SEL = val<31:0>;\n'
374 iop = InstObjParams(name, Name, 'HiLoRdSelOp', code, opt_flags)
375 header_output = BasicDeclare.subst(iop)
376 decoder_output = BasicConstructor.subst(iop)
377 decode_block = BasicDecode.subst(iop)
378 exec_output = HiLoRdSelExecute.subst(iop)
381 def format HiLoOp(code, *opt_flags) {{
382 iop = InstObjParams(name, Name, 'HiLoOp', code, opt_flags)
383 header_output = BasicDeclare.subst(iop)
384 decoder_output = BasicConstructor.subst(iop)
385 decode_block = BasicDecode.subst(iop)
386 exec_output = HiLoExecute.subst(iop)