LLVM: lib/CodeGen/MIRPrinter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

56#include

57#include

58#include

59#include

60#include

61#include

62#include

63#include

64

65using namespace llvm;

66

69 cl::desc("Leave out unnecessary information when printing MIR"));

70

72 cl::desc("Print MIR debug-locations"));

73

74namespace {

75

76

77struct FrameIndexOperand {

78 std::string Name;

79 unsigned ID;

80 bool IsFixed;

81

82 FrameIndexOperand(StringRef Name, unsigned ID, bool IsFixed)

83 : Name(Name.str()), ID(ID), IsFixed(IsFixed) {}

84

85

86 static FrameIndexOperand create(StringRef Name, unsigned ID) {

87 return FrameIndexOperand(Name, ID, false);

88 }

89

90

91 static FrameIndexOperand createFixed(unsigned ID) {

92 return FrameIndexOperand("", ID, true);

93 }

94};

95

96struct MFPrintState {

97 MachineModuleSlotTracker MST;

98 DenseMap<const uint32_t *, unsigned> RegisterMaskIds;

99

100

101 DenseMap<int, FrameIndexOperand> StackObjectOperandMapping;

102

104

105 MFPrintState(const MachineModuleInfo &MMI, const MachineFunction &MF)

106 : MST(MMI, &MF) {}

107};

108

109}

110

111

114 Mod.print(OS, nullptr);

115 }

116

118 llvm_unreachable("LLVM Module is supposed to be parsed separately");

119 return "";

120 }

121};

122

128

133 unsigned I = 0;

134 for (const uint32_t *Mask : TRI->getRegMasks())

135 RegisterMaskIds.insert(std::make_pair(Mask, I++));

136 return RegisterMaskIds;

137}

138

151static void

153 std::vectoryaml::SaveRestorePointEntry &YamlSRPoints,

171

174 MFPrintState State(MMI, MF);

176

182

191

193 YamlMF.Legalized = Props.hasLegalized();

195 YamlMF.Selected = Props.hasSelected();

196 YamlMF.FailedISel = Props.hasFailedISel();

199 YamlMF.NoPHIs = Props.hasNoPHIs();

200 YamlMF.IsSSA = Props.hasIsSSA();

201 YamlMF.NoVRegs = Props.hasNoVRegs();

202

212 const auto &SubSrc = Sub.Src;

213 const auto &SubDest = Sub.Dest;

215 SubDest.first,

216 SubDest.second,

217 Sub.Subreg});

218 }

223

227

229 bool IsNewlineNeeded = false;

230 for (const auto &MBB : MF) {

231 if (IsNewlineNeeded)

232 StrOS << "\n";

234 IsNewlineNeeded = true;

235 }

236

237

239

241

245 Out << YamlMF;

246}

247

250 assert(RegMask && "Can't print an empty register mask");

251 OS << StringRef("CustomRegMask(");

252

253 bool IsRegInRegMaskFound = false;

254 for (int I = 0, E = TRI->getNumRegs(); I < E; I++) {

255

256 if (RegMask[I / 32] & (1u << (I % 32))) {

257 if (IsRegInRegMaskFound)

258 OS << ',';

260 IsRegInRegMaskFound = true;

261 }

262 }

263

264 OS << ')';

265}

266

273

274template

275static void

278 std::array<std::string *, 3> Outputs{{&Object.DebugVar.Value,

279 &Object.DebugExpr.Value,

280 &Object.DebugLoc.Value}};

281 std::array<const Metadata *, 3> Metas{{DebugVar.Var,

282 DebugVar.Expr,

283 DebugVar.Loc}};

284 for (unsigned i = 0; i < 3; ++i) {

286 Metas[i]->printAsOperand(StrOS, MST);

287 }

288}

289

291 std::vectoryaml::FlowStringValue &RegisterFlags,

294 auto FlagValues = TRI->getVRegFlagsOfReg(Reg, MF);

295 for (auto &Flag : FlagValues)

297}

298

303

304

305 for (unsigned I = 0, E = RegInfo.getNumVirtRegs(); I < E; ++I) {

308 VReg.ID = I;

310 continue;

313 if (PreferredReg)

317 }

318

319

320 for (std::pair<MCRegister, Register> LI : RegInfo.liveins()) {

323 if (LI.second)

325 YamlMF.LiveIns.push_back(std::move(LiveIn));

326 }

327

328

329 if (RegInfo.isUpdatedCSRsInitialized()) {

330 const MCPhysReg *CalleeSavedRegs = RegInfo.getCalleeSavedRegs();

331 std::vectoryaml::FlowStringValue CalleeSavedRegisters;

332 for (const MCPhysReg *I = CalleeSavedRegs; *I; ++I) {

335 CalleeSavedRegisters.push_back(std::move(Reg));

336 }

338 }

