Go to the documentation of this file.
35 const Header *TheHeader =
reinterpret_cast<const Header *
>(Start);
44 const Entry *TheEntry =
51 return std::unique_ptr<OffloadBinary>(
55 std::unique_ptr<MemoryBuffer>
59 for (
auto &KeyAndValue : OffloadingData.
StringData) {
60 StrTab.
add(KeyAndValue.getKey());
61 StrTab.
add(KeyAndValue.getValue());
70 StringEntrySize + StrTab.
getSize(),
97 OS << StringRef(reinterpret_cast<char *>(&TheHeader),
sizeof(
Header));
98 OS << StringRef(reinterpret_cast<char *>(&TheEntry),
sizeof(
Entry));
99 for (
auto &KeyAndValue : OffloadingData.
StringData) {
102 Offset + StrTab.
getOffset(KeyAndValue.getValue())};
103 OS << StringRef(reinterpret_cast<char *>(&Map),
sizeof(
StringEntry));
108 OS << OffloadingData.
Image->getBuffer();
StringSwitch & Case(StringLiteral S, T Value)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
uint64_t tell() const
tell - Return the current offset with the file.
static Expected< std::unique_ptr< OffloadBinary > > create(MemoryBufferRef)
Attempt to parse the offloading binary stored in Data.
const char * getBufferStart() const
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
LLVM_NODISCARD R Default(T Value)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
@ offload_binary
LLVM offload object file.
size_t getBufferSize() const
Tagged union holding either a T or a Error.
void finalize()
Analyze the strings and build the final table.
size_t getOffset(CachedHashStringRef S) const
Get the offest of a string in the string table.
The offloading metadata that will be serialized to a memory buffer.
std::unique_ptr< MemoryBuffer > Image
OffloadKind getOffloadKind(StringRef Name)
Convert a string Name to an offload kind.
static std::unique_ptr< MemoryBuffer > write(const OffloadingImage &)
Serialize the contents of File to a binary buffer to be read later.
OffloadKind TheOffloadKind
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
StringMap< StringRef > StringData
A simple binary serialization of an offloading file.
static uint64_t getAlignment()
OffloadKind
The producer of the associated offloading image.
OffloadKind TheOffloadKind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef getBuffer() const
void write(raw_ostream &OS) const
StringRef - Represent a constant reference to a string, i.e.
StringRef str() const
Return a StringRef for the vector contents.
StringRef getImageKindName(ImageKind Name)
Convert an image kind to its string representation.
bool isAddrAligned(Align Lhs, const void *Addr)
Checks that Addr is a multiple of the alignment.
size_t add(CachedHashStringRef S)
Add a string to the builder.
Utility for building string tables with deduplicated suffixes.
StringRef getOffloadKindName(OffloadKind Name)
Convert an offload kind to its string representation.
static const uint32_t Version
The current version of the binary used for backwards compatibility.
A raw_ostream that writes to an SmallVector or SmallString.
ImageKind getImageKind(StringRef Name)
Convert a string Name to an image kind.
A switch()-like statement whose cases are string literals.
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
ImageKind
The type of contents the offloading image contains.