MLIR  16.0.0git
Namespaces | Macros | Functions | Variables
ConvertLaunchFuncToLLVMCalls.cpp File Reference
#include "mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h"
#include "mlir/Conversion/ArithmeticToLLVM/ArithmeticToLLVM.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"
+ Include dependency graph for ConvertLaunchFuncToLLVMCalls.cpp:

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Macros

#define GEN_PASS_DEF_LOWERHOSTCODETOLLVM
 

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_LOWERHOSTCODETOLLVM

#define GEN_PASS_DEF_LOWERHOSTCODETOLLVM

Definition at line 36 of file ConvertLaunchFuncToLLVMCalls.cpp.

Function Documentation

◆ bindingName()

static std::string bindingName ( )
static

◆ 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.

References bindingName().

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

References bindingName(), and descriptorSetName().

Referenced by encodeKernelName().

◆ descriptorSetName()

static std::string descriptorSetName ( )
static

Returns the string name of the DescriptorSet decoration.

Definition at line 49 of file ConvertLaunchFuncToLLVMCalls.cpp.

Referenced by createGlobalVariableWithBindName(), hasDescriptorSetAndBinding(), hasOneBranchOpTo(), parseVariableDecorations(), and printVariableDecorations().

◆ encodeKernelName()

static LogicalResult encodeKernelName ( spirv::ModuleOp  module)
static

◆ 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 110 of file ConvertLaunchFuncToLLVMCalls.cpp.

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

Referenced by encodeKernelName().

◆ 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 99 of file ConvertLaunchFuncToLLVMCalls.cpp.

References bindingName(), and descriptorSetName().

Referenced by getKernelGlobalVariables().

Variable Documentation

◆ kSPIRVModule

constexpr const char kSPIRVModule[] = "__spv__"
static

Definition at line 42 of file ConvertLaunchFuncToLLVMCalls.cpp.

Referenced by encodeKernelName().