339}

340

368

377 MCRegister EntryValReg = DebugVar.getEntryValueRegister();

378 printRegMIR(EntryValReg, Obj.EntryValueRegister, TRI);

379 }

380}

381

383 const MFPrintState &State,

384 int FrameIndex) {

385 auto ObjectInfo = State.StackObjectOperandMapping.find(FrameIndex);

386 assert(ObjectInfo != State.StackObjectOperandMapping.end() &&

387 "Invalid frame index");

388 const FrameIndexOperand &Operand = ObjectInfo->second;

390 Operand.Name);

391}

392

398

399

403 if (BeginIdx < 0)

404 FixedStackObjectsIdx.reserve(-BeginIdx);

405

406 unsigned ID = 0;

407 for (int I = BeginIdx; I < 0; ++I, ++ID) {

408 FixedStackObjectsIdx.push_back(-1);

410 continue;

411

413 YamlObject.ID = ID;

423

426 State.StackObjectOperandMapping.insert(

427 std::make_pair(I, FrameIndexOperand::createFixed(ID)));

428 }

429

430

434 if (EndIdx > 0)

435 StackObjectsIdx.reserve(EndIdx);

436 ID = 0;

437 for (int I = 0; I < EndIdx; ++I, ++ID) {

438 StackObjectsIdx.push_back(-1);

440 continue;

441

443 YamlObject.ID = ID;

445 YamlObject.Name.Value = std::string(

446 Alloca->hasName() ? Alloca->getName() : "");

456

457

460 State.StackObjectOperandMapping.insert(std::make_pair(

461 I, FrameIndexOperand::create(YamlObject.Name.Value, ID)));

462 }

463

465 const int FrameIdx = CSInfo.getFrameIdx();

467 continue;

468

471 if (!CSInfo.isSpilledToReg()) {

474 "Invalid stack object index");

475 if (FrameIdx < 0) {

476 auto &Object =

479 Object.CalleeSavedRegister = std::move(Reg);

480 Object.CalleeSavedRestored = CSInfo.isRestored();

481 } else {

482 auto &Object = YMF.StackObjects[StackObjectsIdx[FrameIdx]];

483 Object.CalleeSavedRegister = std::move(Reg);

484 Object.CalleeSavedRestored = CSInfo.isRestored();

485 }

486 }

487 }

490 assert(LocalObject.first >= 0 && "Expected a locally mapped stack object");

491 YMF.StackObjects[StackObjectsIdx[LocalObject.first]].LocalOffset =

492 LocalObject.second;

493 }

494

495

496

500 }

501

505 }

506

507

510 int Idx = DebugVar.getStackSlot();

512 "Invalid stack object index");

513 if (Idx < 0) {

514 auto &Object =

518 } else {

519 auto &Object = YMF.StackObjects[StackObjectsIdx[Idx]];

521 }

522 }

523}

524

532

533

535 CallLocation.BlockNum = CallI->getParent()->getNumber();

536

537 CallLocation.Offset =

538 std::distance(CallI->getParent()->instr_begin(), CallI);

540

541 auto [ArgRegPairs, CalleeTypeIds] = CallSiteInfo;

542

543 for (auto ArgReg : ArgRegPairs) {

545 YmlArgReg.ArgNo = ArgReg.ArgNo;

548 }

549

550 for (auto *CalleeTypeId : CalleeTypeIds) {

551 YmlCS.CalleeTypeIds.push_back(CalleeTypeId->getZExtValue());

552 }

554 }

555

556

559 return std::tie(A.CallLocation.BlockNum, A.CallLocation.Offset) <

560 std::tie(B.CallLocation.BlockNum, B.CallLocation.Offset);

561 });

562}

563

569 for (auto &MD : MDList) {

570 std::string NS;

574 }

575}

576

583 CallSite.Offset = std::distance(CallInst->getParent()->instr_begin(),

585

587 CG.TargetFlags};

589 }

590

591

594 return std::tie(A.CallSite.BlockNum, A.CallSite.Offset) <

595 std::tie(B.CallSite.BlockNum, B.CallSite.Offset);

596 });

597}

598

601 unsigned ID = 0;

603 std::string Str;

605 if (Constant.isMachineConstantPoolEntry())

607 else

609

611 YamlConstant.ID = ID++;

612 YamlConstant.Value = std::move(Str);

615

616 MF.Constants.push_back(std::move(YamlConstant));

617 }

618}

619

620static void

622 std::vectoryaml::SaveRestorePointEntry &YamlSRPoints,

625 for (const auto &[MBB, CSInfos] : SRPoints) {

630 Entry.Point = StrOS.str().str();

631 Str.clear();

633 if (Info.getReg()) {

635 Entry.Registers.push_back(StrOS.str().str());

636 Str.clear();

637 }

638 }

