17 #include "llvm/ADT/STLExtras.h" 18 #include "llvm/ADT/TypeSwitch.h" 28 using KeyTy = std::tuple<Type, unsigned, unsigned>;
36 return key ==
KeyTy(elementType, elementCount, stride);
40 : elementType(std::get<0>(key)), elementCount(std::get<1>(key)),
41 stride(std::get<2>(key)) {}
49 assert(elementCount &&
"ArrayType needs at least one element");
50 return Base::get(elementType.
getContext(), elementType, elementCount,
56 assert(elementCount &&
"ArrayType needs at least one element");
57 return Base::get(elementType.
getContext(), elementType, elementCount, stride);
98 switch (type.getNumElements()) {
108 return type.getRank() == 1 && type.getElementType().isa<
ScalarType>();
114 [](
auto type) {
return type.getElementType(); })
119 [](
Type) ->
Type { llvm_unreachable(
"invalid composite type"); });
123 if (
auto arrayType = dyn_cast<ArrayType>())
124 return arrayType.getNumElements();
125 if (
auto matrixType = dyn_cast<MatrixType>())
126 return matrixType.getNumColumns();
127 if (
auto structType = dyn_cast<StructType>())
128 return structType.getNumElements();
131 if (isa<CooperativeMatrixNVType>()) {
133 "invalid to query number of elements of spirv::CooperativeMatrix type");
135 if (isa<RuntimeArrayType>()) {
137 "invalid to query number of elements of spirv::RuntimeArray type");
139 llvm_unreachable(
"invalid composite type");
143 return !isa<CooperativeMatrixNVType, RuntimeArrayType>();
152 [&](
auto type) { type.getExtensions(extensions, storage); })
153 .Case<VectorType>([&](VectorType type) {
154 return type.getElementType().cast<
ScalarType>().getExtensions(
155 extensions, storage);
157 .Default([](
Type) { llvm_unreachable(
"invalid composite type"); });
166 [&](
auto type) { type.getCapabilities(capabilities, storage); })
167 .Case<VectorType>([&](VectorType type) {
169 if (vecSize == 8 || vecSize == 16) {
170 static const Capability caps[] = {Capability::Vector16};
172 capabilities.push_back(ref);
174 return type.getElementType().cast<
ScalarType>().getCapabilities(
175 capabilities, storage);
177 .Default([](
Type) { llvm_unreachable(
"invalid composite type"); });
181 if (
auto arrayType = dyn_cast<ArrayType>())
182 return arrayType.getSizeInBytes();
183 if (
auto structType = dyn_cast<StructType>())
184 return structType.getSizeInBytes();
185 if (
auto vectorType = dyn_cast<VectorType>()) {
190 return *elementSize *
vectorType.getNumElements();
200 using KeyTy = std::tuple<Type, Scope, unsigned, unsigned>;
209 return key ==
KeyTy(elementType, scope, rows, columns);
213 : elementType(std::get<0>(key)), rows(std::get<2>(key)),
214 columns(std::get<3>(key)), scope(std::get<1>(key)) {}
223 Scope scope,
unsigned rows,
225 return Base::get(elementType.
getContext(), elementType, scope, rows, columns);
229 return getImpl()->elementType;
237 return getImpl()->columns;
244 static const Extension exts[] = {Extension::SPV_NV_cooperative_matrix};
246 extensions.push_back(ref);
253 static const Capability caps[] = {Capability::CooperativeMatrixNV};
255 capabilities.push_back(ref);
262 template <
typename T>
static constexpr
unsigned getNumBits() {
return 0; }
264 static_assert((1 << 3) > getMaxEnumValForDim(),
265 "Not enough bits to encode Dim value");
269 static_assert((1 << 2) > getMaxEnumValForImageDepthInfo(),
270 "Not enough bits to encode ImageDepthInfo value");
274 static_assert((1 << 1) > getMaxEnumValForImageArrayedInfo(),
275 "Not enough bits to encode ImageArrayedInfo value");
279 static_assert((1 << 1) > getMaxEnumValForImageSamplingInfo(),
280 "Not enough bits to encode ImageSamplingInfo value");
284 static_assert((1 << 2) > getMaxEnumValForImageSamplerUseInfo(),
285 "Not enough bits to encode ImageSamplerUseInfo value");
289 static_assert((1 << 6) > getMaxEnumValForImageFormat(),
290 "Not enough bits to encode ImageFormat value");
296 using KeyTy = std::tuple<
Type,
Dim, ImageDepthInfo, ImageArrayedInfo,
297 ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>;
305 return key ==
KeyTy(elementType, dim, depthInfo, arrayedInfo, samplingInfo,
306 samplerUseInfo, format);
310 : elementType(std::get<0>(key)), dim(std::get<1>(key)),
311 depthInfo(std::get<2>(key)), arrayedInfo(std::get<3>(key)),
312 samplingInfo(std::get<4>(key)), samplerUseInfo(std::get<5>(key)),
313 format(std::get<6>(key)) {}
326 ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>
328 return Base::get(std::get<0>(
value).getContext(),
value);
338 return getImpl()->arrayedInfo;
342 return getImpl()->samplingInfo;
346 return getImpl()->samplerUseInfo;
358 if (
auto dimCaps = spirv::getCapabilities(getDim()))
359 capabilities.push_back(*dimCaps);
361 if (
auto fmtCaps = spirv::getCapabilities(getImageFormat()))
362 capabilities.push_back(*fmtCaps);
372 using KeyTy = std::pair<Type, StorageClass>;
381 return key ==
KeyTy(pointeeType, storageClass);
385 : pointeeType(key.first), storageClass(key.second) {}
392 return Base::get(pointeeType.
getContext(), pointeeType, storageClass);
398 return getImpl()->storageClass;
405 getPointeeType().cast<
SPIRVType>().getExtensions(extensions,
408 if (
auto scExts = spirv::getExtensions(getStorageClass()))
409 extensions.push_back(*scExts);
417 getPointeeType().cast<
SPIRVType>().getCapabilities(capabilities,
420 if (
auto scCaps = spirv::getCapabilities(getStorageClass()))
421 capabilities.push_back(*scCaps);
429 using KeyTy = std::pair<Type, unsigned>;
438 return key ==
KeyTy(elementType, stride);
442 : elementType(key.first), stride(key.second) {}
449 return Base::get(elementType.
getContext(), elementType, 0);
453 return Base::get(elementType.
getContext(), elementType, stride);
470 static const Capability caps[] = {Capability::Shader};
472 capabilities.push_back(ref);
483 return isValid(floatType);
485 if (
auto intType = type.
dyn_cast<IntegerType>()) {
486 return isValid(intType);
494 switch (type.getWidth()) {
515 case StorageClass::PushConstant:
516 case StorageClass::StorageBuffer:
517 case StorageClass::Uniform:
518 if (getIntOrFloatBitWidth() == 8) {
519 static const Extension exts[] = {Extension::SPV_KHR_8bit_storage};
521 extensions.push_back(ref);
524 case StorageClass::Input:
525 case StorageClass::Output:
526 if (getIntOrFloatBitWidth() == 16) {
527 static const Extension exts[] = {Extension::SPV_KHR_16bit_storage};
529 extensions.push_back(ref);
540 unsigned bitwidth = getIntOrFloatBitWidth();
546 #define STORAGE_CASE(storage, cap8, cap16) \ 547 case StorageClass::storage: { \ 548 if (bitwidth == 8) { \ 549 static const Capability caps[] = {Capability::cap8}; \ 550 ArrayRef<Capability> ref(caps, llvm::array_lengthof(caps)); \ 551 capabilities.push_back(ref); \ 554 if (bitwidth == 16) { \ 555 static const Capability caps[] = {Capability::cap16}; \ 556 ArrayRef<Capability> ref(caps, llvm::array_lengthof(caps)); \ 557 capabilities.push_back(ref); \ 568 STORAGE_CASE(PushConstant, StoragePushConstant8, StoragePushConstant16);
570 StorageBuffer16BitAccess);
571 STORAGE_CASE(Uniform, UniformAndStorageBuffer8BitAccess,
573 case StorageClass::Input:
574 case StorageClass::Output: {
575 if (bitwidth == 16) {
576 static const Capability caps[] = {Capability::StorageInputOutput16};
578 capabilities.push_back(ref);
592 #define WIDTH_CASE(type, width) \ 594 static const Capability caps[] = {Capability::type##width}; \ 595 ArrayRef<Capability> ref(caps, llvm::array_lengthof(caps)); \ 596 capabilities.push_back(ref); \ 599 if (
auto intType = dyn_cast<IntegerType>()) {
608 llvm_unreachable(
"invalid bitwidth to getCapabilities");
611 assert(isa<FloatType>());
618 llvm_unreachable(
"invalid bitwidth to getCapabilities");
626 auto bitWidth = getIntOrFloatBitWidth();
644 if (llvm::isa<SPIRVDialect>(type.
getDialect()))
654 return isIntOrFloat() || isa<VectorType>();
659 if (
auto scalarType = dyn_cast<ScalarType>()) {
660 scalarType.getExtensions(extensions, storage);
661 }
else if (
auto compositeType = dyn_cast<CompositeType>()) {
662 compositeType.getExtensions(extensions, storage);
663 }
else if (
auto imageType = dyn_cast<ImageType>()) {
664 imageType.getExtensions(extensions, storage);
665 }
else if (
auto sampledImageType = dyn_cast<SampledImageType>()) {
666 sampledImageType.getExtensions(extensions, storage);
667 }
else if (
auto matrixType = dyn_cast<MatrixType>()) {
668 matrixType.getExtensions(extensions, storage);
669 }
else if (
auto ptrType = dyn_cast<PointerType>()) {
670 ptrType.getExtensions(extensions, storage);
672 llvm_unreachable(
"invalid SPIR-V Type to getExtensions");
679 if (
auto scalarType = dyn_cast<ScalarType>()) {
680 scalarType.getCapabilities(capabilities, storage);
681 }
else if (
auto compositeType = dyn_cast<CompositeType>()) {
682 compositeType.getCapabilities(capabilities, storage);
683 }
else if (
auto imageType = dyn_cast<ImageType>()) {
684 imageType.getCapabilities(capabilities, storage);
685 }
else if (
auto sampledImageType = dyn_cast<SampledImageType>()) {
686 sampledImageType.getCapabilities(capabilities, storage);
687 }
else if (
auto matrixType = dyn_cast<MatrixType>()) {
688 matrixType.getCapabilities(capabilities, storage);
689 }
else if (
auto ptrType = dyn_cast<PointerType>()) {
690 ptrType.getCapabilities(capabilities, storage);
692 llvm_unreachable(
"invalid SPIR-V Type to getCapabilities");
697 if (
auto scalarType = dyn_cast<ScalarType>())
698 return scalarType.getSizeInBytes();
699 if (
auto compositeType = dyn_cast<CompositeType>())
700 return compositeType.getSizeInBytes();
724 return Base::get(imageType.
getContext(), imageType);
739 return emitError() <<
"expected image type";
747 getImageType().cast<
ImageType>().getExtensions(extensions, storage);
753 getImageType().cast<
ImageType>().getCapabilities(capabilities, storage);
779 : memberTypesAndIsBodySet(nullptr, false), offsetInfo(nullptr),
780 numMembers(0), numMemberDecorations(0), memberDecorationsInfo(nullptr),
781 identifier(identifier) {}
786 unsigned numMembers,
Type const *memberTypes,
789 : memberTypesAndIsBodySet(memberTypes, false), offsetInfo(layoutInfo),
790 numMembers(numMembers), numMemberDecorations(numMemberDecorations),
791 memberDecorationsInfo(memberDecorationsInfo), identifier(StringRef()) {}
817 if (isIdentified()) {
819 return getIdentifier() == std::get<0>(key);
822 return key ==
KeyTy(StringRef(), getMemberTypes(), getOffsetInfo(),
823 getMemberDecorationsInfo());
834 StringRef keyIdentifier = std::get<0>(key);
836 if (!keyIdentifier.empty()) {
837 StringRef identifier = allocator.
copyInto(keyIdentifier);
848 const Type *typesList =
nullptr;
849 if (!keyTypes.empty()) {
850 typesList = allocator.
copyInto(keyTypes).data();
854 if (!std::get<2>(key).empty()) {
855 ArrayRef<StructType::OffsetInfo> keyOffsetInfo = std::get<2>(key);
856 assert(keyOffsetInfo.size() == keyTypes.size() &&
857 "size of offset information must be same as the size of number of " 859 offsetInfoList = allocator.
copyInto(keyOffsetInfo).data();
863 unsigned numMemberDecorations = 0;
864 if (!std::get<3>(key).empty()) {
865 auto keyMemberDecorations = std::get<3>(key);
866 numMemberDecorations = keyMemberDecorations.size();
867 memberDecorationList = allocator.
copyInto(keyMemberDecorations).data();
872 numMemberDecorations, memberDecorationList);
876 return ArrayRef<Type>(memberTypesAndIsBodySet.getPointer(), numMembers);
881 return ArrayRef<StructType::OffsetInfo>(offsetInfo, numMembers);
887 if (memberDecorationsInfo) {
889 numMemberDecorations);
908 ArrayRef<StructType::OffsetInfo> structOffsetInfo,
913 if (memberTypesAndIsBodySet.getInt() &&
914 (getMemberTypes() != structMemberTypes ||
915 getOffsetInfo() != structOffsetInfo ||
916 getMemberDecorationsInfo() != structMemberDecorationInfo))
919 memberTypesAndIsBodySet.setInt(
true);
920 numMembers = structMemberTypes.size();
923 if (!structMemberTypes.empty())
924 memberTypesAndIsBodySet.setPointer(
925 allocator.
copyInto(structMemberTypes).data());
927 if (!structOffsetInfo.empty()) {
928 assert(structOffsetInfo.size() == structMemberTypes.size() &&
929 "size of offset information must be same as the size of number of " 931 offsetInfo = allocator.
copyInto(structOffsetInfo).data();
934 if (!structMemberDecorationInfo.empty()) {
935 numMemberDecorations = structMemberDecorationInfo.size();
936 memberDecorationsInfo =
937 allocator.
copyInto(structMemberDecorationInfo).data();
955 assert(!memberTypes.empty() &&
"Struct needs at least one member type");
958 memberDecorations.begin(), memberDecorations.end());
959 llvm::array_pod_sort(sortedDecorations.begin(), sortedDecorations.end());
960 return Base::get(memberTypes.vec().front().getContext(),
961 StringRef(), memberTypes, offsetInfo,
966 StringRef identifier) {
967 assert(!identifier.empty() &&
968 "StructType identifier must be non-empty string");
986 return newStructType;
997 return getImpl()->memberTypesAndIsBodySet.getPointer()[index];
1009 return getImpl()->offsetInfo[index];
1015 memberDecorations.clear();
1016 auto implMemberDecorations = getImpl()->getMemberDecorationsInfo();
1017 memberDecorations.append(implMemberDecorations.begin(),
1018 implMemberDecorations.end());
1025 auto memberDecorations = getImpl()->getMemberDecorationsInfo();
1026 decorationsInfo.clear();
1027 for (
const auto &memberDecoration : memberDecorations) {
1028 if (memberDecoration.memberIndex == index) {
1029 decorationsInfo.push_back(memberDecoration);
1031 if (memberDecoration.memberIndex > index) {
1042 return Base::mutate(memberTypes, offsetInfo, memberDecorations);
1047 for (
Type elementType : getElementTypes())
1048 elementType.cast<
SPIRVType>().getExtensions(extensions, storage);
1054 for (
Type elementType : getElementTypes())
1055 elementType.cast<
SPIRVType>().getCapabilities(capabilities, storage);
1060 return llvm::hash_combine(memberDecorationInfo.
memberIndex,
1070 :
TypeStorage(), columnType(columnType), columnCount(columnCount) {}
1072 using KeyTy = std::tuple<Type, uint32_t>;
1083 return key ==
KeyTy(columnType, columnCount);
1091 return Base::get(columnType.
getContext(), columnType, columnCount);
1095 Type columnType, uint32_t columnCount) {
1101 Type columnType, uint32_t columnCount) {
1102 if (columnCount < 2 || columnCount > 4)
1103 return emitError() <<
"matrix can have 2, 3, or 4 columns only";
1105 if (!isValidColumnType(columnType))
1106 return emitError() <<
"matrix columns must be vectors of floats";
1110 if (columnShape.size() != 1)
1111 return emitError() <<
"matrix columns must be 1D vectors";
1113 if (columnShape[0] < 2 || columnShape[0] > 4)
1114 return emitError() <<
"matrix columns must be of size 2, 3, or 4";
1137 return getImpl()->columnType.cast<VectorType>().
getShape()[0];
1141 return (getImpl()->columnCount) * getNumRows();
1146 getColumnType().cast<
SPIRVType>().getExtensions(extensions, storage);
1153 static const Capability caps[] = {Capability::Matrix};
1155 capabilities.push_back(ref);
1158 getColumnType().cast<
SPIRVType>().getCapabilities(capabilities, storage);
1165 void SPIRVDialect::registerTypes() {
PointerTypeStorage(const KeyTy &key)
constexpr unsigned getNumBits< ImageDepthInfo >()
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
Dialect & getDialect() const
Get the dialect this type is registered to.
unsigned numMemberDecorations
ImageFormat getImageFormat() const
static MatrixTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
unsigned getArrayStride() const
Returns the array stride in bytes.
unsigned getNumElements() const
Return the number of elements of the type.
Type getPointeeType() const
This class represents a diagnostic that is inflight and set to be reported.
RuntimeArrayTypeStorage(const KeyTy &key)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
Base storage class appearing in a Type.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value...
This is a utility allocator used to allocate memory for instances of derived types.
unsigned getNumElements() const
static bool classof(Type type)
std::pair< Type, StorageClass > KeyTy
ArrayTypeStorage(const KeyTy &key)
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity...
LogicalResult mutate(TypeStorageAllocator &allocator, ArrayRef< Type > structMemberTypes, ArrayRef< StructType::OffsetInfo > structOffsetInfo, ArrayRef< StructType::MemberDecorationInfo > structMemberDecorationInfo)
Sets the struct type content for identified structs.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
bool operator==(const KeyTy &key) const
bool isIdentified() const
Returns true if the StructType is identified.
LogicalResult trySetBody(ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={})
Sets the contents of an incomplete identified StructType.
static RuntimeArrayType get(Type elementType)
Type getElementType() const
StructTypeStorage(unsigned numMembers, Type const *memberTypes, StructType::OffsetInfo const *layoutInfo, unsigned numMemberDecorations, StructType::MemberDecorationInfo const *memberDecorationsInfo)
Construct a storage object for a literal struct type.
static StructTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
If the given key contains a non-empty identifier, this method constructs an identified struct and lea...
static ArrayRef< int64_t > getShape(Type type)
Returns the shape of the given type.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
std::tuple< Type, uint32_t > KeyTy
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
static bool isValid(FloatType)
Returns true if the given integer type is valid for the SPIR-V dialect.
Type getElementType() const
ImageArrayedInfo arrayedInfo
static constexpr const bool value
const uint32_t columnCount
Type getElementType(unsigned) const
bool operator==(const KeyTy &key) const
ArrayRef< StructType::OffsetInfo > getOffsetInfo() const
static bool isValidColumnType(Type columnType)
Returns true if the matrix elements are vectors of float elements.
constexpr unsigned getNumBits< ImageArrayedInfo >()
ImageSamplingInfo samplingInfo
static StructType get(ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={})
Construct a literal StructType with at least one member.
static LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Type imageType)
bool operator==(const KeyTy &key) const
T * allocate()
Allocate an instance of the provided type.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
ImageArrayedInfo getArrayedInfo() const
Optional< int64_t > getSizeInBytes()
static SampledImageType get(Type imageType)
This class represents an efficient way to signal success or failure.
Range class for element types.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
bool isIdentified() const
Optional< int64_t > getSizeInBytes()
Returns the array size in bytes.
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< spirv::StorageClass > storage=llvm::None)
bool operator==(const KeyTy &key) const
StorageClass storageClass
static CooperativeMatrixNVType get(Type elementType, Scope scope, unsigned rows, unsigned columns)
static PointerTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
static ArrayType get(Type elementType, unsigned elementCount)
bool operator==(const KeyTy &key) const
StringRef getIdentifier() const
static MatrixType getChecked(function_ref< InFlightDiagnostic()> emitError, Type columnType, uint32_t columnCount)
std::tuple< StringRef, ArrayRef< Type >, ArrayRef< StructType::OffsetInfo >, ArrayRef< StructType::MemberDecorationInfo > > KeyTy
A storage key is divided into 2 parts:
static LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, Type columnType, uint32_t columnCount)
#define WIDTH_CASE(type, width)
ImageSamplerUseInfo getSamplerUseInfo() const
Type getElementType() const
Type getElementType() const
Returns the elements' type (i.e, single element type).
StructType::MemberDecorationInfo const * memberDecorationsInfo
static llvm::Value * getSizeInBytes(llvm::IRBuilderBase &builder, llvm::Value *basePtr)
Computes the size of type in bytes.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< spirv::StorageClass > storage=llvm::None)
static RuntimeArrayTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
StructTypeStorage(StringRef identifier)
Construct a storage object for an identified struct type.
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
ImageDepthInfo getDepthInfo() const
unsigned getNumElements() const
Returns total number of elements (rows*columns).
StringRef getIdentifier() const
For literal structs, return an empty string.
ArrayRef< Type > getMemberTypes() const
bool hasCompileTimeKnownNumElements() const
Return true if the number of elements is known at compile time and is not implementation dependent...
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
std::tuple< Type, unsigned, unsigned > KeyTy
std::tuple< Type, Dim, ImageDepthInfo, ImageArrayedInfo, ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat > KeyTy
ImageTypeStorage(const KeyTy &key)
uint64_t getMemberOffset(unsigned) const
static StructType getEmpty(MLIRContext *context, StringRef identifier="")
Construct a (possibly identified) StructType with no members.
std::pair< Type, unsigned > KeyTy
static ArrayTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
Optional< int64_t > getSizeInBytes()
llvm::PointerIntPair< Type const *, 1, bool > memberTypesAndIsBodySet
constexpr unsigned getNumBits< ImageSamplingInfo >()
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
static SampledImageTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
static PointerType get(Type pointeeType, StorageClass storageClass)
#define STORAGE_CASE(storage, cap8, cap16)
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
ImageSamplerUseInfo samplerUseInfo
constexpr unsigned getNumBits< ImageSamplerUseInfo >()
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
unsigned getNumElements() const
ElementTypeRange getElementTypes() const
std::tuple< Type, Scope, unsigned, unsigned > KeyTy
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
Type getElementType(unsigned) const
static bool classof(Type type)
unsigned getArrayStride() const
Returns the array stride in bytes.
Dim
Dimension level type for a tensor (undef means index does not appear).
CooperativeMatrixTypeStorage(const KeyTy &key)
static ImageTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
unsigned getRows() const
return the number of rows of the matrix.
static int64_t getNumElements(ShapedType type)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
static ImageType get(Type elementType, Dim dim, ImageDepthInfo depth=ImageDepthInfo::DepthUnknown, ImageArrayedInfo arrayed=ImageArrayedInfo::NonArrayed, ImageSamplingInfo samplingInfo=ImageSamplingInfo::SingleSampled, ImageSamplerUseInfo samplerUse=ImageSamplerUseInfo::SamplerUnknown, ImageFormat format=ImageFormat::Unknown)
Type storage for SPIR-V structure types:
static VectorType vectorType(CodeGen &codegen, Type etp)
Constructs vector type.
StructType::OffsetInfo const * offsetInfo
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
static CooperativeMatrixTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
bool operator==(const KeyTy &key) const
ArrayRef< StructType::MemberDecorationInfo > getMemberDecorationsInfo() const
MLIRContext is the top-level object for a collection of MLIR operations.
MatrixTypeStorage(Type columnType, uint32_t columnCount)
static SampledImageType getChecked(function_ref< InFlightDiagnostic()> emitError, Type imageType)
static constexpr unsigned getNumBits()
StorageClass getStorageClass() const
void getMemberDecorations(SmallVectorImpl< StructType::MemberDecorationInfo > &memberDecorations) const
bool operator==(const KeyTy &key) const
For identified structs, return true if the given key contains the same identifier.
void getCapabilities(CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
Appends to capabilities the capabilities needed for this type to appear in the given storage class...
void getExtensions(ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
Appends to extensions the extensions needed for this type to appear in the given storage class...
bool operator==(const KeyTy &key) const
Type getElementType() const
ArrayRef< T > copyInto(ArrayRef< T > elements)
Copy the specified array of elements into memory managed by our bump pointer allocator.
static bool classof(Type type)
Scope getScope() const
Return the scope of the cooperative matrix.
unsigned getNumColumns() const
Returns the number of columns.
static MatrixType get(Type columnType, uint32_t columnCount)
Type getImageType() const
static StructType getIdentified(MLIRContext *context, StringRef identifier)
Construct an identified StructType.
unsigned getNumRows() const
Returns the number of rows.
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
llvm::hash_code hash_value(const StructType::MemberDecorationInfo &memberDecorationInfo)
Type getColumnType() const
void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, Optional< StorageClass > storage=llvm::None)
ImageSamplingInfo getSamplingInfo() const
constexpr unsigned getNumBits< Dim >()
Optional< int64_t > getSizeInBytes()
Returns the size in bytes for each type.
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, Optional< StorageClass > storage=llvm::None)
SampledImageTypeStorage(const KeyTy &key)
unsigned getColumns() const
return the number of columns of the matrix.
constexpr unsigned getNumBits< ImageFormat >()
static bool isValid(VectorType)
Returns true if the given vector type is valid for the SPIR-V dialect.