17#ifndef LLVM_OBJECT_OFFLOADBUNDLE_H
18#define LLVM_OBJECT_OFFLOADBUNDLE_H
37 static inline const size_t MagicSize = 4;
38 static inline const size_t VersionFieldSize =
sizeof(
uint16_t);
39 static inline const size_t MethodFieldSize =
sizeof(
uint16_t);
40 static inline const size_t FileSizeFieldSize =
sizeof(
uint32_t);
41 static inline const size_t UncompressedSizeFieldSize =
sizeof(
uint32_t);
42 static inline const size_t HashFieldSize =
sizeof(
uint64_t);
43 static inline const size_t V1HeaderSize =
44 MagicSize + VersionFieldSize + MethodFieldSize +
45 UncompressedSizeFieldSize + HashFieldSize;
46 static inline const size_t V2HeaderSize =
47 MagicSize + VersionFieldSize + FileSizeFieldSize + MethodFieldSize +
48 UncompressedSizeFieldSize + HashFieldSize;
50 static inline const uint16_t Version = 2;
70 <<
", ID Length = " <<
IDLength <<
", ID = " <<
ID;
73 OS <<
ID.data() <<
"\tfile://" << FilePath <<
"#offset=" <<
Offset
74 <<
"&size=" <<
Size <<
"\n";
101 Entry.dumpInfo(
outs());
106 Entry.dumpURI(
outs(), FileName);
110 : FileName(File), NumberOfEntries(0),
148 if (!Str.consume_front(
"file://"))
150 "Reading type of URI");
153 Str.take_until([](
char C) {
return (
C ==
'#') || (
C ==
'?'); });
154 Str = Str.drop_front(FilePathname.
size());
156 if (!Str.consume_front(
"#offset="))
158 "Reading 'offset' in URI");
160 StringRef OffsetStr = Str.take_until([](
char C) {
return C ==
'&'; });
162 Str = Str.drop_front(OffsetStr.
size());
164 if (Str.consume_front(
"&size="))
166 "Reading 'size' in URI");
168 Str.getAsInteger(10, S);
169 std::unique_ptr<OffloadBundleURI> OffloadingURI(
171 return std::move(OffloadingURI);
178 "Memory Type URI is not currently supported.");
This file implements a map that provides insertion order iteration.
This file defines the SmallString class.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr size_t size() const
size - Get the string size.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > compress(llvm::compression::Params P, const llvm::MemoryBuffer &Input, bool Verbose=false)
static LLVM_ABI llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > decompress(llvm::MemoryBufferRef &Input, bool Verbose=false)
This class is the base class for all object file types.
Fat binary embedded in object files in clang-offload-bundler format.
uint64_t getNumEntries() const
static LLVM_ABI Expected< std::unique_ptr< OffloadBundleFatBin > > create(MemoryBufferRef, uint64_t SectionOffset, StringRef FileName)
LLVM_ABI Error dumpEntryToCodeObject()
LLVM_ABI Error readEntries(StringRef Section, uint64_t SectionOffset)
SmallVector< OffloadBundleEntry > getEntries()
OffloadBundleFatBin(MemoryBufferRef Source, StringRef File)
LLVM_ABI Error extractBundle(const ObjectFile &Source)
StringRef getFileName() const
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI Error extractCodeObject(const ObjectFile &Source, int64_t Offset, int64_t Size, StringRef OutputFileName)
Extract code object memory from the given Source object file at Offset and of Size,...
LLVM_ABI Error extractOffloadBundleByURI(StringRef URIstr)
Extracts an Offload Bundle Entry given by URI.
LLVM_ABI Error extractOffloadBundleFatBinary(const ObjectFile &Obj, SmallVectorImpl< OffloadBundleFatBin > &Bundles)
Extracts fat binary in binary clang-offload-bundler format from object Obj and return it in Bundles.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Bundle entry in binary clang-offload-bundler format.
void dumpInfo(raw_ostream &OS)
OffloadBundleEntry(uint64_t O, uint64_t S, uint64_t I, StringRef T)
void dumpURI(raw_ostream &OS, StringRef FilePath)
static Expected< std::unique_ptr< OffloadBundleURI > > createOffloadBundleURI(StringRef Str, UriTypeT Type)
static Expected< std::unique_ptr< OffloadBundleURI > > createFileURI(StringRef Str)
StringRef getFileName() const
static Expected< std::unique_ptr< OffloadBundleURI > > createMemoryURI(StringRef Str)
OffloadBundleURI(StringRef File, int64_t Off, int64_t Size)