35,187d34
< output header {{
< /**
< * Base class for branch operations.
< */
< class Branch : public SparcStaticInst
< {
< protected:
< // Constructor
< Branch(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
< SparcStaticInst(mnem, _machInst, __opClass)
< {
< }
<
< std::string generateDisassembly(Addr pc,
< const SymbolTable *symtab) const;
< };
<
< /**
< * Base class for branch operations with an immediate displacement.
< */
< class BranchDisp : public Branch
< {
< protected:
< // Constructor
< BranchDisp(const char *mnem, ExtMachInst _machInst,
< OpClass __opClass) :
< Branch(mnem, _machInst, __opClass)
< {
< }
<
< std::string generateDisassembly(Addr pc,
< const SymbolTable *symtab) const;
<
< int32_t disp;
< };
<
< /**
< * Base class for branches with n bit displacements.
< */
< template<int bits>
< class BranchNBits : public BranchDisp
< {
< protected:
< // Constructor
< BranchNBits(const char *mnem, ExtMachInst _machInst,
< OpClass __opClass) :
< BranchDisp(mnem, _machInst, __opClass)
< {
< disp = sext<bits + 2>((_machInst & mask(bits)) << 2);
< }
< };
<
< /**
< * Base class for 16bit split displacements.
< */
< class BranchSplit : public BranchDisp
< {
< protected:
< // Constructor
< BranchSplit(const char *mnem, ExtMachInst _machInst,
< OpClass __opClass) :
< BranchDisp(mnem, _machInst, __opClass)
< {
< disp = sext<18>((D16HI << 16) | (D16LO << 2));
< }
< };
<
< /**
< * Base class for branches that use an immediate and a register to
< * compute their displacements.
< */
< class BranchImm13 : public Branch
< {
< protected:
< // Constructor
< BranchImm13(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
< Branch(mnem, _machInst, __opClass), imm(sext<13>(SIMM13))
< {
< }
<
< std::string generateDisassembly(Addr pc,
< const SymbolTable *symtab) const;
<
< int32_t imm;
< };
< }};
<
< output decoder {{
<
< template class BranchNBits<19>;
<
< template class BranchNBits<22>;
<
< template class BranchNBits<30>;
<
< std::string
< Branch::generateDisassembly(Addr pc, const SymbolTable *symtab) const
< {
< std::stringstream response;
<
< printMnemonic(response, mnemonic);
< printRegArray(response, _srcRegIdx, _numSrcRegs);
< if (_numDestRegs && _numSrcRegs)
< response << ", ";
< printDestReg(response, 0);
<
< return response.str();
< }
<
< std::string
< BranchImm13::generateDisassembly(Addr pc,
< const SymbolTable *symtab) const
< {
< std::stringstream response;
<
< printMnemonic(response, mnemonic);
< printRegArray(response, _srcRegIdx, _numSrcRegs);
< if (_numSrcRegs > 0)
< response << ", ";
< ccprintf(response, "0x%x", imm);
< if (_numDestRegs > 0)
< response << ", ";
< printDestReg(response, 0);
<
< return response.str();
< }
<
< std::string
< BranchDisp::generateDisassembly(Addr pc,
< const SymbolTable *symtab) const
< {
< std::stringstream response;
< std::string symbol;
< Addr symbolAddr;
<
< Addr target = disp + pc;
<
< printMnemonic(response, mnemonic);
< ccprintf(response, "0x%x", target);
<
< if (symtab &&
< symtab->findNearestSymbol(target, symbol, symbolAddr)) {
< ccprintf(response, " <%s", symbol);
< if (symbolAddr != target)
< ccprintf(response, "+%d>", target - symbolAddr);
< else
< ccprintf(response, ">");
< }
<
< return response.str();
< }
< }};
<