13 #ifndef MLIR_TARGET_LLVM_ROCDL_UTILS_H
14 #define MLIR_TARGET_LLVM_ROCDL_UTILS_H
71 virtual std::optional<SmallVector<std::unique_ptr<llvm::Module>>>
83 bool wave64,
bool daz,
bool finiteOnly,
84 bool unsafeMath,
bool fastMath,
bool correctSqrt,
88 virtual std::optional<SmallVector<char, 0>>
92 std::optional<SmallVector<char, 0>>
94 llvm::Module &llvmModule);
97 std::optional<SmallVector<char, 0>>
assembleIsa(StringRef isa);
117 std::optional<DenseMap<StringAttr, NamedAttrList>>
This class is a general helper class for creating context-global objects like types,...
Utility base class for transforming operations into binary objects, by default it returns the seriali...
Operation & module
Module to transform to a binary object.
Operation is the basic unit of execution within MLIR.
Base class for all ROCDL serializations from GPU modules into binary strings.
ROCDLTargetAttr getTarget() const
Returns the target attribute.
ArrayRef< std::string > getFileList() const
Returns the bitcode files to be loaded.
AMDGCNLibraries deviceLibs
AMD GCN libraries to use when linking, the default is using none.
ROCDLTargetAttr target
ROCDL target attribute.
SerializeGPUModuleBase(Operation &module, ROCDLTargetAttr target, const gpu::TargetOptions &targetOptions={})
Initializes the toolkitPath with the path in targetOptions or if empty with the path in getROCMPath.
std::optional< SmallVector< char, 0 > > moduleToObjectImpl(const gpu::TargetOptions &targetOptions, llvm::Module &llvmModule)
Default implementation of ModuleToObject::moduleToObject.
virtual std::optional< SmallVector< std::unique_ptr< llvm::Module > > > loadBitcodeFiles(llvm::Module &module) override
Loads the bitcode files in fileList.
void addControlVariables(llvm::Module &module, AMDGCNLibraries libs, bool wave64, bool daz, bool finiteOnly, bool unsafeMath, bool fastMath, bool correctSqrt, StringRef abiVer)
Adds oclc control variables to the LLVM module.
std::optional< SmallVector< char, 0 > > assembleIsa(StringRef isa)
Returns the assembled ISA.
SmallVector< std::string > fileList
List of LLVM bitcode files to link to.
std::string toolkitPath
ROCM toolkit path.
static void init()
Initializes the LLVM AMDGPU target by safely calling LLVMInitializeAMDGPU* methods if available.
StringRef getToolkitPath() const
Returns the ROCM toolkit path.
LogicalResult appendStandardLibs(AMDGCNLibraries libs)
Appends standard ROCm device libraries to fileList.
LogicalResult handleBitcodeFile(llvm::Module &module) override
Removes unnecessary metadata from the loaded bitcode files.
virtual std::optional< SmallVector< char, 0 > > compileToBinary(const std::string &serializedISA)
Compiles assembly to a binary.
void handleModulePreLink(llvm::Module &module) override
Adds oclc control variables to the LLVM module.
This class serves as an opaque interface for passing options to the TargetAttrInterface methods.
AMDGCNLibraries
Helper enum for specifying the AMD GCN device libraries required for compilation.
@ LLVM_MARK_AS_BITMASK_ENUM
std::optional< DenseMap< StringAttr, NamedAttrList > > getAMDHSAKernelsELFMetadata(Builder &builder, ArrayRef< char > elfData)
Returns a map containing the amdhsa.kernels ELF metadata for each of the kernels in the binary,...
gpu::KernelTableAttr getKernelMetadata(Operation *gpuModule, ArrayRef< char > elfData={})
Returns a #gpu.kernel_table containing kernel metadata for each of the kernels in gpuModule.
StringRef getROCMPath()
Searches & returns the path ROCM toolkit path, the search order is:
Include the generated interface declarations.