MLIR  19.0.0git
Namespaces | Macros | Functions | Variables
ConvertLaunchFuncToLLVMCalls.cpp File Reference
#include "mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h"
#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h"
#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
#include "mlir/Conversion/LLVMCommon/Pattern.h"
#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
#include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h"
#include "mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/FormatVariadic.h"
#include "mlir/Conversion/Passes.h.inc"

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Macros

#define GEN_PASS_DEF_LOWERHOSTCODETOLLVMPASS
 

Functions

static std::string descriptorSetName ()
 Returns the string name of the DescriptorSet decoration. More...
 
static std::string bindingName ()
 Returns the string name of the Binding decoration. More...
 
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. More...
 
static void copy (Location loc, Value dst, Value src, Value size, OpBuilder &builder)
 Copies the given number of bytes from src to dst pointers. More...
 
static std::string createGlobalVariableWithBindName (spirv::GlobalVariableOp op, StringRef kernelModuleName)
 Encodes the binding and descriptor set numbers into a new symbolic name. More...
 
static bool hasDescriptorSetAndBinding (spirv::GlobalVariableOp op)
 Returns true if the given global variable has both a descriptor set number and a binding number. More...
 
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. More...
 
static LogicalResult encodeKernelName (spirv::ModuleOp module)
 Encodes the SPIR-V module's symbolic name into the name of the entry point function. More...
 

Variables

static constexpr const char kSPIRVModule [] = "__spv__"
 

Macro Definition Documentation

◆ GEN_PASS_DEF_LOWERHOSTCODETOLLVMPASS

#define GEN_PASS_DEF_LOWERHOSTCODETOLLVMPASS

Definition at line 36 of file ConvertLaunchFuncToLLVMCalls.cpp.

Function Documentation

◆ bindingName()

static std::string bindingName ( )
static

Returns the string name of the Binding decoration.

Definition at line 55 of file ConvertLaunchFuncToLLVMCalls.cpp.

◆ calculateGlobalIndex()

static 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 65 of file ConvertLaunchFuncToLLVMCalls.cpp.

Referenced by getKernelGlobalVariables().

◆ copy()

static void copy ( Location  loc,
Value  dst,
Value  src,
Value  size,
OpBuilder builder 
)
static

◆ createGlobalVariableWithBindName()

static 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 82 of file ConvertLaunchFuncToLLVMCalls.cpp.

◆ descriptorSetName()

static std::string descriptorSetName ( )
static

Returns the string name of the DescriptorSet decoration.

Definition at line 49 of file ConvertLaunchFuncToLLVMCalls.cpp.

◆ encodeKernelName()

static 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 124 of file ConvertLaunchFuncToLLVMCalls.cpp.

References mlir::failed(), mlir::failure(), mlir::get(), kSPIRVModule, mlir::SymbolTable::replaceAllSymbolUses(), mlir::SymbolTable::setSymbolName(), and mlir::success().

◆ getKernelGlobalVariables()

static 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 106 of file ConvertLaunchFuncToLLVMCalls.cpp.

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

◆ hasDescriptorSetAndBinding()

static 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 95 of file ConvertLaunchFuncToLLVMCalls.cpp.

Referenced by getKernelGlobalVariables().

Variable Documentation

◆ kSPIRVModule

constexpr const char kSPIRVModule[] = "__spv__"
staticconstexpr

Definition at line 42 of file ConvertLaunchFuncToLLVMCalls.cpp.

Referenced by encodeKernelName().