aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2004-06-25 00:13:11 +0000
committerTanya Lattner <tonic@nondot.org>2004-06-25 00:13:11 +0000
commitb140762a45d21aaed054f15adaff0fc2274d939d (patch)
treea68975838c30f8e7ff326503550a907dc17b3f13 /lib/CodeGen/MachineInstr.cpp
parent32b588039e8db86269edab5bd2b49ba1aebb00b8 (diff)
Made a fix so that you can print out MachineInstrs that belong to a MachineBasicBlock that is not yet attached to a MachineFunction. This change includes changing the third operand (TargetMachine) to a pointer for the MachineInstr::print function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
-rw-r--r--lib/CodeGen/MachineInstr.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index f1a5c3ec52..3f7e713ca0 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -235,8 +235,14 @@ static inline void OutputReg(std::ostream &os, unsigned RegNo,
}
static void print(const MachineOperand &MO, std::ostream &OS,
- const TargetMachine &TM) {
- const MRegisterInfo *MRI = TM.getRegisterInfo();
+ const TargetMachine *TM) {
+
+ const MRegisterInfo *MRI = 0;
+
+ if(TM)
+ MRI = TM->getRegisterInfo();
+
+
bool CloseParen = true;
if (MO.isHiBits32())
OS << "%lm(";
@@ -313,7 +319,7 @@ static void print(const MachineOperand &MO, std::ostream &OS,
OS << ")";
}
-void MachineInstr::print(std::ostream &OS, const TargetMachine &TM) const {
+void MachineInstr::print(std::ostream &OS, const TargetMachine *TM) const {
unsigned StartOp = 0;
// Specialize printing if op#0 is definition
@@ -322,7 +328,11 @@ void MachineInstr::print(std::ostream &OS, const TargetMachine &TM) const {
OS << " = ";
++StartOp; // Don't print this operand again!
}
- OS << TM.getInstrInfo()->getName(getOpcode());
+
+ //Must check if Target machine is not null because machine BB could not
+ //be attached to a Machine function yet
+ if(TM)
+ OS << TM->getInstrInfo()->getName(getOpcode());
for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
const MachineOperand& mop = getOperand(i);
@@ -361,7 +371,10 @@ std::ostream &operator<<(std::ostream &os, const MachineInstr &MI) {
// info for the instruction.
if (const MachineBasicBlock *MBB = MI.getParent()) {
const MachineFunction *MF = MBB->getParent();
- MI.print(os, MF->getTarget());
+ if(MF)
+ MI.print(os, &MF->getTarget());
+ else
+ MI.print(os, 0);
return os;
}