* Add printing support for FrameIndex operands

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5194 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-12-28 20:37:37 +00:00
parent 955fad1f99
commit 10cb79b484

View File

@@ -265,7 +265,9 @@ static void print(const MachineOperand &MO, std::ostream &OS,
<< ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName() << ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
<< "," << (void*)MO.getMachineBasicBlock()->getBasicBlock() << ">"; << "," << (void*)MO.getMachineBasicBlock()->getBasicBlock() << ">";
break; break;
case MachineOperand::MO_FrameIndex:
OS << "<fi#" << MO.getFrameIndex() << ">";
break;
default: default:
assert(0 && "Unrecognized operand type"); assert(0 && "Unrecognized operand type");
} }
@@ -341,61 +343,64 @@ std::ostream &operator<<(std::ostream& os, const MachineInstr& minstr)
return os << "\n"; return os << "\n";
} }
std::ostream &operator<<(std::ostream &os, const MachineOperand &MO) std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO)
{ {
if (MO.opHiBits32()) if (MO.opHiBits32())
os << "%lm("; OS << "%lm(";
else if (MO.opLoBits32()) else if (MO.opLoBits32())
os << "%lo("; OS << "%lo(";
else if (MO.opHiBits64()) else if (MO.opHiBits64())
os << "%hh("; OS << "%hh(";
else if (MO.opLoBits64()) else if (MO.opLoBits64())
os << "%hm("; OS << "%hm(";
switch (MO.getType()) switch (MO.getType())
{ {
case MachineOperand::MO_VirtualRegister: case MachineOperand::MO_VirtualRegister:
os << "%reg"; OS << "%reg";
OutputValue(os, MO.getVRegValue()); OutputValue(OS, MO.getVRegValue());
if (MO.hasAllocatedReg()) { if (MO.hasAllocatedReg()) {
os << "=="; OS << "==";
OutputReg(os, MO.getAllocatedRegNum()); OutputReg(OS, MO.getAllocatedRegNum());
} }
break; break;
case MachineOperand::MO_CCRegister: case MachineOperand::MO_CCRegister:
os << "%ccreg"; OS << "%ccreg";
OutputValue(os, MO.getVRegValue()); OutputValue(OS, MO.getVRegValue());
if (MO.hasAllocatedReg()) { if (MO.hasAllocatedReg()) {
os << "=="; OS << "==";
OutputReg(os, MO.getAllocatedRegNum()); OutputReg(OS, MO.getAllocatedRegNum());
} }
break; break;
case MachineOperand::MO_MachineRegister: case MachineOperand::MO_MachineRegister:
OutputReg(os, MO.getMachineRegNum()); OutputReg(OS, MO.getMachineRegNum());
break; break;
case MachineOperand::MO_SignExtendedImmed: case MachineOperand::MO_SignExtendedImmed:
os << (long)MO.getImmedValue(); OS << (long)MO.getImmedValue();
break; break;
case MachineOperand::MO_UnextendedImmed: case MachineOperand::MO_UnextendedImmed:
os << (long)MO.getImmedValue(); OS << (long)MO.getImmedValue();
break; break;
case MachineOperand::MO_PCRelativeDisp: case MachineOperand::MO_PCRelativeDisp:
{ {
const Value* opVal = MO.getVRegValue(); const Value* opVal = MO.getVRegValue();
bool isLabel = isa<Function>(opVal) || isa<BasicBlock>(opVal); bool isLabel = isa<Function>(opVal) || isa<BasicBlock>(opVal);
os << "%disp(" << (isLabel? "label " : "addr-of-val "); OS << "%disp(" << (isLabel? "label " : "addr-of-val ");
if (opVal->hasName()) if (opVal->hasName())
os << opVal->getName(); OS << opVal->getName();
else else
os << (const void*) opVal; OS << (const void*) opVal;
os << ")"; OS << ")";
break; break;
} }
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
os << "bb<" OS << "bb<"
<< ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName() << ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
<< "," << (void*)MO.getMachineBasicBlock()->getBasicBlock() << ">"; << "," << (void*)MO.getMachineBasicBlock()->getBasicBlock() << ">";
break; break;
case MachineOperand::MO_FrameIndex:
OS << "<fi#" << MO.getFrameIndex() << ">";
break;
default: default:
assert(0 && "Unrecognized operand type"); assert(0 && "Unrecognized operand type");
break; break;
@@ -404,7 +409,7 @@ std::ostream &operator<<(std::ostream &os, const MachineOperand &MO)
if (MO.flags & if (MO.flags &
(MachineOperand::HIFLAG32 | MachineOperand::LOFLAG32 | (MachineOperand::HIFLAG32 | MachineOperand::LOFLAG32 |
MachineOperand::HIFLAG64 | MachineOperand::LOFLAG64)) MachineOperand::HIFLAG64 | MachineOperand::LOFLAG64))
os << ")"; OS << ")";
return os; return OS;
} }