MLIR  15.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
mlir::SPIRVTypeConverter Class Reference

Type conversion from builtin types to SPIR-V types for shader interface. More...

#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"

+ Inheritance diagram for mlir::SPIRVTypeConverter:
+ Collaboration diagram for mlir::SPIRVTypeConverter:

Classes

struct  Options
 

Public Member Functions

 SPIRVTypeConverter (spirv::TargetEnvAttr targetAttr, Options options={})
 
Type getIndexType () const
 Gets the SPIR-V correspondence for the standard index type. More...
 
const OptionsgetOptions () const
 Returns the options controlling the SPIR-V type converter. More...
 
- Public Member Functions inherited from mlir::TypeConverter
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)
 Register a materialization function, which must be convertible to the following form: Optional<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 type 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 type from an illegal, or source, type to a legal type. More...
 
LogicalResult convertType (Type t, SmallVectorImpl< Type > &results)
 Convert the given type. More...
 
Type convertType (Type t)
 This hook simplifies defining 1-1 type conversions. More...
 
LogicalResult convertTypes (TypeRange types, SmallVectorImpl< Type > &results)
 Convert the given set of types, filling 'results' as necessary. More...
 
bool isLegal (Type type)
 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)
 Return true if all of the given types are legal for this type converter. More...
 
bool isLegal (Operation *op)
 Return true if the given operation has legal operand and result types. More...
 
bool isLegal (Region *region)
 Return true if the types of block arguments within the region are legal. More...
 
bool isSignatureLegal (FunctionType ty)
 Return true if the inputs and outputs of the given function type are legal. More...
 
LogicalResult convertSignatureArg (unsigned inputNo, Type type, SignatureConversion &result)
 This method allows for converting a specific argument of a signature. More...
 
LogicalResult convertSignatureArgs (TypeRange types, SignatureConversion &result, unsigned origInputOffset=0)
 
Optional< SignatureConversionconvertBlockSignature (Block *block)
 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)
 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)
 
Value materializeTargetConversion (OpBuilder &builder, Location loc, Type resultType, ValueRange inputs)
 

Static Public Member Functions

static unsigned getMemorySpaceForStorageClass (spirv::StorageClass)
 Returns the corresponding memory space for memref given a SPIR-V storage class. More...
 
static Optional< spirv::StorageClass > getStorageClassForMemorySpace (unsigned space)
 Returns the SPIR-V storage class given a memory space for memref. More...
 

Detailed Description

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 33 of file SPIRVConversion.h.

Constructor & Destructor Documentation

◆ SPIRVTypeConverter()

SPIRVTypeConverter::SPIRVTypeConverter ( spirv::TargetEnvAttr  targetAttr,
Options  options = {} 
)
explicit

Member Function Documentation

◆ getIndexType()

Type SPIRVTypeConverter::getIndexType ( ) const

Gets the SPIR-V correspondence for the standard index type.

Definition at line 116 of file SPIRVConversion.cpp.

References mlir::SPIRVTypeConverter::Options::use64bitIndex.

Referenced by mlir::spirv::getElementPtr(), mlir::SPIRVTypeConverter::Options::Options(), and SPIRVTypeConverter().

◆ getMemorySpaceForStorageClass()

unsigned SPIRVTypeConverter::getMemorySpaceForStorageClass ( spirv::StorageClass  storage)
static

Returns the corresponding memory space for memref given a SPIR-V storage class.

Definition at line 155 of file SPIRVConversion.cpp.

References STORAGE_SPACE_MAP_FN, and STORAGE_SPACE_MAP_LIST.

Referenced by isAllocationSupported(), and mlir::SPIRVTypeConverter::Options::Options().

◆ getOptions()

const SPIRVTypeConverter::Options & SPIRVTypeConverter::getOptions ( ) const

Returns the options controlling the SPIR-V type converter.

Definition at line 179 of file SPIRVConversion.cpp.

References mlir::spirv::TargetEnv::getAttr().

Referenced by mlir::SPIRVTypeConverter::Options::Options().

◆ getStorageClassForMemorySpace()

Optional< spirv::StorageClass > SPIRVTypeConverter::getStorageClassForMemorySpace ( unsigned  space)
static

Returns the SPIR-V storage class given a memory space for memref.

Return llvm::None if the memory space does not map to any SPIR-V storage class.

Definition at line 166 of file SPIRVConversion.cpp.

References STORAGE_SPACE_MAP_FN, and STORAGE_SPACE_MAP_LIST.

Referenced by convertBoolMemrefType(), convertMemrefType(), getAtomicOpScope(), and mlir::SPIRVTypeConverter::Options::Options().


The documentation for this class was generated from the following files: