aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOperand.cpp
diff options
context:
space:
mode:
authorPeng Guo <peng_guo@apple.com>2020-01-10 11:18:11 +0100
committerBenjamin Kramer <benny.kra@googlemail.com>2020-01-10 11:18:12 +0100
commitcfd849840134c4632c2f4fa498dfb93c47825b24 (patch)
tree5f4cbedb08687a31f16bbada31c6593b7fcf0e47 /llvm/lib/CodeGen/MachineOperand.cpp
parenta1cc19b581443c84fff4c6e6d4e341351ef3203c (diff)
downloadllvm-cfd849840134c4632c2f4fa498dfb93c47825b24.zip
llvm-cfd849840134c4632c2f4fa498dfb93c47825b24.tar.gz
llvm-cfd849840134c4632c2f4fa498dfb93c47825b24.tar.bz2
[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
Diffstat (limited to 'llvm/lib/CodeGen/MachineOperand.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOperand.cpp16
1 files changed, 8 insertions, 8 deletions
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<StringRef> &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<ExternalSymbolPseudoSourceValue>(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;
}