639

640 std::sort(Entry.Registers.begin(), Entry.Registers.end(),

642 return Lhs.Value < Rhs.Value;

643 });

644 YamlSRPoints.push_back(std::move(Entry));

645 }

646

647 std::sort(YamlSRPoints.begin(), YamlSRPoints.end(),

650 return Lhs.Point.Value < Rhs.Point.Value;

651 });

652}

653

657 unsigned ID = 0;

659 std::string Str;

661 Entry.ID = ID++;

662 for (const auto *MBB : Table.MBBs) {

665 Entry.Blocks.push_back(Str);

666 Str.clear();

667 }

668 YamlJTI.Entries.push_back(std::move(Entry));

669 }

670}

671

674 bool &IsFallthrough) {

676

678 if (MI.isPHI())

679 continue;

681 if (!MO.isMBB())

682 continue;

684 auto RP = Seen.insert(Succ);

685 if (RP.second)

686 Result.push_back(Succ);

687 }

688 }

690 IsFallthrough = I == MBB.end() || I->isBarrier();

691}

692

695 bool GuessedFallthrough;

697 if (GuessedFallthrough) {

700 if (NextI != MF.end()) {

704 }

705 }

706 if (GuessedSuccs.size() != MBB.succ_size())

707 return false;

708 return std::equal(MBB.succ_begin(), MBB.succ_end(), GuessedSuccs.begin());

709}

710

713

718 bool ShouldPrintRegisterTies,

721

724 assert(MBB.getNumber() >= 0 && "Invalid MBB number");

725 MBB.printName(OS,

728 &State.MST);

729 OS << ":\n";

730

731 bool HasLineAttributes = false;

732

733 bool canPredictProbs = MBB.canPredictBranchProbabilities();

734

735

736

737

738

739

740 if ((MBB.succ_empty() && SimplifyMIR) || !canPredictProbs ||

742 OS.indent(2) << "successors:";

743 if (MBB.succ_empty())

744 OS << " ";

746 for (auto I = MBB.succ_begin(), E = MBB.succ_end(); I != E; ++I) {

749 OS << format("(0x%08" PRIx32 ")",

750 MBB.getSuccProbability(I).getNumerator());

751 }

752 OS << "\n";

753 HasLineAttributes = true;

754 }

755

756

758 if (MBB.livein_empty()) {

760 OS.indent(2) << "liveins: ";

762 for (const auto &LI : MBB.liveins_dbg()) {

764 if (!LI.LaneMask.all())

766 }

767 OS << "\n";

768 HasLineAttributes = true;

769 }

770

771 if (HasLineAttributes && MBB.empty())

772 OS << "\n";

773 bool IsInBundle = false;

775 if (IsInBundle && MI.isInsideBundle()) {

776 OS.indent(2) << "}\n";

777 IsInBundle = false;

778 }

779 OS.indent(IsInBundle ? 4 : 2);

782 OS << " {";

783 IsInBundle = true;

784 }

785 OS << "\n";

786 }

787 if (IsInBundle)

788 OS.indent(2) << "}\n";

789}

790

793 const auto *MF = MI.getMF();

794 const auto &MRI = MF->getRegInfo();

795 const auto &SubTarget = MF->getSubtarget();

796 const auto *TRI = SubTarget.getRegisterInfo();

797 assert(TRI && "Expected target register info");

798 const auto *TII = SubTarget.getInstrInfo();

799 assert(TII && "Expected target instruction info");

800 if (MI.isCFIInstruction())

801 assert(MI.getNumOperands() == 1 && "Expected 1 operand in CFI instruction");

802

804 bool ShouldPrintRegisterTies = MI.hasComplexRegisterTies();

806 unsigned I = 0, E = MI.getNumOperands();

807 for (; I < E; ++I) {

810 break;

811 OS << LS;

813 PrintedTypes, MRI, false);

814 }

815

816 if (I)

817 OS << " = ";

819 OS << "frame-setup ";

821 OS << "frame-destroy ";

823 OS << "nnan ";

825 OS << "ninf ";

827 OS << "nsz ";

829 OS << "arcp ";

831 OS << "contract ";

833 OS << "afn ";

835 OS << "reassoc ";

837 OS << "nuw ";

839 OS << "nsw ";

841 OS << "exact ";

843 OS << "nofpexcept ";

845 OS << "nomerge ";

847 OS << "unpredictable ";

849 OS << "noconvergent ";

851 OS << "nneg ";

853 OS << "disjoint ";

855 OS << "nusw ";

857 OS << "samesign ";

859 OS << "inbounds ";

860

861

862

863

