diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 25 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineOperand.cpp | 27 |
2 files changed, 24 insertions, 28 deletions
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index f4f248e6053..5367216c20b 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -835,18 +835,6 @@ void MIPrinter::printTargetFlags(const MachineOperand &Op) { OS << ") "; } -static const char *getTargetIndexName(const MachineFunction &MF, int Index) { - const auto *TII = MF.getSubtarget().getInstrInfo(); - assert(TII && "expected instruction info"); - auto Indices = TII->getSerializableTargetIndices(); - for (const auto &I : Indices) { - if (I.first == Index) { - return I.second; - } - } - return nullptr; -} - void MIPrinter::print(const MachineInstr &MI, unsigned OpIdx, const TargetRegisterInfo *TRI, bool ShouldPrintRegisterTies, LLT TypeToPrint, @@ -863,7 +851,8 @@ void MIPrinter::print(const MachineInstr &MI, unsigned OpIdx, case MachineOperand::MO_Register: case MachineOperand::MO_CImmediate: case MachineOperand::MO_MachineBasicBlock: - case MachineOperand::MO_ConstantPoolIndex: { + case MachineOperand::MO_ConstantPoolIndex: + case MachineOperand::MO_TargetIndex: { unsigned TiedOperandIdx = 0; if (ShouldPrintRegisterTies && Op.isReg() && Op.isTied() && !Op.isDef()) TiedOperandIdx = Op.getParent()->findTiedOperandIdx(OpIdx); @@ -878,16 +867,6 @@ void MIPrinter::print(const MachineInstr &MI, unsigned OpIdx, case MachineOperand::MO_FrameIndex: printStackObjectReference(Op.getIndex()); break; - case MachineOperand::MO_TargetIndex: - OS << "target-index("; - if (const auto *Name = - getTargetIndexName(*Op.getParent()->getMF(), Op.getIndex())) - OS << Name; - else - OS << "<unknown>"; - OS << ')'; - printOffset(Op.getOffset()); - break; case MachineOperand::MO_JumpTableIndex: OS << "%jump-table." << Op.getIndex(); break; diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index 2a2f8f29c48..cd8c86e782a 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -15,6 +15,7 @@ #include "llvm/Analysis/Loads.h" #include "llvm/CodeGen/MIRPrinter.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/TargetInstrInfo.h" #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/IR/Constants.h" #include "llvm/IR/ModuleSlotTracker.h" @@ -386,6 +387,18 @@ static void printOffset(raw_ostream &OS, int64_t Offset) { OS << " + " << Offset; } +static const char *getTargetIndexName(const MachineFunction &MF, int Index) { + const auto *TII = MF.getSubtarget().getInstrInfo(); + assert(TII && "expected instruction info"); + auto Indices = TII->getSerializableTargetIndices(); + auto Found = find_if(Indices, [&](const std::pair<int, const char *> &I) { + return I.first == Index; + }); + if (Found != Indices.end()) + return Found->second; + return nullptr; +} + void MachineOperand::printSubregIdx(raw_ostream &OS, uint64_t Index, const TargetRegisterInfo *TRI) { OS << "%subreg."; @@ -499,12 +512,16 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST, OS << "%const." << getIndex(); printOffset(OS, getOffset()); break; - case MachineOperand::MO_TargetIndex: - OS << "<ti#" << getIndex(); - if (getOffset()) - OS << "+" << getOffset(); - OS << '>'; + case MachineOperand::MO_TargetIndex: { + OS << "target-index("; + const char *Name = "<unknown>"; + if (const MachineFunction *MF = getMFIfAvailable(*this)) + if (const auto *TargetIndexName = getTargetIndexName(*MF, getIndex())) + Name = TargetIndexName; + OS << Name << ')'; + printOffset(OS, getOffset()); break; + } case MachineOperand::MO_JumpTableIndex: OS << "<jt#" << getIndex() << '>'; break; |