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>
129 const std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
136 std::vector<CalleeSavedInfo> &CSIInfo,
138 bool IsRestored,
int FrameIdx);
150 template <
typename T>
207 std::function<
void(
Function &)> Callback)
209 In(SM.getMemoryBuffer(SM.AddNewSourceBuffer(
std::
move(Contents),
SMLoc()))
212 Filename(Filename), ProcessIRFunction(Callback) {
253std::unique_ptr<Module>
255 if (!In.setCurrentDocument()) {
259 NoMIRDocuments =
true;
260 auto M = std::make_unique<Module>(Filename,
Context);
261 if (
auto LayoutOverride = DataLayoutCallback(M->getTargetTriple().str(),
262 M->getDataLayoutStr()))
263 M->setDataLayout(*LayoutOverride);
267 std::unique_ptr<Module> M;
270 if (
const auto *BSN =
271 dyn_cast_or_null<yaml::BlockScalarNode>(In.getCurrentNode())) {
274 Context, &IRSlots, DataLayoutCallback);
280 if (!In.setCurrentDocument())
281 NoMIRDocuments =
true;
284 M = std::make_unique<Module>(Filename,
Context);
285 if (
auto LayoutOverride = DataLayoutCallback(M->getTargetTriple().str(),
286 M->getDataLayoutStr()))
287 M->setDataLayout(*LayoutOverride);
303 }
while (In.setCurrentDocument());
309 auto &
Context = M.getContext();
316 if (ProcessIRFunction)
317 ProcessIRFunction(*
F);
326 yaml::EmptyContext Ctx;
330 TM.createDefaultFuncInfoYAML());
332 yaml::yamlize(In, YamlMF,
false, Ctx);
338 Function *
F = M.getFunction(FunctionName);
343 return error(
Twine(
"function '") + FunctionName +
344 "' isn't defined in the provided LLVM IR");
350 return error(
Twine(
"redefinition of machine function '") + FunctionName +
361 return error(
Twine(
"redefinition of machine function '") + FunctionName +
375 for (
unsigned I = 0, E =
MRI.getNumVirtRegs();
I != E; ++
I) {
377 if (!
MRI.hasOneDef(Reg) && !
MRI.def_empty(Reg))
388bool MIRParserImpl::computeFunctionProperties(
393 bool HasInlineAsm =
false;
394 bool HasFakeUses =
false;
395 bool AllTiedOpsRewritten =
true, HasTiedOps =
false;
400 if (
MI.isInlineAsm())
404 for (
unsigned I = 0;
I <
MI.getNumOperands(); ++
I) {
409 if (MO.
isUse() &&
MI.isRegTiedToDefOperand(
I, &DefIdx)) {
411 if (MO.
getReg() !=
MI.getOperand(DefIdx).getReg())
412 AllTiedOpsRewritten =
false;
420 auto ComputedPropertyHelper =
421 [&Properties](std::optional<bool> ExplicitProp,
bool ComputedProp,
424 if (ExplicitProp.value_or(ComputedProp))
430 return ExplicitProp && *ExplicitProp && !ComputedProp;
433 if (ComputedPropertyHelper(YamlMF.
NoPHIs, !HasPHI,
435 return error(MF.getName() +
436 " has explicit property NoPhi, but contains at least one PHI");
439 MF.setHasInlineAsm(HasInlineAsm);
441 if (HasTiedOps && AllTiedOpsRewritten)
442 Properties.setTiedOpsRewritten();
444 if (ComputedPropertyHelper(YamlMF.
IsSSA,
isSSA(MF),
446 return error(MF.getName() +
447 " has explicit property IsSSA, but is not valid SSA");
451 if (ComputedPropertyHelper(YamlMF.
NoVRegs,
MRI.getNumVirtRegs() == 0,
455 " has explicit property NoVRegs, but contains virtual registers");
465 " has explicit property hasFakeUses=false, but contains fake uses");
466 MF.setHasFakeUses(YamlMF.
HasFakeUses.value_or(HasFakeUses));
476 Twine(
" instruction block out of range.") +
480 if (MILoc.
Offset >= BB->size())
483 " Unable to reference instruction at bb: " +
Twine(MILoc.
BlockNum) +
485 MI = &*std::next(BB->instr_begin(), MILoc.
Offset);
497 if (parseMachineInst(MF, MILoc, CallI))
501 Twine(
" call site info should reference call "
502 "instruction. Instruction at bb:") +
504 " is not a call instruction");
506 for (
auto ArgRegPair : YamlCSInfo.ArgForwardingRegs) {
509 return error(
Error, ArgRegPair.Reg.SourceRange);
510 CSInfo.
ArgRegPairs.emplace_back(Reg, ArgRegPair.ArgNo);
512 if (!YamlCSInfo.CalleeTypeIds.empty()) {
513 for (
auto CalleeTypeId : YamlCSInfo.CalleeTypeIds) {
515 CSInfo.
CalleeTypeIds.push_back(ConstantInt::get(Int64Ty, CalleeTypeId,
520 if (TM.Options.EmitCallSiteInfo || TM.Options.EmitCallGraphSection)
525 !(TM.Options.EmitCallSiteInfo || TM.Options.EmitCallGraphSection))
526 return error(
"call site info provided but not used");
530void MIRParserImpl::setupDebugValueTracking(
534 unsigned MaxInstrNum = 0;
537 MaxInstrNum = std::max(
MI.peekDebugInstrNum(), MaxInstrNum);
538 MF.setDebugInstrNumberingCount(MaxInstrNum);
542 MF.makeDebugValueSubstitution({
Sub.SrcInst,
Sub.SrcOp},
574 Props.setLegalized();
576 Props.setRegBankSelected();
580 Props.setFailedISel();
582 Props.setFailsVerification();
584 Props.setTracksDebugUserValues();
663 MRI.freezeReservedRegs();
665 if (computeFunctionProperties(MF, YamlMF))
674 setupDebugValueTracking(MF, PFS, YamlMF);
695 return error(VReg.ID.SourceRange.Start,
696 Twine(
"redefinition of virtual register '%") +
697 Twine(VReg.ID.Value) +
"'");
698 Info.Explicit =
true;
700 if (VReg.Class.Value ==
"_") {
702 Info.D.RegBank =
nullptr;
704 const auto *RC =
Target->getRegClass(VReg.Class.Value);
712 VReg.Class.SourceRange.Start,
713 Twine(
"use of undefined register class or register bank '") +
714 VReg.Class.Value +
"'");
716 Info.D.RegBank = RegBank;
720 if (!VReg.PreferredRegister.Value.empty()) {
722 return error(VReg.Class.SourceRange.Start,
723 Twine(
"preferred register can only be set for normal vregs"));
726 VReg.PreferredRegister.Value,
Error))
727 return error(
Error, VReg.PreferredRegister.SourceRange);
730 for (
const auto &FlagStringValue : VReg.RegisterFlags) {
732 if (
Target->getVRegFlagValue(FlagStringValue.Value, FlagValue))
733 return error(FlagStringValue.SourceRange.Start,
734 Twine(
"use of undefined register flag '") +
735 FlagStringValue.Value +
"'");
736 Info.Flags |= FlagValue;
742 for (
const auto &LiveIn : YamlMF.
LiveIns) {
745 return error(
Error, LiveIn.Register.SourceRange);
747 if (!LiveIn.VirtualRegister.Value.empty()) {
751 return error(
Error, LiveIn.VirtualRegister.SourceRange);
765 CalleeSavedRegisters.
push_back(Reg.id());
787 (
Twine(
"Cannot determine class/bank of virtual register ") +
Name +
788 " in function '" + MF.
getName() +
"'")
792 if (!
Info.D.RC->isAllocatable()) {
794 TRI->getRegClassName(
Info.D.RC) +
795 "' for virtual register " +
Name +
" in function '" +
801 MRI.setRegClass(Reg,
Info.D.RC);
802 if (
Info.PreferredReg != 0)
803 MRI.setSimpleHint(Reg,
Info.PreferredReg);
808 MRI.setRegBank(Reg, *
Info.D.RegBank);
827 if (
auto *RegMask =
TRI->getCustomEHPadPreservedMask(MF))
828 MRI.addPhysRegsUsedFromRegMask(RegMask);
844 for (
auto &E : Errors)
884 std::vector<CalleeSavedInfo> CSIInfo;
890 Object.IsImmutable, Object.IsAliased);
895 return error(Object.ID.SourceRange.Start,
896 Twine(
"StackID is not supported by target"));
902 return error(Object.ID.SourceRange.Start,
903 Twine(
"redefinition of fixed stack object '%fixed-stack.") +
904 Twine(Object.ID.Value) +
"'");
906 Object.CalleeSavedRestored, ObjectIdx))
917 return error(
Error, Object.EntryValueRegister.SourceRange);
918 if (!Reg.isPhysical())
919 return error(Object.EntryValueRegister.SourceRange.Start,
920 "Expected physical register for entry value field");
922 PFS, Object.DebugVar, Object.DebugExpr, Object.DebugLoc);
925 if (MaybeInfo->DIVar || MaybeInfo->DIExpr || MaybeInfo->DILoc)
927 Reg.asMCReg(), MaybeInfo->DILoc);
935 if (!
Name.Value.empty()) {
936 Alloca = dyn_cast_or_null<AllocaInst>(
937 F.getValueSymbolTable()->lookup(
Name.Value));
940 "alloca instruction named '" +
Name.Value +
941 "' isn't defined in the function '" +
F.getName() +
945 return error(Object.ID.SourceRange.Start,
946 Twine(
"StackID is not supported by target"));
952 Object.Size, Object.Alignment.valueOrOne(),
959 return error(Object.ID.SourceRange.Start,
960 Twine(
"redefinition of stack object '%stack.") +
961 Twine(Object.ID.Value) +
"'");
963 Object.CalleeSavedRestored, ObjectIdx))
965 if (Object.LocalOffset)
971 if (!CSIInfo.empty())
996 std::vector<CalleeSavedInfo> &CSIInfo,
998 if (RegisterSource.
Value.empty())
1006 CSIInfo.push_back(CSI);
1011template <
typename T>
1017 Result = dyn_cast<T>(
Node);
1019 return Parser.
error(Source.SourceRange.Start,
1020 "expected a reference to a '" + TypeString +
1031 if (parseMDNode(PFS, Var, VarStr) || parseMDNode(PFS, Expr, ExprStr) ||
1032 parseMDNode(PFS, Loc, LocStr))
1033 return std::nullopt;
1040 return std::nullopt;
1044template <
typename T>
1046 const T &Object,
int FrameIdx) {
1047 std::optional<VarExprLoc> MaybeInfo =
1048 parseVarExprLoc(PFS, Object.DebugVar, Object.DebugExpr, Object.DebugLoc);
1053 if (MaybeInfo->DIVar || MaybeInfo->DIExpr || MaybeInfo->DILoc)
1061 if (Source.Value.empty())
1075 for (
const auto &YamlConstant : YamlMF.
Constants) {
1076 if (YamlConstant.IsTargetSpecific)
1078 return error(YamlConstant.Value.SourceRange.Start,
1079 "Can't parse target-specific constant pool entries yet");
1083 return error(
Error, YamlConstant.Value.SourceRange);
1084 const Align PrefTypeAlign =
1086 const Align Alignment = YamlConstant.Alignment.value_or(PrefTypeAlign);
1088 if (!ConstantPoolSlots.
insert(std::make_pair(YamlConstant.ID.Value, Index))
1090 return error(YamlConstant.ID.SourceRange.Start,
1091 Twine(
"redefinition of constant pool item '%const.") +
1092 Twine(YamlConstant.ID.Value) +
"'");
1100 const std::vector<yaml::SaveRestorePointEntry> &YamlSRPoints,
1104 if (parseMBBReference(PFS,
MBB, Entry.Point.Value))
1115 for (
const auto &Entry : YamlJTI.
Entries) {
1116 std::vector<MachineBasicBlock *>
Blocks;
1117 for (
const auto &MBBSource : Entry.Blocks) {
1119 if (parseMBBReference(PFS,
MBB, MBBSource.Value))
1126 return error(Entry.ID.SourceRange.Start,
1127 Twine(
"redefinition of jump table entry '%jump-table.") +
1128 Twine(Entry.ID.Value) +
"'");
1154 if (parseMachineMetadata(PFS, MDS))
1160 "use of undefined metadata '!" +
1172 if (parseMachineInst(MF, MILoc, CallI))
1176 Twine(
" called global should reference call "
1177 "instruction. Instruction at bb:") +
1179 " is not a call instruction");
1182 F.getParent()->getValueSymbolTable().lookup(YamlCG.Callee.Value);
1184 return error(YamlCG.Callee.SourceRange.Start,
1185 "use of undefined global '" + YamlCG.Callee.Value +
"'");
1186 if (!isa<GlobalValue>(Callee))
1187 return error(YamlCG.Callee.SourceRange.Start,
1188 "use of non-global value '" + YamlCG.Callee.Value +
"'");
1205 (HasQuote ? 1 : 0));
1219 unsigned Line = LineAndColumn.first +
Error.getLineNo() - 1;
1220 unsigned Column =
Error.getColumnNo();
1228 if (L.line_number() == Line) {
1231 auto Indent = LineStr.
find(
Error.getLineContents());
1239 Error.getMessage(), LineStr,
Error.getRanges(),
1248std::unique_ptr<Module>
1250 return Impl->parseIRModule(DataLayoutCallback);
1254 return Impl->parseMachineFunctions(M, MMI);
1259 return Impl->parseMachineFunctions(M, MMI, &
MAM);
1264 std::function<
void(
Function &)> ProcessIRFunction) {
1266 if (std::error_code EC = FileOrErr.getError()) {
1268 "Could not open input file: " + EC.message());
1275std::unique_ptr<MIRParser>
1278 std::function<
void(
Function &)> ProcessIRFunction) {
1279 auto Filename = Contents->getBufferIdentifier();
1280 if (
Context.shouldDiscardValueNames()) {
1285 "Can't read MIR with a Context that discards named Values")));
1288 return std::make_unique<MIRParser>(std::make_unique<MIRParserImpl>(
1289 std::move(Contents), Filename,
Context, ProcessIRFunction));
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Analysis containing CSE Info
This file defines the DenseMap class.
DenseMap< Block *, BlockRelaxAux > Blocks
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.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Register const TargetRegisterInfo * TRI
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
an instruction to allocate memory on the stack
A container for analyses that lazily runs them and caches their results.
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
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)
Module * getParent()
Get the module that this global value is contained inside of...
@ ExternalLinkage
Externally visible function.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
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.
bool initializeSaveRestorePoints(PerFunctionMIParsingState &PFS, const std::vector< yaml::SaveRestorePointEntry > &YamlSRPoints, SmallVectorImpl< MachineBasicBlock * > &SaveRestorePoints)
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)
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 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 parseMachineFunction(Module &M, MachineModuleInfo &MMI, ModuleAnalysisManager *FAM)
Parse the machine function in the current YAML document.
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.
bool isEHPad() const
Returns true if the block is a landing pad.
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 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 setCVBytesOfCalleeSavedRegisters(unsigned S)
void setRestorePoints(ArrayRef< MachineBasicBlock * > NewRestorePoints)
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 setSavePoints(ArrayRef< MachineBasicBlock * > NewSavePoints)
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.
MachineFunctionProperties & set(Property P)
MachineFunctionProperties & reset(Property P)
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.
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
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.
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,...
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
void invalidateLiveness()
invalidateLiveness - Indicates that register liveness is no longer being tracked accurately.
void noteNewVirtualRegister(Register Reg)
LLVM_ABI void setCalleeSavedRegs(ArrayRef< MCPhysReg > CSRs)
Sets the updated Callee Saved Registers list.
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
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.
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.
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.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
StringRef - Represent a constant reference to a string, i.e.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
static constexpr size_t npos
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.
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.
Target - Wrapper for Target specific 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.
An efficient, type-erasing, non-owning reference to a callable.
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.
This is an optimization pass for GlobalISel generic memory operations.
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine basic block definitions, and skip the machine instructions.
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
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.
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.
@ Sub
Subtraction of integers.
LLVM_ABI std::unique_ptr< Module > parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context, SlotMapping *Slots=nullptr, DataLayoutCallbackTy DataLayoutCallback=[](StringRef, StringRef) { return std::nullopt;})
parseAssemblyFile and parseAssemblyString are wrappers around this function.
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
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.
bool parseMachineMetadata(PerFunctionMIParsingState &PFS, StringRef Src, SMRange SourceRange, SMDiagnostic &Error)
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
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
VRegInfo & getVRegInfo(Register Num)
DenseMap< unsigned, int > FixedStackObjectSlots
DenseMap< unsigned, unsigned > ConstantPoolSlots
StringMap< VRegInfo * > VRegInfosNamed
DenseMap< unsigned, int > StackObjectSlots
std::map< unsigned, std::pair< TempMDTuple, SMLoc > > MachineForwardRefMDNodes
DenseMap< Register, VRegInfo * > VRegInfos
This struct contains the mappings from the slot numbers to unnamed metadata nodes,...
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
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
A wrapper around std::string which contains a source range that's being set during parsing.