MLIR 24.0.0git
mlir::gpu::TargetOptions Class Reference

This class serves as an opaque interface for passing options to the TargetAttrInterface methods. More...

#include "mlir/Dialect/GPU/IR/CompilationInterfaces.h"

Public Member Functions

 TargetOptions (StringRef toolkitPath={}, ArrayRef< Attribute > librariesToLink={}, StringRef cmdOptions={}, StringRef elfSection={}, CompilationTarget compilationTarget=getDefaultCompilationTarget(), function_ref< SymbolTable *()> getSymbolTableCallback={}, function_ref< void(llvm::Module &)> initialLlvmIRCallback={}, function_ref< void(llvm::Module &)> linkedLlvmIRCallback={}, function_ref< void(llvm::Module &)> optimizedLlvmIRCallback={}, function_ref< void(StringRef)> isaCallback={})
 Constructor initializing the toolkit path, the list of files to link to, extra command line options, the compilation target and a callback for obtaining the parent symbol table.
TypeID getTypeID () const
 Returns the typeID.
StringRef getToolkitPath () const
 Returns the toolkit path.
ArrayRef< Attribute > getLibrariesToLink () const
 Returns the LLVM libraries to link to.
StringRef getCmdOptions () const
 Returns the command line options.
StringRef getELFSection () const
 Returns the ELF section.
std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > tokenizeCmdOptions () const
 Returns a tokenization of the command line options.
std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > tokenizeAndRemoveSuffixCmdOptions (llvm::StringRef startsWith)
 Returns a tokenization of the substr of the command line options that starts with startsWith and ends with end of the command line options and consumes it.
CompilationTarget getCompilationTarget () const
 Returns the compilation target.
SymbolTable * getSymbolTable () const
 Returns the result of the getSymbolTableCallback callback or a nullptr if no callback was provided.
function_ref< void(llvm::Module &)> getInitialLlvmIRCallback () const
 Returns the callback invoked with the initial LLVM IR for the device module.
function_ref< void(llvm::Module &)> getLinkedLlvmIRCallback () const
 Returns the callback invoked with LLVM IR for the device module after linking the device libraries.
function_ref< void(llvm::Module &)> getOptimizedLlvmIRCallback () const
 Returns the callback invoked with LLVM IR for the device module after LLVM optimizations but before codegen.
function_ref< void(StringRef)> getISACallback () const
 Returns the callback invoked with the target ISA for the device, for example PTX assembly.
const llvm::cl::LibraryOptionsContext * getLibraryOptions () const
 Returns the LLVM library options for the LLVMContext and TargetMachine that serialization creates, or nullptr for their defaults.
void setLibraryOptions (const llvm::cl::LibraryOptionsContext *options)
 Sets the LLVM library options. They must outlive the serialization.

Static Public Member Functions

static CompilationTarget getDefaultCompilationTarget ()
 Returns the default compilation target: CompilationTarget::Fatbin.
static std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > tokenizeCmdOptions (const std::string &cmdOptions)
 Returns a tokenization of the command line options.

Protected Member Functions

 TargetOptions (TypeID typeID, StringRef toolkitPath={}, ArrayRef< Attribute > librariesToLink={}, StringRef cmdOptions={}, StringRef elfSection={}, CompilationTarget compilationTarget=getDefaultCompilationTarget(), function_ref< SymbolTable *()> getSymbolTableCallback={}, function_ref< void(llvm::Module &)> initialLlvmIRCallback={}, function_ref< void(llvm::Module &)> linkedLlvmIRCallback={}, function_ref< void(llvm::Module &)> optimizedLlvmIRCallback={}, function_ref< void(StringRef)> isaCallback={})
 Derived classes must use this constructor to initialize typeID to the appropiate value: ie.

Protected Attributes

std::string toolkitPath
 Path to the target toolkit.
SmallVector< Attribute > librariesToLink
 List of files to link with the LLVM module.
std::string cmdOptions
 An optional set of command line options to be used by the compilation process.
std::string elfSection
 ELF Section where the binary needs to be located.
