1// -*- mode:c++ -*- 2 3// Copyright (c) 2006 The Regents of The University of Michigan 4// All rights reserved. 5// 6// Redistribution and use in source and binary forms, with or without 7// modification, are permitted provided that the following conditions are 8// met: redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29// Authors: Korey Sewell 30 31//////////////////////////////////////////////////////////////////// 32// 33// Integer operate instructions 34// 35output header {{ 36#include <iostream> |
37 using namespace std; |
38 /** 39 * Base class for integer operations. 40 */ 41 class IntOp : public MipsStaticInst 42 { 43 protected: 44 45 /// Constructor --- 14 unchanged lines hidden (view full) --- 60 HiLoOp(const char *mnem, MachInst _machInst, OpClass __opClass) : 61 IntOp(mnem, _machInst, __opClass) 62 { 63 } 64 65 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 66 }; 67 |
68 class HiLoRsSelOp: public HiLoOp |
69 { 70 protected: 71 72 /// Constructor |
73 HiLoRsSelOp(const char *mnem, MachInst _machInst, OpClass __opClass) : |
74 HiLoOp(mnem, _machInst, __opClass) 75 { 76 } 77 78 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 79 }; 80 |
81 class HiLoRdSelOp: public HiLoOp 82 { 83 protected: |
84 |
85 /// Constructor 86 HiLoRdSelOp(const char *mnem, MachInst _machInst, OpClass __opClass) : 87 HiLoOp(mnem, _machInst, __opClass) 88 { 89 } 90 91 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 92 }; 93 94 class HiLoRdSelValOp: public HiLoOp 95 { 96 protected: 97 98 /// Constructor 99 HiLoRdSelValOp(const char *mnem, MachInst _machInst, OpClass __opClass) : 100 HiLoOp(mnem, _machInst, __opClass) 101 { 102 } 103 104 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 105 }; 106 |
107 class IntImmOp : public MipsStaticInst 108 { 109 protected: 110 111 int16_t imm; 112 int32_t sextImm; 113 uint32_t zextImm; 114 --- 11 unchanged lines hidden (view full) --- 126 127 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 128 129 130 }; 131 132}}; 133 |
134// HiLo instruction class execute method template. |
135def template HiLoExecute {{ 136 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 137 { 138 Fault fault = NoFault; 139 140 %(fp_enable_check)s; 141 %(op_decl)s; 142 %(op_rd)s; 143 %(code)s; 144 145 if(fault == NoFault) 146 { 147 %(op_wb)s; |
148 } 149 return fault; 150 } 151}}; 152 |
153// HiLoRsSel instruction class execute method template. 154def template HiLoRsSelExecute {{ 155 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 156 { 157 Fault fault = NoFault; 158 159 %(op_decl)s; 160 161 if( ACSRC > 0 && !isDspEnabled(xc) ) 162 { 163 fault = new DspStateDisabledFault(); 164 } 165 else 166 { 167 %(op_rd)s; 168 %(code)s; 169 } 170 171 if(fault == NoFault) 172 { 173 %(op_wb)s; 174 } 175 return fault; 176 } 177}}; 178 179// HiLoRdSel instruction class execute method template. 180def template HiLoRdSelExecute {{ 181 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const 182 { 183 Fault fault = NoFault; 184 185 %(op_decl)s; 186 187 if( ACDST > 0 && !isDspEnabled(xc) ) 188 { 189 fault = new DspStateDisabledFault(); 190 } 191 else 192 { 193 %(op_rd)s; 194 %(code)s; 195 } 196 197 if(fault == NoFault) 198 { 199 %(op_wb)s; 200 } 201 return fault; 202 } 203}}; 204 |
205//Outputs to decoder.cc 206output decoder {{ 207 std::string IntOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const 208 { 209 std::stringstream ss; 210 211 ccprintf(ss, "%-10s ", mnemonic); 212 --- 33 unchanged lines hidden (view full) --- 246 if (_numSrcRegs > 1) { 247 ss << ", "; 248 printReg(ss, _srcRegIdx[1]); 249 } 250 251 return ss.str(); 252 } 253 |
254 std::string HiLoRsSelOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const |
255 { 256 std::stringstream ss; 257 258 ccprintf(ss, "%-10s ", mnemonic); 259 260 if (_numDestRegs > 0 && _destRegIdx[0] < 32) { 261 printReg(ss, _destRegIdx[0]); 262 } else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) { 263 printReg(ss, _srcRegIdx[0]); 264 } 265 266 return ss.str(); 267 } 268 |
269 std::string HiLoRdSelOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const 270 { 271 std::stringstream ss; 272 273 ccprintf(ss, "%-10s ", mnemonic); 274 275 if (_numDestRegs > 0 && _destRegIdx[0] < 32) { 276 printReg(ss, _destRegIdx[0]); 277 } else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) { 278 printReg(ss, _srcRegIdx[0]); 279 } 280 281 return ss.str(); 282 } 283 284 std::string HiLoRdSelValOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const 285 { 286 std::stringstream ss; 287 288 ccprintf(ss, "%-10s ", mnemonic); 289 290 if (_numDestRegs > 0 && _destRegIdx[0] < 32) { 291 printReg(ss, _destRegIdx[0]); 292 } else if (_numSrcRegs > 0 && _srcRegIdx[0] < 32) { 293 printReg(ss, _srcRegIdx[0]); 294 } 295 296 return ss.str(); 297 } 298 |
299 std::string IntImmOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const 300 { 301 std::stringstream ss; 302 303 ccprintf(ss, "%-10s ", mnemonic); 304 305 if (_numDestRegs > 0) { 306 printReg(ss, _destRegIdx[0]); --- 27 unchanged lines hidden (view full) --- 334def format IntImmOp(code, *opt_flags) {{ 335 iop = InstObjParams(name, Name, 'IntImmOp', code, opt_flags) 336 header_output = BasicDeclare.subst(iop) 337 decoder_output = BasicConstructor.subst(iop) 338 decode_block = ImmNopCheckDecode.subst(iop) 339 exec_output = BasicExecute.subst(iop) 340}}; 341 |
342def format HiLoRsSelOp(code, *opt_flags) {{ 343 iop = InstObjParams(name, Name, 'HiLoRsSelOp', code, opt_flags) |
344 header_output = BasicDeclare.subst(iop) 345 decoder_output = BasicConstructor.subst(iop) 346 decode_block = BasicDecode.subst(iop) |
347 exec_output = HiLoRsSelExecute.subst(iop) |
348}}; 349 |
350def format HiLoRdSelOp(code, *opt_flags) {{ 351 iop = InstObjParams(name, Name, 'HiLoRdSelOp', code, opt_flags) |
352 header_output = BasicDeclare.subst(iop) 353 decoder_output = BasicConstructor.subst(iop) 354 decode_block = BasicDecode.subst(iop) |
355 exec_output = HiLoRdSelExecute.subst(iop) |
356}}; 357 |
358def format HiLoRdSelValOp(code, *opt_flags) {{ |
359 |
360 if '.sd' in code: 361 code = 'int64_t ' + code 362 elif '.ud' in code: 363 code = 'uint64_t ' + code |
364 |
365 code += 'HI_RD_SEL = val<63:32>;\n' 366 code += 'LO_RD_SEL = val<31:0>;\n' |
367 |
368 iop = InstObjParams(name, Name, 'HiLoRdSelOp', code, opt_flags) 369 header_output = BasicDeclare.subst(iop) 370 decoder_output = BasicConstructor.subst(iop) 371 decode_block = BasicDecode.subst(iop) 372 exec_output = HiLoRdSelExecute.subst(iop) 373}}; |
374 |
375def format HiLoOp(code, *opt_flags) {{ 376 iop = InstObjParams(name, Name, 'HiLoOp', code, opt_flags) 377 header_output = BasicDeclare.subst(iop) 378 decoder_output = BasicConstructor.subst(iop) 379 decode_block = BasicDecode.subst(iop) 380 exec_output = HiLoExecute.subst(iop) 381}}; |