Improved printing routines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1263 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vikram S. Adve
2001-11-12 14:19:47 +00:00
parent af00d485a4
commit d9beb975f2

View File

@ -132,11 +132,18 @@ operator<< (ostream& os, const MachineInstr& minstr)
static inline ostream& static inline ostream&
OutputOperand(ostream &os, const MachineOperand &mop) OutputOperand(ostream &os, const MachineOperand &mop)
{ {
Value* val;
switch (mop.getOperandType()) switch (mop.getOperandType())
{ {
case MachineOperand::MO_CCRegister: case MachineOperand::MO_CCRegister:
case MachineOperand::MO_VirtualRegister: case MachineOperand::MO_VirtualRegister:
return os << "(val " << mop.getVRegValue() << ")"; val = mop.getVRegValue();
os << "(val ";
if (val && val->hasName())
os << val->getName().c_str();
else
os << val;
return os << ")";
case MachineOperand::MO_MachineRegister: case MachineOperand::MO_MachineRegister:
return os << "(" << mop.getMachineRegNum() << ")"; return os << "(" << mop.getMachineRegNum() << ")";
default: default:
@ -166,9 +173,12 @@ operator<<(ostream &os, const MachineOperand &mop)
{ {
const Value* opVal = mop.getVRegValue(); const Value* opVal = mop.getVRegValue();
bool isLabel = isa<Method>(opVal) || isa<BasicBlock>(opVal); bool isLabel = isa<Method>(opVal) || isa<BasicBlock>(opVal);
return os << "%disp(" os << "%disp(" << (isLabel? "label " : "addr-of-val ");
<< (isLabel? "label " : "addr-of-val ") if (opVal->hasName())
<< opVal << ")"; os << opVal->getName().c_str();
else
os << opVal;
return os << ")";
} }
default: default:
assert(0 && "Unrecognized operand type"); assert(0 && "Unrecognized operand type");