CompilationTarget compilationTarget
 Compilation process target format.
function_ref< SymbolTable *()> getSymbolTableCallback
 Callback for obtaining the parent symbol table of all the GPU modules being serialized.
function_ref< void(llvm::Module &)> initialLlvmIRCallback
 Callback invoked with the initial LLVM IR for the device module.
function_ref< void(llvm::Module &)> linkedLlvmIRCallback
 Callback invoked with LLVM IR for the device module after linking the device libraries.
function_ref< void(llvm::Module &)> optimizedLlvmIRCallback
 Callback invoked with LLVM IR for the device module after LLVM optimizations but before codegen.
function_ref< void(StringRef)> isaCallback
 Callback invoked with the target ISA for the device, for example PTX assembly.
const llvm::cl::LibraryOptionsContext * libraryOptions = nullptr

Detailed Description

This class serves as an opaque interface for passing options to the TargetAttrInterface methods.

Users of this class must implement the classof method as well as using the macros MLIR_*_EXPLICIT_TYPE_ID to ensure type safeness. Targets are free to ignore these options.

Definition at line 51 of file CompilationInterfaces.h.

Constructor & Destructor Documentation

◆ TargetOptions() [1/2]

TargetOptions::TargetOptions ( StringRef toolkitPath = {},
ArrayRef< Attribute > librariesToLink = {},
StringRef cmdOptions = {},
StringRef elfSection = {},
CompilationTarget compilationTarget = getDefaultCompilationTarget(),
function_ref< SymbolTable *()> getSymbolTableCallback = {},
function_ref< void(llvm::Module &)> initialLlvmIRCallback = {},
function_ref< void(llvm::Module &)> linkedLlvmIRCallback = {},
function_ref< void(llvm::Module &)> optimizedLlvmIRCallback = {},
function_ref< void(StringRef)> isaCallback = {} )

Constructor initializing the toolkit path, the list of files to link to, extra command line options, the compilation target and a callback for obtaining the parent symbol table.

The default compilation target is Fatbin.

Definition at line 374 of file GPUBase.cpp.

References cmdOptions, compilationTarget, elfSection, mlir::get(), getSymbolTableCallback, initialLlvmIRCallback, isaCallback, librariesToLink, linkedLlvmIRCallback, optimizedLlvmIRCallback, TargetOptions(), and toolkitPath.

Referenced by TargetOptions().

◆ TargetOptions() [2/2]

TargetOptions::TargetOptions ( TypeID typeID,
StringRef toolkitPath = {},
ArrayRef< Attribute > librariesToLink = {},
StringRef cmdOptions = {},
StringRef elfSection = {},
CompilationTarget compilationTarget = getDefaultCompilationTarget(),
function_ref< SymbolTable *()> getSymbolTableCallback = {},
function_ref< void(llvm::Module &)> initialLlvmIRCallback = {},
function_ref< void(llvm::Module &)> linkedLlvmIRCallback = {},
function_ref< void(llvm::Module &)> optimizedLlvmIRCallback = {},
function_ref< void(StringRef)> isaCallback = {} )
protected

Derived classes must use this constructor to initialize typeID to the appropiate value: ie.

TargetOptions(TypeID::get<DerivedClass>()).

Definition at line 389 of file GPUBase.cpp.

References cmdOptions, compilationTarget, elfSection, getSymbolTableCallback, initialLlvmIRCallback, isaCallback, librariesToLink, linkedLlvmIRCallback, optimizedLlvmIRCallback, and toolkitPath.

Member Function Documentation

◆ getCmdOptions()

StringRef TargetOptions::getCmdOptions ( ) const

Returns the command line options.

Definition at line 415 of file GPUBase.cpp.

References cmdOptions.

◆ getCompilationTarget()

CompilationTarget TargetOptions::getCompilationTarget ( ) const

Returns the compilation target.

Definition at line 442 of file GPUBase.cpp.

References compilationTarget.

Referenced by mlir::ROCDL::SerializeGPUModuleBase::moduleToObjectImpl().

