MLIR 22.0.0git
ConvertLaunchFuncToLLVMCalls.cpp File Reference

Go to the source code of this file.

Classes

class  mlir::impl::LowerHostCodeToLLVMPassBase< DerivedT >

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::impl
 Attribute collections provide a dictionary-like interface.

Macros

#define GEN_PASS_DEF_LOWERHOSTCODETOLLVMPASS

Functions

std::unique_ptr<::mlir::Passmlir::impl::createLowerHostCodeToLLVMPass ()
std::unique_ptr<::mlir::Passmlir::createLowerHostCodeToLLVMPass ()
static std::string descriptorSetName ()
 Returns the string name of the DescriptorSet decoration.
static std::string bindingName ()
 Returns the string name of the Binding decoration.
static unsigned calculateGlobalIndex (spirv::GlobalVariableOp op)
 Calculates the index of the kernel's operand that is represented by the given global variable with the bind attribute.
static void copy (Location loc, Value dst, Value src, Value size, OpBuilder &builder)
 Copies the given number of bytes from src to dst pointers.
static std::string createGlobalVariableWithBindName (spirv::GlobalVariableOp op, StringRef kernelModuleName)
 Encodes the binding and descriptor set numbers into a new symbolic name.
static bool hasDescriptorSetAndBinding (spirv::GlobalVariableOp op)
 Returns true if the given global variable has both a descriptor set number and a binding number.
static LogicalResult getKernelGlobalVariables (spirv::ModuleOp module, DenseMap< uint32_t, spirv::GlobalVariableOp > &globalVariableMap)
 Fills globalVariableMap with SPIR-V global variables that represent kernel arguments from the given SPIR-V module.
static LogicalResult encodeKernelName (spirv::ModuleOp module)
 Encodes the SPIR-V module's symbolic name into the name of the entry point function.

Variables

static constexpr const char kSPIRVModule [] = "__spv__"

Macro Definition Documentation

◆ GEN_PASS_DEF_LOWERHOSTCODETOLLVMPASS

#define GEN_PASS_DEF_LOWERHOSTCODETOLLVMPASS

Definition at line 34 of file ConvertLaunchFuncToLLVMCalls.cpp.

Function Documentation

◆ bindingName()

std::string bindingName ( )
static

◆ calculateGlobalIndex()

unsigned calculateGlobalIndex ( spirv::GlobalVariableOp op)
static

Calculates the index of the kernel's operand that is represented by the given global variable with the bind attribute.

We assume that the index of each kernel's operand is mapped to (descriptorSet, binding) by the map: i -> (0, i) which is implemented under LowerABIAttributesPass.

Definition at line 63 of file ConvertLaunchFuncToLLVMCalls.cpp.

References bindingName().

Referenced by getKernelGlobalVariables().

◆ copy()

◆ createGlobalVariableWithBindName()

std::string createGlobalVariableWithBindName ( spirv::GlobalVariableOp op,
StringRef kernelModuleName )
static

Encodes the binding and descriptor set numbers into a new symbolic name.

The name is specified by {kernel_module_name}_{variable_name}_descriptor_set{ds}_binding{b} to avoid symbolic conflicts, where 'ds' and 'b' are descriptor set and binding numbers.

Definition at line 80 of file ConvertLaunchFuncToLLVMCalls.cpp.

References bindingName(), and descriptorSetName().

◆ descriptorSetName()

std::string descriptorSetName ( )
static

◆ encodeKernelName()

LogicalResult encodeKernelName ( spirv::ModuleOp module)
static

Encodes the SPIR-V module's symbolic name into the name of the entry point function.

Definition at line 122 of file ConvertLaunchFuncToLLVMCalls.cpp.

References mlir::SymbolTable::replaceAllSymbolUses(), mlir::SymbolTable::setSymbolName(), and success().

◆ getKernelGlobalVariables()

LogicalResult getKernelGlobalVariables ( spirv::ModuleOp module,
DenseMap< uint32_t, spirv::GlobalVariableOp > & globalVariableMap )
static

Fills globalVariableMap with SPIR-V global variables that represent kernel arguments from the given SPIR-V module.

We assume that the module contains a single entry point function. Hence, all spirv.GlobalVariables with a bind attribute are kernel arguments.

Definition at line 104 of file ConvertLaunchFuncToLLVMCalls.cpp.

References calculateGlobalIndex(), hasDescriptorSetAndBinding(), and success().

◆ hasDescriptorSetAndBinding()

bool hasDescriptorSetAndBinding ( spirv::GlobalVariableOp op)
static

Returns true if the given global variable has both a descriptor set number and a binding number.

Definition at line 93 of file ConvertLaunchFuncToLLVMCalls.cpp.

References bindingName(), and descriptorSetName().

Referenced by getKernelGlobalVariables().

Variable Documentation

◆ kSPIRVModule

const char kSPIRVModule[] = "__spv__"
staticconstexpr

Definition at line 40 of file ConvertLaunchFuncToLLVMCalls.cpp.