LLVM 19.0.0git
MIRPrinter.cpp
Go to the documentation of this file.
1//===- MIRPrinter.cpp - MIR serialization format printer ------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the class that prints out the LLVM IR and machine
10// functions using the MIR serialization format.
11//
12//===----------------------------------------------------------------------===//
13
15#include "llvm/ADT/DenseMap.h"
16#include "llvm/ADT/STLExtras.h"
20#include "llvm/ADT/StringRef.h"
38#include "llvm/IR/DebugLoc.h"
39#include "llvm/IR/Function.h"
42#include "llvm/IR/Module.h"
44#include "llvm/IR/Value.h"
45#include "llvm/MC/LaneBitmask.h"
50#include "llvm/Support/Format.h"
54#include <algorithm>
55#include <cassert>
56#include <cinttypes>
57#include <cstdint>
58#include <iterator>
59#include <string>
60#include <utility>
61#include <vector>
62
63using namespace llvm;
64
66 "simplify-mir", cl::Hidden,
67 cl::desc("Leave out unnecessary information when printing MIR"));
68
69static cl::opt<bool> PrintLocations("mir-debug-loc", cl::Hidden, cl::init(true),
70 cl::desc("Print MIR debug-locations"));
71
73
74namespace {
75
76/// This structure describes how to print out stack object references.
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 /// Return an ordinary stack object reference.
86 static FrameIndexOperand create(StringRef Name, unsigned ID) {
87 return FrameIndexOperand(Name, ID, /*IsFixed=*/false);
88 }
89
90 /// Return a fixed stack object reference.
91 static FrameIndexOperand createFixed(unsigned ID) {
92 return FrameIndexOperand("", ID, /*IsFixed=*/true);
93 }
94};
95
96} // end anonymous namespace
97
98namespace llvm {
99
100/// This class prints out the machine functions using the MIR serialization
101/// format.
103 raw_ostream &OS;
105 /// Maps from stack object indices to operand indices which will be used when
106 /// printing frame index machine operands.
107 DenseMap<int, FrameIndexOperand> StackObjectOperandMapping;
108
109public:
111
112 void print(const MachineFunction &MF);
113
114 void convert(yaml::MachineFunction &MF, const MachineRegisterInfo &RegInfo,
115 const TargetRegisterInfo *TRI);
117 const MachineFrameInfo &MFI);
121 const MachineJumpTableInfo &JTI);
123 const MachineFunction &MF, ModuleSlotTracker &MST);
125 const MachineFunction &MF,
126 ModuleSlotTracker &MST);
128 const MachineFunction &MF,
129 ModuleSlotTracker &MST);
131 const MachineFunction &MF,
133
134private:
135 void initRegisterMaskIds(const MachineFunction &MF);
136};
137
138/// This class prints out the machine instructions using the MIR serialization
139/// format.
141 raw_ostream &OS;
143 const DenseMap<const uint32_t *, unsigned> &RegisterMaskIds;
144 const DenseMap<int, FrameIndexOperand> &StackObjectOperandMapping;
145 /// Synchronization scope names registered with LLVMContext.
147
148 bool canPredictBranchProbabilities(const MachineBasicBlock &MBB) const;
149 bool canPredictSuccessors(const MachineBasicBlock &MBB) const;
150
151public:
153 const DenseMap<const uint32_t *, unsigned> &RegisterMaskIds,
154 const DenseMap<int, FrameIndexOperand> &StackObjectOperandMapping)
155 : OS(OS), MST(MST), RegisterMaskIds(RegisterMaskIds),
156 StackObjectOperandMapping(StackObjectOperandMapping) {}
157
158 void print(const MachineBasicBlock &MBB);
159
160 void print(const MachineInstr &MI);
161 void printStackObjectReference(int FrameIndex);
162 void print(const MachineInstr &MI, unsigned OpIdx,
164 bool ShouldPrintRegisterTies, LLT TypeToPrint,
165 bool PrintDef = true);
166};
167
168} // end namespace llvm
169
170namespace llvm {
171namespace yaml {
172
173/// This struct serializes the LLVM IR module.
174template <> struct BlockScalarTraits<Module> {
175 static void output(const Module &Mod, void *Ctxt, raw_ostream &OS) {
176 Mod.print(OS, nullptr);
177 }
178
179 static StringRef input(StringRef Str, void *Ctxt, Module &Mod) {
180 llvm_unreachable("LLVM Module is supposed to be parsed separately");
181 return "";
182 }
183};
184
185} // end namespace yaml
186} // end namespace llvm
187
188static void printRegMIR(unsigned Reg, yaml::StringValue &Dest,
189 const TargetRegisterInfo *TRI) {
191 OS << printReg(Reg, TRI);
192}
193
195 initRegisterMaskIds(MF);
196
198 YamlMF.Name = MF.getName();
199 YamlMF.Alignment = MF.getAlignment();
201 YamlMF.HasWinCFI = MF.hasWinCFI();
202
203 YamlMF.CallsEHReturn = MF.callsEHReturn();
204 YamlMF.CallsUnwindInit = MF.callsUnwindInit();
205 YamlMF.HasEHCatchret = MF.hasEHCatchret();
206 YamlMF.HasEHScopes = MF.hasEHScopes();
207 YamlMF.HasEHFunclets = MF.hasEHFunclets();
208 YamlMF.IsOutlined = MF.isOutlined();
210
211 YamlMF.Legalized = MF.getProperties().hasProperty(
215 YamlMF.Selected = MF.getProperties().hasProperty(
223
224 convert(YamlMF, MF.getRegInfo(), MF.getSubtarget().getRegisterInfo());
227 convert(MST, YamlMF.FrameInfo, MF.getFrameInfo());
228 convertStackObjects(YamlMF, MF, MST);
229 convertEntryValueObjects(YamlMF, MF, MST);
230 convertCallSiteObjects(YamlMF, MF, MST);
231 for (const auto &Sub : MF.DebugValueSubstitutions) {
232 const auto &SubSrc = Sub.Src;
233 const auto &SubDest = Sub.Dest;
234 YamlMF.DebugValueSubstitutions.push_back({SubSrc.first, SubSrc.second,
235 SubDest.first,
236 SubDest.second,
237 Sub.Subreg});
238 }
239 if (const auto *ConstantPool = MF.getConstantPool())
240 convert(YamlMF, *ConstantPool);
241 if (const auto *JumpTableInfo = MF.getJumpTableInfo())
242 convert(MST, YamlMF.JumpTableInfo, *JumpTableInfo);
243
244 const TargetMachine &TM = MF.getTarget();
245 YamlMF.MachineFuncInfo =
246 std::unique_ptr<yaml::MachineFunctionInfo>(TM.convertFuncInfoToYAML(MF));
247
248 raw_string_ostream StrOS(YamlMF.Body.Value.Value);
249 bool IsNewlineNeeded = false;
250 for (const auto &MBB : MF) {
251 if (IsNewlineNeeded)
252 StrOS << "\n";
253 MIPrinter(StrOS, MST, RegisterMaskIds, StackObjectOperandMapping)
254 .print(MBB);
255 IsNewlineNeeded = true;
256 }
257 StrOS.flush();
258 // Convert machine metadata collected during the print of the machine
259 // function.
260 convertMachineMetadataNodes(YamlMF, MF, MST);
261
262 yaml::Output Out(OS);
263 if (!SimplifyMIR)
264 Out.setWriteDefaultValues(true);
265 Out << YamlMF;
266}
267
268static void printCustomRegMask(const uint32_t *RegMask, raw_ostream &OS,
269 const TargetRegisterInfo *TRI) {
270 assert(RegMask && "Can't print an empty register mask");
271 OS << StringRef("CustomRegMask(");
272
273 bool IsRegInRegMaskFound = false;
274 for (int I = 0, E = TRI->getNumRegs(); I < E; I++) {
275 // Check whether the register is asserted in regmask.
276 if (RegMask[I / 32] & (1u << (I % 32))) {
277 if (IsRegInRegMaskFound)
278 OS << ',';
279 OS << printReg(I, TRI);
280 IsRegInRegMaskFound = true;
281 }
282 }
283
284 OS << ')';
285}
286
287static void printRegClassOrBank(unsigned Reg, yaml::StringValue &Dest,
289 const TargetRegisterInfo *TRI) {
292}
293
294template <typename T>
295static void
297 T &Object, ModuleSlotTracker &MST) {
298 std::array<std::string *, 3> Outputs{{&Object.DebugVar.Value,
299 &Object.DebugExpr.Value,
300 &Object.DebugLoc.Value}};
301 std::array<const Metadata *, 3> Metas{{DebugVar.Var,
302 DebugVar.Expr,
303 DebugVar.Loc}};
304 for (unsigned i = 0; i < 3; ++i) {
305 raw_string_ostream StrOS(*Outputs[i]);
306 Metas[i]->printAsOperand(StrOS, MST);
307 }
308}
309
311 const MachineRegisterInfo &RegInfo,
312 const TargetRegisterInfo *TRI) {
313 MF.TracksRegLiveness = RegInfo.tracksLiveness();
314
315 // Print the virtual register definitions.
316 for (unsigned I = 0, E = RegInfo.getNumVirtRegs(); I < E; ++I) {
319 VReg.ID = I;
320 if (RegInfo.getVRegName(Reg) != "")
321 continue;
322 ::printRegClassOrBank(Reg, VReg.Class, RegInfo, TRI);
323 Register PreferredReg = RegInfo.getSimpleHint(Reg);
324 if (PreferredReg)
325 printRegMIR(PreferredReg, VReg.PreferredRegister, TRI);
326 MF.VirtualRegisters.push_back(VReg);
327 }
328
329 // Print the live ins.
330 for (std::pair<unsigned, unsigned> LI : RegInfo.liveins()) {
332 printRegMIR(LI.first, LiveIn.Register, TRI);
333 if (LI.second)
334 printRegMIR(LI.second, LiveIn.VirtualRegister, TRI);
335 MF.LiveIns.push_back(LiveIn);
336 }
337
338 // Prints the callee saved registers.
339 if (RegInfo.isUpdatedCSRsInitialized()) {
340 const MCPhysReg *CalleeSavedRegs = RegInfo.getCalleeSavedRegs();
341 std::vector<yaml::FlowStringValue> CalleeSavedRegisters;
342 for (const MCPhysReg *I = CalleeSavedRegs; *I; ++I) {
344 printRegMIR(*I, Reg, TRI);
345 CalleeSavedRegisters.push_back(Reg);
346 }
347 MF.CalleeSavedRegisters = CalleeSavedRegisters;
348 }
349}
350
352 yaml::MachineFrameInfo &YamlMFI,
353 const MachineFrameInfo &MFI) {
356 YamlMFI.HasStackMap = MFI.hasStackMap();
357 YamlMFI.HasPatchPoint = MFI.hasPatchPoint();
358 YamlMFI.StackSize = MFI.getStackSize();
360 YamlMFI.MaxAlignment = MFI.getMaxAlign().value();
361 YamlMFI.AdjustsStack = MFI.adjustsStack();
362 YamlMFI.HasCalls = MFI.hasCalls();
364 ? MFI.getMaxCallFrameSize() : ~0u;
368 YamlMFI.HasVAStart = MFI.hasVAStart();
370 YamlMFI.HasTailCall = MFI.hasTailCall();
372 YamlMFI.LocalFrameSize = MFI.getLocalFrameSize();
373 if (MFI.getSavePoint()) {
374 raw_string_ostream StrOS(YamlMFI.SavePoint.Value);
375 StrOS << printMBBReference(*MFI.getSavePoint());
376 }
377 if (MFI.getRestorePoint()) {
379 StrOS << printMBBReference(*MFI.getRestorePoint());
380 }
381}
382
384 const MachineFunction &MF,
385 ModuleSlotTracker &MST) {
387 for (const MachineFunction::VariableDbgInfo &DebugVar :
389 yaml::EntryValueObject &Obj = YMF.EntryValueObjects.emplace_back();
390 printStackObjectDbgInfo(DebugVar, Obj, MST);
391 MCRegister EntryValReg = DebugVar.getEntryValueRegister();
392 printRegMIR(EntryValReg, Obj.EntryValueRegister, TRI);
393 }
394}
395
397 const MachineFunction &MF,
398 ModuleSlotTracker &MST) {
399 const MachineFrameInfo &MFI = MF.getFrameInfo();
401
402 // Process fixed stack objects.
403 assert(YMF.FixedStackObjects.empty());
404 SmallVector<int, 32> FixedStackObjectsIdx;
405 const int BeginIdx = MFI.getObjectIndexBegin();
406 if (BeginIdx < 0)
407 FixedStackObjectsIdx.reserve(-BeginIdx);
408
409 unsigned ID = 0;
410 for (int I = BeginIdx; I < 0; ++I, ++ID) {
411 FixedStackObjectsIdx.push_back(-1); // Fill index for possible dead.
412 if (MFI.isDeadObjectIndex(I))
413 continue;
414
416 YamlObject.ID = ID;
417 YamlObject.Type = MFI.isSpillSlotObjectIndex(I)
420 YamlObject.Offset = MFI.getObjectOffset(I);
421 YamlObject.Size = MFI.getObjectSize(I);
422 YamlObject.Alignment = MFI.getObjectAlign(I);
423 YamlObject.StackID = (TargetStackID::Value)MFI.getStackID(I);
424 YamlObject.IsImmutable = MFI.isImmutableObjectIndex(I);
425 YamlObject.IsAliased = MFI.isAliasedObjectIndex(I);
426 // Save the ID' position in FixedStackObjects storage vector.
427 FixedStackObjectsIdx[ID] = YMF.FixedStackObjects.size();
428 YMF.FixedStackObjects.push_back(YamlObject);
429 StackObjectOperandMapping.insert(
430 std::make_pair(I, FrameIndexOperand::createFixed(ID)));
431 }
432
433 // Process ordinary stack objects.
434 assert(YMF.StackObjects.empty());
435 SmallVector<unsigned, 32> StackObjectsIdx;
436 const int EndIdx = MFI.getObjectIndexEnd();
437 if (EndIdx > 0)
438 StackObjectsIdx.reserve(EndIdx);
439 ID = 0;
440 for (int I = 0; I < EndIdx; ++I, ++ID) {
441 StackObjectsIdx.push_back(-1); // Fill index for possible dead.
442 if (MFI.isDeadObjectIndex(I))
443 continue;
444
445 yaml::MachineStackObject YamlObject;
446 YamlObject.ID = ID;
447 if (const auto *Alloca = MFI.getObjectAllocation(I))
448 YamlObject.Name.Value = std::string(
449 Alloca->hasName() ? Alloca->getName() : "");
450 YamlObject.Type = MFI.isSpillSlotObjectIndex(I)
455 YamlObject.Offset = MFI.getObjectOffset(I);
456 YamlObject.Size = MFI.getObjectSize(I);
457 YamlObject.Alignment = MFI.getObjectAlign(I);
458 YamlObject.StackID = (TargetStackID::Value)MFI.getStackID(I);
459
460 // Save the ID' position in StackObjects storage vector.
461 StackObjectsIdx[ID] = YMF.StackObjects.size();
462 YMF.StackObjects.push_back(YamlObject);
463 StackObjectOperandMapping.insert(std::make_pair(
464 I, FrameIndexOperand::create(YamlObject.Name.Value, ID)));
465 }
466
467 for (const auto &CSInfo : MFI.getCalleeSavedInfo()) {
468 const int FrameIdx = CSInfo.getFrameIdx();
469 if (!CSInfo.isSpilledToReg() && MFI.isDeadObjectIndex(FrameIdx))
470 continue;
471
473 printRegMIR(CSInfo.getReg(), Reg, TRI);
474 if (!CSInfo.isSpilledToReg()) {
475 assert(FrameIdx >= MFI.getObjectIndexBegin() &&
476 FrameIdx < MFI.getObjectIndexEnd() &&
477 "Invalid stack object index");
478 if (FrameIdx < 0) { // Negative index means fixed objects.
479 auto &Object =
481 [FixedStackObjectsIdx[FrameIdx + MFI.getNumFixedObjects()]];
482 Object.CalleeSavedRegister = Reg;
483 Object.CalleeSavedRestored = CSInfo.isRestored();
484 } else {
485 auto &Object = YMF.StackObjects[StackObjectsIdx[FrameIdx]];
486 Object.CalleeSavedRegister = Reg;
487 Object.CalleeSavedRestored = CSInfo.isRestored();
488 }
489 }
490 }
491 for (unsigned I = 0, E = MFI.getLocalFrameObjectCount(); I < E; ++I) {
492 auto LocalObject = MFI.getLocalFrameObjectMap(I);
493 assert(LocalObject.first >= 0 && "Expected a locally mapped stack object");
494 YMF.StackObjects[StackObjectsIdx[LocalObject.first]].LocalOffset =
495 LocalObject.second;
496 }
497
498 // Print the stack object references in the frame information class after
499 // converting the stack objects.
500 if (MFI.hasStackProtectorIndex()) {
502 MIPrinter(StrOS, MST, RegisterMaskIds, StackObjectOperandMapping)
504 }
505
506 if (MFI.hasFunctionContextIndex()) {
508 MIPrinter(StrOS, MST, RegisterMaskIds, StackObjectOperandMapping)
510 }
511
512 // Print the debug variable information.
513 for (const MachineFunction::VariableDbgInfo &DebugVar :
515 int Idx = DebugVar.getStackSlot();
516 assert(Idx >= MFI.getObjectIndexBegin() && Idx < MFI.getObjectIndexEnd() &&
517 "Invalid stack object index");
518 if (Idx < 0) { // Negative index means fixed objects.
519 auto &Object =
520 YMF.FixedStackObjects[FixedStackObjectsIdx[Idx +
521 MFI.getNumFixedObjects()]];
522 printStackObjectDbgInfo(DebugVar, Object, MST);
523 } else {
524 auto &Object = YMF.StackObjects[StackObjectsIdx[Idx]];
525 printStackObjectDbgInfo(DebugVar, Object, MST);
526 }
527 }
528}
529
531 const MachineFunction &MF,
532 ModuleSlotTracker &MST) {
533 const auto *TRI = MF.getSubtarget().getRegisterInfo();
534 for (auto CSInfo : MF.getCallSitesInfo()) {
535 yaml::CallSiteInfo YmlCS;
537
538 // Prepare instruction position.
539 MachineBasicBlock::const_instr_iterator CallI = CSInfo.first->getIterator();
540 CallLocation.BlockNum = CallI->getParent()->getNumber();
541 // Get call instruction offset from the beginning of block.
542 CallLocation.Offset =
543 std::distance(CallI->getParent()->instr_begin(), CallI);
544 YmlCS.CallLocation = CallLocation;
545 // Construct call arguments and theirs forwarding register info.
546 for (auto ArgReg : CSInfo.second.ArgRegPairs) {
548 YmlArgReg.ArgNo = ArgReg.ArgNo;
549 printRegMIR(ArgReg.Reg, YmlArgReg.Reg, TRI);
550 YmlCS.ArgForwardingRegs.emplace_back(YmlArgReg);
551 }
552 YMF.CallSitesInfo.push_back(YmlCS);
553 }
554
555 // Sort call info by position of call instructions.
556 llvm::sort(YMF.CallSitesInfo.begin(), YMF.CallSitesInfo.end(),
558 if (A.CallLocation.BlockNum == B.CallLocation.BlockNum)
559 return A.CallLocation.Offset < B.CallLocation.Offset;
560 return A.CallLocation.BlockNum < B.CallLocation.BlockNum;
561 });
562}
563
565 const MachineFunction &MF,
568 MST.collectMachineMDNodes(MDList);
569 for (auto &MD : MDList) {
570 std::string NS;
571 raw_string_ostream StrOS(NS);
572 MD.second->print(StrOS, MST, MF.getFunction().getParent());
573 YMF.MachineMetadataNodes.push_back(StrOS.str());
574 }
575}
576
579 unsigned ID = 0;
580 for (const MachineConstantPoolEntry &Constant : ConstantPool.getConstants()) {
581 std::string Str;
582 raw_string_ostream StrOS(Str);
583 if (Constant.isMachineConstantPoolEntry()) {
584 Constant.Val.MachineCPVal->print(StrOS);
585 } else {
586 Constant.Val.ConstVal->printAsOperand(StrOS);
587 }
588
590 YamlConstant.ID = ID++;
591 YamlConstant.Value = StrOS.str();
592 YamlConstant.Alignment = Constant.getAlign();
593 YamlConstant.IsTargetSpecific = Constant.isMachineConstantPoolEntry();
594
595 MF.Constants.push_back(YamlConstant);
596 }
597}
598
600 yaml::MachineJumpTable &YamlJTI,
601 const MachineJumpTableInfo &JTI) {
602 YamlJTI.Kind = JTI.getEntryKind();
603 unsigned ID = 0;
604 for (const auto &Table : JTI.getJumpTables()) {
605 std::string Str;
607 Entry.ID = ID++;
608 for (const auto *MBB : Table.MBBs) {
609 raw_string_ostream StrOS(Str);
610 StrOS << printMBBReference(*MBB);
611 Entry.Blocks.push_back(StrOS.str());
612 Str.clear();
613 }
614 YamlJTI.Entries.push_back(Entry);
615 }
616}
617
618void MIRPrinter::initRegisterMaskIds(const MachineFunction &MF) {
619 const auto *TRI = MF.getSubtarget().getRegisterInfo();
620 unsigned I = 0;
621 for (const uint32_t *Mask : TRI->getRegMasks())
622 RegisterMaskIds.insert(std::make_pair(Mask, I++));
623}
624
627 bool &IsFallthrough) {
629
630 for (const MachineInstr &MI : MBB) {
631 if (MI.isPHI())
632 continue;
633 for (const MachineOperand &MO : MI.operands()) {
634 if (!MO.isMBB())
635 continue;
636 MachineBasicBlock *Succ = MO.getMBB();
637 auto RP = Seen.insert(Succ);
638 if (RP.second)
639 Result.push_back(Succ);
640 }
641 }
643 IsFallthrough = I == MBB.end() || !I->isBarrier();
644}
645
646bool
647MIPrinter::canPredictBranchProbabilities(const MachineBasicBlock &MBB) const {
648 if (MBB.succ_size() <= 1)
649 return true;
651 return true;
652
653 SmallVector<BranchProbability,8> Normalized(MBB.Probs.begin(),
654 MBB.Probs.end());
656 Normalized.end());
657 SmallVector<BranchProbability,8> Equal(Normalized.size());
658 BranchProbability::normalizeProbabilities(Equal.begin(), Equal.end());
659
660 return std::equal(Normalized.begin(), Normalized.end(), Equal.begin());
661}
662
663bool MIPrinter::canPredictSuccessors(const MachineBasicBlock &MBB) const {
665 bool GuessedFallthrough;
666 guessSuccessors(MBB, GuessedSuccs, GuessedFallthrough);
667 if (GuessedFallthrough) {
668 const MachineFunction &MF = *MBB.getParent();
670 if (NextI != MF.end()) {
671 MachineBasicBlock *Next = const_cast<MachineBasicBlock*>(&*NextI);
672 if (!is_contained(GuessedSuccs, Next))
673 GuessedSuccs.push_back(Next);
674 }
675 }
676 if (GuessedSuccs.size() != MBB.succ_size())
677 return false;
678 return std::equal(MBB.succ_begin(), MBB.succ_end(), GuessedSuccs.begin());
679}
680
682 assert(MBB.getNumber() >= 0 && "Invalid MBB number");
683 MBB.printName(OS,
686 &MST);
687 OS << ":\n";
688
689 bool HasLineAttributes = false;
690 // Print the successors
691 bool canPredictProbs = canPredictBranchProbabilities(MBB);
692 // Even if the list of successors is empty, if we cannot guess it,
693 // we need to print it to tell the parser that the list is empty.
694 // This is needed, because MI model unreachable as empty blocks
695 // with an empty successor list. If the parser would see that
696 // without the successor list, it would guess the code would
697 // fallthrough.
698 if ((!MBB.succ_empty() && !SimplifyMIR) || !canPredictProbs ||
699 !canPredictSuccessors(MBB)) {
700 OS.indent(2) << "successors:";
701 if (!MBB.succ_empty())
702 OS << " ";
703 for (auto I = MBB.succ_begin(), E = MBB.succ_end(); I != E; ++I) {
704 if (I != MBB.succ_begin())
705 OS << ", ";
706 OS << printMBBReference(**I);
707 if (!SimplifyMIR || !canPredictProbs)
708 OS << '('
709 << format("0x%08" PRIx32, MBB.getSuccProbability(I).getNumerator())
710 << ')';
711 }
712 OS << "\n";
713 HasLineAttributes = true;
714 }
715
716 // Print the live in registers.
718 if (!MBB.livein_empty()) {
719 const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
720 OS.indent(2) << "liveins: ";
721 bool First = true;
722 for (const auto &LI : MBB.liveins_dbg()) {
723 if (!First)
724 OS << ", ";
725 First = false;
726 OS << printReg(LI.PhysReg, &TRI);
727 if (!LI.LaneMask.all())
728 OS << ":0x" << PrintLaneMask(LI.LaneMask);
729 }
730 OS << "\n";
731 HasLineAttributes = true;
732 }
733
734 if (HasLineAttributes && !MBB.empty())
735 OS << "\n";
736 bool IsInBundle = false;
737 for (const MachineInstr &MI : MBB.instrs()) {
738 if (IsInBundle && !MI.isInsideBundle()) {
739 OS.indent(2) << "}\n";
740 IsInBundle = false;
741 }
742 OS.indent(IsInBundle ? 4 : 2);
743 print(MI);
744 if (!IsInBundle && MI.getFlag(MachineInstr::BundledSucc)) {
745 OS << " {";
746 IsInBundle = true;
747 }
748 OS << "\n";
749 }
750 if (IsInBundle)
751 OS.indent(2) << "}\n";
752}
753
755 const auto *MF = MI.getMF();
756 const auto &MRI = MF->getRegInfo();
757 const auto &SubTarget = MF->getSubtarget();
758 const auto *TRI = SubTarget.getRegisterInfo();
759 assert(TRI && "Expected target register info");
760 const auto *TII = SubTarget.getInstrInfo();
761 assert(TII && "Expected target instruction info");
762 if (MI.isCFIInstruction())
763 assert(MI.getNumOperands() == 1 && "Expected 1 operand in CFI instruction");
764
765 SmallBitVector PrintedTypes(8);
766 bool ShouldPrintRegisterTies = MI.hasComplexRegisterTies();
767 unsigned I = 0, E = MI.getNumOperands();
768 for (; I < E && MI.getOperand(I).isReg() && MI.getOperand(I).isDef() &&
769 !MI.getOperand(I).isImplicit();
770 ++I) {
771 if (I)
772 OS << ", ";
773 print(MI, I, TRI, TII, ShouldPrintRegisterTies,
774 MI.getTypeToPrint(I, PrintedTypes, MRI),
775 /*PrintDef=*/false);
776 }
777
778 if (I)
779 OS << " = ";
780 if (MI.getFlag(MachineInstr::FrameSetup))
781 OS << "frame-setup ";
782 if (MI.getFlag(MachineInstr::FrameDestroy))
783 OS << "frame-destroy ";
784 if (MI.getFlag(MachineInstr::FmNoNans))
785 OS << "nnan ";
786 if (MI.getFlag(MachineInstr::FmNoInfs))
787 OS << "ninf ";
788 if (MI.getFlag(MachineInstr::FmNsz))
789 OS << "nsz ";
790 if (MI.getFlag(MachineInstr::FmArcp))
791 OS << "arcp ";
792 if (MI.getFlag(MachineInstr::FmContract))
793 OS << "contract ";
794 if (MI.getFlag(MachineInstr::FmAfn))
795 OS << "afn ";
796 if (MI.getFlag(MachineInstr::FmReassoc))
797 OS << "reassoc ";
798 if (MI.getFlag(MachineInstr::NoUWrap))
799 OS << "nuw ";
800 if (MI.getFlag(MachineInstr::NoSWrap))
801 OS << "nsw ";
802 if (MI.getFlag(MachineInstr::IsExact))
803 OS << "exact ";
804 if (MI.getFlag(MachineInstr::NoFPExcept))
805 OS << "nofpexcept ";
806 if (MI.getFlag(MachineInstr::NoMerge))
807 OS << "nomerge ";
808 if (MI.getFlag(MachineInstr::Unpredictable))
809 OS << "unpredictable ";
810 if (MI.getFlag(MachineInstr::NoConvergent))
811 OS << "noconvergent ";
812 if (MI.getFlag(MachineInstr::NonNeg))
813 OS << "nneg ";
814 if (MI.getFlag(MachineInstr::Disjoint))
815 OS << "disjoint ";
816
817 OS << TII->getName(MI.getOpcode());
818 if (I < E)
819 OS << ' ';
820
821 bool NeedComma = false;
822 for (; I < E; ++I) {
823 if (NeedComma)
824 OS << ", ";
825 print(MI, I, TRI, TII, ShouldPrintRegisterTies,
826 MI.getTypeToPrint(I, PrintedTypes, MRI));
827 NeedComma = true;
828 }
829
830 // Print any optional symbols attached to this instruction as-if they were
831 // operands.
832 if (MCSymbol *PreInstrSymbol = MI.getPreInstrSymbol()) {
833 if (NeedComma)
834 OS << ',';
835 OS << " pre-instr-symbol ";
836 MachineOperand::printSymbol(OS, *PreInstrSymbol);
837 NeedComma = true;
838 }
839 if (MCSymbol *PostInstrSymbol = MI.getPostInstrSymbol()) {
840 if (NeedComma)
841 OS << ',';
842 OS << " post-instr-symbol ";
843 MachineOperand::printSymbol(OS, *PostInstrSymbol);
844 NeedComma = true;
845 }
846 if (MDNode *HeapAllocMarker = MI.getHeapAllocMarker()) {
847 if (NeedComma)
848 OS << ',';
849 OS << " heap-alloc-marker ";
850 HeapAllocMarker->printAsOperand(OS, MST);
851 NeedComma = true;
852 }
853 if (MDNode *PCSections = MI.getPCSections()) {
854 if (NeedComma)
855 OS << ',';
856 OS << " pcsections ";
857 PCSections->printAsOperand(OS, MST);
858 NeedComma = true;
859 }
860 if (MDNode *MMRA = MI.getMMRAMetadata()) {
861 if (NeedComma)
862 OS << ',';
863 OS << " mmra ";
864 MMRA->printAsOperand(OS, MST);
865 NeedComma = true;
866 }
867 if (uint32_t CFIType = MI.getCFIType()) {
868 if (NeedComma)
869 OS << ',';
870 OS << " cfi-type " << CFIType;
871 NeedComma = true;
872 }
873
874 if (auto Num = MI.peekDebugInstrNum()) {
875 if (NeedComma)
876 OS << ',';
877 OS << " debug-instr-number " << Num;
878 NeedComma = true;
879 }
880
881 if (PrintLocations) {
882 if (const DebugLoc &DL = MI.getDebugLoc()) {
883 if (NeedComma)
884 OS << ',';
885 OS << " debug-location ";
886 DL->printAsOperand(OS, MST);
887 }
888 }
889
890 if (!MI.memoperands_empty()) {
891 OS << " :: ";
892 const LLVMContext &Context = MF->getFunction().getContext();
893 const MachineFrameInfo &MFI = MF->getFrameInfo();
894 bool NeedComma = false;
895 for (const auto *Op : MI.memoperands()) {
896 if (NeedComma)
897 OS << ", ";
898 Op->print(OS, MST, SSNs, Context, &MFI, TII);
899 NeedComma = true;
900 }
901 }
902}
903
905 auto ObjectInfo = StackObjectOperandMapping.find(FrameIndex);
906 assert(ObjectInfo != StackObjectOperandMapping.end() &&
907 "Invalid frame index");
908 const FrameIndexOperand &Operand = ObjectInfo->second;
909 MachineOperand::printStackObjectReference(OS, Operand.ID, Operand.IsFixed,
910 Operand.Name);
911}
912
913static std::string formatOperandComment(std::string Comment) {
914 if (Comment.empty())
915 return Comment;
916 return std::string(" /* " + Comment + " */");
917}
918
919void MIPrinter::print(const MachineInstr &MI, unsigned OpIdx,
920 const TargetRegisterInfo *TRI,
921 const TargetInstrInfo *TII,
922 bool ShouldPrintRegisterTies, LLT TypeToPrint,
923 bool PrintDef) {
924 const MachineOperand &Op = MI.getOperand(OpIdx);
925 std::string MOComment = TII->createMIROperandComment(MI, Op, OpIdx, TRI);
926
927 switch (Op.getType()) {
929 if (MI.isOperandSubregIdx(OpIdx)) {
932 break;
933 }
934 [[fallthrough]];
953 unsigned TiedOperandIdx = 0;
954 if (ShouldPrintRegisterTies && Op.isReg() && Op.isTied() && !Op.isDef())
955 TiedOperandIdx = Op.getParent()->findTiedOperandIdx(OpIdx);
956 const TargetIntrinsicInfo *TII = MI.getMF()->getTarget().getIntrinsicInfo();
957 Op.print(OS, MST, TypeToPrint, OpIdx, PrintDef, /*IsStandalone=*/false,
958 ShouldPrintRegisterTies, TiedOperandIdx, TRI, TII);
959 OS << formatOperandComment(MOComment);
960 break;
961 }
963 printStackObjectReference(Op.getIndex());
964 break;
966 auto RegMaskInfo = RegisterMaskIds.find(Op.getRegMask());
967 if (RegMaskInfo != RegisterMaskIds.end())
968 OS << StringRef(TRI->getRegMaskNames()[RegMaskInfo->second]).lower();
969 else
970 printCustomRegMask(Op.getRegMask(), OS, TRI);
971 break;
972 }
973 }
974}
975
977 ModuleSlotTracker &MST) {
978 if (isa<GlobalValue>(V)) {
979 V.printAsOperand(OS, /*PrintType=*/false, MST);
980 return;
981 }
982 if (isa<Constant>(V)) {
983 // Machine memory operands can load/store to/from constant value pointers.
984 OS << '`';
985 V.printAsOperand(OS, /*PrintType=*/true, MST);
986 OS << '`';
987 return;
988 }
989 OS << "%ir.";
990 if (V.hasName()) {
991 printLLVMNameWithoutPrefix(OS, V.getName());
992 return;
993 }
994 int Slot = MST.getCurrentFunction() ? MST.getLocalSlot(&V) : -1;
996}
997
999 ScopedDbgInfoFormatSetter FormatSetter(const_cast<Module &>(M),
1001
1002 yaml::Output Out(OS);
1003 Out << const_cast<Module &>(M);
1004}
1005
1007 // RemoveDIs: as there's no textual form for DbgRecords yet, print debug-info
1008 // in dbg.value format.
1009 ScopedDbgInfoFormatSetter FormatSetter(
1010 const_cast<Function &>(MF.getFunction()), WriteNewDbgInfoFormat);
1011
1013 Printer.print(MF);
1014}
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
dxil pretty DXIL Metadata Pretty Printer
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
expand large fp convert
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
This file contains an interface for creating legacy passes to print out IR in various granularities.
cl::opt< bool > WriteNewDbgInfoFormat
A common definition of LaneBitmask for use in TableGen and CodeGen.
Implement a low-level type suitable for MachineInstr level instruction selection.
#define I(x, y, z)
Definition: MD5.cpp:58
static std::string formatOperandComment(std::string Comment)
Definition: MIRPrinter.cpp:913
static void printRegMIR(unsigned Reg, yaml::StringValue &Dest, const TargetRegisterInfo *TRI)
Definition: MIRPrinter.cpp:188
static cl::opt< bool > PrintLocations("mir-debug-loc", cl::Hidden, cl::init(true), cl::desc("Print MIR debug-locations"))
cl::opt< bool > WriteNewDbgInfoFormat
static void printStackObjectDbgInfo(const MachineFunction::VariableDbgInfo &DebugVar, T &Object, ModuleSlotTracker &MST)
Definition: MIRPrinter.cpp:296
static void printCustomRegMask(const uint32_t *RegMask, raw_ostream &OS, const TargetRegisterInfo *TRI)
Definition: MIRPrinter.cpp:268
static cl::opt< bool > SimplifyMIR("simplify-mir", cl::Hidden, cl::desc("Leave out unnecessary information when printing MIR"))
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
unsigned const TargetRegisterInfo * TRI
static bool isReg(const MCInst &MI, unsigned OpNo)
Module.h This file contains the declarations for the Module class.
LLVMContext & Context
Module * Mod
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
raw_pwrite_stream & OS
This file implements the SmallBitVector class.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
uint32_t getNumerator() const
static void normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End)
This is an important base class in LLVM.
Definition: Constant.h:41
This class represents an Operation in the Expression.
bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, DWARFUnit *U) const
A debug info location.
Definition: DebugLoc.h:33
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:155
iterator end()
Definition: DenseMap.h:84
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:220
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition: Function.cpp:358
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:656
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
Metadata node.
Definition: Metadata.h:1067
This class prints out the machine instructions using the MIR serialization format.
Definition: MIRPrinter.cpp:140
void print(const MachineBasicBlock &MBB)
Definition: MIRPrinter.cpp:681
MIPrinter(raw_ostream &OS, ModuleSlotTracker &MST, const DenseMap< const uint32_t *, unsigned > &RegisterMaskIds, const DenseMap< int, FrameIndexOperand > &StackObjectOperandMapping)
Definition: MIRPrinter.cpp:152
void printStackObjectReference(int FrameIndex)
Definition: MIRPrinter.cpp:904
static 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:976
This class prints out the machine functions using the MIR serialization format.
Definition: MIRPrinter.cpp:102
void convert(yaml::MachineFunction &MF, const MachineRegisterInfo &RegInfo, const TargetRegisterInfo *TRI)
Definition: MIRPrinter.cpp:310
void convertEntryValueObjects(yaml::MachineFunction &YMF, const MachineFunction &MF, ModuleSlotTracker &MST)
Definition: MIRPrinter.cpp:383
void convertCallSiteObjects(yaml::MachineFunction &YMF, const MachineFunction &MF, ModuleSlotTracker &MST)
Definition: MIRPrinter.cpp:530
void print(const MachineFunction &MF)
Definition: MIRPrinter.cpp:194
void convertMachineMetadataNodes(yaml::MachineFunction &YMF, const MachineFunction &MF, MachineModuleSlotTracker &MST)
Definition: MIRPrinter.cpp:564
MIRPrinter(raw_ostream &OS)
Definition: MIRPrinter.cpp:110
void convertStackObjects(yaml::MachineFunction &YMF, const MachineFunction &MF, ModuleSlotTracker &MST)
Definition: MIRPrinter.cpp:396
BranchProbability getSuccProbability(const_succ_iterator Succ) const
Return probability of the edge from this block to MBB.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
@ PrintNameIr
Add IR name where available.
@ PrintNameAttributes
Print attributes.
void printAsOperand(raw_ostream &OS, bool PrintType=true) const
unsigned succ_size() const
iterator_range< livein_iterator > liveins_dbg() const
bool hasSuccessorProbabilities() const
Return true if any of the successors have probabilities attached to them.
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
Instructions::const_iterator const_instr_iterator
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void printName(raw_ostream &os, unsigned printNameFlags=PrintNameIr, ModuleSlotTracker *moduleSlotTracker=nullptr) const
Print the basic block's name as:
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.
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.
MachineBasicBlock * getRestorePoint() const
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.
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.
int getOffsetAdjustment() const
Return the correction for frame offsets.
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.
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
int getObjectIndexEnd() const
Return one past the maximum frame object index.
bool hasStackProtectorIndex() const
uint8_t getStackID(int ObjectIdx) 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.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
MachineBasicBlock * getSavePoint() const
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...
bool hasProperty(Property P) const
Description of the location of a variable whose Address is valid and unchanging during function execu...
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
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.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const MachineFunctionProperties & getProperties() const
Get the function properties.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
BasicBlockListType::const_iterator const_iterator
Representation of each machine instruction.
Definition: MachineInstr.h:69
JTEntryKind getEntryKind() const
const std::vector< MachineJumpTableEntry > & getJumpTables() const
void collectMachineMDNodes(MachineMDNodeListType &L) const
MachineOperand class - Representation of each machine instruction operand.
static void printStackObjectReference(raw_ostream &OS, unsigned FrameIndex, bool IsFixed, StringRef Name)
Print a stack object reference.
static void printSubRegIdx(raw_ostream &OS, uint64_t Index, const TargetRegisterInfo *TRI)
Print a subreg index operand.
static void printTargetFlags(raw_ostream &OS, const MachineOperand &Op)
Print operand target flags.
static void printIRSlotNumber(raw_ostream &OS, int Slot)
Print an IRSlotNumber.
static 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_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,...
Register getSimpleHint(Register VReg) const
getSimpleHint - same as getRegAllocationHint except it will only return a target independent hint.
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
bool isUpdatedCSRsInitialized() const
Returns true if the updated CSR list was initialized and false otherwise.
ArrayRef< std::pair< MCRegister, Register > > liveins() const
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
StringRef getVRegName(Register Reg) const
void print(raw_ostream &OS, const Module *M=nullptr, bool IsForDebug=false) const
Print.
Definition: AsmWriter.cpp:5195
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.
Definition: AsmWriter.cpp:913
const Function * getCurrentFunction() const
void incorporateFunction(const Function &F)
Incorporate the given function.
Definition: AsmWriter.cpp:899
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the module to an output stream with an optional AssemblyAnnotationWriter.
Definition: AsmWriter.cpp:4847
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
Definition: Register.h:84
Used to temporarily set the debug info format of a function, module, or basic block for the duration ...
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.
Definition: SmallPtrSet.h:342
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:427
size_t size() const
Definition: SmallVector.h:91
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
void reserve(size_type N)
Definition: SmallVector.h:676
void push_back(const T &Elt)
Definition: SmallVector.h:426
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::string lower() const
Definition: StringRef.cpp:111
TargetInstrInfo - Interface to description of machine instruction set.
TargetIntrinsicInfo - Interface to description of machine instruction set.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:76
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
LLVM Value Representation.
Definition: Value.h:74
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Definition: AsmWriter.cpp:4996
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.
Definition: AsmWriter.cpp:5079
self_iterator getIterator()
Definition: ilist_node.h:109
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:660
std::string & str()
Returns the string's reference.
Definition: raw_ostream.h:678
#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.
Definition: CallingConv.h:24
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:450
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
Definition: LaneBitmask.h:92
void printMIR(raw_ostream &OS, const Module &M)
Print LLVM IR using the MIR serialization format to the given output stream.
Definition: MIRPrinter.cpp:998
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:625
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1647
Printable printRegClassOrBank(Register Reg, const MachineRegisterInfo &RegInfo, const TargetRegisterInfo *TRI)
Create Printable object to print register classes or register banks on a raw_ostream.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:125
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition: STLExtras.h:1879
void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name)
Print out a name of an LLVM value without any prefixes.
Definition: AsmWriter.cpp:380
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.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
static void output(const Module &Mod, void *Ctxt, raw_ostream &OS)
Definition: MIRPrinter.cpp:175
static StringRef input(StringRef Str, void *Ctxt, Module &Mod)
Definition: MIRPrinter.cpp:179
Identifies call instruction location in machine function.
Serializable representation of CallSiteInfo.
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.
Serializable representation of MachineFrameInfo.
unsigned MaxCallFrameSize
~0u means: not computed yet.
std::vector< MachineStackObject > StackObjects
std::vector< StringValue > MachineMetadataNodes
std::optional< std::vector< FlowStringValue > > CalleeSavedRegisters
std::vector< EntryValueObject > EntryValueObjects
std::vector< MachineConstantPoolValue > Constants
std::vector< CallSiteInfo > CallSitesInfo
std::vector< MachineFunctionLiveIn > LiveIns
std::vector< VirtualRegisterDefinition > VirtualRegisters
std::vector< FixedMachineStackObject > FixedStackObjects
std::vector< DebugValueSubstitution > DebugValueSubstitutions
std::unique_ptr< MachineFunctionInfo > MachineFuncInfo
Constant pool.
MachineJumpTable JumpTableInfo
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.