57 std::unique_ptr<PerTargetMIParsingState> Target;
61 bool NoLLVMIR =
false;
64 bool NoMIRDocuments =
false;
66 std::function<void(
Function &)> ProcessIRFunction;
71 std::function<
void(
Function &)> ProcessIRFunction);
95 std::unique_ptr<Module>
136 const std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
140 std::vector<CalleeSavedInfo> &CSIInfo,
142 bool IsRestored,
int FrameIdx);
154 template <
typename T>
204 reinterpret_cast<MIRParserImpl *
>(Context)->reportDiagnostic(Diag);
209 std::function<
void(
Function &)> Callback)
211 In(SM.getMemoryBuffer(SM.AddNewSourceBuffer(
std::
move(Contents),
SMLoc()))
214 Filename(Filename), ProcessIRFunction(Callback) {
255std::unique_ptr<Module>
257 if (!In.setCurrentDocument()) {
261 NoMIRDocuments =
true;
262 auto M = std::make_unique<Module>(Filename, Context);
263 if (
auto LayoutOverride = DataLayoutCallback(M->getTargetTriple().str(),
264 M->getDataLayoutStr()))
265 M->setDataLayout(*LayoutOverride);
269 std::unique_ptr<Module> M;
272 if (
const auto *BSN =
276 Context, &IRSlots, DataLayoutCallback);
282 if (!In.setCurrentDocument())
283 NoMIRDocuments =
true;
286 M = std::make_unique<Module>(Filename, Context);
287 if (
auto LayoutOverride = DataLayoutCallback(M->getTargetTriple().str(),
288 M->getDataLayoutStr()))
289 M->setDataLayout(*LayoutOverride);
301 auto FirstUnvisitedFunction = M.begin();
306 }
while (In.setCurrentDocument());
319 if (ProcessIRFunction)
320 ProcessIRFunction(*
F);
328 for (; FirstUnvisitedFunction != M.end(); ++FirstUnvisitedFunction)
329 if (!FirstUnvisitedFunction->hasName())
330 return &*FirstUnvisitedFunction++;
352 Function *
F = M.getFunction(FunctionName);
356 }
else if (!FunctionName.
empty() ||
358 return error(
Twine(
"function '") + FunctionName +
359 "' isn't defined in the provided LLVM IR");
365 return error(
Twine(
"redefinition of machine function '") + FunctionName +
376 return error(
Twine(
"redefinition of machine function '") + FunctionName +
390 for (
unsigned I = 0,
E =
MRI.getNumVirtRegs();
I !=
E; ++
I) {
403bool MIRParserImpl::computeFunctionProperties(
408 bool HasInlineAsm =
false;
409 bool HasFakeUses =
false;
410 bool AllTiedOpsRewritten =
true, HasTiedOps =
false;
411 for (
const MachineBasicBlock &
MBB : MF) {
412 for (
const MachineInstr &
MI :
MBB) {
415 if (
MI.isInlineAsm())
419 for (
unsigned I = 0;
I <
MI.getNumOperands(); ++
I) {
420 const MachineOperand &MO =
MI.getOperand(
I);
424 if (MO.
isUse() &&
MI.isRegTiedToDefOperand(
I, &DefIdx)) {
426 if (MO.
getReg() !=
MI.getOperand(DefIdx).getReg())
427 AllTiedOpsRewritten =
false;
435 auto ComputedPropertyHelper =
436 [&
Properties](std::optional<bool> ExplicitProp,
bool ComputedProp,
439 if (ExplicitProp.value_or(ComputedProp))
445 return ExplicitProp && *ExplicitProp && !ComputedProp;
448 if (ComputedPropertyHelper(YamlMF.
NoPHIs, !HasPHI,
450 return error(MF.getName() +
451 " has explicit property NoPhi, but contains at least one PHI");
454 MF.setHasInlineAsm(HasInlineAsm);
456 if (HasTiedOps && AllTiedOpsRewritten)
459 if (ComputedPropertyHelper(YamlMF.
IsSSA,
isSSA(MF),
461 return error(MF.getName() +
462 " has explicit property IsSSA, but is not valid SSA");
465 const MachineRegisterInfo &
MRI = MF.getRegInfo();
470 " has explicit property NoVRegs, but contains virtual registers");
480 " has explicit property hasFakeUses=false, but contains fake uses");
481 MF.setHasFakeUses(YamlMF.
HasFakeUses.value_or(HasFakeUses));
490 MachineBasicBlock *BB;
491 if (parseMBBReference(PFS, BB, MILoc.
Block))
495 Twine(
" instruction offset out of range.") +
496 " Unable to reference instruction at " + MILoc.
Block.
Value +
497 " at offset:" + Twine(MILoc.
Offset));
510 if (parseMachineInst(PFS, MILoc, CallI))
514 Twine(
" call site info should reference call "
515 "instruction. Instruction at ") +
517 " is not a call instruction");
519 for (
auto ArgRegPair : YamlCSInfo.ArgForwardingRegs) {
522 return error(
Error, ArgRegPair.Reg.SourceRange);
523 CSInfo.
ArgRegPairs.emplace_back(Reg, ArgRegPair.ArgNo);
525 if (!YamlCSInfo.CalleeTypeIds.empty()) {
526 for (
auto CalleeTypeId : YamlCSInfo.CalleeTypeIds) {
528 CSInfo.
CalleeTypeIds.push_back(ConstantInt::get(Int64Ty, CalleeTypeId,
539 return error(
"call site info provided but not used");
543void MIRParserImpl::setupDebugValueTracking(
548 unsigned MaxInstrNum = 0;
551 MaxInstrNum = std::max(
MI.peekDebugInstrNum(), MaxInstrNum);
553 if (
MI.isDebugPHI() &&
MI.getNumOperands() > 1 &&
554 MI.getOperand(1).isImm())
556 std::max(
unsigned(
MI.getOperand(1).getImm()), MaxInstrNum);
559 if (
MI.isDebugRef()) {
569 MaxInstrNum = std::max({MaxInstrNum,
Sub.SrcInst,
Sub.DstInst});
570 MF.makeDebugValueSubstitution({
Sub.SrcInst,
Sub.SrcOp},
573 MF.setDebugInstrNumberingCount(MaxInstrNum);
603 Props.setLegalized();
605 Props.setRegBankSelected();
609 Props.setFailedISel();
611 Props.setFailsVerification();
613 Props.setTracksDebugUserValues();
694 MRI.freezeReservedRegs();
696 if (computeFunctionProperties(MF, YamlMF))
708 setupDebugValueTracking(MF, PFS, YamlMF);
725 Targets[Target.BBID].push_back(Target.CallsiteIndex);
735 assert(RegInfo.tracksLiveness());
737 RegInfo.invalidateLiveness();
744 return error(VReg.ID.SourceRange.Start,
745 Twine(
"redefinition of virtual register '%") +
746 Twine(VReg.ID.Value) +
"'");
747 Info.Explicit =
true;
749 if (VReg.Class.Value ==
"_") {
751 Info.D.RegBank =
nullptr;
753 const auto *RC = Target->getRegClass(VReg.Class.Value);
758 const RegisterBank *RegBank = Target->getRegBank(VReg.Class.Value);
761 VReg.Class.SourceRange.Start,
762 Twine(
"use of undefined register class or register bank '") +
763 VReg.Class.Value +
"'");
765 Info.D.RegBank = RegBank;
769 if (!VReg.PreferredRegister.Value.empty()) {
771 return error(VReg.Class.SourceRange.Start,
772 Twine(
"preferred register can only be set for normal vregs"));
775 VReg.PreferredRegister.Value,
Error))
776 return error(
Error, VReg.PreferredRegister.SourceRange);
779 for (
const auto &FlagStringValue : VReg.RegisterFlags) {
781 if (Target->getVRegFlagValue(FlagStringValue.Value, FlagValue))
782 return error(FlagStringValue.SourceRange.Start,
783 Twine(
"use of undefined register flag '") +
784 FlagStringValue.Value +
"'");
785 Info.Flags |= FlagValue;
788 return error(VReg.AntiHints.front().SourceRange.Start,
789 "anti-hints can only be set for normal vregs");
791 for (
const auto &AntiHintValue : VReg.AntiHints) {
794 return error(
Error, AntiHintValue.SourceRange);
797 return error(AntiHintValue.SourceRange.Start,
798 "anti-hint '" +
Twine(AntiHintValue.Value) +
799 "' must be a virtual register");
802 Info.AntiHints.push_back(AntiHintReg);
804 RegInfo.noteNewVirtualRegister(Info.VReg);
808 for (
const auto &LiveIn : YamlMF.
LiveIns) {
811 return error(
Error, LiveIn.Register.SourceRange);
813 if (!LiveIn.VirtualRegister.Value.empty()) {
817 return error(
Error, LiveIn.VirtualRegister.SourceRange);
820 RegInfo.addLiveIn(Reg, VReg);
831 CalleeSavedRegisters.
push_back(Reg.id());
833 RegInfo.setCalleeSavedRegs(CalleeSavedRegisters);
840 if (VReg.SplitFrom.Value.empty() && VReg.AssignedPhys.Value.empty())
843 auto It = PFS.
VRegInfos.find(VReg.ID.Value);
846 Register ChildReg = It->second->VReg;
849 Pending.VReg = ChildReg;
851 if (!VReg.SplitFrom.Value.empty()) {
855 return error(
Error, VReg.SplitFrom.SourceRange);
856 if (Parent->
VReg == ChildReg)
857 return error(VReg.SplitFrom.SourceRange.Start,
858 Twine(
"'split-from' references the same vreg as 'id' (%") +
859 Twine(VReg.ID.Value) +
")");
860 Pending.SplitFrom = Parent->
VReg;
862 if (!VReg.AssignedPhys.Value.empty()) {
865 return error(
Error, VReg.AssignedPhys.SourceRange);
868 VReg.AssignedPhys.SourceRange.Start,
869 Twine(
"'assigned-phys' must be a physical register, got '") +
870 VReg.AssignedPhys.Value +
"'");
871 Pending.AssignedPhys = Phys.
asMCReg();
873 RegInfo.addPendingVirtRegMapEntry(Pending);
888 auto populateVRegInfo = [&](
const VRegInfo &Info,
const Twine &Name) {
893 (
Twine(
"Cannot determine class/bank of virtual register ") + Name +
894 " in function '" + MF.
getName() +
"'")
898 if (!Info.D.RC->isAllocatable()) {
900 TRI->getRegClassName(Info.D.RC) +
901 "' for virtual register " + Name +
" in function '" +
907 MRI.setRegClass(Reg, Info.D.RC);
908 if (Info.PreferredReg != 0)
909 MRI.setSimpleHint(Reg, Info.PreferredReg);
910 if (!Info.AntiHints.empty())
911 MRI.addRegAllocationAntiHints(Reg, Info.AntiHints);
916 MRI.setRegBank(Reg, *Info.D.RegBank);
923 populateVRegInfo(Info,
Twine(
P.first()));
928 populateVRegInfo(Info,
Twine(
P.first.id()));
935 if (
auto *RegMask =
TRI->getCustomEHPadPreservedMask(MF))
936 MRI.addPhysRegsUsedFromRegMask(RegMask);
952 for (
auto &E : Errors)
994 std::vector<CalleeSavedInfo> CSIInfo;
1000 Object.IsImmutable, Object.IsAliased);
1005 return error(Object.ID.SourceRange.Start,
1006 Twine(
"StackID is not supported by target"));
1012 return error(Object.ID.SourceRange.Start,
1013 Twine(
"redefinition of fixed stack object '%fixed-stack.") +
1014 Twine(Object.ID.Value) +
"'");
1016 Object.CalleeSavedRestored, ObjectIdx))
1027 return error(
Error, Object.EntryValueRegister.SourceRange);
1028 if (!Reg.isPhysical())
1029 return error(Object.EntryValueRegister.SourceRange.Start,
1030 "Expected physical register for entry value field");
1032 PFS, Object.DebugVar, Object.DebugExpr, Object.DebugLoc);
1035 if (MaybeInfo->DIVar || MaybeInfo->DIExpr || MaybeInfo->DILoc)
1037 Reg.asMCReg(), MaybeInfo->DILoc);
1045 if (!Name.Value.empty()) {
1047 F.getValueSymbolTable()->lookup(Name.Value));
1049 return error(Name.SourceRange.Start,
1050 "alloca instruction named '" + Name.Value +
1051 "' isn't defined in the function '" +
F.getName() +
1055 return error(Object.ID.SourceRange.Start,
1056 Twine(
"StackID is not supported by target"));
1062 Object.Size, Object.Alignment.valueOrOne(),
1069 return error(Object.ID.SourceRange.Start,
1070 Twine(
"redefinition of stack object '%stack.") +
1071 Twine(Object.ID.Value) +
"'");
1073 Object.CalleeSavedRestored, ObjectIdx))
1075 if (Object.LocalOffset)
1081 if (!CSIInfo.empty())
1106 std::vector<CalleeSavedInfo> &CSIInfo,
1108 if (RegisterSource.
Value.empty())
1116 CSIInfo.push_back(CSI);
1121template <
typename T>
1129 return Parser.
error(Source.SourceRange.Start,
1130 "expected a reference to a '" + TypeString +
1141 if (parseMDNode(PFS, Var, VarStr) || parseMDNode(PFS, Expr, ExprStr) ||
1142 parseMDNode(PFS,
Loc, LocStr))
1143 return std::nullopt;
1150 return std::nullopt;
1154template <
typename T>
1156 const T &Object,
int FrameIdx) {
1157 std::optional<VarExprLoc> MaybeInfo =
1158 parseVarExprLoc(PFS, Object.DebugVar, Object.DebugExpr, Object.DebugLoc);
1163 if (MaybeInfo->DIVar || MaybeInfo->DIExpr || MaybeInfo->DILoc)
1171 if (Source.Value.empty())
1185 for (
const auto &YamlConstant : YamlMF.
Constants) {
1186 if (YamlConstant.IsTargetSpecific)
1188 return error(YamlConstant.Value.SourceRange.Start,
1189 "Can't parse target-specific constant pool entries yet");
1193 return error(
Error, YamlConstant.Value.SourceRange);
1194 const Align PrefTypeAlign =
1196 const Align Alignment = YamlConstant.Alignment.value_or(PrefTypeAlign);
1198 if (!ConstantPoolSlots.
insert(std::make_pair(YamlConstant.ID.Value, Index))
1200 return error(YamlConstant.ID.SourceRange.Start,
1201 Twine(
"redefinition of constant pool item '%const.") +
1202 Twine(YamlConstant.ID.Value) +
"'");
1210 const std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
1215 if (parseMBBReference(PFS,
MBB, Entry.Point.Value))
1219 for (
auto &RegStr : Entry.Registers) {
1233 for (
const auto &Entry : YamlJTI.
Entries) {
1234 std::vector<MachineBasicBlock *> Blocks;
1235 for (
const auto &MBBSource : Entry.Blocks) {
1237 if (parseMBBReference(PFS,
MBB, MBBSource.Value))
1239 Blocks.push_back(
MBB);
1244 return error(Entry.ID.SourceRange.Start,
1245 Twine(
"redefinition of jump table entry '%jump-table.") +
1246 Twine(Entry.ID.Value) +
"'");
1269 unsigned ErrorDefinitionIndex = 0;
1272 ErrorDefinitionIndex)) {
1295 if (parseMachineInst(PFS, MILoc, CallI))
1299 Twine(
" called global should reference call "
1300 "instruction. Instruction at ") +
1302 " is not a call instruction");
1305 F.getParent()->getValueSymbolTable().lookup(YamlCG.Callee.Value);
1307 return error(YamlCG.Callee.SourceRange.Start,
1308 "use of undefined global '" + YamlCG.Callee.Value +
"'");
1310 return error(YamlCG.Callee.SourceRange.Start,
1311 "use of non-global value '" + YamlCG.Callee.Value +
"'");
1324 *
Loc.getPointer() ==
'\'';
1327 Loc =
Loc.getFromPointer(
Loc.getPointer() +
Error.getColumnNo() +
1328 (HasQuote ? 1 : 0));
1342 unsigned Line = LineAndColumn.first +
Error.getLineNo() - 1;
1343 unsigned Column =
Error.getColumnNo();
1351 if (L.line_number() == Line) {
1354 auto Indent = LineStr.
find(
Error.getLineContents());
1361 return SMDiagnostic(SM, Loc, Filename, Line, Column,
Error.getKind(),
1362 Error.getMessage(), LineStr,
Error.getRanges(),
1371std::unique_ptr<Module>
1373 return Impl->parseIRModule(DataLayoutCallback);
1377 return Impl->parseMachineFunctions(M, MMI);
1382 return Impl->parseMachineFunctions(M, MMI, &
MAM);
1387 std::function<
void(
Function &)> ProcessIRFunction) {
1389 if (std::error_code EC = FileOrErr.getError()) {
1391 "could not open input file: " + EC.message());
1398std::unique_ptr<MIRParser>
1401 std::function<
void(
Function &)> ProcessIRFunction) {
1402 auto Filename = Contents->getBufferIdentifier();
1403 if (
Context.shouldDiscardValueNames()) {
1408 "cannot read MIR with a Context that discards named Values")));
1411 return std::make_unique<MIRParser>(std::make_unique<MIRParserImpl>(
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Reserve WWM Registers
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
Module.h This file contains the declarations for the Module class.
static bool isSSA(const MachineFunction &MF)
static void handleYAMLDiag(const SMDiagnostic &Diag, void *Context)
static bool typecheckMDNode(T *&Result, MDNode *Node, const yaml::StringValue &Source, StringRef TypeString, MIRParserImpl &Parser)
Verify that given node is of a certain type. Return true on error.
static Function * getNextUnusedUnnamedFunction(const Module &M, Module::iterator &FirstUnvisitedFunction)
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Register const TargetRegisterInfo * TRI
static constexpr StringLiteral Filename
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
MachineRegisterInfo & MRI
an instruction to allocate memory on the stack
LLVM Basic Block Representation.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
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)
Diagnostic information for machine IR parser.
Lightweight error class with error context and mandatory checking.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Module * getParent()
Get the module that this global value is contained inside of...
@ ExternalLinkage
Externally visible function.
Class to represent integer types.
This is an important class for using LLVM in a threaded context.
This class implements the parsing of LLVM IR that's embedded inside a MIR file.
bool error(const Twine &Message)
Report an error with the given message at unknown location.
void reportDiagnostic(const SMDiagnostic &Diag)
bool setupRegisterInfo(const PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
bool parseRegisterInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
bool initializeFrameInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
bool parseMachineFunction(Module &M, MachineModuleInfo &MMI, ModuleAnalysisManager *FAM, Module::iterator &FirstUnvisitedFunction)
Parse the machine function in the current YAML document.
Function * createDummyFunction(StringRef Name, Module &M)
Create an empty function with the given name.
bool parseStackObjectsDebugInfo(PerFunctionMIParsingState &PFS, const T &Object, int FrameIdx)
bool initializeMachineFunction(const yaml::MachineFunction &YamlMF, MachineFunction &MF)
Initialize the machine function to the state that's described in the MIR file.
std::unique_ptr< Module > parseIRModule(DataLayoutCallbackTy DataLayoutCallback)
Try to parse the optional LLVM module and the machine functions in the MIR file.
bool initializePrefetchTargets(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
bool initializeJumpTableInfo(PerFunctionMIParsingState &PFS, const yaml::MachineJumpTable &YamlJTI)
bool initializeConstantPool(PerFunctionMIParsingState &PFS, MachineConstantPool &ConstantPool, const yaml::MachineFunction &YamlMF)
MIRParserImpl(std::unique_ptr< MemoryBuffer > Contents, StringRef Filename, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction)
std::optional< VarExprLoc > parseVarExprLoc(PerFunctionMIParsingState &PFS, const yaml::StringValue &VarStr, const yaml::StringValue &ExprStr, const yaml::StringValue &LocStr)
bool parseCalledGlobals(PerFunctionMIParsingState &PFS, MachineFunction &MF, const yaml::MachineFunction &YMF)
bool parseCalleeSavedRegister(PerFunctionMIParsingState &PFS, std::vector< CalleeSavedInfo > &CSIInfo, const yaml::StringValue &RegisterSource, bool IsRestored, int FrameIdx)
bool parseMachineMetadataNodes(PerFunctionMIParsingState &PFS, MachineFunction &MF, const yaml::MachineFunction &YMF)
bool initializeCallSiteInfo(PerFunctionMIParsingState &PFS, const yaml::MachineFunction &YamlMF)
bool initializeSaveRestorePoints(PerFunctionMIParsingState &PFS, const std::vector< yaml::SaveRestorePointEntry > &YamlSRPoints, llvm::SaveRestorePoints &SaveRestorePoints)
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI, ModuleAnalysisManager *FAM=nullptr)
LLVM_ABI MIRParser(std::unique_ptr< MIRParserImpl > Impl)
LLVM_ABI std::unique_ptr< Module > parseIRModule(DataLayoutCallbackTy DataLayoutCallback=[](StringRef, StringRef) { return std::nullopt;})
Parses the optional LLVM IR module in the MIR file.
LLVM_ABI bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI)
Parses MachineFunctions in the MIR file and add them to the given MachineModuleInfo MMI.
instr_iterator instr_begin()
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.
void setMaxCallFrameSize(uint64_t S)
LLVM_ABI int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
void setAdjustsStack(bool V)
LLVM_ABI int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
LLVM_ABI void ensureMaxAlignment(Align Alignment)
Make sure the function's frame is at least Align bytes aligned.
void setHasPatchPoint(bool s=true)
void setLocalFrameSize(int64_t sz)
Set the size of the local object blob.
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
void setFrameAddressIsTaken(bool T)
void setHasStackMap(bool s=true)
void setSavePoints(SaveRestorePoints NewSavePoints)
void setFramePointerPolicy(FramePointerKind Kind)
void setCVBytesOfCalleeSavedRegisters(unsigned S)
void setStackID(int ObjectIdx, uint8_t ID)
void setHasTailCall(bool V=true)
void setStackProtectorIndex(int I)
void setCalleeSavedInfoValid(bool v)
void setReturnAddressIsTaken(bool s)
void mapLocalFrameObject(int ObjectIndex, int64_t Offset)
Map a frame index into the local object block.
void setHasOpaqueSPAdjustment(bool B)
void setCalleeSavedInfo(std::vector< CalleeSavedInfo > CSI)
Used by prolog/epilog inserter to set the function's callee saved information.
LLVM_ABI int CreateVariableSizedObject(Align Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created.
void setRestorePoints(SaveRestorePoints NewRestorePoints)
LLVM_ABI int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool IsImmutable=false)
Create a spill slot at a fixed location on the stack.
void setStackSize(uint64_t Size)
Set the size of the stack.
void setHasVAStart(bool B)
void setHasMustTailInVarArgFunc(bool B)
void setObjectAlignment(int ObjectIdx, Align Alignment)
setObjectAlignment - Change the alignment of the specified stack object.
void setOffsetAdjustment(int64_t Adj)
Set the correction for frame offsets.
void setFunctionContextIndex(int I)
This analysis create MachineFunction for given Function.
Properties which a MachineFunction may have at a given point in time.
void setCallsUnwindInit(bool b)
void setHasEHFunclets(bool V)
void setExposesReturnsTwice(bool B)
setCallsSetJmp - Set a flag that indicates if there's a call to a "returns twice" function.
void setHasWinCFI(bool v)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist,...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void setCallsEHReturn(bool b)
void setAlignment(Align A)
setAlignment - Set the alignment of the function.
void setPrefetchTargets(const DenseMap< UniqueBBID, SmallVector< unsigned > > &V)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool hasBBSections() const
Returns true if this function has basic block sections enabled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
bool verify(Pass *p=nullptr, const char *Banner=nullptr, raw_ostream *OS=nullptr, bool AbortOnError=true) const
Run the current MachineFunction through the machine code verifier, useful for debugger use.
Function & getFunction()
Return the LLVM function that this machine code represents.
void setIsOutlined(bool V)
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
void addCallSiteInfo(const MachineInstr *CallI, CallSiteInfo &&CallInfo)
Start tracking the arguments passed to the call CallI.
const MachineFunctionProperties & getProperties() const
Get the function properties.
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable in a stack slot.
void setHasEHScopes(bool V)
void setHasEHContTarget(bool V)
void addCalledGlobal(const MachineInstr *MI, CalledGlobalInfo Details)
Notes the global and target flags for a call site.
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Representation of each machine instruction.
bool isCall(QueryType Type=AnyInBundle) const
LLVM_ABI unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
An analysis that produces MachineModuleInfo for a module.
This class contains meta information specific to a module.
LLVM_ABI MachineFunction & getOrCreateMachineFunction(Function &F)
Returns the MachineFunction constructed for the IR function F.
const TargetMachine & getTarget() const
LLVM_ABI MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
unsigned getInstrRefInstrIndex() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
Register getReg() const
getReg - Returns the register number.
bool isDbgInstrRef() const
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
A Module instance is used to store all the information related to an LLVM module.
FunctionListType::iterator iterator
The Function iterators.
This class implements the register bank concept.
Wrapper class representing virtual and physical registers.
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
SourceMgr::DiagKind getKind() const
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
constexpr const char * getPointer() const
Represents a range in source code.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
unsigned getMainFileID() const
LLVM_ABI std::pair< unsigned, unsigned > getLineAndColumn(SMLoc Loc, unsigned BufferID=0) const
Find the line and column number for the specified location in the specified file.
const MemoryBuffer * getMemoryBuffer(unsigned i) const
LLVM_ABI SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges={}, ArrayRef< SMFixIt > FixIts={}) const
Return an SMDiagnostic at the specified location with the specified string.
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
Represent a constant reference to a string, i.e.
static constexpr size_t npos
constexpr bool empty() const
Check if the string is empty.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Information about stack frame layout on the target.
virtual bool isSupportedStackID(TargetStackID::Value ID) const
Primary interface to the complete machine description for the target machine.
virtual yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
virtual bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
unsigned EmitCallSiteInfo
The flag enables call site info production.
unsigned EmitCallGraphSection
Emit section containing call graph metadata.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual void mirFileLoaded(MachineFunction &MF) const
This is called after a .mir file was loaded.
virtual const TargetFrameLowering * getFrameLowering() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
This function has undefined behavior.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
A forward iterator which reads text lines from a buffer.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
EnumSet< Property > Properties
std::enable_if_t< has_ScalarEnumerationTraits< T >::value, void > yamlize(IO &io, T &Val, bool, EmptyContext &Ctx)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
LLVM_ABI bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI std::unique_ptr< Module > parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context, SlotMapping *Slots=nullptr, DataLayoutCallbackTy DataLayoutCallback=[](StringRef, StringRef) { return std::nullopt;}, AsmParserContext *ParserContext=nullptr)
parseAssemblyFile and parseAssemblyString are wrappers around this function.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
LLVM_ABI bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine basic block definitions, and skip the machine instructions.
LLVM_ABI bool parsePrefetchTarget(PerFunctionMIParsingState &PFS, CallsiteID &Target, StringRef Src, SMDiagnostic &Error)
LLVM_ABI bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
LLVM_ABI bool parseMetadataDefinitions(ArrayRef< StringRef > Definitions, SMDiagnostic &Err, const Module &M, SlotMapping &Slots, unsigned &ErrorDefinitionIndex)
Parse standalone metadata definitions using and updating the supplied slot mapping.
auto dyn_cast_or_null(const Y &Val)
DenseMap< MachineBasicBlock *, std::vector< CalleeSavedInfo > > SaveRestorePoints
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI std::unique_ptr< MIRParser > createMIRParserFromFile(StringRef Filename, SMDiagnostic &Error, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction=nullptr)
This function is the main interface to the MIR serialization format parser.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI std::unique_ptr< MIRParser > createMIRParser(std::unique_ptr< MemoryBuffer > Contents, LLVMContext &Context, std::function< void(Function &)> ProcessIRFunction=nullptr)
This function is another interface to the MIR serialization format parser.
llvm::function_ref< std::optional< std::string >(StringRef, StringRef)> DataLayoutCallbackTy
@ Sub
Subtraction of integers.
LLVM_ABI bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
LLVM_ABI bool parseRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
LLVM_ABI Constant * parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M, const SlotMapping *Slots=nullptr)
Parse a type and a constant value in the given string.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
LLVM_ABI bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
SmallVector< ConstantInt *, 4 > CalleeTypeIds
Callee type ids.
SmallVector< ArgRegPair, 1 > ArgRegPairs
Vector of call argument and its forwarding register.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
DenseMap< unsigned, unsigned > JumpTableSlots
LLVM_ABI VRegInfo & getVRegInfo(Register Num)
DenseMap< unsigned, int > FixedStackObjectSlots
const SlotMapping & IRSlots
DenseMap< unsigned, unsigned > ConstantPoolSlots
StringMap< VRegInfo * > VRegInfosNamed
std::map< unsigned, TrackingMDNodeRef > MachineMetadataNodes
DenseMap< unsigned, int > StackObjectSlots
DenseMap< Register, VRegInfo * > VRegInfos
This struct contains the mappings from the slot numbers to unnamed metadata nodes,...
std::map< unsigned, TrackingMDNodeRef > MetadataNodes
constexpr EnumSet & set(Enum E)
constexpr EnumSet & reset(Enum E)
Serializable representation of MachineFrameInfo.
std::vector< SaveRestorePointEntry > RestorePoints
bool IsCalleeSavedInfoValid
unsigned MaxCallFrameSize
~0u means: not computed yet.
FramePointerKind FramePointerPolicy
StringValue StackProtector
std::vector< SaveRestorePointEntry > SavePoints
bool HasMustTailInVarArgFunc
unsigned CVBytesOfCalleeSavedRegisters
bool HasOpaqueSPAdjustment
bool IsReturnAddressTaken
StringValue FunctionContext
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
std::vector< FlowStringValue > PrefetchTargets
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
A wrapper around std::string which contains a source range that's being set during parsing.