diff options
Diffstat (limited to 'llvm/lib/CodeGen/MIRPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 72 |
1 files changed, 55 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index e8cd3d60ccb12..fa23df6288e99 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -79,6 +79,9 @@ static cl::opt<bool> SimplifyMIR( "simplify-mir", cl::Hidden, cl::desc("Leave out unnecessary information when printing MIR")); +static cl::opt<bool> PrintLocations("mir-debug-loc", cl::Hidden, cl::init(true), + cl::desc("Print MIR debug-locations")); + namespace { /// This structure describes how to print out stack object references. @@ -162,8 +165,9 @@ public: void print(const MachineInstr &MI); void printStackObjectReference(int FrameIndex); void print(const MachineInstr &MI, unsigned OpIdx, - const TargetRegisterInfo *TRI, bool ShouldPrintRegisterTies, - LLT TypeToPrint, bool PrintDef = true); + const TargetRegisterInfo *TRI, const TargetInstrInfo *TII, + bool ShouldPrintRegisterTies, LLT TypeToPrint, + bool PrintDef = true); }; } // end namespace llvm @@ -197,7 +201,7 @@ void MIRPrinter::print(const MachineFunction &MF) { yaml::MachineFunction YamlMF; YamlMF.Name = MF.getName(); - YamlMF.Alignment = MF.getAlignment().value(); + YamlMF.Alignment = MF.getAlignment(); YamlMF.ExposesReturnsTwice = MF.exposesReturnsTwice(); YamlMF.HasWinCFI = MF.hasWinCFI(); @@ -333,7 +337,7 @@ void MIRPrinter::convert(ModuleSlotTracker &MST, YamlMFI.HasPatchPoint = MFI.hasPatchPoint(); YamlMFI.StackSize = MFI.getStackSize(); YamlMFI.OffsetAdjustment = MFI.getOffsetAdjustment(); - YamlMFI.MaxAlignment = MFI.getMaxAlignment(); + YamlMFI.MaxAlignment = MFI.getMaxAlign().value(); YamlMFI.AdjustsStack = MFI.adjustsStack(); YamlMFI.HasCalls = MFI.hasCalls(); YamlMFI.MaxCallFrameSize = MFI.isMaxCallFrameSizeComputed() @@ -372,7 +376,7 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF, : yaml::FixedMachineStackObject::DefaultType; YamlObject.Offset = MFI.getObjectOffset(I); YamlObject.Size = MFI.getObjectSize(I); - YamlObject.Alignment = MFI.getObjectAlignment(I); + YamlObject.Alignment = MFI.getObjectAlign(I); YamlObject.StackID = (TargetStackID::Value)MFI.getStackID(I); YamlObject.IsImmutable = MFI.isImmutableObjectIndex(I); YamlObject.IsAliased = MFI.isAliasedObjectIndex(I); @@ -390,8 +394,8 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF, yaml::MachineStackObject YamlObject; YamlObject.ID = ID; if (const auto *Alloca = MFI.getObjectAllocation(I)) - YamlObject.Name.Value = - Alloca->hasName() ? Alloca->getName() : "<unnamed alloca>"; + YamlObject.Name.Value = std::string( + Alloca->hasName() ? Alloca->getName() : "<unnamed alloca>"); YamlObject.Type = MFI.isSpillSlotObjectIndex(I) ? yaml::MachineStackObject::SpillSlot : MFI.isVariableSizedObjectIndex(I) @@ -399,7 +403,7 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF, : yaml::MachineStackObject::DefaultType; YamlObject.Offset = MFI.getObjectOffset(I); YamlObject.Size = MFI.getObjectSize(I); - YamlObject.Alignment = MFI.getObjectAlignment(I); + YamlObject.Alignment = MFI.getObjectAlign(I); YamlObject.StackID = (TargetStackID::Value)MFI.getStackID(I); YMF.StackObjects.push_back(YamlObject); @@ -513,7 +517,7 @@ void MIRPrinter::convert(yaml::MachineFunction &MF, yaml::MachineConstantPoolValue YamlConstant; YamlConstant.ID = ID++; YamlConstant.Value = StrOS.str(); - YamlConstant.Alignment = Constant.getAlignment(); + YamlConstant.Alignment = Constant.getAlign(); YamlConstant.IsTargetSpecific = Constant.isMachineConstantPoolEntry(); MF.Constants.push_back(YamlConstant); @@ -629,11 +633,31 @@ void MIPrinter::print(const MachineBasicBlock &MBB) { OS << "landing-pad"; HasAttributes = true; } - if (MBB.getAlignment() != Align::None()) { + if (MBB.isEHFuncletEntry()) { + OS << (HasAttributes ? ", " : " ("); + OS << "ehfunclet-entry"; + HasAttributes = true; + } + if (MBB.getAlignment() != Align(1)) { OS << (HasAttributes ? ", " : " ("); OS << "align " << MBB.getAlignment().value(); HasAttributes = true; } + if (MBB.getSectionID() != MBBSectionID(0)) { + OS << (HasAttributes ? ", " : " ("); + OS << "bbsections "; + switch (MBB.getSectionID().Type) { + case MBBSectionID::SectionType::Exception: + OS << "Exception"; + break; + case MBBSectionID::SectionType::Cold: + OS << "Cold"; + break; + default: + OS << MBB.getSectionID().Number; + } + HasAttributes = true; + } if (HasAttributes) OS << ")"; OS << ":\n"; @@ -721,7 +745,7 @@ void MIPrinter::print(const MachineInstr &MI) { ++I) { if (I) OS << ", "; - print(MI, I, TRI, ShouldPrintRegisterTies, + print(MI, I, TRI, TII, ShouldPrintRegisterTies, MI.getTypeToPrint(I, PrintedTypes, MRI), /*PrintDef=*/false); } @@ -754,6 +778,8 @@ void MIPrinter::print(const MachineInstr &MI) { OS << "exact "; if (MI.getFlag(MachineInstr::NoFPExcept)) OS << "nofpexcept "; + if (MI.getFlag(MachineInstr::NoMerge)) + OS << "nomerge "; OS << TII->getName(MI.getOpcode()); if (I < E) @@ -763,7 +789,7 @@ void MIPrinter::print(const MachineInstr &MI) { for (; I < E; ++I) { if (NeedComma) OS << ", "; - print(MI, I, TRI, ShouldPrintRegisterTies, + print(MI, I, TRI, TII, ShouldPrintRegisterTies, MI.getTypeToPrint(I, PrintedTypes, MRI)); NeedComma = true; } @@ -792,11 +818,13 @@ void MIPrinter::print(const MachineInstr &MI) { NeedComma = true; } - if (const DebugLoc &DL = MI.getDebugLoc()) { - if (NeedComma) - OS << ','; - OS << " debug-location "; - DL->printAsOperand(OS, MST); + if (PrintLocations) { + if (const DebugLoc &DL = MI.getDebugLoc()) { + if (NeedComma) + OS << ','; + OS << " debug-location "; + DL->printAsOperand(OS, MST); + } } if (!MI.memoperands_empty()) { @@ -822,11 +850,20 @@ void MIPrinter::printStackObjectReference(int FrameIndex) { Operand.Name); } +static std::string formatOperandComment(std::string Comment) { + if (Comment.empty()) + return Comment; + return std::string(" /* " + Comment + " */"); +} + void MIPrinter::print(const MachineInstr &MI, unsigned OpIdx, const TargetRegisterInfo *TRI, + const TargetInstrInfo *TII, bool ShouldPrintRegisterTies, LLT TypeToPrint, bool PrintDef) { const MachineOperand &Op = MI.getOperand(OpIdx); + std::string MOComment = TII->createMIROperandComment(MI, Op, OpIdx, TRI); + switch (Op.getType()) { case MachineOperand::MO_Immediate: if (MI.isOperandSubregIdx(OpIdx)) { @@ -858,6 +895,7 @@ void MIPrinter::print(const MachineInstr &MI, unsigned OpIdx, const TargetIntrinsicInfo *TII = MI.getMF()->getTarget().getIntrinsicInfo(); Op.print(OS, MST, TypeToPrint, OpIdx, PrintDef, /*IsStandalone=*/false, ShouldPrintRegisterTies, TiedOperandIdx, TRI, TII); + OS << formatOperandComment(MOComment); break; } case MachineOperand::MO_FrameIndex: |