MLIR
17.0.0git
|
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include <functional>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "mlir-spirv-conversion" |
Functions | |
template<typename LabelT > | |
static LogicalResult | checkExtensionRequirements (LabelT label, const spirv::TargetEnv &targetEnv, const spirv::SPIRVType::ExtensionArrayRefVector &candidates) |
Checks that candidates extension requirements are possible to be satisfied with the given targetEnv . More... | |
template<typename LabelT > | |
static LogicalResult | checkCapabilityRequirements (LabelT label, const spirv::TargetEnv &targetEnv, const spirv::SPIRVType::CapabilityArrayRefVector &candidates) |
Checks that candidates capability requirements are possible to be satisfied with the given isAllowedFn . More... | |
static bool | needsExplicitLayout (spirv::StorageClass storageClass) |
Returns true if the given storageClass needs explicit layout when used in Shader environments. More... | |
static spirv::PointerType | wrapInStructAndGetPointer (Type elementType, spirv::StorageClass storageClass) |
Wraps the given elementType in a struct and gets the pointer to the struct. More... | |
static std::optional< int64_t > | getTypeNumBytes (const SPIRVConversionOptions &options, Type type) |
static Type | convertScalarType (const spirv::TargetEnv &targetEnv, const SPIRVConversionOptions &options, spirv::ScalarType type, std::optional< spirv::StorageClass > storageClass={}) |
Converts a scalar type to a suitable type under the given targetEnv . More... | |
static Type | convertVectorType (const spirv::TargetEnv &targetEnv, const SPIRVConversionOptions &options, VectorType type, std::optional< spirv::StorageClass > storageClass={}) |
Converts a vector type to a suitable type under the given targetEnv . More... | |
static Type | convertTensorType (const spirv::TargetEnv &targetEnv, const SPIRVConversionOptions &options, TensorType type) |
Converts a tensor type to a suitable type under the given targetEnv . More... | |
static Type | convertBoolMemrefType (const spirv::TargetEnv &targetEnv, const SPIRVConversionOptions &options, MemRefType type, spirv::StorageClass storageClass) |
static Type | convertMemrefType (const spirv::TargetEnv &targetEnv, const SPIRVConversionOptions &options, MemRefType type) |
static spirv::GlobalVariableOp | getBuiltinVariable (Block &body, spirv::BuiltIn builtin) |
static std::string | getBuiltinVarName (spirv::BuiltIn builtin) |
Gets name of global variable for a builtin. More... | |
static spirv::GlobalVariableOp | getOrInsertBuiltinVariable (Block &body, Location loc, spirv::BuiltIn builtin, Type integerType, OpBuilder &builder) |
Gets or inserts a global variable for a builtin within body block. More... | |
static spirv::PointerType | getPushConstantStorageType (unsigned elementCount, Builder &builder, Type indexType) |
Returns the pointer type for the push constant storage containing elementCount 32-bit integer values. More... | |
static spirv::GlobalVariableOp | getPushConstantVariable (Block &body, unsigned elementCount) |
Returns the push constant varible containing elementCount 32-bit integer values in body . More... | |
static spirv::GlobalVariableOp | getOrInsertPushConstantVariable (Location loc, Block &block, unsigned elementCount, OpBuilder &b, Type indexType) |
Gets or inserts a global variable for push constant storage containing elementCount 32-bit integer values in block . More... | |
#define DEBUG_TYPE "mlir-spirv-conversion" |
Definition at line 26 of file SPIRVConversion.cpp.
|
static |
Checks that candidates
capability requirements are possible to be satisfied with the given isAllowedFn
.
candidates
is a vector of vector for capability requirements following ((Capability::A OR Capability::B) AND (Capability::C OR Capability::D)) convention.
Definition at line 69 of file SPIRVConversion.cpp.
References mlir::spirv::TargetEnv::allows(), mlir::failure(), and mlir::success().
|
static |
Checks that candidates
extension requirements are possible to be satisfied with the given targetEnv
.
candidates
is a vector of vector for extension requirements following ((Extension::A OR Extension::B) AND (Extension::C OR Extension::D)) convention.
Definition at line 41 of file SPIRVConversion.cpp.
References mlir::spirv::TargetEnv::allows(), mlir::failure(), and mlir::success().
|
static |
Definition at line 325 of file SPIRVConversion.cpp.
References mlir::spirv::TargetEnv::allows(), convertScalarType(), mlir::spirv::RuntimeArrayType::get(), mlir::spirv::ArrayType::get(), mlir::spirv::PointerType::get(), getTypeNumBytes(), needsExplicitLayout(), options, and wrapInStructAndGetPointer().
Referenced by convertMemrefType().
|
static |
Definition at line 373 of file SPIRVConversion.cpp.
References mlir::spirv::TargetEnv::allows(), convertBoolMemrefType(), convertScalarType(), convertVectorType(), mlir::Type::dyn_cast(), mlir::Type::dyn_cast_or_null(), mlir::spirv::RuntimeArrayType::get(), mlir::spirv::ArrayType::get(), mlir::spirv::PointerType::get(), getTypeNumBytes(), needsExplicitLayout(), options, and wrapInStructAndGetPointer().
Referenced by mlir::SPIRVTypeConverter::SPIRVTypeConverter().
|
static |
Converts a scalar type
to a suitable type under the given targetEnv
.
Definition at line 207 of file SPIRVConversion.cpp.
Referenced by convertBoolMemrefType(), convertMemrefType(), convertTensorType(), and mlir::SPIRVTypeConverter::SPIRVTypeConverter().
|
static |
Converts a tensor type
to a suitable type under the given targetEnv
.
Note that this is mainly for lowering constant tensors. In SPIR-V one can create composite constants with OpConstantComposite to embed relative large constant values and use OpCompositeExtract and OpCompositeInsert to manipulate, like what we do for vectors.
Definition at line 285 of file SPIRVConversion.cpp.
References convertScalarType(), mlir::Type::dyn_cast(), mlir::spirv::ArrayType::get(), mlir::TensorType::getElementType(), getTypeNumBytes(), and options.
Referenced by mlir::SPIRVTypeConverter::SPIRVTypeConverter().
|
static |
Converts a vector type
to a suitable type under the given targetEnv
.
Definition at line 247 of file SPIRVConversion.cpp.
Referenced by convertMemrefType(), and mlir::SPIRVTypeConverter::SPIRVTypeConverter().
|
static |
Definition at line 560 of file SPIRVConversion.cpp.
References mlir::Block::getOps().
Referenced by getOrInsertBuiltinVariable().
|
static |
Gets name of global variable for a builtin.
Definition at line 578 of file SPIRVConversion.cpp.
Referenced by getOrInsertBuiltinVariable().
|
static |
Gets or inserts a global variable for a builtin within body
block.
Definition at line 584 of file SPIRVConversion.cpp.
References mlir::OpBuilder::create(), mlir::emitError(), mlir::spirv::PointerType::get(), getBuiltinVariable(), getBuiltinVarName(), and mlir::OpBuilder::setInsertionPointToStart().
|
static |
Gets or inserts a global variable for push constant storage containing elementCount
32-bit integer values in block
.
Definition at line 683 of file SPIRVConversion.cpp.
References mlir::OpBuilder::atBlockBegin(), mlir::OpBuilder::create(), mlir::OpBuilder::getListener(), getPushConstantStorageType(), and getPushConstantVariable().
Referenced by mlir::spirv::getPushConstantValue().
|
static |
Returns the pointer type for the push constant storage containing elementCount
32-bit integer values.
Definition at line 646 of file SPIRVConversion.cpp.
References mlir::spirv::StructType::get(), mlir::spirv::ArrayType::get(), and mlir::spirv::PointerType::get().
Referenced by getOrInsertPushConstantVariable().
|
static |
Returns the push constant varible containing elementCount
32-bit integer values in body
.
Returns null op if such an op does not exit.
Definition at line 657 of file SPIRVConversion.cpp.
References mlir::Type::cast(), getElementType(), getNumElements(), mlir::Block::getOps(), and mlir::spirv::PointerType::getPointeeType().
Referenced by getOrInsertPushConstantVariable().
|
static |
Definition at line 133 of file SPIRVConversion.cpp.
References mlir::Type::dyn_cast(), mlir::detail::enumerate(), mlir::failed(), mlir::Type::getIntOrFloatBitWidth(), mlir::getStridesAndOffset(), mlir::Type::isa(), max(), and options.
Referenced by convertBoolMemrefType(), convertMemrefType(), and convertTensorType().
|
static |
Returns true if the given storageClass
needs explicit layout when used in Shader environments.
Definition at line 92 of file SPIRVConversion.cpp.
Referenced by convertBoolMemrefType(), convertMemrefType(), and wrapInStructAndGetPointer().
|
static |
Wraps the given elementType
in a struct and gets the pointer to the struct.
This is used to satisfy Vulkan interface requirements.
Definition at line 107 of file SPIRVConversion.cpp.
References mlir::spirv::StructType::get(), mlir::spirv::PointerType::get(), and needsExplicitLayout().
Referenced by convertBoolMemrefType(), and convertMemrefType().