[clang] [llvm] [Offloading] Extend OffloadBinary format to support multiple metadata entries (PR #169425)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 1 19:21:38 PST 2025
================
@@ -82,76 +116,79 @@ class OffloadBinary : public Binary {
LLVM_ABI static Expected<std::unique_ptr<OffloadBinary>>
create(MemoryBufferRef);
- /// Serialize the contents of \p File to a binary buffer to be read later.
- LLVM_ABI static SmallString<0> write(const OffloadingImage &);
+ /// Serialize the contents of \p OffloadingData to a binary buffer to be read
+ /// later.
+ LLVM_ABI static SmallString<0>
+ write(ArrayRef<OffloadingImage> OffloadingData);
static uint64_t getAlignment() { return 8; }
- ImageKind getImageKind() const { return TheEntry->TheImageKind; }
- OffloadKind getOffloadKind() const { return TheEntry->TheOffloadKind; }
+ ImageKind getOnlyImageKind() const {
+ assert(getEntriesCount() == 1 && "Expected exactly one entry.");
+ return Entries[0].first->TheImageKind;
+ }
+
+ OffloadKind getOffloadKind() const { return Entries[0].first->TheOffloadKind; }
uint32_t getVersion() const { return TheHeader->Version; }
- uint32_t getFlags() const { return TheEntry->Flags; }
+ uint32_t getFlags() const { return Entries[0].first->Flags; }
uint64_t getSize() const { return TheHeader->Size; }
+ uint64_t getEntriesCount() const { return TheHeader->EntriesCount; }
StringRef getTriple() const { return getString("triple"); }
StringRef getArch() const { return getString("arch"); }
StringRef getImage() const {
- return StringRef(&Buffer[TheEntry->ImageOffset], TheEntry->ImageSize);
+ return StringRef(&Buffer[Entries[0].first->ImageOffset], Entries[0].first->ImageSize);
----------------
jhuber6 wrote:
Ideally we won't need an index here, that's what we can hopefully avoid
https://github.com/llvm/llvm-project/pull/169425
More information about the llvm-commits
mailing list