MLIR  19.0.0git
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
mlir::NVVM::SerializeGPUModuleBase Class Reference

Base class for all NVVM serializations from GPU modules into binary strings. More...

#include "mlir/Target/LLVM/NVVM/Utils.h"

+ Inheritance diagram for mlir::NVVM::SerializeGPUModuleBase:

Public Member Functions

 SerializeGPUModuleBase (Operation &module, NVVMTargetAttr target, const gpu::TargetOptions &targetOptions={})
 Initializes the toolkitPath with the path in targetOptions or if empty with the path in getCUDAToolkitPath. More...
 
NVVMTargetAttr getTarget () const
 Returns the target attribute. More...
 
StringRef getToolkitPath () const
 Returns the CUDA toolkit path. More...
 
ArrayRef< std::string > getFileList () const
 Returns the bitcode files to be loaded. More...
 
LogicalResult appendStandardLibs ()
 Appends nvvm/libdevice.bc into fileList. More...
 
virtual std::optional< SmallVector< std::unique_ptr< llvm::Module > > > loadBitcodeFiles (llvm::Module &module) override
 Loads the bitcode files in fileList. More...
 
- Public Member Functions inherited from mlir::LLVM::ModuleToObject
 ModuleToObject (Operation &module, StringRef triple, StringRef chip, StringRef features={}, int optLevel=3)
 
virtual ~ModuleToObject ()
 
OperationgetOperation ()
 Returns the operation being serialized. More...
 
virtual std::optional< SmallVector< char, 0 > > run ()
 Runs the serialization pipeline, returning std::nullopt on error. More...
 

Static Public Member Functions

static void init ()
 Initializes the LLVM NVPTX target by safely calling LLVMInitializeNVPTX* methods if available. More...
 

Protected Attributes

NVVMTargetAttr target
 NVVM target attribute. More...
 
std::string toolkitPath
 CUDA toolkit path. More...
 
SmallVector< std::string > fileList
 List of LLVM bitcode files to link to. More...
 
- Protected Attributes inherited from mlir::LLVM::ModuleToObject
Operationmodule
 Module to transform to a binary object. More...
 
StringRef triple
 Target triple. More...
 
StringRef chip
 Target chip. More...
 
StringRef features
 Target features. More...
 
int optLevel
 Optimization level. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mlir::LLVM::ModuleToObject
virtual void setDataLayoutAndTriple (llvm::Module &module)
 Hook for computing the Datalayout. More...
 
virtual LogicalResult handleBitcodeFile (llvm::Module &module)
 Hook for performing additional actions on a loaded bitcode file. More...
 
virtual void handleModulePreLink (llvm::Module &module)
 Hook for performing additional actions on the llvmModule pre linking. More...
 
virtual void handleModulePostLink (llvm::Module &module)
 Hook for performing additional actions on the llvmModule post linking. More...
 
virtual std::optional< SmallVector< char, 0 > > moduleToObject (llvm::Module &llvmModule)
 Serializes the LLVM IR bitcode to an object file, by default it serializes to LLVM bitcode. More...
 
std::optional< llvm::TargetMachine * > getOrCreateTargetMachine ()
 Create the target machine based on the target triple and chip. More...
 
std::unique_ptr< llvm::Module > loadBitcodeFile (llvm::LLVMContext &context, StringRef path)
 Loads a bitcode file from path. More...
 
LogicalResult loadBitcodeFilesFromList (llvm::LLVMContext &context, ArrayRef< std::string > fileList, SmallVector< std::unique_ptr< llvm::Module >> &llvmModules, bool failureOnError=true)
 Loads multiple bitcode files. More...
 
std::unique_ptr< llvm::Module > translateToLLVMIR (llvm::LLVMContext &llvmContext)
 Translates the operation to LLVM IR. More...
 
LogicalResult linkFiles (llvm::Module &module, SmallVector< std::unique_ptr< llvm::Module >> &&libs)
 Link the llvmModule to other bitcode file. More...
 
virtual LogicalResult optimizeModule (llvm::Module &module, int optL)
 Optimize the module. More...
 
- Static Protected Member Functions inherited from mlir::LLVM::ModuleToObject
static std::optional< std::string > translateToISA (llvm::Module &llvmModule, llvm::TargetMachine &targetMachine)
 Utility function for translating to ISA, returns std::nullopt on failure. More...
 

Detailed Description

Base class for all NVVM serializations from GPU modules into binary strings.

By default this class serializes into LLVM bitcode.

Definition at line 32 of file Utils.h.

Constructor & Destructor Documentation

◆ SerializeGPUModuleBase()

SerializeGPUModuleBase::SerializeGPUModuleBase ( Operation module,
NVVMTargetAttr  target,
const gpu::TargetOptions targetOptions = {} 
)

Initializes the toolkitPath with the path in targetOptions or if empty with the path in getCUDAToolkitPath.

Definition at line 85 of file Target.cpp.

References appendStandardLibs(), fileList, mlir::NVVM::getCUDAToolkitPath(), target, and toolkitPath.

Member Function Documentation

◆ appendStandardLibs()

LogicalResult SerializeGPUModuleBase::appendStandardLibs ( )

Appends nvvm/libdevice.bc into fileList.

Returns failure if the library couldn't be found.

Definition at line 129 of file Target.cpp.

References mlir::Operation::emitError(), mlir::failure(), fileList, mlir::LLVM::ModuleToObject::getOperation(), getToolkitPath(), and mlir::success().

Referenced by SerializeGPUModuleBase().

◆ getFileList()

ArrayRef< std::string > SerializeGPUModuleBase::getFileList ( ) const

Returns the bitcode files to be loaded.

Definition at line 124 of file Target.cpp.

References fileList.

◆ getTarget()

NVVMTargetAttr SerializeGPUModuleBase::getTarget ( ) const

Returns the target attribute.

Definition at line 120 of file Target.cpp.

References target.

◆ getToolkitPath()

StringRef SerializeGPUModuleBase::getToolkitPath ( ) const

Returns the CUDA toolkit path.

Definition at line 122 of file Target.cpp.

References toolkitPath.

Referenced by appendStandardLibs().

◆ init()

void SerializeGPUModuleBase::init ( )
static

Initializes the LLVM NVPTX target by safely calling LLVMInitializeNVPTX* methods if available.

Definition at line 107 of file Target.cpp.

◆ loadBitcodeFiles()

std::optional< SmallVector< std::unique_ptr< llvm::Module > > > SerializeGPUModuleBase::loadBitcodeFiles ( llvm::Module &  module)
overridevirtual

Member Data Documentation

◆ fileList

SmallVector<std::string> mlir::NVVM::SerializeGPUModuleBase::fileList
protected

List of LLVM bitcode files to link to.

Definition at line 68 of file Utils.h.

Referenced by appendStandardLibs(), getFileList(), loadBitcodeFiles(), and SerializeGPUModuleBase().

◆ target

NVVMTargetAttr mlir::NVVM::SerializeGPUModuleBase::target
protected

NVVM target attribute.

Definition at line 62 of file Utils.h.

Referenced by getTarget(), and SerializeGPUModuleBase().

◆ toolkitPath

std::string mlir::NVVM::SerializeGPUModuleBase::toolkitPath
protected

CUDA toolkit path.

Definition at line 65 of file Utils.h.

Referenced by getToolkitPath(), and SerializeGPUModuleBase().


The documentation for this class was generated from the following files: