MLIR
18.0.0git
|
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable component. More...
#include "mlir/IR/Types.h"
Public Types | |
template<typename ConcreteType , typename BaseType , typename StorageType , template< typename T > class... Traits> | |
using | TypeBase = detail::StorageUserBase< ConcreteType, BaseType, StorageType, detail::TypeUniquer, Traits... > |
Utility class for implementing types. More... | |
using | ImplType = TypeStorage |
using | AbstractTy = AbstractType |
Public Member Functions | |
constexpr | Type ()=default |
Type (const ImplType *impl) | |
Type (const Type &other)=default | |
Type & | operator= (const Type &other)=default |
bool | operator== (Type other) const |
bool | operator!= (Type other) const |
operator bool () const | |
bool | operator! () const |
template<typename... Tys> | |
bool | isa () const |
template<typename... Tys> | |
bool | isa_and_nonnull () const |
template<typename U > | |
U | dyn_cast () const |
template<typename U > | |
U | dyn_cast_or_null () const |
template<typename U > | |
U | cast () const |
TypeID | getTypeID () |
Return a unique identifier for the concrete type. More... | |
MLIRContext * | getContext () const |
Return the MLIRContext in which this type was uniqued. More... | |
Dialect & | getDialect () const |
Get the dialect this type is registered to. More... | |
bool | isIndex () const |
bool | isFloat8E5M2 () const |
bool | isFloat8E4M3FN () const |
bool | isFloat8E5M2FNUZ () const |
bool | isFloat8E4M3FNUZ () const |
bool | isFloat8E4M3B11FNUZ () const |
bool | isBF16 () const |
bool | isF16 () const |
bool | isTF32 () const |
bool | isF32 () const |
bool | isF64 () const |
bool | isF80 () const |
bool | isF128 () const |
bool | isInteger (unsigned width) const |
Return true if this is an integer type with the specified width. More... | |
bool | isSignlessInteger () const |
Return true if this is a signless integer type (with the specified width). More... | |
bool | isSignlessInteger (unsigned width) const |
bool | isSignedInteger () const |
Return true if this is a signed integer type (with the specified width). More... | |
bool | isSignedInteger (unsigned width) const |
bool | isUnsignedInteger () const |
Return true if this is an unsigned integer type (with the specified width). More... | |
bool | isUnsignedInteger (unsigned width) const |
unsigned | getIntOrFloatBitWidth () const |
Return the bit width of an integer or a float type, assert failure on other types. More... | |
bool | isSignlessIntOrIndex () const |
Return true if this is a signless integer or index type. More... | |
bool | isSignlessIntOrIndexOrFloat () const |
Return true if this is a signless integer, index, or float type. More... | |
bool | isSignlessIntOrFloat () const |
Return true of this is a signless integer or a float type. More... | |
bool | isIntOrIndex () const |
Return true if this is an integer (of any signedness) or an index type. More... | |
bool | isIntOrFloat () const |
Return true if this is an integer (of any signedness) or a float type. More... | |
bool | isIntOrIndexOrFloat () const |
Return true if this is an integer (of any signedness), index, or float type. More... | |
void | print (raw_ostream &os) const |
Print the current type. More... | |
void | print (raw_ostream &os, AsmState &state) const |
void | dump () const |
const void * | getAsOpaquePointer () const |
Methods for supporting PointerLikeTypeTraits. More... | |
template<typename InterfaceT > | |
bool | hasPromiseOrImplementsInterface () |
Returns true if InterfaceT has been promised by the dialect or implemented. More... | |
template<template< typename T > class Trait> | |
bool | hasTrait () |
Returns true if the type was registered with a particular trait. More... | |
const AbstractTy & | getAbstractType () const |
Return the abstract type descriptor for this type. More... | |
ImplType * | getImpl () const |
Return the Type implementation. More... | |
void | walkImmediateSubElements (function_ref< void(Attribute)> walkAttrsFn, function_ref< void(Type)> walkTypesFn) const |
Walk all of the immediately nested sub-attributes and sub-types. More... | |
auto | replaceImmediateSubElements (ArrayRef< Attribute > replAttrs, ArrayRef< Type > replTypes) const |
Replace the immediately nested sub-attributes and sub-types with those provided. More... | |
template<WalkOrder Order = WalkOrder::PostOrder, typename... WalkFns> | |
auto | walk (WalkFns &&...walkFns) |
Walk this type and all attibutes/types nested within using the provided walk functions. More... | |
template<typename... ReplacementFns> | |
auto | replace (ReplacementFns &&...replacementFns) |
Recursively replace all of the nested sub-attributes and sub-types using the provided map functions. More... | |
Static Public Member Functions | |
static Type | getFromOpaquePointer (const void *pointer) |
Protected Attributes | |
ImplType * | impl {nullptr} |
Friends | |
::llvm::hash_code | hash_value (Type arg) |
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable component.
They wrap a pointer to the storage object owned by MLIRContext. Therefore, instances of Type are passed around by value.
Some types are "primitives" meaning they do not have any parameters, for example the Index type. Parametric types have additional information that differentiates the types of the same class, for example the Integer type has bitwidth, making i8 and i16 belong to the same kind by be different instances of the IntegerType. Type parameters are part of the unique immutable key. The mutable component of the type can be modified after the type is created, but cannot affect the identity of the type.
Types are constructed and uniqued via the 'detail::TypeUniquer' class.
Derived type classes are expected to implement several required implementation hooks:
Type storage objects inherit from TypeStorage and contain the following:
using mlir::Type::AbstractTy = AbstractType |
using mlir::Type::ImplType = TypeStorage |
using mlir::Type::TypeBase = detail::StorageUserBase<ConcreteType, BaseType, StorageType, detail::TypeUniquer, Traits...> |
|
constexprdefault |
Referenced by getFromOpaquePointer().
|
default |
U mlir::Type::cast |
Definition at line 339 of file Types.h.
Referenced by broadcastDynamicDimension(), broadcastDynamicDimensions(), MmaSyncBuilder::buildMmaSync(), castToCompatibleMemRefType(), emitElementwiseComputation(), expandInputRanks(), extendMaskRank(), foreachIndividualVectorElement(), getCuSparseDataTypeFrom(), and mlir::linalg::pack().
void Type::dump | ( | ) | const |
Definition at line 3736 of file AsmPrinter.cpp.
U mlir::Type::dyn_cast |
Definition at line 329 of file Types.h.
Referenced by mlir::LLVM::SplitStores::matchAndRewrite(), mlir::arith::populateEmulateUnsupportedFloatsConversions(), wmmaPushInputOperand(), and wmmaPushOutputOperand().
|
inline |
Return the abstract type descriptor for this type.
Definition at line 199 of file Types.h.
Referenced by mlir::TypeInterface< ConcreteType, Traits >::getInterfaceFor(), hasTrait(), replaceImmediateSubElements(), and walkImmediateSubElements().
|
inline |
Methods for supporting PointerLikeTypeTraits.
Definition at line 176 of file Types.h.
References impl.
Referenced by llvm::PointerLikeTypeTraits< mlir::Type >::getAsVoidPointer().
MLIRContext * Type::getContext | ( | ) | const |
Return the MLIRContext in which this type was uniqued.
Definition at line 35 of file Types.cpp.
Referenced by combineOneSpec(), mlir::TypeConverter::convertType(), mlir::quant::fakeQuantAttrsToType(), mlir::gpu::MMAMatrixType::get(), mlir::spirv::MatrixType::get(), mlir::spirv::RuntimeArrayType::get(), mlir::spirv::CooperativeMatrixNVType::get(), mlir::spirv::JointMatrixINTELType::get(), mlir::spirv::CooperativeMatrixType::get(), mlir::spirv::ArrayType::get(), mlir::quant::CalibratedQuantizedType::get(), mlir::spirv::SampledImageType::get(), mlir::DataLayoutEntryAttr::get(), mlir::spirv::PointerType::get(), mlir::quant::UniformQuantizedPerAxisType::get(), mlir::quant::UniformQuantizedType::get(), mlir::quant::AnyQuantizedType::get(), mlir::sparse_tensor::get1DMemRefType(), mlir::gpu::MMAMatrixType::getChecked(), mlir::spirv::MatrixType::getChecked(), mlir::quant::CalibratedQuantizedType::getChecked(), mlir::spirv::SampledImageType::getChecked(), mlir::quant::UniformQuantizedPerAxisType::getChecked(), mlir::quant::UniformQuantizedType::getChecked(), mlir::quant::AnyQuantizedType::getChecked(), mlir::Value::getContext(), mlir::detail::getDefaultABIAlignment(), mlir::detail::getDefaultPreferredAlignment(), mlir::detail::getDefaultTypeSizeInBits(), getFirstSubelementType(), getGetValueTypeOpValueType(), getI1SameShape(), mlir::bufferization::getMemRefTypeWithFullyDynamicLayout(), getPointerType(), getRegisterIndexToTileOffsetMap(), mlir::memref::getTensorTypeFromMemRefType(), mlir::spirv::getUnaryOpResultType(), getValAndBoolStructType(), inferIntrinsicResultType(), mlir::LLVM::isCompatibleType(), isSupportedElementType(), mlir::spirv::MemorySpaceToStorageClassConverter::MemorySpaceToStorageClassConverter(), mlir::arith::NarrowTypeEmulationConverter::NarrowTypeEmulationConverter(), mlir::UnrankedMemRefDescriptor::sizeBasePtr(), and mlir::arith::WideIntEmulationConverter::WideIntEmulationConverter().
|
inline |
Get the dialect this type is registered to.
Definition at line 118 of file Types.h.
Referenced by mlir::pdl::PDLType::classof(), mlir::quant::QuantizedType::classof(), mlir::spirv::SPIRVType::classof(), combineOneSpec(), mlir::TypeInterface< ConcreteType, Traits >::getInterfaceFor(), hasPromiseOrImplementsInterface(), mlir::TensorType::isValidElementType(), and parseAndVerifyType().
|
inlinestatic |
Definition at line 179 of file Types.h.
References Type().
Referenced by mlir::DiagnosticArgument::getAsType(), and llvm::PointerLikeTypeTraits< mlir::Type >::getFromVoidPointer().
|
inline |
unsigned Type::getIntOrFloatBitWidth | ( | ) | const |
Return the bit width of an integer or a float type, assert failure on other types.
Definition at line 123 of file Types.cpp.
Referenced by areSameBitwidthScalarType(), buildAttributeAPInt(), castF32To(), castToF32(), convertScalarToComplexDtype(), createCtlzFunc(), createElementIPowIFunc(), declareReduction(), deduceCanonicalResource(), findEntryForIntegerType(), mlir::sparse_tensor::genIndexLoad(), getBitWidth(), mlir::spirv::getBitWidth(), mlir::spirv::ScalarType::getCapabilities(), mlir::detail::getDefaultTypeSizeInBits(), mlir::detail::getDenseElementBitWidth(), mlir::spirv::ScalarType::getExtensions(), mlir::Builder::getIntegerAttr(), mlir::nvgpu::getLaneIdAndValueIdToOperandCoord(), mlir::nvgpu::getLdMatrixParams(), getNumBits(), getRegisterIndexToTileOffsetMap(), getScalarOrElementWidth(), mlir::spirv::ScalarType::getSizeInBytes(), mlir::arm_sme::getSMETileSliceMinNumElts(), getTileShape(), getTypeNumBytes(), mlir::nvgpu::inferTileWidthInBits(), mlir::GPUPrintfOpToHIPLowering::matchAndRewrite(), mlir::detail::Parser::parseDenseArrayAttr(), parseSwitchOpCases(), resultsInSupportedAsyncCopy(), shiftValue(), and truncToI32().
|
inline |
Return a unique identifier for the concrete type.
This is used to support dynamic type casting.
Definition at line 112 of file Types.h.
Referenced by mlir::TypeInterface< ConcreteType, Traits >::getInterfaceFor(), mlir::DataLayout::getTypeABIAlignment(), mlir::DataLayout::getTypePreferredAlignment(), mlir::DataLayout::getTypeSize(), mlir::DataLayout::getTypeSizeInBits(), hasPromiseOrImplementsInterface(), and mlir::DynamicType::isa().
|
inline |
Returns true if InterfaceT
has been promised by the dialect or implemented.
Definition at line 186 of file Types.h.
References getDialect(), getTypeID(), and mlir::dialect_extension_detail::hasPromisedInterface().
|
inline |
Returns true if the type was registered with a particular trait.
Definition at line 194 of file Types.h.
References getAbstractType(), and mlir::AbstractType::hasTrait().
Referenced by mlir::DynamicType::classof().
bool mlir::Type::isa |
Definition at line 319 of file Types.h.
Referenced by createMemcpy(), and isMemref().
bool mlir::Type::isa_and_nonnull |
Definition at line 324 of file Types.h.
Referenced by destructureIndices().
bool Type::isBF16 | ( | ) | const |
Definition at line 48 of file Types.cpp.
Referenced by fltSemanticsForType(), getCuSparseDataTypeFrom(), isAllowedSizeN(), isAllowedWGMMADataType(), mlir::spirv::ScalarType::isValid(), mlir::arm_sme::isValidSMETileElementType(), mfmaOpToIntrinsic(), parseAndVerifyType(), and mlir::sparse_tensor::primaryTypeEncoding().
bool Type::isF128 | ( | ) | const |
Definition at line 54 of file Types.cpp.
Referenced by fltSemanticsForType(), and mlir::arm_sme::isValidSMETileElementType().
bool Type::isF16 | ( | ) | const |
Definition at line 49 of file Types.cpp.
Referenced by floatCst(), fltSemanticsForType(), getCuSparseDataTypeFrom(), getCuSparseLtDataTypeFrom(), mlir::nvgpu::getMmaSyncRegisterType(), isAllowedSizeN(), isAllowedWGMMADataType(), mlir::gpu::MMAMatrixType::isValidElementType(), mlir::arm_sme::isValidSMETileElementType(), mfmaOpToIntrinsic(), and mlir::sparse_tensor::primaryTypeEncoding().
bool Type::isF32 | ( | ) | const |
Definition at line 51 of file Types.cpp.
Referenced by castF32To(), castToF32(), convertFloatAttr(), floatCst(), fltSemanticsForType(), getCuSparseDataTypeFrom(), mlir::nvgpu::getMmaSyncRegisterType(), isAllowedWGMMADataType(), mlir::gpu::MMAMatrixType::isValidElementType(), mlir::arm_sme::isValidSMETileElementType(), mfmaOpToIntrinsic(), and mlir::sparse_tensor::primaryTypeEncoding().
bool Type::isF64 | ( | ) | const |
Definition at line 52 of file Types.cpp.
Referenced by fltSemanticsForType(), getCuSparseDataTypeFrom(), mlir::nvgpu::getMmaSyncRegisterType(), mlir::arm_sme::isValidSMETileElementType(), mfmaOpToIntrinsic(), and mlir::sparse_tensor::primaryTypeEncoding().
bool Type::isF80 | ( | ) | const |
Definition at line 53 of file Types.cpp.
Referenced by fltSemanticsForType().
bool Type::isFloat8E4M3FN | ( | ) | const |
Definition at line 38 of file Types.cpp.
Referenced by isAllowedSizeN(), and isAllowedWGMMADataType().
bool Type::isFloat8E4M3FNUZ | ( | ) | const |
Definition at line 42 of file Types.cpp.
Referenced by mfmaOpToIntrinsic().
bool Type::isFloat8E5M2 | ( | ) | const |
Definition at line 37 of file Types.cpp.
Referenced by isAllowedSizeN(), and isAllowedWGMMADataType().
bool Type::isFloat8E5M2FNUZ | ( | ) | const |
Definition at line 39 of file Types.cpp.
Referenced by mfmaOpToIntrinsic().
bool Type::isIndex | ( | ) | const |
Definition at line 56 of file Types.cpp.
Referenced by areIndexCastCompatible(), assertValidValueDim(), buildAttributeAPInt(), ceilDivPositive(), mlir::ValueBoundsConstraintSet::computeBound(), convertScalarToIntDtype(), mlir::detail::getDenseElementBitWidth(), mlir::Builder::getIntegerAttr(), mlir::ConstantIntRanges::getStorageBitwidth(), mlir::getValueOrCreateCastToIndexLike(), getZero(), inferIndexCast(), isMatchingWidth(), mlir::affine::isValidDim(), isValidIntOrFloat(), mlir::affine::isValidSymbol(), mlir::affine::materializeComputedBound(), mlir::sparse_tensor::overheadTypeEncoding(), and reifyValueBound().
bool Type::isInteger | ( | unsigned | width | ) | const |
Return true if this is an integer type with the specified width.
Definition at line 59 of file Types.cpp.
Referenced by castBoolToIntN(), castIntNToBool(), castToSourceType(), mlir::DenseElementsAttr::get(), getConstantUint32(), getCuSparseDataTypeFrom(), getCuSparseIndexTypeFrom(), getCuSparseLtDataTypeFrom(), mlir::nvgpu::getMmaSyncRegisterType(), getScalarOrVectorI32Constant(), isAllowedSizeN(), isAllowedWGMMADataType(), isBoolScalarOrVector(), isMatchingWidth(), mlir::DenseElementsAttr::isValidBool(), mlir::gpu::MMAMatrixType::isValidElementType(), mlir::arm_sme::isValidSMETileElementType(), mfmaOpToIntrinsic(), mlir::detail::Parser::parseDenseArrayAttr(), and mlir::sparse_tensor::primaryTypeEncoding().
bool Type::isIntOrFloat | ( | ) | const |
Return true if this is an integer (of any signedness) or a float type.
Definition at line 117 of file Types.cpp.
Referenced by areSameBitwidthScalarType(), getBitWidth(), mlir::spirv::getBitWidth(), getScalarOrElementWidth(), isAllocationSupported(), mlir::spirv::SPIRVType::isScalarOrVector(), mlir::GPUPrintfOpToVPrintfLowering::matchAndRewrite(), and ConvertAccessChain::matchAndRewrite().
bool Type::isIntOrIndex | ( | ) | const |
Return true if this is an integer (of any signedness) or an index type.
Definition at line 113 of file Types.cpp.
Referenced by mlir::sparse_tensor::genIsNonzero(), isSupportedCombiningKind(), and mlir::detail::Parser::parseDenseArrayAttr().
bool Type::isIntOrIndexOrFloat | ( | ) | const |
Return true if this is an integer (of any signedness), index, or float type.
Definition at line 121 of file Types.cpp.
Referenced by mlir::DenseElementsAttr::get(), getZero(), mlir::vector::isBroadcastableTo(), isSupportedCombiningKind(), isSupportedSourceType(), mlir::BaseMemRefType::isValidElementType(), mlir::detail::Parser::parseDenseArrayAttr(), and verifyRegionAttribute().
bool Type::isSignedInteger | ( | ) | const |
Return true if this is a signed integer type (with the specified width).
Definition at line 77 of file Types.cpp.
Referenced by buildAttributeAPInt(), castToSourceType(), mlir::Builder::getIntegerAttr(), isSignedIntegerOrVector(), and mlir::gpu::MMAMatrixType::isValidElementType().
bool Type::isSignlessInteger | ( | ) | const |
Return true if this is a signless integer type (with the specified width).
Definition at line 65 of file Types.cpp.
Referenced by areIndexCastCompatible(), and mlir::arith::ConstantIntOp::build().
bool Type::isSignlessIntOrFloat | ( | ) | const |
bool Type::isSignlessIntOrIndex | ( | ) | const |
bool Type::isSignlessIntOrIndexOrFloat | ( | ) | const |
Return true if this is a signless integer, index, or float type.
Definition at line 105 of file Types.cpp.
Referenced by appendMangledType().
bool Type::isTF32 | ( | ) | const |
Definition at line 50 of file Types.cpp.
Referenced by isAllowedSizeN(), and isAllowedWGMMADataType().
bool Type::isUnsignedInteger | ( | ) | const |
Return true if this is an unsigned integer type (with the specified width).
Definition at line 89 of file Types.cpp.
Referenced by isUnsignedIntegerOrVector(), mlir::gpu::MMAMatrixType::isValidElementType(), and mlir::detail::Parser::parseDecOrHexAttr().
|
inlineexplicit |
|
inline |
|
inline |
void Type::print | ( | raw_ostream & | os | ) | const |
Print the current type.
Definition at line 3723 of file AsmPrinter.cpp.
Referenced by createCtlzFunc(), and mlir::operator<<().
void Type::print | ( | raw_ostream & | os, |
AsmState & | state | ||
) | const |
Definition at line 3732 of file AsmPrinter.cpp.
|
inline |
Recursively replace all of the nested sub-attributes and sub-types using the provided map functions.
Returns nullptr in the case of failure. See AttrTypeReplacer
for information on the support replacement function types.
Definition at line 238 of file Types.h.
References mlir::AttrTypeReplacer::addReplacement(), and mlir::AttrTypeReplacer::replace().
|
inline |
Replace the immediately nested sub-attributes and sub-types with those provided.
The order of the provided elements is derived from the order of the elements returned by the callbacks of walkImmediateSubElements
. The element at index 0 would replace the very first attribute given by walkImmediateSubElements
. On success, the new instance with the values replaced is returned. If replacement fails, nullptr is returned.
Definition at line 217 of file Types.h.
References getAbstractType(), and mlir::AbstractType::replaceImmediateSubElements().
|
inline |
Walk this type and all attibutes/types nested within using the provided walk functions.
See AttrTypeWalker
for information on the supported walk function types.
Definition at line 227 of file Types.h.
References mlir::AttrTypeWalker::addWalk(), and mlir::AttrTypeWalker::walk().
|
inline |
Walk all of the immediately nested sub-attributes and sub-types.
This method does not recurse into sub elements.
Definition at line 206 of file Types.h.
References getAbstractType(), and mlir::AbstractType::walkImmediateSubElements().
|
protected |
Definition at line 246 of file Types.h.
Referenced by getAsOpaquePointer(), getImpl(), operator bool(), and operator==().