diff options
Diffstat (limited to 'llvm/lib/CodeGen/MIRPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index 664a0f532e9..9c5988c32e4 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -17,6 +17,7 @@ #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/MIRYamlMapping.h" @@ -114,8 +115,10 @@ public: void print(const MachineInstr &MI); void printMBBReference(const MachineBasicBlock &MBB); void printIRBlockReference(const BasicBlock &BB); + void printIRValueReference(const Value &V); void printStackObjectReference(int FrameIndex); void print(const MachineOperand &Op, const TargetRegisterInfo *TRI); + void print(const MachineMemOperand &Op); void print(const MCCFIInstruction &CFI, const TargetRegisterInfo *TRI); }; @@ -426,7 +429,7 @@ void MIPrinter::print(const MachineInstr &MI) { if (MI.getFlag(MachineInstr::FrameSetup)) OS << "frame-setup "; OS << TII->getName(MI.getOpcode()); - // TODO: Print the bundling instruction flags, machine mem operands. + // TODO: Print the bundling instruction flags. if (I < E) OS << ' '; @@ -444,6 +447,17 @@ void MIPrinter::print(const MachineInstr &MI) { OS << " debug-location "; MI.getDebugLoc()->printAsOperand(OS, MST); } + + if (!MI.memoperands_empty()) { + OS << " :: "; + bool NeedComma = false; + for (const auto *Op : MI.memoperands()) { + if (NeedComma) + OS << ", "; + print(*Op); + NeedComma = true; + } + } } void MIPrinter::printMBBReference(const MachineBasicBlock &MBB) { @@ -467,6 +481,16 @@ void MIPrinter::printIRBlockReference(const BasicBlock &BB) { OS << Slot; } +void MIPrinter::printIRValueReference(const Value &V) { + OS << "%ir."; + if (V.hasName()) { + printLLVMNameWithoutPrefix(OS, V.getName()); + return; + } + // TODO: Serialize the unnamed IR value references. + OS << "<unserializable ir value>"; +} + void MIPrinter::printStackObjectReference(int FrameIndex) { auto ObjectInfo = StackObjectOperandMapping.find(FrameIndex); assert(ObjectInfo != StackObjectOperandMapping.end() && @@ -581,6 +605,24 @@ void MIPrinter::print(const MachineOperand &Op, const TargetRegisterInfo *TRI) { } } +void MIPrinter::print(const MachineMemOperand &Op) { + OS << '('; + // TODO: Print operand's other flags. + if (Op.isLoad()) + OS << "load "; + else { + assert(Op.isStore() && "Non load machine operand must be a store"); + OS << "store "; + } + OS << Op.getSize() << (Op.isLoad() ? " from " : " into "); + if (const Value *Val = Op.getValue()) + printIRValueReference(*Val); + // TODO: Print PseudoSourceValue. + // TODO: Print the base alignment. + // TODO: Print the metadata attributes. + OS << ')'; +} + static void printCFIRegister(unsigned DwarfReg, raw_ostream &OS, const TargetRegisterInfo *TRI) { int Reg = TRI->getLLVMRegNum(DwarfReg, true); |