MLIR
20.0.0git
|
Type conversion from builtin types to SPIR-V types for shader interface. More...
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
Public Member Functions | |
SPIRVTypeConverter (spirv::TargetEnvAttr targetAttr, const SPIRVConversionOptions &options={}) | |
Type | getIndexType () const |
Gets the SPIR-V correspondence for the standard index type. More... | |
unsigned | getIndexTypeBitwidth () const |
Gets the bitwidth of the index type when converted to SPIR-V. More... | |
const spirv::TargetEnv & | getTargetEnv () const |
const SPIRVConversionOptions & | getOptions () const |
Returns the options controlling the SPIR-V type converter. More... | |
bool | allows (spirv::Capability capability) const |
Checks if the SPIR-V capability inquired is supported. More... | |
Public Member Functions inherited from mlir::TypeConverter | |
virtual | ~TypeConverter ()=default |
TypeConverter ()=default | |
TypeConverter (const TypeConverter &other) | |
TypeConverter & | operator= (const TypeConverter &other) |
template<typename FnT , typename T = typename llvm::function_traits< std::decay_t<FnT>>::template arg_t<0>> | |
void | addConversion (FnT &&callback) |
Register a conversion function. More... | |
template<typename FnT , typename T = typename llvm::function_traits< std::decay_t<FnT>>::template arg_t<1>> | |
void | addArgumentMaterialization (FnT &&callback) |
All of the following materializations require function objects that are convertible to the following form: Value(OpBuilder &, T, ValueRange, Location) , where T is any subclass of Type . More... | |
template<typename FnT , typename T = typename llvm::function_traits< std::decay_t<FnT>>::template arg_t<1>> | |
void | addSourceMaterialization (FnT &&callback) |
This method registers a materialization that will be called when converting a legal replacement value back to an illegal source type. More... | |
template<typename FnT , typename T = typename llvm::function_traits< std::decay_t<FnT>>::template arg_t<1>> | |
void | addTargetMaterialization (FnT &&callback) |
This method registers a materialization that will be called when converting an illegal (source) value to a legal (target) type. More... | |
template<typename FnT , typename T = typename llvm::function_traits<std::decay_t<FnT>>::template arg_t<0>, typename A = typename llvm::function_traits<std::decay_t<FnT>>::template arg_t<1>> | |
void | addTypeAttributeConversion (FnT &&callback) |
Register a conversion function for attributes within types. More... | |
LogicalResult | convertType (Type t, SmallVectorImpl< Type > &results) const |
Convert the given type. More... | |
Type | convertType (Type t) const |
This hook simplifies defining 1-1 type conversions. More... | |
template<typename TargetType > | |
TargetType | convertType (Type t) const |
Attempts a 1-1 type conversion, expecting the result type to be TargetType . More... | |
LogicalResult | convertTypes (TypeRange types, SmallVectorImpl< Type > &results) const |
Convert the given set of types, filling 'results' as necessary. More... | |
bool | isLegal (Type type) const |
Return true if the given type is legal for this type converter, i.e. More... | |
template<typename RangeT > | |
std::enable_if_t<!std::is_convertible< RangeT, Type >::value &&!std::is_convertible< RangeT, Operation * >::value, bool > | isLegal (RangeT &&range) const |
Return true if all of the given types are legal for this type converter. More... | |
bool | isLegal (Operation *op) const |
Return true if the given operation has legal operand and result types. More... | |
bool | isLegal (Region *region) const |
Return true if the types of block arguments within the region are legal. More... | |
bool | isSignatureLegal (FunctionType ty) const |
Return true if the inputs and outputs of the given function type are legal. More... | |
LogicalResult | convertSignatureArg (unsigned inputNo, Type type, SignatureConversion &result) const |
This method allows for converting a specific argument of a signature. More... | |
LogicalResult | convertSignatureArgs (TypeRange types, SignatureConversion &result, unsigned origInputOffset=0) const |
std::optional< SignatureConversion > | convertBlockSignature (Block *block) const |
This function converts the type signature of the given block, by invoking 'convertSignatureArg' for each argument. More... | |
Value | materializeArgumentConversion (OpBuilder &builder, Location loc, Type resultType, ValueRange inputs) const |
Materialize a conversion from a set of types into one result type by generating a cast sequence of some kind. More... | |
Value | materializeSourceConversion (OpBuilder &builder, Location loc, Type resultType, ValueRange inputs) const |
Value | materializeTargetConversion (OpBuilder &builder, Location loc, Type resultType, ValueRange inputs, Type originalType={}) const |
SmallVector< Value > | materializeTargetConversion (OpBuilder &builder, Location loc, TypeRange resultType, ValueRange inputs, Type originalType={}) const |
std::optional< Attribute > | convertTypeAttribute (Type type, Attribute attr) const |
Convert an attribute present attr from within the type type using the registered conversion functions. More... | |
Type conversion from builtin types to SPIR-V types for shader interface.
For memref types, this converter additionally performs type wrapping to satisfy shader interface requirements: shader interface types must be pointers to structs.
Definition at line 71 of file SPIRVConversion.h.
|
explicit |
Definition at line 1407 of file SPIRVConversion.cpp.
References mlir::TypeConverter::addConversion(), mlir::TypeConverter::addSourceMaterialization(), mlir::TypeConverter::addTargetMaterialization(), mlir::OpBuilder::create(), getIndexType(), and mlir::Operation::getResult().
bool SPIRVTypeConverter::allows | ( | spirv::Capability | capability | ) | const |
Checks if the SPIR-V capability inquired is supported.
Definition at line 1474 of file SPIRVConversion.cpp.
References mlir::spirv::TargetEnv::allows().
Referenced by mlir::spirv::getElementPtr().
Type SPIRVTypeConverter::getIndexType | ( | ) | const |
Gets the SPIR-V correspondence for the standard index type.
Definition at line 1466 of file SPIRVConversion.cpp.
Referenced by mlir::spirv::getOpenCLElementPtr(), mlir::spirv::getVulkanElementPtr(), and SPIRVTypeConverter().
|
inline |
Gets the bitwidth of the index type when converted to SPIR-V.
Definition at line 80 of file SPIRVConversion.h.
References mlir::SPIRVConversionOptions::use64bitIndex.
|
inline |
Returns the options controlling the SPIR-V type converter.
Definition at line 87 of file SPIRVConversion.h.
|
inline |
Definition at line 84 of file SPIRVConversion.h.