diff options
author | Tanya Lattner <tonic@nondot.org> | 2004-06-25 00:13:11 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2004-06-25 00:13:11 +0000 |
commit | 23dbc8170c91c09bf1c7f3f18d4321e05c500db3 (patch) | |
tree | 97c958f3a4f7910e0899d5bf5886ad8a41a71954 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 521eb8752b2e1ab7318169c10dd7a23acf78664b (diff) | |
download | llvm-23dbc8170c91c09bf1c7f3f18d4321e05c500db3.zip llvm-23dbc8170c91c09bf1c7f3f18d4321e05c500db3.tar.gz llvm-23dbc8170c91c09bf1c7f3f18d4321e05c500db3.tar.bz2 |
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.
llvm-svn: 14389
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index f1a5c3e..3f7e713 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/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; } |