17#ifndef LLVM_OBJECT_OFFLOADBINARY_H
18#define LLVM_OBJECT_OFFLOADBINARY_H
88 std::unique_ptr<MemoryBuffer>
Image;
163 return StringRef(&Buffer[TheEntry->ImageOffset], TheEntry->ImageSize);
174 OffloadBinary(std::shared_ptr<MemoryBuffer> Owned,
const Header *TheHeader,
175 const Entry *TheEntry,
const uint64_t Index = 0)
177 Buffer(OwnedBuffer->getBufferStart()), TheHeader(TheHeader),
178 TheEntry(TheEntry), Index(Index) {
181 const char *StringMapBegin = &Buffer[TheEntry->StringOffset];
182 const size_t StringEntrySize =
183 TheHeader->Version == 1 ?
sizeof(StringEntryV1) :
sizeof(
StringEntry);
184 for (
uint64_t I = 0,
E = TheEntry->NumStrings;
I !=
E; ++
I) {
185 const char *StringEntryPtr = StringMapBegin + I * StringEntrySize;
186 const StringEntryV1 *EntryV1 =
187 reinterpret_cast<const StringEntryV1 *>(StringEntryPtr);
188 StringRef Key = &Buffer[EntryV1->KeyOffset];
189 if (TheHeader->Version == 1) {
190 StringData[Key] = &Buffer[EntryV1->ValueOffset];
192 const StringEntry *Entry =
193 reinterpret_cast<const StringEntry *>(StringEntryPtr);
195 StringRef(&Buffer[Entry->ValueOffset], Entry->ValueSize);
200 OffloadBinary(
const OffloadBinary &
Other) =
delete;
203 std::shared_ptr<MemoryBuffer> OwnedBuffer;
209 const Header *TheHeader;
211 const Entry *TheEntry;
232 assert(NewBinaryOrErr &&
"Failed to parse a copy of the binary?");
235 return OffloadFile(std::move((*NewBinaryOrErr)[0]));
245 std::unique_ptr<OffloadBinary>
Binary;
277LLVM_ABI bool areTargetsCompatible(
const OffloadFile::TargetID &Provided,
278 const OffloadFile::TargetID &Requested);
282LLVM_ABI bool areTargetsEquivalent(
const OffloadFile::TargetID &
LHS,
283 const OffloadFile::TargetID &
RHS);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file implements a map that provides insertion order iteration.
This file defines the SmallString class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
This class implements a map that also provides access to all stored values in a deterministic order.
typename VectorType::const_iterator const_iterator
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Represent a constant reference to a string, i.e.
A range adaptor for a pair of iterators.
Binary(unsigned int Type, MemoryBufferRef Source)
A simple binary serialization of an offloading file.
static uint64_t getAlignment()
OffloadKind getOffloadKind() const
iterator_range< string_iterator > string_iterator_range
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.
StringRef getString(StringRef Key) const
uint32_t getVersion() const
static LLVM_ABI bool isCompressed(MemoryBufferRef Buf)
True if Buf is a compressed offload package, false otherwise.
StringRef getImage() const
static LLVM_ABI Expected< const Header * > extractHeader(MemoryBufferRef Buf)
Attempt to extract and validate the header from the offloading binary in Buf.
uint32_t getFlags() const
uint64_t getIndex() const
StringRef getTriple() const
ImageKind getImageKind() const
static bool classof(const Binary *V)
string_iterator_range strings() const
StringRef getArch() const
static const uint32_t Version
The current version of the binary used for backwards compatibility.
MapVector< StringRef, StringRef >::const_iterator string_iterator
const OffloadBinary * getBinary() const
std::pair< StringRef, StringRef > TargetID
OffloadFile copy() const
Make a deep copy of this offloading file.
OffloadFile(std::unique_ptr< OffloadBinary > Binary)
OffloadBinary * getBinary()
StringMapEntry< EmptyStringSetTag > StringEntry
StringEntry keeps data of the string: the length, external offset and a string body which is placed r...
OffloadEntryFlags
Flags associated with the Entry.
OffloadKind
The producer of the associated offloading image.
ImageKind
The type of contents the offloading image contains.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.
OffloadKind TheOffloadKind
The offloading metadata that will be serialized to a memory buffer.
OffloadKind TheOffloadKind
std::unique_ptr< MemoryBuffer > Image
MapVector< StringRef, StringRef > StringData