LLVM 20.0.0git
|
This class implements the parsing of LLVM IR that's embedded inside a MIR file. More...
Classes | |
struct | VarExprLoc |
This class implements the parsing of LLVM IR that's embedded inside a MIR file.
Definition at line 51 of file MIRParser.cpp.
MIRParserImpl::MIRParserImpl | ( | std::unique_ptr< MemoryBuffer > | Contents, |
StringRef | Filename, | ||
LLVMContext & | Context, | ||
std::function< void(Function &)> | ProcessIRFunction | ||
) |
Definition at line 194 of file MIRParser.cpp.
Create an empty function with the given name.
Definition at line 297 of file MIRParser.cpp.
References llvm::Function::Create(), llvm::BasicBlock::Create(), llvm::GlobalValue::ExternalLinkage, F, llvm::FunctionType::get(), llvm::Type::getVoidTy(), and Name.
Referenced by parseMachineFunction().
bool MIRParserImpl::error | ( | const SMDiagnostic & | Error, |
SMRange | SourceRange | ||
) |
Report a given error with the location translated from the location in an embedded string literal to a location in the MIR file.
Always returns true.
Definition at line 217 of file MIRParser.cpp.
References assert(), llvm::SourceMgr::DK_Error, and reportDiagnostic().
Report an error with the given message at unknown location.
Always returns true.
Definition at line 205 of file MIRParser.cpp.
References llvm::LLVMContext::diagnose(), llvm::SourceMgr::DK_Error, llvm::DS_Error, and llvm::Twine::str().
Referenced by typecheckMDNode().
Report an error with the given message at the given location.
Always returns true.
Definition at line 211 of file MIRParser.cpp.
References llvm::LLVMContext::diagnose(), llvm::SourceMgr::DK_Error, llvm::DS_Error, and llvm::SourceMgr::GetMessage().
bool MIRParserImpl::initializeCallSiteInfo | ( | PerFunctionMIParsingState & | PFS, |
const yaml::MachineFunction & | YamlMF | ||
) |
Definition at line 460 of file MIRParser.cpp.
References llvm::MachineFunction::addCallSiteInfo(), llvm::MachineFunction::CallSiteInfo::ArgRegPairs, llvm::MachineFunction::begin(), llvm::yaml::CallSiteInfo::MachineInstrLoc::BlockNum, llvm::yaml::MachineFunction::CallSitesInfo, error, llvm::MachineFunction::getName(), llvm::MachineFunction::getTarget(), llvm::MachineInstr::IgnoreBundle, llvm::PerFunctionMIParsingState::MF, llvm::yaml::CallSiteInfo::MachineInstrLoc::Offset, llvm::parseNamedRegisterReference(), and llvm::MachineFunction::size().
Referenced by initializeMachineFunction().
bool MIRParserImpl::initializeConstantPool | ( | PerFunctionMIParsingState & | PFS, |
MachineConstantPool & | ConstantPool, | ||
const yaml::MachineFunction & | YamlMF | ||
) |
Definition at line 1033 of file MIRParser.cpp.
References llvm::PerFunctionMIParsingState::ConstantPoolSlots, llvm::yaml::MachineFunction::Constants, error, llvm::MachineFunction::getFunction(), llvm::GlobalValue::getParent(), llvm::Value::getType(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::PerFunctionMIParsingState::MF, and llvm::parseConstantValue().
Referenced by initializeMachineFunction().
bool MIRParserImpl::initializeFrameInfo | ( | PerFunctionMIParsingState & | PFS, |
const yaml::MachineFunction & | YamlMF | ||
) |
Definition at line 809 of file MIRParser.cpp.
References llvm::yaml::MachineFrameInfo::AdjustsStack, llvm::MachineFrameInfo::CreateFixedObject(), llvm::MachineFrameInfo::CreateFixedSpillStackObject(), llvm::MachineFrameInfo::CreateStackObject(), llvm::MachineFrameInfo::CreateVariableSizedObject(), llvm::yaml::MachineFrameInfo::CVBytesOfCalleeSavedRegisters, llvm::MachineFrameInfo::ensureMaxAlignment(), llvm::yaml::MachineFunction::EntryValueObjects, error, F, llvm::yaml::MachineFunction::FixedStackObjects, llvm::PerFunctionMIParsingState::FixedStackObjectSlots, llvm::yaml::MachineFunction::FrameInfo, llvm::yaml::MachineFrameInfo::FunctionContext, llvm::MachineFunction::getFrameInfo(), llvm::TargetSubtargetInfo::getFrameLowering(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getSubtarget(), llvm::yaml::MachineFrameInfo::HasCalls, llvm::yaml::MachineFrameInfo::HasMustTailInVarArgFunc, llvm::yaml::MachineFrameInfo::HasOpaqueSPAdjustment, llvm::yaml::MachineFrameInfo::HasPatchPoint, llvm::yaml::MachineFrameInfo::HasStackMap, llvm::yaml::MachineFrameInfo::HasTailCall, llvm::yaml::MachineFrameInfo::HasVAStart, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::yaml::MachineFrameInfo::IsCalleeSavedInfoValid, llvm::yaml::MachineFrameInfo::IsFrameAddressTaken, llvm::yaml::MachineFrameInfo::IsReturnAddressTaken, llvm::TargetFrameLowering::isSupportedStackID(), llvm::yaml::MachineFrameInfo::LocalFrameSize, llvm::MachineFrameInfo::mapLocalFrameObject(), llvm::yaml::MachineFrameInfo::MaxAlignment, llvm::yaml::MachineFrameInfo::MaxCallFrameSize, MBB, llvm::PerFunctionMIParsingState::MF, Name, llvm::yaml::MachineFrameInfo::OffsetAdjustment, parseCalleeSavedRegister(), llvm::parseNamedRegisterReference(), llvm::parseStackObjectReference(), parseStackObjectsDebugInfo(), parseVarExprLoc(), llvm::yaml::MachineFrameInfo::RestorePoint, llvm::yaml::MachineFrameInfo::SavePoint, llvm::MachineFrameInfo::setAdjustsStack(), llvm::MachineFrameInfo::setCalleeSavedInfo(), llvm::MachineFrameInfo::setCalleeSavedInfoValid(), llvm::MachineFrameInfo::setCVBytesOfCalleeSavedRegisters(), llvm::MachineFrameInfo::setFrameAddressIsTaken(), llvm::MachineFrameInfo::setFunctionContextIndex(), llvm::MachineFrameInfo::setHasCalls(), llvm::MachineFrameInfo::setHasMustTailInVarArgFunc(), llvm::MachineFrameInfo::setHasOpaqueSPAdjustment(), llvm::MachineFrameInfo::setHasPatchPoint(), llvm::MachineFrameInfo::setHasStackMap(), llvm::MachineFrameInfo::setHasTailCall(), llvm::MachineFrameInfo::setHasVAStart(), llvm::MachineFrameInfo::setLocalFrameSize(), llvm::MachineFrameInfo::setMaxCallFrameSize(), llvm::MachineFrameInfo::setObjectAlignment(), llvm::MachineFrameInfo::setObjectOffset(), llvm::MachineFrameInfo::setOffsetAdjustment(), llvm::MachineFrameInfo::setRestorePoint(), llvm::MachineFrameInfo::setReturnAddressIsTaken(), llvm::MachineFrameInfo::setSavePoint(), llvm::MachineFrameInfo::setStackID(), llvm::MachineFrameInfo::setStackProtectorIndex(), llvm::MachineFrameInfo::setStackSize(), llvm::MachineFunction::setVariableDbgInfo(), llvm::yaml::StringValue::SourceRange, llvm::yaml::MachineStackObject::SpillSlot, llvm::yaml::FixedMachineStackObject::SpillSlot, llvm::yaml::MachineFunction::StackObjects, llvm::PerFunctionMIParsingState::StackObjectSlots, llvm::yaml::MachineFrameInfo::StackProtector, llvm::yaml::MachineFrameInfo::StackSize, llvm::yaml::StringValue::Value, and llvm::yaml::MachineStackObject::VariableSized.
Referenced by initializeMachineFunction().
bool MIRParserImpl::initializeJumpTableInfo | ( | PerFunctionMIParsingState & | PFS, |
const yaml::MachineJumpTable & | YamlJTI | ||
) |
Definition at line 1061 of file MIRParser.cpp.
References Blocks, llvm::MachineJumpTableInfo::createJumpTableIndex(), llvm::yaml::MachineJumpTable::Entries, error, llvm::MachineFunction::getOrCreateJumpTableInfo(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::PerFunctionMIParsingState::JumpTableSlots, llvm::yaml::MachineJumpTable::Kind, MBB, and llvm::PerFunctionMIParsingState::MF.
Referenced by initializeMachineFunction().
bool MIRParserImpl::initializeMachineFunction | ( | const yaml::MachineFunction & | YamlMF, |
MachineFunction & | MF | ||
) |
Initialize the machine function to the state that's described in the MIR file.
Return true if error occurred.
Definition at line 522 of file MIRParser.cpp.
References llvm::SourceMgr::AddNewSourceBuffer(), llvm::yaml::MachineFunction::Alignment, assert(), llvm::MachineFunction::assignBeginEndSections(), llvm::yaml::MachineFunction::Body, llvm::yaml::MachineFunction::CallsEHReturn, llvm::yaml::MachineFunction::CallsUnwindInit, llvm::yaml::MachineFunction::Constants, llvm::yaml::MachineJumpTable::Entries, error, llvm::errs(), llvm::yaml::MachineFunction::ExposesReturnsTwice, llvm::MachineFunctionProperties::FailedISel, llvm::yaml::MachineFunction::FailedISel, llvm::MachineFunctionProperties::FailsVerification, llvm::yaml::MachineFunction::FailsVerification, llvm::MachineFunction::getConstantPool(), llvm::MemoryBuffer::getMemBuffer(), llvm::MachineFunction::getProperties(), llvm::MachineFunction::getRegInfo(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), llvm::MachineFunction::hasBBSections(), llvm::yaml::MachineFunction::HasEHCatchret, llvm::yaml::MachineFunction::HasEHFunclets, llvm::yaml::MachineFunction::HasEHScopes, llvm::yaml::MachineFunction::HasWinCFI, initializeCallSiteInfo(), initializeConstantPool(), initializeFrameInfo(), initializeJumpTableInfo(), llvm::yaml::MachineFunction::IsOutlined, llvm::yaml::MachineFunction::JumpTableInfo, llvm::MachineFunctionProperties::Legalized, llvm::yaml::MachineFunction::Legalized, llvm::yaml::MachineFunction::MachineFuncInfo, llvm::yaml::MachineFunction::MachineMetadataNodes, llvm::TargetSubtargetInfo::mirFileLoaded(), MRI, llvm::parseMachineBasicBlockDefinitions(), llvm::parseMachineInstructions(), parseMachineMetadataNodes(), parseRegisterInfo(), llvm::MachineFunctionProperties::RegBankSelected, llvm::yaml::MachineFunction::RegBankSelected, reportDiagnostic(), llvm::MachineFunctionProperties::Selected, llvm::yaml::MachineFunction::Selected, llvm::MachineFunctionProperties::set(), llvm::MachineFunction::setAlignment(), llvm::MachineFunction::setCallsEHReturn(), llvm::MachineFunction::setCallsUnwindInit(), llvm::MachineFunction::setExposesReturnsTwice(), llvm::MachineFunction::setHasEHCatchret(), llvm::MachineFunction::setHasEHFunclets(), llvm::MachineFunction::setHasEHScopes(), llvm::MachineFunction::setHasWinCFI(), llvm::MachineFunction::setIsOutlined(), setupRegisterInfo(), llvm::PerFunctionMIParsingState::SM, llvm::yaml::StringValue::SourceRange, llvm::MachineFunctionProperties::TracksDebugUserValues, llvm::yaml::MachineFunction::TracksDebugUserValues, llvm::yaml::StringValue::Value, llvm::yaml::BlockStringValue::Value, llvm::MaybeAlign::valueOrOne(), and llvm::MachineFunction::verify().
Referenced by parseMachineFunction().
bool MIRParserImpl::parseCalleeSavedRegister | ( | PerFunctionMIParsingState & | PFS, |
std::vector< CalleeSavedInfo > & | CSIInfo, | ||
const yaml::StringValue & | RegisterSource, | ||
bool | IsRestored, | ||
int | FrameIdx | ||
) |
Definition at line 959 of file MIRParser.cpp.
References error, llvm::parseNamedRegisterReference(), llvm::CalleeSavedInfo::setRestored(), llvm::yaml::StringValue::SourceRange, and llvm::yaml::StringValue::Value.
Referenced by initializeFrameInfo().
std::unique_ptr< Module > MIRParserImpl::parseIRModule | ( | DataLayoutCallbackTy | DataLayoutCallback | ) |
Try to parse the optional LLVM module and the machine functions in the MIR file.
Return null if an error occurred.
Definition at line 243 of file MIRParser.cpp.
References llvm::parseAssembly(), and reportDiagnostic().
bool MIRParserImpl::parseMachineFunction | ( | Module & | M, |
MachineModuleInfo & | MMI, | ||
ModuleAnalysisManager * | FAM | ||
) |
Parse the machine function in the current YAML document.
Return true if an error occurred.
Definition at line 311 of file MIRParser.cpp.
References createDummyFunction(), error, F, FAM, llvm::AnalysisManager< IRUnitT, ExtraArgTs >::getCachedResult(), llvm::MachineModuleInfo::getMachineFunction(), llvm::MachineModuleInfo::getOrCreateMachineFunction(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::getResult(), llvm::MachineModuleInfo::getTarget(), initializeMachineFunction(), llvm::yaml::MachineFunction::MachineFuncInfo, MAM, and llvm::yaml::MachineFunction::Name.
Referenced by parseMachineFunctions().
bool MIRParserImpl::parseMachineFunctions | ( | Module & | M, |
MachineModuleInfo & | MMI, | ||
ModuleAnalysisManager * | FAM = nullptr |
||
) |
Definition at line 282 of file MIRParser.cpp.
References MAM, and parseMachineFunction().
bool MIRParserImpl::parseMachineMetadataNodes | ( | PerFunctionMIParsingState & | PFS, |
MachineFunction & | MF, | ||
const yaml::MachineFunction & | YMF | ||
) |
Definition at line 1099 of file MIRParser.cpp.
References error, llvm::PerFunctionMIParsingState::MachineForwardRefMDNodes, and llvm::yaml::MachineFunction::MachineMetadataNodes.
Referenced by initializeMachineFunction().
bool MIRParserImpl::parseRegisterInfo | ( | PerFunctionMIParsingState & | PFS, |
const yaml::MachineFunction & | YamlMF | ||
) |
Definition at line 652 of file MIRParser.cpp.
References llvm::MachineRegisterInfo::addLiveIn(), assert(), llvm::yaml::MachineFunction::CalleeSavedRegisters, error, llvm::VRegInfo::GENERIC, llvm::MachineFunction::getRegInfo(), llvm::PerFunctionMIParsingState::getVRegInfo(), Info, llvm::MachineRegisterInfo::invalidateLiveness(), llvm::yaml::MachineFunction::LiveIns, llvm::PerFunctionMIParsingState::MF, llvm::VRegInfo::NORMAL, llvm::MachineRegisterInfo::noteNewVirtualRegister(), llvm::parseNamedRegisterReference(), llvm::parseRegisterReference(), llvm::parseVirtualRegisterReference(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::VRegInfo::REGBANK, llvm::MachineRegisterInfo::setCalleeSavedRegs(), llvm::MachineRegisterInfo::tracksLiveness(), llvm::yaml::MachineFunction::TracksRegLiveness, and llvm::yaml::MachineFunction::VirtualRegisters.
Referenced by initializeMachineFunction().
bool MIRParserImpl::parseStackObjectsDebugInfo | ( | PerFunctionMIParsingState & | PFS, |
const T & | Object, | ||
int | FrameIdx | ||
) |
Definition at line 1009 of file MIRParser.cpp.
References llvm::PerFunctionMIParsingState::MF, parseVarExprLoc(), and llvm::MachineFunction::setVariableDbgInfo().
Referenced by initializeFrameInfo().
std::optional< MIRParserImpl::VarExprLoc > MIRParserImpl::parseVarExprLoc | ( | PerFunctionMIParsingState & | PFS, |
const yaml::StringValue & | VarStr, | ||
const yaml::StringValue & | ExprStr, | ||
const yaml::StringValue & | LocStr | ||
) |
Definition at line 989 of file MIRParser.cpp.
References typecheckMDNode().
Referenced by initializeFrameInfo(), and parseStackObjectsDebugInfo().
void MIRParserImpl::reportDiagnostic | ( | const SMDiagnostic & | Diag | ) |
Definition at line 223 of file MIRParser.cpp.
References llvm::LLVMContext::diagnose(), llvm::SourceMgr::DK_Error, llvm::SourceMgr::DK_Note, llvm::SourceMgr::DK_Remark, llvm::SourceMgr::DK_Warning, llvm::DS_Error, llvm::DS_Note, llvm::DS_Warning, llvm::SMDiagnostic::getKind(), and llvm_unreachable.
Referenced by error(), initializeMachineFunction(), and parseIRModule().
bool MIRParserImpl::setupRegisterInfo | ( | const PerFunctionMIParsingState & | PFS, |
const yaml::MachineFunction & | YamlMF | ||
) |
Definition at line 743 of file MIRParser.cpp.
References error, llvm::VRegInfo::GENERIC, llvm::MachineFunction::getName(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineOperand::getRegMask(), llvm::MachineFunction::getSubtarget(), Info, llvm::MachineBasicBlock::isEHPad(), llvm::MachineOperand::isRegMask(), MBB, llvm::PerFunctionMIParsingState::MF, MI, MRI, Name, llvm::VRegInfo::NORMAL, P, llvm::VRegInfo::REGBANK, TRI, llvm::VRegInfo::UNKNOWN, llvm::PerFunctionMIParsingState::VRegInfos, and llvm::PerFunctionMIParsingState::VRegInfosNamed.
Referenced by initializeMachineFunction().