864 OS << TII->getName(MI.getOpcode());

865

866

868

869 for (; I < E; ++I) {

870 OS << LS;

872 PrintedTypes, MRI, true);

873 }

874

875

876

877 if (MCSymbol *PreInstrSymbol = MI.getPreInstrSymbol()) {

878 OS << LS << "pre-instr-symbol ";

880 }

881 if (MCSymbol *PostInstrSymbol = MI.getPostInstrSymbol()) {

882 OS << LS << "post-instr-symbol ";

884 }

885 if (MDNode *HeapAllocMarker = MI.getHeapAllocMarker()) {

886 OS << LS << "heap-alloc-marker ";

887 HeapAllocMarker->printAsOperand(OS, State.MST);

888 }

889 if (MDNode *PCSections = MI.getPCSections()) {

890 OS << LS << "pcsections ";

891 PCSections->printAsOperand(OS, State.MST);

892 }

893 if (MDNode *MMRA = MI.getMMRAMetadata()) {

894 OS << LS << "mmra ";

895 MMRA->printAsOperand(OS, State.MST);

896 }

897 if (uint32_t CFIType = MI.getCFIType())

898 OS << LS << "cfi-type " << CFIType;

899 if (Value *DS = MI.getDeactivationSymbol()) {

900 OS << LS << "deactivation-symbol ";

902 }

903

904 if (auto Num = MI.peekDebugInstrNum())

905 OS << LS << "debug-instr-number " << Num;

906

909 OS << LS << "debug-location ";

910 DL->printAsOperand(OS, State.MST);

911 }

912 }

913

914 if (MI.memoperands_empty()) {

915 OS << " :: ";

916 const LLVMContext &Context = MF->getFunction().getContext();

919 for (const auto *Op : MI.memoperands()) {

920 OS << LS;

921 Op->print(OS, State.MST, State.SSNs, Context, &MFI, TII);

922 }

923 }

924}

925

927 if (Comment.empty())

928 return Comment;

929 return std::string(" /* " + Comment + " */");

930}

931

936 bool ShouldPrintRegisterTies,

939 LLT TypeToPrint = MI.getTypeToPrint(OpIdx, PrintedTypes, MRI);

941 std::string MOComment = TII->createMIROperandComment(MI, Op, OpIdx, TRI);

942

943 switch (Op.getType()) {

945 if (MI.isOperandSubregIdx(OpIdx)) {

948 break;

949 }

950 [[fallthrough]];

970 unsigned TiedOperandIdx = 0;

971 if (ShouldPrintRegisterTies && Op.isReg() && Op.isTied() && Op.isDef())

972 TiedOperandIdx = Op.getParent()->findTiedOperandIdx(OpIdx);

973 Op.print(OS, State.MST, TypeToPrint, OpIdx, PrintDef,

974 false, ShouldPrintRegisterTies, TiedOperandIdx,

977 break;

978 }

981 break;

983 const auto &RegisterMaskIds = State.RegisterMaskIds;

984 auto RegMaskInfo = RegisterMaskIds.find(Op.getRegMask());

985 if (RegMaskInfo != RegisterMaskIds.end())

986 OS << StringRef(TRI->getRegMaskNames()[RegMaskInfo->second]).lower();

987 else

989 break;

990 }

991 }

992}

993

997 V.printAsOperand(OS, false, MST);

998 return;

999 }

1001

1002 OS << '`';

1003 V.printAsOperand(OS, true, MST);

1004 OS << '`';

1005 return;

1006 }

1007 OS << "%ir.";

1008 if (V.hasName()) {

1010 return;

1011 }

1014}

1015

1018 Out << const_cast<Module &>(M);

1019}

1020

unsigned const MachineRegisterInfo * MRI

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

const TargetInstrInfo & TII

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

Analysis containing CSE Info

This file defines the DenseMap class.

This file contains an interface for creating legacy passes to print out IR in various granularities.

Module.h This file contains the declarations for the Module class.

A common definition of LaneBitmask for use in TableGen and CodeGen.

Implement a low-level type suitable for MachineInstr level instruction selection.

static void convertCallSiteObjects(yaml::MachineFunction &YMF, const MachineFunction &MF, ModuleSlotTracker &MST)

Definition MIRPrinter.cpp:525

static void convertMCP(yaml::MachineFunction &MF, const MachineConstantPool &ConstantPool)

Definition MIRPrinter.cpp:599

static void printMI(raw_ostream &OS, MFPrintState &State, const MachineInstr &MI)

Definition MIRPrinter.cpp:791

static void convertSRPoints(ModuleSlotTracker &MST, std::vector< yaml::SaveRestorePointEntry > &YamlSRPoints, const llvm::SaveRestorePoints &SRPoints, const TargetRegisterInfo *TRI)

