13 #ifndef MLIR_TARGET_LLVM_ROCDL_UTILS_H
14 #define MLIR_TARGET_LLVM_ROCDL_UTILS_H
72 virtual std::optional<SmallVector<std::unique_ptr<llvm::Module>>>
88 bool wave64,
bool daz,
bool finiteOnly,
89 bool unsafeMath,
bool fastMath,
bool correctSqrt,
93 virtual std::optional<SmallVector<char, 0>>
97 std::optional<SmallVector<char, 0>>
99 llvm::Module &llvmModule);
102 std::optional<SmallVector<char, 0>>
assembleIsa(StringRef isa);
122 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< Attribute > getLibrariesToLink() const
Returns the LLVM bitcode libraries to be linked.
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 if needed.
std::optional< SmallVector< char, 0 > > assembleIsa(StringRef isa)
Returns the assembled ISA.
std::string toolkitPath
ROCM toolkit path.
SmallVector< Attribute > librariesToLink
List of LLVM bitcode files to link to.
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
Determines required Device Libraries and adds oclc control variables to the LLVM Module if needed.
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.