LLVM 19.0.0git
Typedefs | Enumerations | Functions
llvm::offloading Namespace Reference

Typedefs

using EntryArrayTy = std::pair< GlobalVariable *, GlobalVariable * >
 

Enumerations

enum  OffloadEntryKindFlag : uint32_t {
  OffloadGlobalEntry = 0x0 , OffloadGlobalManagedEntry = 0x1 , OffloadGlobalSurfaceEntry = 0x2 , OffloadGlobalTextureEntry = 0x3 ,
  OffloadGlobalExtern = 0x1 << 3 , OffloadGlobalConstant = 0x1 << 4 , OffloadGlobalNormalized = 0x1 << 5
}
 Offloading entry flags for CUDA / HIP. More...
 

Functions

llvm::Error wrapOpenMPBinaries (llvm::Module &M, llvm::ArrayRef< llvm::ArrayRef< char > > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool Relocatable=false)
 Wraps the input device images into the module M as global symbols and registers the images with the OpenMP Offloading runtime libomptarget.
 
llvm::Error wrapCudaBinary (llvm::Module &M, llvm::ArrayRef< char > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool EmitSurfacesAndTextures=true)
 Wraps the input fatbinary image into the module M as global symbols and registers the images with the CUDA runtime.
 
llvm::Error wrapHIPBinary (llvm::Module &M, llvm::ArrayRef< char > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool EmitSurfacesAndTextures=true)
 Wraps the input bundled image into the module M as global symbols and registers the images with the HIP runtime.
 
StructTypegetEntryTy (Module &M)
 Returns the type of the offloading entry we use to store kernels and globals that will be registered with the offloading runtime.
 
void emitOffloadingEntry (Module &M, Constant *Addr, StringRef Name, uint64_t Size, int32_t Flags, int32_t Data, StringRef SectionName)
 Create an offloading section struct used to register this global at runtime.
 
std::pair< Constant *, GlobalVariable * > getOffloadingEntryInitializer (Module &M, Constant *Addr, StringRef Name, uint64_t Size, int32_t Flags, int32_t Data)
 Create a constant struct initializer used to register this global at runtime.
 
std::pair< GlobalVariable *, GlobalVariable * > getOffloadEntryArray (Module &M, StringRef SectionName)
 Creates a pair of globals used to iterate the array of offloading entries by accessing the section variables provided by the linker.
 

Typedef Documentation

◆ EntryArrayTy

Definition at line 17 of file OffloadWrapper.h.

Enumeration Type Documentation

◆ OffloadEntryKindFlag

Offloading entry flags for CUDA / HIP.

The first three bits indicate the type of entry while the others are a bit field for additional information.

Enumerator
OffloadGlobalEntry 

Mark the entry as a global entry.

This indicates the presense of a kernel if the size size field is zero and a variable otherwise.

OffloadGlobalManagedEntry 

Mark the entry as a managed global variable.

OffloadGlobalSurfaceEntry 

Mark the entry as a surface variable.

OffloadGlobalTextureEntry 

Mark the entry as a texture variable.

OffloadGlobalExtern 

Mark the entry as being extern.

OffloadGlobalConstant 

Mark the entry as being constant.

OffloadGlobalNormalized 

Mark the entry as being a normalized surface.

Definition at line 20 of file Utility.h.

Function Documentation

◆ emitOffloadingEntry()

void llvm::offloading::emitOffloadingEntry ( Module M,
Constant Addr,
StringRef  Name,
uint64_t  Size,
int32_t  Flags,
int32_t  Data,
StringRef  SectionName 
)

Create an offloading section struct used to register this global at runtime.