Definition MIRPrinter.cpp:621

static DenseMap< const uint32_t *, unsigned > initRegisterMaskIds(const MachineFunction &MF)

Definition MIRPrinter.cpp:130

static void convertCalledGlobals(yaml::MachineFunction &YMF, const MachineFunction &MF, MachineModuleSlotTracker &MST)

Definition MIRPrinter.cpp:577

static void printMBB(raw_ostream &OS, MFPrintState &State, const MachineBasicBlock &MBB)

Definition MIRPrinter.cpp:722

static std::string formatOperandComment(std::string Comment)

Definition MIRPrinter.cpp:926

static cl::opt< bool > PrintLocations("mir-debug-loc", cl::Hidden, cl::init(true), cl::desc("Print MIR debug-locations"))

static bool canPredictSuccessors(const MachineBasicBlock &MBB)

Definition MIRPrinter.cpp:693

static void convertStackObjects(yaml::MachineFunction &YMF, const MachineFunction &MF, ModuleSlotTracker &MST, MFPrintState &State)

Definition MIRPrinter.cpp:393

static void printMF(raw_ostream &OS, const MachineModuleInfo &MMI, const MachineFunction &MF)

Definition MIRPrinter.cpp:172

static void printStackObjectReference(raw_ostream &OS, const MFPrintState &State, int FrameIndex)

Definition MIRPrinter.cpp:382

static void convertEntryValueObjects(yaml::MachineFunction &YMF, const MachineFunction &MF, ModuleSlotTracker &MST)

Definition MIRPrinter.cpp:369

static void convertMRI(yaml::MachineFunction &YamlMF, const MachineFunction &MF, const MachineRegisterInfo &RegInfo, const TargetRegisterInfo *TRI)

Definition MIRPrinter.cpp:299

static void printStackObjectDbgInfo(const MachineFunction::VariableDbgInfo &DebugVar, T &Object, ModuleSlotTracker &MST)

Definition MIRPrinter.cpp:276

static void printCustomRegMask(const uint32_t *RegMask, raw_ostream &OS, const TargetRegisterInfo *TRI)

Definition MIRPrinter.cpp:248

static void convertMFI(ModuleSlotTracker &MST, yaml::MachineFrameInfo &YamlMFI, const MachineFrameInfo &MFI, const TargetRegisterInfo *TRI)

Definition MIRPrinter.cpp:341

static void printRegMIR(Register Reg, yaml::StringValue &Dest, const TargetRegisterInfo *TRI)

Definition MIRPrinter.cpp:123

static cl::opt< bool > SimplifyMIR("simplify-mir", cl::Hidden, cl::desc("Leave out unnecessary information when printing MIR"))

static void printMIOperand(raw_ostream &OS, MFPrintState &State, const MachineInstr &MI, unsigned OpIdx, const TargetRegisterInfo *TRI, const TargetInstrInfo *TII, bool ShouldPrintRegisterTies, SmallBitVector &PrintedTypes, const MachineRegisterInfo &MRI, bool PrintDef)

Definition MIRPrinter.cpp:932

static void printRegFlags(Register Reg, std::vector< yaml::FlowStringValue > &RegisterFlags, const MachineFunction &MF, const TargetRegisterInfo *TRI)

Definition MIRPrinter.cpp:290

static void convertMachineMetadataNodes(yaml::MachineFunction &YMF, const MachineFunction &MF, MachineModuleSlotTracker &MST)

Definition MIRPrinter.cpp:564

static void convertMJTI(ModuleSlotTracker &MST, yaml::MachineJumpTable &YamlJTI, const MachineJumpTableInfo &JTI)

Definition MIRPrinter.cpp:654

This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...

Register const TargetRegisterInfo * TRI

MachineInstr unsigned OpIdx

This file implements the SmallBitVector class.

This file defines the SmallPtrSet class.

This file defines the SmallVector class.

This class represents a function call, abstracting a target machine's calling convention.

The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...

This is an important base class in LLVM.

std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)

Module * getParent()

Get the module that this global value is contained inside of...

This is an important class for using LLVM in a threaded context.

A helper class to return the specified delimiter string after the first invocation of operator String...

Wrapper class representing physical registers. Should be passed by value.

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

static LLVM_ABI void printIRValue(raw_ostream &OS, const Value &V, ModuleSlotTracker &MST)

Helper functions to print IR value as MIR serialization format which will be useful for target specif...

Definition MIRPrinter.cpp:994

MachineInstrBundleIterator< const MachineInstr > const_iterator

@ PrintNameIr

Add IR name where available.

@ PrintNameAttributes

Print attributes.

Instructions::const_iterator const_instr_iterator

This class is a data container for one entry in a MachineConstantPool.

