From cfd849840134c4632c2f4fa498dfb93c47825b24 Mon Sep 17 00:00:00 2001 From: Peng Guo Date: Fri, 10 Jan 2020 11:18:11 +0100 Subject: [MIR] Fix cyclic dependency of MIR formatter Summary: Move MIR formatter pointer from TargetMachine to TargetInstrInfo to avoid cyclic dependency between target & codegen. Reviewers: dsanders, bkramer, arsenm Subscribers: wdng, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72485 --- llvm/lib/CodeGen/MachineOperand.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'llvm/lib/CodeGen/MachineOperand.cpp') diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index 5dd9846..0ea495b 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -784,8 +784,11 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST, } case MachineOperand::MO_Immediate: { const MIRFormatter *Formatter = nullptr; - if (const MachineFunction *MF = getMFIfAvailable(*this)) - Formatter = MF->getTarget().getMIRFormatter(); + if (const MachineFunction *MF = getMFIfAvailable(*this)) { + const auto *TII = MF->getSubtarget().getInstrInfo(); + assert(TII && "expected instruction info"); + Formatter = TII->getMIRFormatter(); + } if (Formatter) Formatter->printImm(OS, *getParent(), OpIdx, getImm()); else @@ -1057,8 +1060,7 @@ void MachineMemOperand::print(raw_ostream &OS, ModuleSlotTracker &MST, SmallVectorImpl &SSNs, const LLVMContext &Context, const MachineFrameInfo *MFI, - const TargetInstrInfo *TII, - const MIRFormatter* MIRF) const { + const TargetInstrInfo *TII) const { OS << '('; if (isVolatile()) OS << "volatile "; @@ -1133,15 +1135,13 @@ void MachineMemOperand::print(raw_ostream &OS, ModuleSlotTracker &MST, OS, cast(PVal)->getSymbol()); break; default: { + const MIRFormatter *Formatter = TII->getMIRFormatter(); // FIXME: This is not necessarily the correct MIR serialization format for // a custom pseudo source value, but at least it allows // -print-machineinstrs to work on a target with custom pseudo source // values. OS << "custom \""; - if (MIRF) - MIRF->printCustomPseudoSourceValue(OS, MST, *PVal); - else - PVal->printCustom(OS); + Formatter->printCustomPseudoSourceValue(OS, MST, *PVal); OS << '\"'; break; } -- cgit v1.1