Add support for 3 new forms of MachineOperand

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5217 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-01-13 00:23:24 +00:00
parent 4d149cdae1
commit 8d95ef4973

View File

@ -10,6 +10,7 @@
#include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/MRegisterInfo.h"
using std::cerr; using std::cerr;
// Global variable holding an array of descriptors for machine instructions. // Global variable holding an array of descriptors for machine instructions.
// The actual object needs to be created separately for each target machine. // The actual object needs to be created separately for each target machine.
// This variable is initialized and reset by class MachineInstrInfo. // This variable is initialized and reset by class MachineInstrInfo.
@ -268,6 +269,15 @@ static void print(const MachineOperand &MO, std::ostream &OS,
case MachineOperand::MO_FrameIndex: case MachineOperand::MO_FrameIndex:
OS << "<fi#" << MO.getFrameIndex() << ">"; OS << "<fi#" << MO.getFrameIndex() << ">";
break; break;
case MachineOperand::MO_ConstantPoolIndex:
OS << "<cp#" << MO.getConstantPoolIndex() << ">";
break;
case MachineOperand::MO_GlobalAddress:
OS << "<ga:" << ((Value*)MO.getGlobal())->getName() << ">";
break;
case MachineOperand::MO_ExternalSymbol:
OS << "<es:" << MO.getSymbolName() << ">";
break;
default: default:
assert(0 && "Unrecognized operand type"); assert(0 && "Unrecognized operand type");
} }
@ -316,26 +326,26 @@ void MachineInstr::print(std::ostream &OS, const TargetMachine &TM) const {
} }
std::ostream &operator<<(std::ostream& os, const MachineInstr& minstr) std::ostream &operator<<(std::ostream& os, const MachineInstr& MI)
{ {
os << TargetInstrDescriptors[minstr.opCode].Name; os << TargetInstrDescriptors[MI.opCode].Name;
for (unsigned i=0, N=minstr.getNumOperands(); i < N; i++) { for (unsigned i=0, N=MI.getNumOperands(); i < N; i++) {
os << "\t" << minstr.getOperand(i); os << "\t" << MI.getOperand(i);
if( minstr.operandIsDefined(i) ) if (MI.operandIsDefined(i))
os << "*"; os << "<d>";
if( minstr.operandIsDefinedAndUsed(i) ) if (MI.operandIsDefinedAndUsed(i))
os << "*"; os << "<d&u>";
} }
// code for printing implict references // code for printing implict references
unsigned NumOfImpRefs = minstr.getNumImplicitRefs(); unsigned NumOfImpRefs = MI.getNumImplicitRefs();
if( NumOfImpRefs > 0 ) { if (NumOfImpRefs > 0) {
os << "\tImplicit: "; os << "\tImplicit: ";
for(unsigned z=0; z < NumOfImpRefs; z++) { for (unsigned z=0; z < NumOfImpRefs; z++) {
OutputValue(os, minstr.getImplicitRef(z)); OutputValue(os, MI.getImplicitRef(z));
if( minstr.implicitRefIsDefined(z)) os << "*"; if (MI.implicitRefIsDefined(z)) os << "<d>";
if( minstr.implicitRefIsDefinedAndUsed(z)) os << "*"; if (MI.implicitRefIsDefinedAndUsed(z)) os << "<d&u>";
os << "\t"; os << "\t";
} }
} }
@ -357,11 +367,13 @@ std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO)
switch (MO.getType()) switch (MO.getType())
{ {
case MachineOperand::MO_VirtualRegister: case MachineOperand::MO_VirtualRegister:
OS << "%reg"; if (MO.hasAllocatedReg())
OutputValue(OS, MO.getVRegValue());
if (MO.hasAllocatedReg()) {
OS << "==";
OutputReg(OS, MO.getAllocatedRegNum()); OutputReg(OS, MO.getAllocatedRegNum());
if (MO.getVRegValue()) {
if (MO.hasAllocatedReg()) OS << "==";
OS << "%vreg";
OutputValue(OS, MO.getVRegValue());
} }
break; break;
case MachineOperand::MO_CCRegister: case MachineOperand::MO_CCRegister:
@ -401,6 +413,15 @@ std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO)
case MachineOperand::MO_FrameIndex: case MachineOperand::MO_FrameIndex:
OS << "<fi#" << MO.getFrameIndex() << ">"; OS << "<fi#" << MO.getFrameIndex() << ">";
break; break;
case MachineOperand::MO_ConstantPoolIndex:
OS << "<cp#" << MO.getConstantPoolIndex() << ">";
break;
case MachineOperand::MO_GlobalAddress:
OS << "<ga:" << ((Value*)MO.getGlobal())->getName() << ">";
break;
case MachineOperand::MO_ExternalSymbol:
OS << "<es:" << MO.getSymbolName() << ">";
break;
default: default:
assert(0 && "Unrecognized operand type"); assert(0 && "Unrecognized operand type");
break; break;