The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...

The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.

uint64_t getStackSize() const

Return the number of bytes that must be allocated to hold all of the fixed size frame objects.

const AllocaInst * getObjectAllocation(int ObjectIdx) const

Return the underlying Alloca of the specified stack object if it exists.

bool adjustsStack() const

Return true if this function adjusts the stack – e.g., when calling another function.

bool isReturnAddressTaken() const

This method may be called any time after instruction selection is complete to determine if there is a...

int64_t getLocalFrameObjectCount() const

Return the number of objects allocated into the local object block.

bool hasCalls() const

Return true if the current function has any function calls.

bool isFrameAddressTaken() const

This method may be called any time after instruction selection is complete to determine if there is a...

Align getMaxAlign() const

Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...

std::pair< int, int64_t > getLocalFrameObjectMap(int i) const

Get the local offset mapping for a for an object.

uint64_t getMaxCallFrameSize() const

Return the maximum size of a call frame that must be allocated for an outgoing function call.

bool hasPatchPoint() const

This method may be called any time after instruction selection is complete to determine if there is a...

bool hasOpaqueSPAdjustment() const

Returns true if the function contains opaque dynamic stack adjustments.

bool isImmutableObjectIndex(int ObjectIdx) const

Returns true if the specified index corresponds to an immutable object.

int getStackProtectorIndex() const

Return the index for the stack protector object.

int64_t getOffsetAdjustment() const

Return the correction for frame offsets.

bool hasTailCall() const

Returns true if the function contains a tail call.

bool hasMustTailInVarArgFunc() const

Returns true if the function is variadic and contains a musttail call.

bool isCalleeSavedInfoValid() const

Has the callee saved info been calculated yet?

Align getObjectAlign(int ObjectIdx) const

Return the alignment of the specified stack object.

bool isSpillSlotObjectIndex(int ObjectIdx) const

Returns true if the specified index corresponds to a spill slot.

int64_t getObjectSize(int ObjectIdx) const

Return the size of the specified object.

bool isMaxCallFrameSizeComputed() const

int64_t getLocalFrameSize() const

Get the size of the local object blob.

bool hasStackMap() const

This method may be called any time after instruction selection is complete to determine if there is a...

const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const

Returns a reference to call saved info vector for the current function.

bool hasVAStart() const

Returns true if the function calls the llvm.va_start intrinsic.

unsigned getCVBytesOfCalleeSavedRegisters() const

Returns how many bytes of callee-saved registers the target pushed in the prologue.

bool isVariableSizedObjectIndex(int ObjectIdx) const

Returns true if the specified index corresponds to a variable sized object.

int getObjectIndexEnd() const

Return one past the maximum frame object index.

bool hasStackProtectorIndex() const

uint8_t getStackID(int ObjectIdx) const

const SaveRestorePoints & getRestorePoints() const

unsigned getNumFixedObjects() const

Return the number of fixed objects.

int64_t getObjectOffset(int ObjectIdx) const

Return the assigned stack offset of the specified object from the incoming stack pointer.

bool hasFunctionContextIndex() const

int getObjectIndexBegin() const

Return the minimum frame object index.

const SaveRestorePoints & getSavePoints() const

bool isDeadObjectIndex(int ObjectIdx) const

Returns true if the specified index corresponds to a dead object.

int getFunctionContextIndex() const

Return the index for the function context object.

bool isAliasedObjectIndex(int ObjectIdx) const

Returns true if the specified index corresponds to an object that might be pointed to by an LLVM IR v...

Properties which a MachineFunction may have at a given point in time.

Description of the location of a variable whose Address is valid and unchanging during function execu...

const DILocalVariable * Var

const DIExpression * Expr

auto getEntryValueVariableDbgInfo() const

Returns the collection of variables for which we have debug info and that have been assigned an entry...

bool useDebugInstrRef() const

Returns true if the function's variable locations are tracked with instruction referencing.

SmallVector< DebugSubstitution, 8 > DebugValueSubstitutions

Debug value substitutions: a collection of DebugSubstitution objects, recording changes in where a va...

const TargetSubtargetInfo & getSubtarget() const

getSubtarget - Return the subtarget for which this machine code is being compiled.

StringRef getName() const

getName - Return the name of the corresponding LLVM function.

bool exposesReturnsTwice() const

exposesReturnsTwice - Returns true if the function calls setjmp or any other similar functions with a...

MachineFrameInfo & getFrameInfo()

getFrameInfo - Return the frame info object for the current function.

bool callsUnwindInit() const

const CallSiteInfoMap & getCallSitesInfo() const

bool callsEHReturn() const

MachineRegisterInfo & getRegInfo()

getRegInfo - Return information about the registers currently in use.