◆ getDefaultCompilationTarget()

CompilationTarget TargetOptions::getDefaultCompilationTarget ( )
static

Returns the default compilation target: CompilationTarget::Fatbin.

Definition at line 446 of file GPUBase.cpp.

◆ getELFSection()

StringRef TargetOptions::getELFSection ( ) const

Returns the ELF section.

Definition at line 417 of file GPUBase.cpp.

References elfSection.

◆ getInitialLlvmIRCallback()

function_ref< void(llvm::Module &)> TargetOptions::getInitialLlvmIRCallback ( ) const

Returns the callback invoked with the initial LLVM IR for the device module.

Definition at line 424 of file GPUBase.cpp.

References initialLlvmIRCallback.

◆ getISACallback()

function_ref< void(StringRef)> TargetOptions::getISACallback ( ) const

Returns the callback invoked with the target ISA for the device, for example PTX assembly.

Definition at line 438 of file GPUBase.cpp.

References isaCallback.

◆ getLibrariesToLink()

ArrayRef< Attribute > TargetOptions::getLibrariesToLink ( ) const

Returns the LLVM libraries to link to.

Definition at line 411 of file GPUBase.cpp.

References librariesToLink.

◆ getLibraryOptions()

const llvm::cl::LibraryOptionsContext * mlir::gpu::TargetOptions::getLibraryOptions ( ) const
inline

Returns the LLVM library options for the LLVMContext and TargetMachine that serialization creates, or nullptr for their defaults.

Definition at line 120 of file CompilationInterfaces.h.

References libraryOptions.

◆ getLinkedLlvmIRCallback()

function_ref< void(llvm::Module &)> TargetOptions::getLinkedLlvmIRCallback ( ) const

Returns the callback invoked with LLVM IR for the device module after linking the device libraries.

Definition at line 429 of file GPUBase.cpp.

References linkedLlvmIRCallback.

◆ getOptimizedLlvmIRCallback()

function_ref< void(llvm::Module &)> TargetOptions::getOptimizedLlvmIRCallback ( ) const

Returns the callback invoked with LLVM IR for the device module after LLVM optimizations but before codegen.

Definition at line 434 of file GPUBase.cpp.

References optimizedLlvmIRCallback.

◆ getSymbolTable()

SymbolTable * TargetOptions::getSymbolTable ( ) const

Returns the result of the getSymbolTableCallback callback or a nullptr if no callback was provided.

Note: The callback itself can return nullptr. It is up to the target how to react to getting a nullptr, e.g., emitting an error or constructing the table.

Definition at line 419 of file GPUBase.cpp.

References getSymbolTableCallback.

◆ getToolkitPath()

StringRef TargetOptions::getToolkitPath ( ) const

Returns the toolkit path.

Definition at line 409 of file GPUBase.cpp.

References toolkitPath.

◆ getTypeID()

TypeID TargetOptions::getTypeID ( ) const

Returns the typeID.

Definition at line 407 of file GPUBase.cpp.

◆ setLibraryOptions()

void mlir::gpu::TargetOptions::setLibraryOptions ( const llvm::cl::LibraryOptionsContext * options)
inline

Sets the LLVM library options. They must outlive the serialization.

Definition at line 124 of file CompilationInterfaces.h.

References libraryOptions, and options.

◆ tokenizeAndRemoveSuffixCmdOptions()

std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > TargetOptions::tokenizeAndRemoveSuffixCmdOptions ( llvm::StringRef startsWith)

Returns a tokenization of the substr of the command line options that starts with startsWith and ends with end of the command line options and consumes it.

Definition at line 479 of file GPUBase.cpp.

References cmdOptions, and tokenizeCmdOptions().

◆ tokenizeCmdOptions() [1/2]

std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > TargetOptions::tokenizeCmdOptions ( ) const

Returns a tokenization of the command line options.

Definition at line 474 of file GPUBase.cpp.

References cmdOptions, and tokenizeCmdOptions().

