base.isa revision 2479
1// -*- mode:c++ -*- 2 3//////////////////////////////////////////////////////////////////// 4// 5// Base class for MIPS instructions, and some support functions 6// 7 8//Outputs to decoder.hh 9output header {{ 10 11#define R31 31 12#include "arch/mips/faults.hh" 13#include "arch/mips/isa_traits.hh" 14 15 using namespace MipsISA; 16 17 18 /** 19 * Base class for all MIPS static instructions. 20 */ 21 class MipsStaticInst : public StaticInst 22 { 23 protected: 24 25 /// Make MipsISA register dependence tags directly visible in 26 /// this class and derived classes. Maybe these should really 27 /// live here and not in the MipsISA namespace. 28 /*enum DependenceTags { 29 FP_Base_DepTag = MipsISA::FP_Base_DepTag, 30 Fpcr_DepTag = MipsISA::Fpcr_DepTag, 31 Uniq_DepTag = MipsISA::Uniq_DepTag, 32 IPR_Base_DepTag = MipsISA::IPR_Base_DepTag 33 };*/ 34 35 // Constructor 36 MipsStaticInst(const char *mnem, MachInst _machInst, OpClass __opClass) 37 : StaticInst(mnem, _machInst, __opClass) 38 { 39 } 40 41 /// Print a register name for disassembly given the unique 42 /// dependence tag number (FP or int). 43 void printReg(std::ostream &os, int reg) const; 44 45 std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 46 }; 47 48}}; 49 50//Ouputs to decoder.cc 51output decoder {{ 52 53 void MipsStaticInst::printReg(std::ostream &os, int reg) const 54 { 55 if (reg < FP_Base_DepTag) { 56 ccprintf(os, "r%d", reg); 57 } 58 else { 59 ccprintf(os, "f%d", reg - FP_Base_DepTag); 60 } 61 } 62 63 std::string MipsStaticInst::generateDisassembly(Addr pc, const SymbolTable *symtab) const 64 { 65 std::stringstream ss; 66 67 ccprintf(ss, "%-10s ", mnemonic); 68 69 if(_numDestRegs > 0){ 70 if(_numSrcRegs > 0) 71 ss << ","; 72 printReg(ss, _destRegIdx[0]); 73 } 74 75 if(_numSrcRegs > 0) { 76 printReg(ss, _srcRegIdx[0]); 77 } 78 79 if(_numSrcRegs > 1) { 80 ss << ","; 81 printReg(ss, _srcRegIdx[1]); 82 } 83 84 85 if(mnemonic == "sll"){ 86 ccprintf(ss," %d",SA); 87 } 88 89 return ss.str(); 90 } 91 92}}; 93 94