auto getInStackSlotVariableDbgInfo()

Returns the collection of variables for which we have debug info and that have been assigned a stack ...

Align getAlignment() const

getAlignment - Return the alignment of the function.

Function & getFunction()

Return the LLVM function that this machine code represents.

MachineConstantPool * getConstantPool()

getConstantPool - Return the constant pool object for the current function.

const MachineFunctionProperties & getProperties() const

Get the function properties.

bool hasEHFunclets() const

const MachineJumpTableInfo * getJumpTableInfo() const

getJumpTableInfo - Return the jump table info object for the current function.

auto getCalledGlobals() const

Iterates over the full set of call sites and their associated globals.

bool hasEHContTarget() const

const TargetMachine & getTarget() const

getTarget - Return the target machine this machine code is compiled with

BasicBlockListType::const_iterator const_iterator

Representation of each machine instruction.

JTEntryKind getEntryKind() const

const std::vector< MachineJumpTableEntry > & getJumpTables() const

This class contains meta information specific to a module.

void collectMachineMDNodes(MachineMDNodeListType &L) const

MachineOperand class - Representation of each machine instruction operand.

static LLVM_ABI void printStackObjectReference(raw_ostream &OS, unsigned FrameIndex, bool IsFixed, StringRef Name)

Print a stack object reference.

static LLVM_ABI void printSubRegIdx(raw_ostream &OS, uint64_t Index, const TargetRegisterInfo *TRI)

Print a subreg index operand.

static LLVM_ABI void printTargetFlags(raw_ostream &OS, const MachineOperand &Op)

Print operand target flags.

bool isReg() const

isReg - Tests if this is a MO_Register operand.

static LLVM_ABI void printIRSlotNumber(raw_ostream &OS, int Slot)

Print an IRSlotNumber.

static LLVM_ABI void printSymbol(raw_ostream &OS, MCSymbol &Sym)

Print a MCSymbol as an operand.

@ MO_CFIIndex

MCCFIInstruction index.

@ MO_Immediate

Immediate operand.

@ MO_ConstantPoolIndex

Address of indexed Constant in Constant Pool.

@ MO_MCSymbol

MCSymbol reference (for debug/eh info)

@ MO_Predicate

Generic predicate for ISel.

@ MO_GlobalAddress

Address of a global value.

@ MO_RegisterMask

Mask of preserved registers.

@ MO_ShuffleMask

Other IR Constant for ISel (shuffle masks)

@ MO_CImmediate

Immediate >64bit operand.

@ MO_BlockAddress

Address of a basic block.

@ MO_DbgInstrRef

Integer indices referring to an instruction+operand.

@ MO_MachineBasicBlock

MachineBasicBlock reference.

@ MO_LaneMask

Mask to represent active parts of registers.

@ MO_FrameIndex

Abstract Stack Frame Index.

@ MO_Register

Register operand.

@ MO_ExternalSymbol

Name of external global symbol.

@ MO_IntrinsicID

Intrinsic ID for ISel.

@ MO_JumpTableIndex

Address of indexed Jump Table for switch.

@ MO_TargetIndex

Target-dependent index+offset operand.

@ MO_Metadata

Metadata reference (for debug info)

@ MO_FPImmediate

Floating-point immediate operand.

@ MO_RegisterLiveOut

Mask of live-out registers.

MachineRegisterInfo - Keep track of information for virtual and physical registers,...

Manage lifetime of a slot tracker for printing IR.

std::vector< std::pair< unsigned, const MDNode * > > MachineMDNodeListType

int getLocalSlot(const Value *V)

Return the slot number of the specified local value.

const Function * getCurrentFunction() const

void incorporateFunction(const Function &F)

Incorporate the given function.

A Module instance is used to store all the information related to an LLVM module.

Wrapper class representing virtual and physical registers.

static Register index2VirtReg(unsigned Index)

Convert a 0-based index to a virtual register number.

This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...

std::pair< iterator, bool > insert(PtrType Ptr)

Inserts Ptr if and only if there is no element in the container equal to Ptr.

SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

void reserve(size_type N)

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

std::string str() const

str - Get the contents as an std::string.

LLVM_ABI std::string lower() const

TargetInstrInfo - Interface to description of machine instruction set.

Primary interface to the complete machine description for the target machine.

virtual yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const

Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.

TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...

virtual const TargetRegisterInfo * getRegisterInfo() const =0

Return the target's register information.

LLVM Value Representation.

LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const

Implement operator<< on Value.

LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const

Print the name of this Value out to the specified raw_ostream.

const ParentTy * getParent() const

self_iterator getIterator()

This class implements an extremely fast bulk output stream that can only output to a stream.

raw_ostream & indent(unsigned NumSpaces)

indent - Insert 'NumSpaces' spaces.

