|
LLVM 23.0.0git
|
A simple binary serialization of an offloading file. More...
#include "llvm/Object/OffloadBinary.h"
Classes | |
| struct | Entry |
| struct | Header |
| struct | OffloadingImage |
| The offloading metadata that will be serialized to a memory buffer. More... | |
| struct | StringEntry |
| struct | StringEntryV1 |
Public Types | |
| using | string_iterator = MapVector<StringRef, StringRef>::const_iterator |
| using | string_iterator_range = iterator_range<string_iterator> |
Static Public Member Functions | |
| static LLVM_ABI Expected< const Header * > | extractHeader (MemoryBufferRef Buf) |
Attempt to extract and validate the header from the offloading binary in Buf. | |
| static LLVM_ABI Expected< SmallVector< std::unique_ptr< OffloadBinary > > > | create (MemoryBufferRef Buf, std::optional< uint64_t > Index=std::nullopt) |
Attempt to parse the offloading binary stored in Buf. | |
| static LLVM_ABI SmallString< 0 > | write (ArrayRef< OffloadingImage > OffloadingData) |
Serialize the contents of OffloadingData to a binary buffer to be read later. | |
| static uint64_t | getAlignment () |
| static bool | classof (const Binary *V) |
| Static Public Member Functions inherited from llvm::object::Binary | |
| static Error | checkOffset (MemoryBufferRef M, uintptr_t Addr, const uint64_t Size) |
Static Public Attributes | |
| static const uint32_t | Version = 2 |
| The current version of the binary used for backwards compatibility. | |
Additional Inherited Members | |
| Protected Types inherited from llvm::object::Binary | |
| enum | { ID_Archive , ID_MachOUniversalBinary , ID_COFFImportFile , ID_IR , ID_TapiUniversal , ID_TapiFile , ID_Minidump , ID_WinRes , ID_Offload , ID_StartObjects , ID_COFF , ID_XCOFF32 , ID_XCOFF64 , ID_ELF32L , ID_ELF32B , ID_ELF64L , ID_ELF64B , ID_MachO32L , ID_MachO32B , ID_MachO64L , ID_MachO64B , ID_GOFF , ID_Wasm , ID_DXContainer , ID_EndObjects } |
| Protected Member Functions inherited from llvm::object::Binary | |
| Binary (unsigned int Type, MemoryBufferRef Source) | |
| Static Protected Member Functions inherited from llvm::object::Binary | |
| static unsigned int | getELFType (bool isLE, bool is64Bits) |
| static unsigned int | getMachOType (bool isLE, bool is64Bits) |
| Protected Attributes inherited from llvm::object::Binary | |
| MemoryBufferRef | Data |
A simple binary serialization of an offloading file.
We use this format to embed the offloading image into the host executable so it can be extracted and used by the linker.
Many of these could be stored in the same section by the time the linker sees it so we mark this information with a header. The version is used to detect ABI stability and the size is used to find other offloading entries that may exist in the same section. All offsets are given as absolute byte offsets from the beginning of the file.
Definition at line 71 of file OffloadBinary.h.
| using llvm::object::OffloadBinary::string_iterator = MapVector<StringRef, StringRef>::const_iterator |
Definition at line 73 of file OffloadBinary.h.
Definition at line 74 of file OffloadBinary.h.
Definition at line 160 of file OffloadBinary.h.
References llvm::object::Binary::Binary().
|
static |
Attempt to parse the offloading binary stored in Buf.
For version 1 binaries, always returns a single OffloadBinary. For version 2+ binaries:
Index is provided, returns the OffloadBinary at that index.Index is std::nullopt, returns all OffloadBinary entries. | Buf | The memory buffer containing the offload binary. |
| Index | Optional index to select a specific entry. If not provided, all entries are returned (version 2+ only). |
Definition at line 234 of file OffloadBinary.cpp.
References llvm::SmallVectorImpl< T >::emplace_back(), llvm::errorCodeToError(), extractHeader(), llvm::MemoryBufferRef::getBufferSize(), llvm::MemoryBufferRef::getBufferStart(), I, llvm::object::parse_failed, llvm::Error::success(), and llvm::object::unexpected_eof.
Referenced by llvm::object::OffloadFile::copy(), and llvm::object::createBinary().
|
static |
Attempt to extract and validate the header from the offloading binary in Buf.
Definition at line 202 of file OffloadBinary.cpp.
References llvm::errorCodeToError(), getAlignment(), llvm::MemoryBufferRef::getBuffer(), llvm::MemoryBufferRef::getBufferSize(), llvm::MemoryBufferRef::getBufferStart(), llvm::identify_magic(), llvm::isAddrAligned(), llvm::file_magic::offload_binary, llvm::object::parse_failed, llvm::object::unexpected_eof, and Version.
Referenced by create().
|
inlinestatic |
Definition at line 140 of file OffloadBinary.h.
Referenced by llvm::offloading::emitOffloadingEntry(), extractHeader(), llvm::offloading::getOffloadEntryArray(), and write().
|
inline |
Definition at line 150 of file OffloadBinary.h.
References getString().
|
inline |
Definition at line 145 of file OffloadBinary.h.
|
inline |
Definition at line 151 of file OffloadBinary.h.
|
inline |
Definition at line 142 of file OffloadBinary.h.
|
inline |
Definition at line 147 of file OffloadBinary.h.
|
inline |
Definition at line 143 of file OffloadBinary.h.
|
inline |
Definition at line 146 of file OffloadBinary.h.
Definition at line 158 of file OffloadBinary.h.
References llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key.
Referenced by getArch(), and getTriple().
|
inline |
Definition at line 149 of file OffloadBinary.h.
References getString().
|
inline |
Definition at line 144 of file OffloadBinary.h.
|
inline |
Definition at line 156 of file OffloadBinary.h.
|
static |
Serialize the contents of OffloadingData to a binary buffer to be read later.
Definition at line 277 of file OffloadBinary.cpp.
References llvm::StringTableBuilder::add(), llvm::alignTo(), assert(), llvm::object::Binary::Data, llvm::StringTableBuilder::ELF, llvm::StringTableBuilder::finalize(), getAlignment(), llvm::StringTableBuilder::getOffset(), llvm::StringTableBuilder::getSize(), llvm::object::OffloadBinary::Header::Size, llvm::ArrayRef< T >::size(), llvm::raw_ostream::tell(), llvm::object::OffloadBinary::Entry::TheImageKind, llvm::StringTableBuilder::write(), and llvm::raw_ostream::write_zeros().
Referenced by llvm::yaml::yaml2offload().
The current version of the binary used for backwards compatibility.
Definition at line 77 of file OffloadBinary.h.
Referenced by extractHeader().