LLVM 23.0.0git
Utility.cpp
Go to the documentation of this file.
1//===- Utility.cpp ------ Collection of generic offloading utilities ------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
13#include "llvm/IR/Constants.h"
14#include "llvm/IR/GlobalValue.h"
16#include "llvm/IR/Value.h"
23
24using namespace llvm;
25using namespace llvm::offloading;
26
39
40std::pair<Constant *, GlobalVariable *>
42 Constant *Addr, StringRef Name,
43 uint64_t Size, uint32_t Flags,
44 uint64_t Data, Constant *AuxAddr) {
45 const llvm::Triple &Triple = M.getTargetTriple();
46 Type *PtrTy = PointerType::getUnqual(M.getContext());
47 Type *Int64Ty = Type::getInt64Ty(M.getContext());
48 Type *Int32Ty = Type::getInt32Ty(M.getContext());
49 Type *Int16Ty = Type::getInt16Ty(M.getContext());
50
51 Constant *AddrName = ConstantDataArray::getString(M.getContext(), Name);
52
53 StringRef Prefix =
54 Triple.isNVPTX() ? "$offloading$entry_name" : ".offloading.entry_name";
55
56 // Create the constant string used to look up the symbol in the device.
57 auto *Str =
58 new GlobalVariable(M, AddrName->getType(), /*isConstant=*/true,
59 GlobalValue::InternalLinkage, AddrName, Prefix);
60 StringRef SectionName = ".llvm.rodata.offloading";
61 Str->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
62 Str->setSection(SectionName);
63 Str->setAlignment(Align(1));
64
65 // Make a metadata node for these constants so it can be queried from IR.
66 NamedMDNode *MD = M.getOrInsertNamedMetadata("llvm.offloading.symbols");
67 Metadata *MDVals[] = {ConstantAsMetadata::get(Str)};
68 MD->addOperand(llvm::MDNode::get(M.getContext(), MDVals));
69
70 // Construct the offloading entry.
71 Constant *EntryData[] = {
73 ConstantInt::get(Int16Ty, 1),
74 ConstantInt::get(Int16Ty, Kind),
75 ConstantInt::get(Int32Ty, Flags),
78 ConstantInt::get(Int64Ty, Size),
79 ConstantInt::get(Int64Ty, Data),
82 Constant *EntryInitializer = ConstantStruct::get(getEntryTy(M), EntryData);
83 return {EntryInitializer, Str};
84}
85
88 Constant *Addr, StringRef Name, uint64_t Size,
89 uint32_t Flags, uint64_t Data,
90 Constant *AuxAddr, StringRef SectionName) {
91 const llvm::Triple &Triple = M.getTargetTriple();
92
93 auto [EntryInitializer, NameGV] = getOffloadingEntryInitializer(
94 M, Kind, Addr, Name, Size, Flags, Data, AuxAddr);
95
96 StringRef Prefix =
97 Triple.isNVPTX() ? "$offloading$entry$" : ".offloading.entry.";
98 auto *Entry = new GlobalVariable(
99 M, getEntryTy(M),
100 /*isConstant=*/true, GlobalValue::WeakAnyLinkage, EntryInitializer,
101 Prefix + Name, nullptr, GlobalValue::NotThreadLocal,
102 M.getDataLayout().getDefaultGlobalsAddressSpace());
103
104 // The entry has to be created in the section the linker expects it to be.
106 Entry->setSection((SectionName + "$OE").str());
107 else
108 Entry->setSection(SectionName);
109 Entry->setAlignment(Align(object::OffloadBinary::getAlignment()));
110 return Entry;
111}
112
113std::pair<GlobalVariable *, GlobalVariable *>
115 const llvm::Triple &Triple = M.getTargetTriple();
116
117 auto *ZeroInitilaizer =
119 auto *EntryInit = Triple.isOSBinFormatCOFF() ? ZeroInitilaizer : nullptr;
120 auto *EntryType = ArrayType::get(getEntryTy(M), 0);
123
124 auto *EntriesB =
125 new GlobalVariable(M, EntryType, /*isConstant=*/true, Linkage, EntryInit,
126 "__start_" + SectionName);
127 EntriesB->setVisibility(GlobalValue::HiddenVisibility);
128 auto *EntriesE =
129 new GlobalVariable(M, EntryType, /*isConstant=*/true, Linkage, EntryInit,
130 "__stop_" + SectionName);
131 EntriesE->setVisibility(GlobalValue::HiddenVisibility);
132
133 if (Triple.isOSBinFormatELF()) {
134 // We assume that external begin/end symbols that we have created above will
135 // be defined by the linker. This is done whenever a section name with a
136 // valid C-identifier is present. We define a dummy variable here to force
137 // the linker to always provide these symbols.
138 auto *DummyEntry = new GlobalVariable(
139 M, ZeroInitilaizer->getType(), true, GlobalVariable::InternalLinkage,
140 ZeroInitilaizer, "__dummy." + SectionName);
141 DummyEntry->setSection(SectionName);
142 DummyEntry->setAlignment(Align(object::OffloadBinary::getAlignment()));
143 appendToCompilerUsed(M, DummyEntry);
144 } else {
145 // The COFF linker will merge sections containing a '$' together into a
146 // single section. The order of entries in this section will be sorted
147 // alphabetically by the characters following the '$' in the name. Set the
148 // sections here to ensure that the beginning and end symbols are sorted.
149 EntriesB->setSection((SectionName + "$OA").str());
150 EntriesE->setSection((SectionName + "$OZ").str());
151 }
152
153 return std::make_pair(EntriesB, EntriesE);
154}
155
157 uint32_t ImageFlags,
158 StringRef EnvTargetID) {
159 using namespace llvm::ELF;
160 StringRef EnvArch = EnvTargetID.split(":").first;
161
162 // Trivial check if the base processors match.
163 if (EnvArch != ImageArch)
164 return false;
165
166 // Check if the image is requesting xnack on or off.
167 switch (ImageFlags & EF_AMDGPU_FEATURE_XNACK_V4) {
169 // The image is 'xnack-' so the environment must be 'xnack-'.
170 if (!EnvTargetID.contains("xnack-"))
171 return false;
172 break;
174 // The image is 'xnack+' so the environment must be 'xnack+'.
175 if (!EnvTargetID.contains("xnack+"))
176 return false;
177 break;
180 default:
181 break;
182 }
183
184 // Check if the image is requesting sramecc on or off.
185 switch (ImageFlags & EF_AMDGPU_FEATURE_SRAMECC_V4) {
187 // The image is 'sramecc-' so the environment must be 'sramecc-'.
188 if (!EnvTargetID.contains("sramecc-"))
189 return false;
190 break;
192 // The image is 'sramecc+' so the environment must be 'sramecc+'.
193 if (!EnvTargetID.contains("sramecc+"))
194 return false;
195 break;
198 break;
199 }
200
201 return true;
202}
203
204namespace {
205/// Reads the AMDGPU specific per-kernel-metadata from an image.
206class KernelInfoReader {
207public:
209 : KernelInfoMap(KIM) {}
210
211 /// Process ELF note to read AMDGPU metadata from respective information
212 /// fields.
213 Error processNote(const llvm::object::ELF64LE::Note &Note, size_t Align) {
214 if (Note.getName() != "AMDGPU")
215 return Error::success(); // We are not interested in other things
216
217 assert(Note.getType() == ELF::NT_AMDGPU_METADATA &&
218 "Parse AMDGPU MetaData");
219 auto Desc = Note.getDesc(Align);
220 StringRef MsgPackString =
221 StringRef(reinterpret_cast<const char *>(Desc.data()), Desc.size());
222 msgpack::Document MsgPackDoc;
223 if (!MsgPackDoc.readFromBlob(MsgPackString, /*Multi=*/false))
224 return Error::success();
225
227 if (!Verifier.verify(MsgPackDoc.getRoot()))
228 return Error::success();
229
230 auto RootMap = MsgPackDoc.getRoot().getMap(true);
231
232 if (auto Err = iterateAMDKernels(RootMap))
233 return Err;
234
235 return Error::success();
236 }
237
238private:
239 /// Extracts the relevant information via simple string look-up in the msgpack
240 /// document elements.
241 Error
242 extractKernelData(msgpack::MapDocNode::MapTy::value_type V,
243 std::string &KernelName,
245 if (!V.first.isString())
246 return Error::success();
247
248 const auto IsKey = [](const msgpack::DocNode &DK, StringRef SK) {
249 return DK.getString() == SK;
250 };
251
252 const auto GetSequenceOfThreeInts = [](msgpack::DocNode &DN,
253 uint32_t *Vals) {
254 assert(DN.isArray() && "MsgPack DocNode is an array node");
255 auto DNA = DN.getArray();
256 assert(DNA.size() == 3 && "ArrayNode has at most three elements");
257
258 int I = 0;
259 for (auto DNABegin = DNA.begin(), DNAEnd = DNA.end(); DNABegin != DNAEnd;
260 ++DNABegin) {
261 Vals[I++] = DNABegin->getUInt();
262 }
263 };
264
265 if (IsKey(V.first, ".name")) {
266 KernelName = V.second.toString();
267 } else if (IsKey(V.first, ".sgpr_count")) {
268 KernelData.SGPRCount = V.second.getUInt();
269 } else if (IsKey(V.first, ".sgpr_spill_count")) {
270 KernelData.SGPRSpillCount = V.second.getUInt();
271 } else if (IsKey(V.first, ".vgpr_count")) {
272 KernelData.VGPRCount = V.second.getUInt();
273 } else if (IsKey(V.first, ".vgpr_spill_count")) {
274 KernelData.VGPRSpillCount = V.second.getUInt();
275 } else if (IsKey(V.first, ".agpr_count")) {
276 KernelData.AGPRCount = V.second.getUInt();
277 } else if (IsKey(V.first, ".private_segment_fixed_size")) {
278 KernelData.PrivateSegmentSize = V.second.getUInt();
279 } else if (IsKey(V.first, ".group_segment_fixed_size")) {
280 KernelData.GroupSegmentList = V.second.getUInt();
281 } else if (IsKey(V.first, ".reqd_workgroup_size")) {
282 GetSequenceOfThreeInts(V.second, KernelData.RequestedWorkgroupSize);
283 } else if (IsKey(V.first, ".workgroup_size_hint")) {
284 GetSequenceOfThreeInts(V.second, KernelData.WorkgroupSizeHint);
285 } else if (IsKey(V.first, ".wavefront_size")) {
286 KernelData.WavefrontSize = V.second.getUInt();
287 } else if (IsKey(V.first, ".max_flat_workgroup_size")) {
288 KernelData.MaxFlatWorkgroupSize = V.second.getUInt();
289 }
290
291 return Error::success();
292 }
293
294 /// Get the "amdhsa.kernels" element from the msgpack Document
295 Expected<msgpack::ArrayDocNode> getAMDKernelsArray(msgpack::MapDocNode &MDN) {
296 auto Res = MDN.find("amdhsa.kernels");
297 if (Res == MDN.end())
299 "Could not find amdhsa.kernels key");
300
301 auto Pair = *Res;
302 assert(Pair.second.isArray() &&
303 "AMDGPU kernel entries are arrays of entries");
304
305 return Pair.second.getArray();
306 }
307
308 /// Iterate all entries for one "amdhsa.kernels" entry. Each entry is a
309 /// MapDocNode that either maps a string to a single value (most of them) or
310 /// to another array of things. Currently, we only handle the case that maps
311 /// to scalar value.
312 Error generateKernelInfo(msgpack::ArrayDocNode::ArrayTy::iterator It) {
313 offloading::amdgpu::AMDGPUKernelMetaData KernelData;
314 std::string KernelName;
315 auto Entry = (*It).getMap();
316 for (auto MI = Entry.begin(), E = Entry.end(); MI != E; ++MI)
317 if (auto Err = extractKernelData(*MI, KernelName, KernelData))
318 return Err;
319
320 KernelInfoMap.insert({KernelName, KernelData});
321 return Error::success();
322 }
323
324 /// Go over the list of AMD kernels in the "amdhsa.kernels" entry
325 Error iterateAMDKernels(msgpack::MapDocNode &MDN) {
326 auto KernelsOrErr = getAMDKernelsArray(MDN);
327 if (auto Err = KernelsOrErr.takeError())
328 return Err;
329
330 auto KernelsArr = *KernelsOrErr;
331 for (auto It = KernelsArr.begin(), E = KernelsArr.end(); It != E; ++It) {
332 if (!It->isMap())
333 continue; // we expect <key,value> pairs
334
335 // Obtain the value for the different entries. Each array entry is a
336 // MapDocNode
337 if (auto Err = generateKernelInfo(It))
338 return Err;
339 }
340 return Error::success();
341 }
342
343 // Kernel names are the keys
344 StringMap<offloading::amdgpu::AMDGPUKernelMetaData> &KernelInfoMap;
345};
346} // namespace
347
349 MemoryBufferRef MemBuffer,
351 uint16_t &ELFABIVersion) {
352 Error Err = Error::success(); // Used later as out-parameter
353
354 auto ELFOrError = object::ELF64LEFile::create(MemBuffer.getBuffer());
355 if (auto Err = ELFOrError.takeError())
356 return Err;
357
358 const object::ELF64LEFile ELFObj = ELFOrError.get();
360 if (!Sections)
361 return Sections.takeError();
362 KernelInfoReader Reader(KernelInfoMap);
363
364 // Read the code object version from ELF image header
365 auto Header = ELFObj.getHeader();
366 ELFABIVersion = (uint8_t)(Header.e_ident[ELF::EI_ABIVERSION]);
367 for (const auto &S : *Sections) {
368 if (S.sh_type != ELF::SHT_NOTE)
369 continue;
370
371 for (const auto N : ELFObj.notes(S, Err)) {
372 if (Err)
373 return Err;
374 // Fills the KernelInfoTabel entries in the reader
375 if ((Err = Reader.processNote(N, S.sh_addralign)))
376 return Err;
377 }
378 }
379 return Error::success();
380}
381
382Error offloading::containerizeImage(std::unique_ptr<MemoryBuffer> &Img,
384 object::ImageKind ImageKind,
385 object::OffloadKind OffloadKind,
386 int32_t ImageFlags,
388 using namespace object;
389
390 // Create inner OffloadBinary containing the raw image.
391 OffloadBinary::OffloadingImage InnerImage;
392 InnerImage.TheImageKind = ImageKind;
393 InnerImage.TheOffloadKind = OffloadKind;
394 InnerImage.Flags = ImageFlags;
395
396 InnerImage.StringData["triple"] = Triple.getTriple();
397 for (const auto &[Key, Value] : MetaData)
398 InnerImage.StringData[Key] = Value;
399
400 InnerImage.Image = std::move(Img);
401
402 SmallString<0> InnerBinaryData = OffloadBinary::write(InnerImage);
403
404 Img = MemoryBuffer::getMemBufferCopy(InnerBinaryData);
405 return Error::success();
406}
407
409 std::unique_ptr<MemoryBuffer> &Binary, llvm::Triple Triple,
410 StringRef CompileOpts, StringRef LinkOpts) {
411 constexpr char INTEL_ONEOMP_OFFLOAD_VERSION[] = "1.0";
412
414 "Expected SPIR-V triple with Intel vendor");
415
417 MetaData["version"] = INTEL_ONEOMP_OFFLOAD_VERSION;
418 if (!CompileOpts.empty())
419 MetaData["compile-opts"] = CompileOpts;
420 if (!LinkOpts.empty())
421 MetaData["link-opts"] = LinkOpts;
422
424 object::OffloadKind::OFK_OpenMP, /*ImageFlags=*/0,
425 MetaData);
426}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This is a verifier for AMDGPU HSA metadata, which can verify both well-typed metadata and untyped met...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file declares classes for handling the YAML representation of ELF.
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
This file declares a class that exposes a simple in-memory representation of a document of MsgPack ob...
verify safepoint Safepoint IR Verifier
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
static ConstantAsMetadata * get(Constant *C)
Definition Metadata.h:537
static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
static LLVM_ABI Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
This is an important base class in LLVM.
Definition Constant.h:43
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
Error takeError()
Take ownership of the stored error.
Definition Error.h:612
@ HiddenVisibility
The GV is hidden.
Definition GlobalValue.h:69
@ InternalLinkage
Rename collisions when linking (static functions).
Definition GlobalValue.h:60
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition GlobalValue.h:58
@ ExternalLinkage
Externally visible function.
Definition GlobalValue.h:53
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition GlobalValue.h:57
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1572
This class implements a map that also provides access to all stored values in a deterministic order.
Definition MapVector.h:36
StringRef getBuffer() const
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.
Root of the metadata hierarchy.
Definition Metadata.h:64
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A tuple of MDNodes.
Definition Metadata.h:1760
LLVM_ABI void addOperand(MDNode *M)
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition StringRef.h:730
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:140
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition StringRef.h:446
Class to represent struct types.
static LLVM_ABI StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
Definition Type.cpp:738
static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition Type.cpp:619
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition Triple.h:808
const std::string & getTriple() const
Definition Triple.h:489
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition Triple.h:942
VendorType getVendor() const
Get the parsed vendor type of this triple.
Definition Triple.h:426
bool isSPIRV() const
Tests whether the target is SPIR-V (32/64-bit/Logical).
Definition Triple.h:928
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition Triple.h:803
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:297
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:296
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
Definition Type.cpp:295
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
A node in a MsgPack Document.
MapDocNode & getMap(bool Convert=false)
Get a MapDocNode for a map node.
ArrayDocNode & getArray(bool Convert=false)
Get an ArrayDocNode for an array node.
StringRef getString() const
Simple in-memory representation of a document of msgpack objects with ability to find and create arra...
DocNode & getRoot()
Get ref to the document's root element.
LLVM_ABI bool readFromBlob(StringRef Blob, bool Multi, function_ref< int(DocNode *DestNode, DocNode SrcNode, DocNode MapKey)> Merger=[](DocNode *DestNode, DocNode SrcNode, DocNode MapKey) { return -1;})
Read a document from a binary msgpack blob, merging into anything already in the Document.
MapTy::iterator find(DocNode Key)
const Elf_Ehdr & getHeader() const
Definition ELF.h:347
static Expected< ELFFile > create(StringRef Object)
iterator_range< Elf_Note_Iterator > notes(const Elf_Phdr &Phdr, Error &Err) const
Get an iterator range over notes of a program header.
Definition ELF.h:536
Expected< Elf_Shdr_Range > sections() const
Definition ELF.h:1038
static uint64_t getAlignment()
@ Entry
Definition COFF.h:862
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
@ NT_AMDGPU_METADATA
Definition ELF.h:1985
@ EI_ABIVERSION
Definition ELF.h:59
@ SHT_NOTE
Definition ELF.h:1152
@ EF_AMDGPU_FEATURE_XNACK_ANY_V4
Definition ELF.h:900
@ EF_AMDGPU_FEATURE_SRAMECC_UNSUPPORTED_V4
Definition ELF.h:911
@ EF_AMDGPU_FEATURE_SRAMECC_OFF_V4
Definition ELF.h:915
@ EF_AMDGPU_FEATURE_XNACK_UNSUPPORTED_V4
Definition ELF.h:898
@ EF_AMDGPU_FEATURE_XNACK_OFF_V4
Definition ELF.h:902
@ EF_AMDGPU_FEATURE_XNACK_V4
Definition ELF.h:896
@ EF_AMDGPU_FEATURE_SRAMECC_V4
Definition ELF.h:909
@ EF_AMDGPU_FEATURE_XNACK_ON_V4
Definition ELF.h:904
@ EF_AMDGPU_FEATURE_SRAMECC_ANY_V4
Definition ELF.h:913
@ EF_AMDGPU_FEATURE_SRAMECC_ON_V4
Definition ELF.h:917
OffloadKind
The producer of the associated offloading image.
ImageKind
The type of contents the offloading image contains.
ELFFile< ELF64LE > ELF64LEFile
Definition ELF.h:602
LLVM_ABI Error getAMDGPUMetaDataFromImage(MemoryBufferRef MemBuffer, StringMap< AMDGPUKernelMetaData > &KernelInfoMap, uint16_t &ELFABIVersion)
Reads AMDGPU specific metadata from the ELF file and propagates the KernelInfoMap.
Definition Utility.cpp:348
LLVM_ABI bool isImageCompatibleWithEnv(StringRef ImageArch, uint32_t ImageFlags, StringRef EnvTargetID)
Check if an image is compatible with current system's environment.
Definition Utility.cpp:156
LLVM_ABI Error containerizeOpenMPSPIRVImage(std::unique_ptr< MemoryBuffer > &Binary, llvm::Triple Triple, StringRef CompileOpts="", StringRef LinkOpts="")
Containerizes an OpenMP SPIR-V image into an OffloadBinary image.
Definition Utility.cpp:408
LLVM_ABI GlobalVariable * emitOffloadingEntry(Module &M, object::OffloadKind Kind, Constant *Addr, StringRef Name, uint64_t Size, uint32_t Flags, uint64_t Data, Constant *AuxAddr=nullptr, StringRef SectionName="llvm_offload_entries")
Create an offloading section struct used to register this global at runtime.
Definition Utility.cpp:87
LLVM_ABI Error containerizeImage(std::unique_ptr< MemoryBuffer > &Binary, llvm::Triple Triple, object::ImageKind ImageKind, object::OffloadKind OffloadKind, int32_t ImageFlags, MapVector< StringRef, StringRef > &MetaData)
Containerizes an image within an OffloadBinary image.
Definition Utility.cpp:382
LLVM_ABI std::pair< Constant *, GlobalVariable * > getOffloadingEntryInitializer(Module &M, object::OffloadKind Kind, Constant *Addr, StringRef Name, uint64_t Size, uint32_t Flags, uint64_t Data, Constant *AuxAddr)
Create a constant struct initializer used to register this global at runtime.
Definition Utility.cpp:41
LLVM_ABI StructType * getEntryTy(Module &M)
Returns the type of the offloading entry we use to store kernels and globals that will be registered ...
Definition Utility.cpp:27
LLVM_ABI std::pair< GlobalVariable *, GlobalVariable * > getOffloadEntryArray(Module &M, StringRef SectionName="llvm_offload_entries")
Creates a pair of globals used to iterate the array of offloading entries by accessing the section va...
Definition Utility.cpp:114
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
Definition InstrProf.h:296
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition Error.h:1305
Op::Description Desc
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
LLVM_ABI void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Elf_Note_Impl< ELFType< E, Is64 > > Note
Definition ELFTypes.h:92
This is the record of an object that just be registered with the offloading runtime.
Definition Utility.h:28
Struct for holding metadata related to AMDGPU kernels, for more information about the metadata and it...
Definition Utility.h:121
uint32_t SGPRSpillCount
Number of stores from a scalar register to a register allocator created spill location.
Definition Utility.h:136
uint32_t SGPRCount
Number of scalar registers required by a wavefront.
Definition Utility.h:131
uint32_t VGPRSpillCount
Number of stores from a vector register to a register allocator created spill location.
Definition Utility.h:139
uint32_t VGPRCount
Number of vector registers required by each work-item.
Definition Utility.h:133
uint32_t PrivateSegmentSize
The amount of fixed private address space memory required for a work-item in bytes.
Definition Utility.h:129
uint32_t GroupSegmentList
The amount of group segment memory required by a work-group in bytes.
Definition Utility.h:126
uint32_t MaxFlatWorkgroupSize
Maximum flat work-group size supported by the kernel in work-items.
Definition Utility.h:150
uint32_t WorkgroupSizeHint[3]
Corresponds to the OpenCL work_group_size_hint attribute.
Definition Utility.h:146
uint32_t AGPRCount
Number of accumulator registers required by each work-item.
Definition Utility.h:141
uint32_t RequestedWorkgroupSize[3]
Corresponds to the OpenCL reqd_work_group_size attribute.
Definition Utility.h:143
Common declarations for yaml2obj.