Type struct __tgt_offload_entry { void *addr; // Pointer to the offload entry info. // (function or global) char *name; // Name of the function or global. size_t size; // Size of the entry info (0 if it a function). int32_t flags; int32_t data; };

Parameters
MThe module to be used
AddrThe pointer to the global being registered.
NameThe symbol name associated with the global.
SizeThe size in bytes of the global (0 for functions).
FlagsFlags associated with the entry.
DataExtra data storage associated with the entry.
SectionNameThe section this entry will be placed at.

Definition at line 64 of file Utility.cpp.

References Addr, getEntryTy(), getOffloadingEntryInitializer(), llvm::Triple::isNVPTX(), llvm::Triple::isOSBinFormatCOFF(), Name, llvm::GlobalValue::NotThreadLocal, Size, and llvm::GlobalValue::WeakAnyLinkage.

Referenced by llvm::OpenMPIRBuilder::createOffloadEntriesAndInfoMetadata(), and llvm::OpenMPIRBuilder::createOffloadEntry().

◆ getEntryTy()

StructType * llvm::offloading::getEntryTy ( Module M)

Returns the type of the offloading entry we use to store kernels and globals that will be registered with the offloading runtime.

Definition at line 19 of file Utility.cpp.

References llvm::CallingConv::C, llvm::StructType::create(), llvm::Type::getInt32Ty(), and llvm::StructType::getTypeByName().

Referenced by emitOffloadingEntry(), getOffloadEntryArray(), and getOffloadingEntryInitializer().

◆ getOffloadEntryArray()

std::pair< GlobalVariable *, GlobalVariable * > llvm::offloading::getOffloadEntryArray ( Module M,
StringRef  SectionName 
)

Creates a pair of globals used to iterate the array of offloading entries by accessing the section variables provided by the linker.

Definition at line 89 of file Utility.cpp.

References llvm::appendToCompilerUsed(), llvm::GlobalValue::ExternalLinkage, llvm::ConstantAggregateZero::get(), getEntryTy(), llvm::GlobalValue::HiddenVisibility, llvm::Triple::isOSBinFormatCOFF(), llvm::Triple::isOSBinFormatELF(), and llvm::GlobalValue::WeakODRLinkage.

◆ getOffloadingEntryInitializer()

std::pair< Constant *, GlobalVariable * > llvm::offloading::getOffloadingEntryInitializer ( Module M,
Constant Addr,
StringRef  Name,
uint64_t  Size,
int32_t  Flags,
int32_t  Data 
)

Create a constant struct initializer used to register this global at runtime.

Returns
the constant struct and the global variable holding the symbol name.

Definition at line 33 of file Utility.cpp.

References Addr, llvm::ConstantStruct::get(), getEntryTy(), llvm::Type::getInt32Ty(), llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(), llvm::ConstantDataArray::getString(), llvm::Value::getType(), Int32Ty, llvm::GlobalValue::InternalLinkage, llvm::Triple::isNVPTX(), Name, and Size.

Referenced by emitOffloadingEntry().

◆ wrapCudaBinary()

Error llvm::offloading::wrapCudaBinary ( llvm::Module M,
llvm::ArrayRef< char Images,
EntryArrayTy  EntryArray,
llvm::StringRef  Suffix = "",
bool  EmitSurfacesAndTextures = true 
)

Wraps the input fatbinary image into the module M as global symbols and registers the images with the CUDA runtime.

Parameters
EntryArrayOptional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array.
SuffixAn optional suffix appended to the emitted symbols.
EmitSurfacesAndTexturesWhether to emit surface and textures registration code. It defaults to false.

Definition at line 602 of file OffloadWrapper.cpp.

References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().

◆ wrapHIPBinary()

Error llvm::offloading::wrapHIPBinary ( llvm::Module M,
llvm::ArrayRef< char Images,
EntryArrayTy  EntryArray,
llvm::StringRef  Suffix = "",
bool  EmitSurfacesAndTextures = true 
)

Wraps the input bundled image into the module M as global symbols and registers the images with the HIP runtime.

Parameters
EntryArrayOptional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array.
SuffixAn optional suffix appended to the emitted symbols.
EmitSurfacesAndTexturesWhether to emit surface and textures registration code. It defaults to false.

Definition at line 616 of file OffloadWrapper.cpp.

References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().

◆ wrapOpenMPBinaries()

Error llvm::offloading::wrapOpenMPBinaries ( llvm::Module M,
llvm::ArrayRef< llvm::ArrayRef< char > >  Images,
EntryArrayTy  EntryArray,
llvm::StringRef  Suffix = "",
bool  Relocatable = false 
)

Wraps the input device images into the module M as global symbols and registers the images with the OpenMP Offloading runtime libomptarget.

Parameters
EntryArrayOptional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array.
SuffixAn optional suffix appended to the emitted symbols.
RelocatableIndicate if we need to change the offloading section to create a relocatable object.

Definition at line 590 of file OffloadWrapper.cpp.

References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().