ARM: Tune up predicated instruction decoding.

This commit is contained in:
Gabe Black 2009-07-08 23:02:19 -07:00
parent ddcf084f16
commit 2fb8d481ab
4 changed files with 113 additions and 106 deletions

View file

@ -32,10 +32,18 @@
namespace ArmISA
{
std::string
PredOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
PredIntOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
{
std::stringstream ss;
printDataInst(ss);
printDataInst(ss, false);
return ss.str();
}
std::string
PredImmOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
{
std::stringstream ss;
printDataInst(ss, true);
return ss.str();
}

View file

@ -56,8 +56,6 @@ class PredOp : public ArmStaticInst
condCode((ConditionCode)(unsigned)machInst.condCode)
{
}
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
};
/**
@ -82,6 +80,8 @@ class PredImmOp : public PredOp
if (rotate != 0)
rotated_carry = (rotated_imm >> 31) & 1;
}
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
};
/**
@ -100,6 +100,8 @@ class PredIntOp : public PredOp
shift_size(machInst.shiftSize), shift(machInst.shift)
{
}
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
};
/**

View file

@ -330,14 +330,6 @@ ArmStaticInst::printMemSymbol(std::ostream &os,
void
ArmStaticInst::printShiftOperand(std::ostream &os) const
{
// Shifter operand
if (bits((uint32_t)machInst, 25)) {
// Immediate form
unsigned rotate = machInst.rotate * 2;
uint32_t imm = machInst.imm;
ccprintf(os, "#%#x", (imm << (32 - rotate)) | (imm >> rotate));
} else {
// Register form
printReg(os, machInst.rm);
bool immShift = (machInst.opcode4 == 0);
@ -380,11 +372,10 @@ ArmStaticInst::printShiftOperand(std::ostream &os) const
else
printReg(os, machInst.rs);
}
}
}
void
ArmStaticInst::printDataInst(std::ostream &os) const
ArmStaticInst::printDataInst(std::ostream &os, bool withImm) const
{
printMnemonic(os, machInst.sField ? "s" : "");
//XXX It would be nice if the decoder figured this all out for us.
@ -409,7 +400,13 @@ ArmStaticInst::printDataInst(std::ostream &os) const
if (!firstOp)
os << ", ";
if (withImm) {
unsigned rotate = machInst.rotate * 2;
uint32_t imm = machInst.imm;
ccprintf(os, "#%#x", (imm << (32 - rotate)) | (imm >> rotate));
} else {
printShiftOperand(os);
}
}
std::string

View file

@ -71,7 +71,7 @@ class ArmStaticInst : public StaticInst
void printShiftOperand(std::ostream &os) const;
void printDataInst(std::ostream &os) const;
void printDataInst(std::ostream &os, bool withImm) const;
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
};