Referenced by mlir::impl::GpuNVVMAttachTargetBase< DerivedT >::getDescription(), tokenizeAndRemoveSuffixCmdOptions(), and tokenizeCmdOptions().

◆ tokenizeCmdOptions() [2/2]

std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > TargetOptions::tokenizeCmdOptions ( const std::string & cmdOptions)
static

Returns a tokenization of the command line options.

Definition at line 451 of file GPUBase.cpp.

References cmdOptions, and options.

Member Data Documentation

◆ cmdOptions

std::string mlir::gpu::TargetOptions::cmdOptions
protected

An optional set of command line options to be used by the compilation process.

Definition at line 157 of file CompilationInterfaces.h.

Referenced by getCmdOptions(), TargetOptions(), TargetOptions(), tokenizeAndRemoveSuffixCmdOptions(), tokenizeCmdOptions(), and tokenizeCmdOptions().

◆ compilationTarget

CompilationTarget mlir::gpu::TargetOptions::compilationTarget
protected

Compilation process target format.

Definition at line 163 of file CompilationInterfaces.h.

Referenced by getCompilationTarget(), TargetOptions(), and TargetOptions().

◆ elfSection

std::string mlir::gpu::TargetOptions::elfSection
protected

ELF Section where the binary needs to be located.

Definition at line 160 of file CompilationInterfaces.h.

Referenced by getELFSection(), TargetOptions(), and TargetOptions().

◆ getSymbolTableCallback

function_ref<SymbolTable *()> mlir::gpu::TargetOptions::getSymbolTableCallback
protected

Callback for obtaining the parent symbol table of all the GPU modules being serialized.

Definition at line 167 of file CompilationInterfaces.h.

Referenced by getSymbolTable(), TargetOptions(), and TargetOptions().

◆ initialLlvmIRCallback

function_ref<void(llvm::Module &)> mlir::gpu::TargetOptions::initialLlvmIRCallback
protected

Callback invoked with the initial LLVM IR for the device module.

Definition at line 170 of file CompilationInterfaces.h.

Referenced by getInitialLlvmIRCallback(), TargetOptions(), and TargetOptions().

◆ isaCallback

function_ref<void(StringRef)> mlir::gpu::TargetOptions::isaCallback
protected

Callback invoked with the target ISA for the device, for example PTX assembly.

Definition at line 182 of file CompilationInterfaces.h.

Referenced by getISACallback(), TargetOptions(), and TargetOptions().

◆ librariesToLink

SmallVector<Attribute> mlir::gpu::TargetOptions::librariesToLink
protected

List of files to link with the LLVM module.

Definition at line 153 of file CompilationInterfaces.h.

Referenced by getLibrariesToLink(), TargetOptions(), and TargetOptions().

◆ libraryOptions

const llvm::cl::LibraryOptionsContext* mlir::gpu::TargetOptions::libraryOptions = nullptr
protected

Definition at line 184 of file CompilationInterfaces.h.

Referenced by getLibraryOptions(), and setLibraryOptions().

◆ linkedLlvmIRCallback

function_ref<void(llvm::Module &)> mlir::gpu::TargetOptions::linkedLlvmIRCallback
protected

Callback invoked with LLVM IR for the device module after linking the device libraries.

Definition at line 174 of file CompilationInterfaces.h.

Referenced by getLinkedLlvmIRCallback(), TargetOptions(), and TargetOptions().

◆ optimizedLlvmIRCallback

function_ref<void(llvm::Module &)> mlir::gpu::TargetOptions::optimizedLlvmIRCallback
protected

Callback invoked with LLVM IR for the device module after LLVM optimizations but before codegen.

Definition at line 178 of file CompilationInterfaces.h.

Referenced by getOptimizedLlvmIRCallback(), TargetOptions(), and TargetOptions().

◆ toolkitPath

std::string mlir::gpu::TargetOptions::toolkitPath
protected

Path to the target toolkit.

Definition at line 150 of file CompilationInterfaces.h.

Referenced by getToolkitPath(), TargetOptions(), and TargetOptions().


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