|
LLVM 23.0.0git
|
Namespaces | |
| namespace | amdgpu |
| namespace | intel |
| namespace | sycl |
Classes | |
| struct | EntryTy |
| This is the record of an object that just be registered with the offloading runtime. More... | |
| struct | InputDesc |
| Description of a single input (file or library). More... | |
| struct | ResolvedInputs |
| Result of archive member resolution. More... | |
| struct | SYCLJITOptions |
| struct | Symbol |
| A minimum symbol interface that provides the necessary information to extract archive members and resolve LTO symbols. More... | |
Typedefs | |
| using | EntryArrayTy = std::pair<GlobalVariable *, GlobalVariable *> |
| using | ByteArray = SmallVector<unsigned char, 0> |
| using | PropertyValue = std::variant<uint32_t, ByteArray> |
| using | PropertySet = std::map<std::string, PropertyValue> |
| using | PropertySetRegistry = std::map<std::string, PropertySet> |
Enumerations | |
| enum | OffloadEntryKindFlag : uint32_t { OffloadGlobalEntry = 0x0 , OffloadGlobalManagedEntry = 0x1 , OffloadGlobalSurfaceEntry = 0x2 , OffloadGlobalTextureEntry = 0x3 , OffloadGlobalExtern = 0x1 << 3 , OffloadGlobalConstant = 0x1 << 4 , OffloadGlobalNormalized = 0x1 << 5 } |
| Offloading entry flags for CUDA / HIP. More... | |
Functions | |
| Expected< ResolvedInputs > | resolveArchiveMembers (ArrayRef< InputDesc > Order, ArrayRef< StringRef > SearchPaths, ArrayRef< StringRef > ForcedUndefs={}, StringRef Root="", ArrayRef< Triple::ArchType > DeviceArchs={}) |
| Resolve archive members from the given inputs using a symbol-driven fixed-point algorithm. | |
| LLVM_ABI llvm::Error | wrapOpenMPBinaries (llvm::Module &M, llvm::ArrayRef< llvm::ArrayRef< char > > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool Relocatable=false) |
Wraps the input device images into the module M as global symbols and registers the images with the OpenMP Offloading runtime libomptarget. | |
| LLVM_ABI llvm::Error | wrapCudaBinary (llvm::Module &M, llvm::ArrayRef< char > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool EmitSurfacesAndTextures=true) |
Wraps the input fatbinary image into the module M as global symbols and registers the images with the CUDA runtime. | |
| LLVM_ABI llvm::Error | wrapHIPBinary (llvm::Module &M, llvm::ArrayRef< char > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool EmitSurfacesAndTextures=true) |
Wraps the input bundled image into the module M as global symbols and registers the images with the HIP runtime. | |
| LLVM_ABI llvm::Error | wrapSYCLBinaries (llvm::Module &M, llvm::ArrayRef< char > Buffer, SYCLJITOptions Options=SYCLJITOptions()) |
Wraps OffloadBinaries in the given Buffers into the module M as global symbols and registers the images with the SYCL Runtime. | |
| LLVM_ABI void | writePropertiesToJSON (const PropertySetRegistry &P, raw_ostream &O) |
| LLVM_ABI Expected< PropertySetRegistry > | readPropertiesFromJSON (MemoryBufferRef Buf) |
| LLVM_ABI StructType * | getEntryTy (Module &M) |
| Returns the type of the offloading entry we use to store kernels and globals that will be registered with the offloading runtime. | |
| LLVM_ABI StringRef | getOffloadEntrySection (Module &M) |
| Create an offloading section struct used to register this global at runtime. | |
| LLVM_ABI GlobalVariable * | emitOffloadingEntry (Module &M, object::OffloadKind Kind, Constant *Addr, StringRef Name, uint64_t Size, uint32_t Flags, uint64_t Data, Constant *AuxAddr=nullptr) |
| LLVM_ABI std::pair< Constant *, GlobalVariable * > | getOffloadingEntryInitializer (Module &M, object::OffloadKind Kind, Constant *Addr, StringRef Name, uint64_t Size, uint32_t Flags, uint64_t Data, Constant *AuxAddr) |
| Create a constant struct initializer used to register this global at runtime. | |
| LLVM_ABI std::pair< GlobalVariable *, GlobalVariable * > | getOffloadEntryArray (Module &M) |
| Creates a pair of globals used to iterate the array of offloading entries by accessing the section variables provided by the linker. | |
| LLVM_ABI Error | containerizeImage (std::unique_ptr< MemoryBuffer > &Binary, llvm::Triple Triple, object::ImageKind ImageKind, object::OffloadKind OffloadKind, int32_t ImageFlags, MapVector< StringRef, StringRef > &MetaData) |
| Containerizes an image within an OffloadBinary image. | |
| static std::optional< std::string > | findFile (StringRef Dir, StringRef Root, const Twine &Name) |
| static std::optional< std::string > | findFromSearchPaths (StringRef Name, StringRef Root, ArrayRef< StringRef > SearchPaths) |
| static std::optional< std::string > | searchLibrary (StringRef Input, StringRef Root, ArrayRef< StringRef > SearchPaths) |
| Search for static libraries in the linker's library path given input like -lfoo or -l:libfoo.a. | |
| static Expected< bool > | getSymbolsFromBitcode (MemoryBufferRef Buffer, StringMap< Symbol > &SymTab, bool IsLazy) |
| static Expected< bool > | getSymbolsFromObject (ObjectFile &ObjFile, StringMap< Symbol > &SymTab, bool IsLazy) |
| static bool | isFatBinary (MemoryBufferRef Buffer, ArrayRef< Triple::ArchType > DeviceArchs) |
| Identify "fat binary" inputs that should be passed through to the linker without symbol-driven extraction. | |
| static Expected< bool > | getSymbols (MemoryBufferRef Buffer, StringMap< Symbol > &SymTab, bool IsLazy) |
| using llvm::offloading::ByteArray = SmallVector<unsigned char, 0> |
Definition at line 25 of file PropertySet.h.
| using llvm::offloading::EntryArrayTy = std::pair<GlobalVariable *, GlobalVariable *> |
Definition at line 20 of file OffloadWrapper.h.
| using llvm::offloading::PropertySet = std::map<std::string, PropertyValue> |
Definition at line 27 of file PropertySet.h.
| using llvm::offloading::PropertySetRegistry = std::map<std::string, PropertySet> |
Definition at line 28 of file PropertySet.h.
| using llvm::offloading::PropertyValue = std::variant<uint32_t, ByteArray> |
Definition at line 26 of file PropertySet.h.
Offloading entry flags for CUDA / HIP.
The first three bits indicate the type of entry while the others are a bit field for additional information.
| Error llvm::offloading::containerizeImage | ( | std::unique_ptr< MemoryBuffer > & | Binary, |
| llvm::Triple | Triple, | ||
| object::ImageKind | ImageKind, | ||
| object::OffloadKind | OffloadKind, | ||
| int32_t | ImageFlags, | ||
| MapVector< StringRef, StringRef > & | MetaData ) |
Containerizes an image within an OffloadBinary image.
Creates a nested OffloadBinary structure where the inner binary contains the raw image and associated metadata (version, format, triple, etc.).
| Binary | The image to containerize. |
| Triple | The target triple to be associated with the image. |
| ImageKind | The format of the image, e.g. SPIR-V or CUBIN. |
| OffloadKind | The expected consuming runtime of the image, e.g. CUDA or OpenMP. |
| ImageFlags | Flags associated with the image, e.g. for AMDGPU the features. |
| MetaData | The key-value map of metadata to be associated with the image. |
Definition at line 432 of file Utility.cpp.
References llvm::MemoryBuffer::getMemBufferCopy(), llvm::Triple::getTriple(), llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, and llvm::Error::success().
Referenced by llvm::offloading::intel::containerizeOpenMPSPIRVImage().
| GlobalVariable * llvm::offloading::emitOffloadingEntry | ( | Module & | M, |
| object::OffloadKind | Kind, | ||
| Constant * | Addr, | ||
| StringRef | Name, | ||
| uint64_t | Size, | ||
| uint32_t | Flags, | ||
| uint64_t | Data, | ||
| Constant * | AuxAddr = nullptr ) |
Definition at line 105 of file Utility.cpp.
References llvm::Data, llvm::object::OffloadBinary::getAlignment(), getEntryTy(), getOffloadEntrySection(), getOffloadingEntryInitializer(), llvm::Triple::isNVPTX(), llvm::Triple::isOSBinFormatCOFF(), llvm::GlobalValue::NotThreadLocal, Size, and llvm::GlobalValue::WeakAnyLinkage.
Referenced by llvm::OpenMPIRBuilder::createOffloadEntriesAndInfoMetadata(), and llvm::OpenMPIRBuilder::createOffloadEntry().
|
static |
Definition at line 50 of file ArchiveLinker.cpp.
References llvm::sys::path::append(), llvm::sys::fs::exists(), llvm::StringRef::starts_with(), and llvm::StringRef::substr().
Referenced by findFromSearchPaths().
|
static |
Definition at line 64 of file ArchiveLinker.cpp.
References findFile().
Referenced by searchLibrary().
| StructType * llvm::offloading::getEntryTy | ( | Module & | M | ) |
Returns the type of the offloading entry we use to store kernels and globals that will be registered with the offloading runtime.
Definition at line 28 of file Utility.cpp.
References llvm::CallingConv::C, llvm::StructType::create(), llvm::Type::getInt16Ty(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::StructType::getTypeByName(), and llvm::PointerType::getUnqual().
Referenced by emitOffloadingEntry(), getOffloadEntryArray(), and getOffloadingEntryInitializer().
| std::pair< GlobalVariable *, GlobalVariable * > llvm::offloading::getOffloadEntryArray | ( | Module & | M | ) |
Creates a pair of globals used to iterate the array of offloading entries by accessing the section variables provided by the linker.
Definition at line 132 of file Utility.cpp.
References llvm::appendToCompilerUsed(), llvm::GlobalValue::ExternalLinkage, llvm::ArrayType::get(), llvm::ConstantAggregateZero::get(), llvm::object::OffloadBinary::getAlignment(), getEntryTy(), getOffloadEntryBoundarySymbols(), getOffloadEntrySection(), llvm::GlobalValue::HiddenVisibility, llvm::GlobalValue::InternalLinkage, llvm::Triple::isOSBinFormatCOFF(), llvm::Triple::isOSBinFormatELF(), llvm::Triple::isOSBinFormatMachO(), and llvm::GlobalValue::WeakODRLinkage.
Create an offloading section struct used to register this global at runtime.
| M | The module to be used |
| Addr | The pointer to the global being registered. |
| Kind | The offloading language expected to consume this. |
| Name | The symbol name associated with the global. |
| Size | The size in bytes of the global (0 for functions). |
| Flags | Flags associated with the entry. |
| Data | Extra data storage associated with the entry. |
| SectionName | The section this entry will be placed at. |
| AuxAddr | An extra pointer if needed. Returns the section name for offloading entries based on the target triple. ELF: "llvm_offload_entries", COFF: "llvm_offload_entries", Mach-O: "__LLVM,offload_entries". |
Definition at line 87 of file Utility.cpp.
Referenced by emitOffloadingEntry(), and getOffloadEntryArray().
| std::pair< Constant *, GlobalVariable * > llvm::offloading::getOffloadingEntryInitializer | ( | Module & | M, |
| object::OffloadKind | Kind, | ||
| Constant * | Addr, | ||
| StringRef | Name, | ||
| uint64_t | Size, | ||
| uint32_t | Flags, | ||
| uint64_t | Data, | ||
| Constant * | AuxAddr ) |
Create a constant struct initializer used to register this global at runtime.
Definition at line 42 of file Utility.cpp.
References llvm::NamedMDNode::addOperand(), llvm::Data, llvm::ConstantAsMetadata::get(), llvm::ConstantStruct::get(), llvm::MDNode::get(), getEntryTy(), llvm::Type::getInt16Ty(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::Constant::getNullValue(), llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(), llvm::ConstantDataArray::getString(), llvm::Value::getType(), llvm::PointerType::getUnqual(), llvm::GlobalValue::Global, llvm::Int32Ty, llvm::GlobalValue::InternalLinkage, llvm::Triple::isNVPTX(), and Size.
Referenced by emitOffloadingEntry().
|
static |
Definition at line 178 of file ArchiveLinker.cpp.
References llvm::file_magic::bitcode, llvm::ObjectFile::createObjectFile(), llvm::createStringError(), llvm::file_magic::elf_relocatable, llvm::MemoryBufferRef::getBuffer(), llvm::MemoryBufferRef::getBufferIdentifier(), getSymbolsFromBitcode(), getSymbolsFromObject(), llvm::identify_magic(), and llvm::Expected< T >::takeError().
Referenced by resolveArchiveMembers().
|
static |
Definition at line 84 of file ArchiveLinker.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::count(), I, llvm::offloading::Symbol::isUndefined(), llvm::offloading::Symbol::isWeak(), llvm::offloading::Symbol::None, llvm::object::readIRSymtab(), llvm::offloading::Symbol::SymFlags, llvm::Expected< T >::takeError(), and llvm::offloading::Symbol::UsedInRegularObj.
Referenced by getSymbols().
|
static |
Definition at line 121 of file ArchiveLinker.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::count(), llvm::offloading::Symbol::createFromObject(), llvm::object::Binary::getMemoryBufferRef(), llvm::offloading::Symbol::isUndefined(), llvm::offloading::Symbol::isWeak(), llvm::offloading::Symbol::None, llvm::object::ObjectFile::symbols(), llvm::offloading::Symbol::SymFlags, and llvm::offloading::Symbol::UsedInRegularObj.
Referenced by getSymbols().
|
static |
Identify "fat binary" inputs that should be passed through to the linker without symbol-driven extraction.
An input is a fat binary if DeviceArchs is non-empty and the input is an ELF object whose architecture is not one of the device architectures (or which fails to parse as an object file).
Definition at line 162 of file ArchiveLinker.cpp.
References llvm::consumeError(), llvm::ObjectFile::createObjectFile(), llvm::file_magic::elf_relocatable, llvm::ArrayRef< T >::empty(), llvm::MemoryBufferRef::getBuffer(), llvm::identify_magic(), llvm::is_contained(), and llvm::Expected< T >::takeError().
Referenced by resolveArchiveMembers().
| Expected< PropertySetRegistry > llvm::offloading::readPropertiesFromJSON | ( | MemoryBufferRef | Buf | ) |
Definition at line 67 of file PropertySet.cpp.
References assert(), llvm::createStringErrorV(), llvm::MemoryBufferRef::getBuffer(), llvm::json::parse(), readPropertyValueFromJSON(), llvm::Expected< T >::takeError(), and llvm::toString().
| Expected< ResolvedInputs > llvm::offloading::resolveArchiveMembers | ( | ArrayRef< InputDesc > | Order, |
| ArrayRef< StringRef > | SearchPaths, | ||
| ArrayRef< StringRef > | ForcedUndefs = {}, | ||
| StringRef | Root = "", | ||
| ArrayRef< Triple::ArchType > | DeviceArchs = {} ) |
Resolve archive members from the given inputs using a symbol-driven fixed-point algorithm.
For each input:
Returns the buffers to link and the symbol table for LTO resolution.
| Order | Positional inputs + -l libraries in order. |
| SearchPaths | -L paths for library search. |
| ForcedUndefs | -u symbols (may be empty). |
| Root | Sysroot for "=" prefixed paths ("" if none). |
| DeviceArchs | Architectures of the device code being linked. When non-empty, any ELF input whose architecture is not in this list (or which cannot be parsed as an object) is treated as a "fat binary" and passed through without symbol scanning (e.g., nvlink's cubin detection). When empty, all inputs are scanned normally. |
Definition at line 198 of file ArchiveLinker.cpp.
References llvm::file_magic::archive, llvm::file_magic::bitcode, llvm::object::Archive::create(), llvm::createFileError(), llvm::createStringError(), llvm::file_magic::elf_relocatable, llvm::SmallVectorImpl< T >::emplace_back(), llvm::errorOrToExpected(), llvm::sys::fs::exists(), Filename, llvm::MemoryBufferRef::getBuffer(), llvm::MemoryBuffer::getFileOrSTDIN(), llvm::MemoryBuffer::getMemBufferCopy(), getSymbols(), llvm::identify_magic(), llvm::sys::fs::is_directory(), isFatBinary(), llvm::offloading::InputDesc::Library, searchLibrary(), llvm::Error::success(), llvm::Expected< T >::takeError(), and llvm::offloading::Symbol::Undefined.
|
static |
Search for static libraries in the linker's library path given input like -lfoo or -l:libfoo.a.
Definition at line 75 of file ArchiveLinker.cpp.
References findFromSearchPaths().
Referenced by resolveArchiveMembers().
| Error llvm::offloading::wrapCudaBinary | ( | llvm::Module & | M, |
| llvm::ArrayRef< char > | Images, | ||
| EntryArrayTy | EntryArray, | ||
| llvm::StringRef | Suffix = "", | ||
| bool | EmitSurfacesAndTextures = true ) |
Wraps the input fatbinary image into the module M as global symbols and registers the images with the CUDA runtime.
| EntryArray | Optional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array. |
| Suffix | An optional suffix appended to the emitted symbols. |
| EmitSurfacesAndTextures | Whether to emit surface and textures registration code. It defaults to false. |
Definition at line 724 of file OffloadWrapper.cpp.
References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().
| Error llvm::offloading::wrapHIPBinary | ( | llvm::Module & | M, |
| llvm::ArrayRef< char > | Images, | ||
| EntryArrayTy | EntryArray, | ||
| llvm::StringRef | Suffix = "", | ||
| bool | EmitSurfacesAndTextures = true ) |
Wraps the input bundled image into the module M as global symbols and registers the images with the HIP runtime.
| EntryArray | Optional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array. |
| Suffix | An optional suffix appended to the emitted symbols. |
| EmitSurfacesAndTextures | Whether to emit surface and textures registration code. It defaults to false. |
Definition at line 738 of file OffloadWrapper.cpp.
References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().
| Error llvm::offloading::wrapOpenMPBinaries | ( | llvm::Module & | M, |
| llvm::ArrayRef< llvm::ArrayRef< char > > | Images, | ||
| EntryArrayTy | EntryArray, | ||
| llvm::StringRef | Suffix = "", | ||
| bool | Relocatable = false ) |
Wraps the input device images into the module M as global symbols and registers the images with the OpenMP Offloading runtime libomptarget.
| EntryArray | Optional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array. |
| Suffix | An optional suffix appended to the emitted symbols. |
| Relocatable | Indicate if we need to change the offloading section to create a relocatable object. |
Definition at line 712 of file OffloadWrapper.cpp.
References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().
| Error llvm::offloading::wrapSYCLBinaries | ( | llvm::Module & | M, |
| llvm::ArrayRef< char > | Buffer, | ||
| SYCLJITOptions | Options = SYCLJITOptions() ) |
Wraps OffloadBinaries in the given Buffers into the module M as global symbols and registers the images with the SYCL Runtime.
| Options | Compiler and linker options to be encoded for the later use by a runtime for JIT compilation. Not used for AOT. |
Definition at line 751 of file OffloadWrapper.cpp.
References Options, Size, and llvm::Error::success().
| void llvm::offloading::writePropertiesToJSON | ( | const PropertySetRegistry & | P, |
| raw_ostream & | O ) |
Definition at line 17 of file PropertySet.cpp.
References llvm::json::OStream::attribute(), llvm::json::OStream::attributeObject(), llvm::encodeBase64(), llvm_unreachable, and llvm::json::OStream::object().