A raw_ostream that writes to an std::string.

A raw_ostream that writes to an SmallVector or SmallString.

StringRef str() const

Return a StringRef for the vector contents.

The Output class is used to generate a yaml document from in-memory structs and vectors.

void setWriteDefaultValues(bool Write)

Set whether or not to output optional values which are equal to the default value....

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

initializer< Ty > init(const Ty &Val)

This is an optimization pass for GlobalISel generic memory operations.

Printable PrintLaneMask(LaneBitmask LaneMask)

Create Printable object to print LaneBitmasks on a raw_ostream.

LLVM_ABI void printMIR(raw_ostream &OS, const Module &M)

Print LLVM IR using the MIR serialization format to the given output stream.

Definition MIRPrinter.cpp:1016

LLVM_ABI void guessSuccessors(const MachineBasicBlock &MBB, SmallVectorImpl< MachineBasicBlock * > &Result, bool &IsFallthrough)

Determine a possible list of successors of a basic block based on the basic block machine operand bei...

Definition MIRPrinter.cpp:672

DenseMap< MachineBasicBlock *, std::vector< CalleeSavedInfo > > SaveRestorePoints

void sort(IteratorTy Start, IteratorTy End)

LLVM_ABI Printable printRegClassOrBank(Register Reg, const MachineRegisterInfo &RegInfo, const TargetRegisterInfo *TRI)

Create Printable object to print register classes or register banks on a raw_ostream.

class LLVM_GSL_OWNER SmallVector

Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

@ Mod

The access may modify the value stored in memory.

@ Sub

Subtraction of integers.

uint16_t MCPhysReg

An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...

FunctionAddr VTableAddr Next

DWARFExpression::Operation Op

bool is_contained(R &&Range, const E &Element)

Returns true if Element is found in Range.

LLVM_ABI void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name)

Print out a name of an LLVM value without any prefixes.

LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)

Prints virtual and physical registers with or without a TRI instance.

LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)

Prints a machine basic block reference.

constexpr uint64_t value() const

This is a hole in the type system and should not be abused.

This class should be specialized by type that requires custom conversion to/from a YAML literal block...

Serializable representation of CallSiteInfo.

std::vector< uint64_t > CalleeTypeIds

Numeric callee type identifiers for the callgraph section.

std::vector< ArgRegPair > ArgForwardingRegs

MachineInstrLoc CallLocation

Serializable representation of the MCRegister variant of MachineFunction::VariableDbgInfo.

Serializable representation of the fixed stack object from the MachineFrameInfo class.

TargetStackID::Value StackID

Serializable representation of MachineFrameInfo.

std::vector< SaveRestorePointEntry > RestorePoints

bool IsCalleeSavedInfoValid

unsigned MaxCallFrameSize

~0u means: not computed yet.

StringValue StackProtector

std::vector< SaveRestorePointEntry > SavePoints

bool HasMustTailInVarArgFunc

unsigned CVBytesOfCalleeSavedRegisters

bool HasOpaqueSPAdjustment

bool IsReturnAddressTaken

StringValue FunctionContext

StringValue VirtualRegister

std::vector< MachineStackObject > StackObjects

std::vector< StringValue > MachineMetadataNodes

std::optional< std::vector< FlowStringValue > > CalleeSavedRegisters

std::vector< CalledGlobal > CalledGlobals

std::optional< bool > HasFakeUses

std::vector< EntryValueObject > EntryValueObjects

std::optional< bool > NoPHIs

bool TracksDebugUserValues

std::vector< MachineConstantPoolValue > Constants

std::optional< bool > NoVRegs

std::vector< CallSiteInfo > CallSitesInfo

std::vector< MachineFunctionLiveIn > LiveIns

std::vector< VirtualRegisterDefinition > VirtualRegisters

std::vector< FixedMachineStackObject > FixedStackObjects

std::optional< bool > IsSSA

std::vector< DebugValueSubstitution > DebugValueSubstitutions

std::unique_ptr< MachineFunctionInfo > MachineFuncInfo

Constant pool.

MachineJumpTable JumpTableInfo

MachineFrameInfo FrameInfo

Identifies call instruction location in machine function.

std::vector< Entry > Entries

MachineJumpTableInfo::JTEntryKind Kind

Serializable representation of stack object from the MachineFrameInfo class.

TargetStackID::Value StackID

A wrapper around std::string which contains a source range that's being set during parsing.

std::vector< FlowStringValue > RegisterFlags

StringValue PreferredRegister

static void output(const Module &Mod, void *Ctxt, raw_ostream &OS)

Definition MIRPrinter.cpp:113

static StringRef input(StringRef Str, void *Ctxt, Module &Mod)

Definition MIRPrinter.cpp:117