3 ////////////////////////////////////////////////////////////////////
5 // Integer operate instructions
11 * Base class for integer operations.
13 class IntOp : public MipsStaticInst
18 IntOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
19 MipsStaticInst(mnem, _machInst, __opClass)
23 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
27 class HiLoOp: public IntOp
32 HiLoOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
33 IntOp(mnem, _machInst, __opClass)
37 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
40 class HiLoMiscOp: public HiLoOp
45 HiLoMiscOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
46 HiLoOp(mnem, _machInst, __opClass)
50 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
54 class IntImmOp : public MipsStaticInst
63 IntImmOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
64 MipsStaticInst(mnem, _machInst, __opClass),imm(INTIMM),
65 sextImm(INTIMM),zextImm(0x0000FFFF & INTIMM)
67 //If Bit 15 is 1 then Sign Extend
68 int32_t temp = sextImm & 0x00008000;
69 if (temp > 0 && mnemonic != "lui") {
70 sextImm |= 0xFFFF0000;
74 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
81 // HiLo<Misc> instruction class execute method template.
82 // Mainly to get instruction trace data to print out
84 def template HiLoExecute {{
85 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
87 Fault fault = NoFault;
97 //If there are 2 Destination Registers then
98 //concatenate the values for the traceData
99 if(traceData && _numDestRegs == 2) {
100 uint64_t hilo_final_val = (uint64_t)HI << 32 | LO;
101 traceData->setData(hilo_final_val);
108 //Outputs to decoder.cc
110 std::string IntOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
112 std::stringstream ss;
114 ccprintf(ss, "%-10s ", mnemonic);
116 // just print the first dest... if there's a second one,
117 // it's generally implicit
118 if (_numDestRegs > 0) {
119 printReg(ss, _destRegIdx[0]);
123 // just print the first two source regs... if there's
124 // a third one, it's a read-modify-write dest (Rc),
126 if (_numSrcRegs > 0) {
127 printReg(ss, _srcRegIdx[0]);
130 if (_numSrcRegs > 1) {
132 printReg(ss, _srcRegIdx[1]);
138 std::string HiLoOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
140 std::stringstream ss;
142 ccprintf(ss, "%-10s ", mnemonic);
144 //Destination Registers are implicit for HI/LO ops
145 if (_numSrcRegs > 0) {
146 printReg(ss, _srcRegIdx[0]);
149 if (_numSrcRegs > 1) {
151 printReg(ss, _srcRegIdx[1]);
157 std::string HiLoMiscOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
159 std::stringstream ss;
161 ccprintf(ss, "%-10s ", mnemonic);
163 if (_numDestRegs > 0 && _destRegIdx[0] < 32) {
164 printReg(ss, _destRegIdx[0]);
165 } else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) {
166 printReg(ss, _srcRegIdx[0]);
172 std::string IntImmOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
174 std::stringstream ss;
176 ccprintf(ss, "%-10s ", mnemonic);
178 if (_numDestRegs > 0) {
179 printReg(ss, _destRegIdx[0]);
184 if (_numSrcRegs > 0) {
185 printReg(ss, _srcRegIdx[0]);
189 if( mnemonic == "lui")
190 ccprintf(ss, "0x%x ", sextImm);
199 def format IntOp(code, *opt_flags) {{
200 iop = InstObjParams(name, Name, 'IntOp', CodeBlock(code), opt_flags)
201 header_output = BasicDeclare.subst(iop)
202 decoder_output = BasicConstructor.subst(iop)
203 decode_block = OperateNopCheckDecode.subst(iop)
204 exec_output = BasicExecute.subst(iop)
207 def format IntImmOp(code, *opt_flags) {{
208 iop = InstObjParams(name, Name, 'IntImmOp', CodeBlock(code), opt_flags)
209 header_output = BasicDeclare.subst(iop)
210 decoder_output = BasicConstructor.subst(iop)
211 decode_block = OperateNopCheckDecode.subst(iop)
212 exec_output = BasicExecute.subst(iop)
215 def format HiLoOp(code, *opt_flags) {{
217 code = 'int64_t ' + code
219 code = 'uint64_t ' + code
221 code += 'HI = val<63:32>;\n'
222 code += 'LO = val<31:0>;\n'
224 iop = InstObjParams(name, Name, 'HiLoOp', CodeBlock(code), opt_flags)
225 header_output = BasicDeclare.subst(iop)
226 decoder_output = BasicConstructor.subst(iop)
227 decode_block = OperateNopCheckDecode.subst(iop)
228 exec_output = HiLoExecute.subst(iop)
231 def format HiLoMiscOp(code, *opt_flags) {{
232 iop = InstObjParams(name, Name, 'HiLoMiscOp', CodeBlock(code), opt_flags)
233 header_output = BasicDeclare.subst(iop)
234 decoder_output = BasicConstructor.subst(iop)
235 decode_block = OperateNopCheckDecode.subst(iop)
236 exec_output = HiLoExecute.subst(iop)