From: Lei Zhang Date: Wed, 11 Mar 2020 20:03:43 +0000 (-0400) Subject: [mlir][spirv] NFC: put SPIR-V attributes in separate files X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c818c3cc96ec0894fc08e490a74066da57f7b6d3;p=platform%2Fupstream%2Fllvm.git [mlir][spirv] NFC: put SPIR-V attributes in separate files Differential Revision: https://reviews.llvm.org/D75871 --- diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h new file mode 100644 index 0000000..4e1eb12 --- /dev/null +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h @@ -0,0 +1,137 @@ +//===- SPIRVAttributes.h - SPIR-V attribute declarations -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares SPIR-V dialect specific attributes. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H +#define MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H + +#include "mlir/IR/Attributes.h" +#include "mlir/Support/LLVM.h" + +namespace mlir { +// Pull in SPIR-V attribute definitions for target and ABI. +#include "mlir/Dialect/SPIRV/TargetAndABI.h.inc" + +namespace spirv { +enum class Capability : uint32_t; +enum class Extension; +enum class Version : uint32_t; + +namespace detail { +struct TargetEnvAttributeStorage; +struct VerCapExtAttributeStorage; +} // namespace detail + +/// SPIR-V dialect-specific attribute kinds. +namespace AttrKind { +enum Kind { + TargetEnv = Attribute::FIRST_SPIRV_ATTR, /// Target environment + VerCapExt, /// (version, extension, capability) triple +}; +} // namespace AttrKind + +/// An attribute that specifies the SPIR-V (version, capabilities, extensions) +/// triple. +class VerCapExtAttr + : public Attribute::AttrBase { +public: + using Base::Base; + + /// Gets a VerCapExtAttr instance. + static VerCapExtAttr get(Version version, ArrayRef capabilities, + ArrayRef extensions, + MLIRContext *context); + static VerCapExtAttr get(IntegerAttr version, ArrayAttr capabilities, + ArrayAttr extensions); + + /// Returns the attribute kind's name (without the 'spv.' prefix). + static StringRef getKindName(); + + /// Returns the version. + Version getVersion(); + + struct ext_iterator final + : public llvm::mapped_iterator { + explicit ext_iterator(ArrayAttr::iterator it); + }; + using ext_range = llvm::iterator_range; + + /// Returns the extensions. + ext_range getExtensions(); + /// Returns the extensions as a string array attribute. + ArrayAttr getExtensionsAttr(); + + struct cap_iterator final + : public llvm::mapped_iterator { + explicit cap_iterator(ArrayAttr::iterator it); + }; + using cap_range = llvm::iterator_range; + + /// Returns the capabilities. + cap_range getCapabilities(); + /// Returns the capabilities as an integer array attribute. + ArrayAttr getCapabilitiesAttr(); + + static bool kindof(unsigned kind) { return kind == AttrKind::VerCapExt; } + + static LogicalResult verifyConstructionInvariants(Location loc, + IntegerAttr version, + ArrayAttr capabilities, + ArrayAttr extensions); +}; + +/// An attribute that specifies the target version, allowed extensions and +/// capabilities, and resource limits. These information describles a SPIR-V +/// target environment. +class TargetEnvAttr + : public Attribute::AttrBase { +public: + using Base::Base; + + /// Gets a TargetEnvAttr instance. + static TargetEnvAttr get(VerCapExtAttr triple, DictionaryAttr limits); + + /// Returns the attribute kind's name (without the 'spv.' prefix). + static StringRef getKindName(); + + /// Returns the (version, capabilities, extensions) triple attribute. + VerCapExtAttr getTripleAttr(); + + /// Returns the target version. + Version getVersion(); + + /// Returns the target extensions. + VerCapExtAttr::ext_range getExtensions(); + /// Returns the target extensions as a string array attribute. + ArrayAttr getExtensionsAttr(); + + /// Returns the target capabilities. + VerCapExtAttr::cap_range getCapabilities(); + /// Returns the target capabilities as an integer array attribute. + ArrayAttr getCapabilitiesAttr(); + + /// Returns the target resource limits. + ResourceLimitsAttr getResourceLimits(); + + static bool kindof(unsigned kind) { return kind == AttrKind::TargetEnv; } + + static LogicalResult verifyConstructionInvariants(Location loc, + VerCapExtAttr triple, + DictionaryAttr limits); +}; +} // namespace spirv +} // namespace mlir + +#endif // MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H diff --git a/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h b/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h index d004680..5ffd00c 100644 --- a/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h +++ b/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h @@ -13,130 +13,14 @@ #ifndef MLIR_DIALECT_SPIRV_TARGETANDABI_H #define MLIR_DIALECT_SPIRV_TARGETANDABI_H -#include "mlir/IR/Attributes.h" +#include "mlir/Dialect/SPIRV/SPIRVAttributes.h" #include "mlir/Support/LLVM.h" namespace mlir { -class OpBuilder; class Operation; -class Value; - -// Pull in SPIR-V attribute definitions. -#include "mlir/Dialect/SPIRV/TargetAndABI.h.inc" namespace spirv { -enum class Capability : uint32_t; -enum class Extension; enum class StorageClass : uint32_t; -enum class Version : uint32_t; - -namespace detail { -struct TargetEnvAttributeStorage; -struct VerCapExtAttributeStorage; -} // namespace detail - -/// SPIR-V dialect-specific attribute kinds. -// TODO(antiagainst): move to a more suitable place if we have more attributes. -namespace AttrKind { -enum Kind { - TargetEnv = Attribute::FIRST_SPIRV_ATTR, /// Target environment - VerCapExt, /// (version, extension, capability) triple -}; -} // namespace AttrKind - -/// An attribute that specifies the SPIR-V (version, capabilities, extensions) -/// triple. -class VerCapExtAttr - : public Attribute::AttrBase { -public: - using Base::Base; - - /// Gets a VerCapExtAttr instance. - static VerCapExtAttr get(Version version, ArrayRef capabilities, - ArrayRef extensions, - MLIRContext *context); - static VerCapExtAttr get(IntegerAttr version, ArrayAttr capabilities, - ArrayAttr extensions); - - /// Returns the attribute kind's name (without the 'spv.' prefix). - static StringRef getKindName(); - - /// Returns the version. - Version getVersion(); - - struct ext_iterator final - : public llvm::mapped_iterator { - explicit ext_iterator(ArrayAttr::iterator it); - }; - using ext_range = llvm::iterator_range; - - /// Returns the extensions. - ext_range getExtensions(); - /// Returns the extensions as a string array attribute. - ArrayAttr getExtensionsAttr(); - - struct cap_iterator final - : public llvm::mapped_iterator { - explicit cap_iterator(ArrayAttr::iterator it); - }; - using cap_range = llvm::iterator_range; - - /// Returns the capabilities. - cap_range getCapabilities(); - /// Returns the capabilities as an integer array attribute. - ArrayAttr getCapabilitiesAttr(); - - static bool kindof(unsigned kind) { return kind == AttrKind::VerCapExt; } - - static LogicalResult verifyConstructionInvariants(Location loc, - IntegerAttr version, - ArrayAttr capabilities, - ArrayAttr extensions); -}; - -/// An attribute that specifies the target version, allowed extensions and -/// capabilities, and resource limits. These information describles a SPIR-V -/// target environment. -class TargetEnvAttr - : public Attribute::AttrBase { -public: - using Base::Base; - - /// Gets a TargetEnvAttr instance. - static TargetEnvAttr get(VerCapExtAttr triple, DictionaryAttr limits); - - /// Returns the attribute kind's name (without the 'spv.' prefix). - static StringRef getKindName(); - - /// Returns the (version, capabilities, extensions) triple attribute. - VerCapExtAttr getTripleAttr(); - - /// Returns the target version. - Version getVersion(); - - /// Returns the target extensions. - VerCapExtAttr::ext_range getExtensions(); - /// Returns the target extensions as a string array attribute. - ArrayAttr getExtensionsAttr(); - - /// Returns the target capabilities. - VerCapExtAttr::cap_range getCapabilities(); - /// Returns the target capabilities as an integer array attribute. - ArrayAttr getCapabilitiesAttr(); - - /// Returns the target resource limits. - ResourceLimitsAttr getResourceLimits(); - - static bool kindof(unsigned kind) { return kind == AttrKind::TargetEnv; } - - static LogicalResult verifyConstructionInvariants(Location loc, - VerCapExtAttr triple, - DictionaryAttr limits); -}; /// Returns the attribute name for specifying argument ABI information. StringRef getInterfaceVarABIAttrName(); diff --git a/mlir/lib/Dialect/SPIRV/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/CMakeLists.txt index aa1d235..afb7497 100644 --- a/mlir/lib/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/lib/Dialect/SPIRV/CMakeLists.txt @@ -4,6 +4,7 @@ add_public_tablegen_target(MLIRSPIRVCanonicalizationIncGen) add_mlir_dialect_library(MLIRSPIRV LayoutUtils.cpp + SPIRVAttributes.cpp SPIRVCanonicalization.cpp SPIRVDialect.cpp SPIRVOps.cpp diff --git a/mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp b/mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp new file mode 100644 index 0000000..4ce42a5a --- /dev/null +++ b/mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp @@ -0,0 +1,220 @@ +//===- SPIRVAttributes.cpp - SPIR-V attribute definitions -----------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "mlir/Dialect/SPIRV/SPIRVAttributes.h" +#include "mlir/Dialect/SPIRV/SPIRVTypes.h" +#include "mlir/IR/Builders.h" + +using namespace mlir; + +//===----------------------------------------------------------------------===// +// DictionaryDict derived attributes +//===----------------------------------------------------------------------===// + +namespace mlir { +#include "mlir/Dialect/SPIRV/TargetAndABI.cpp.inc" + +//===----------------------------------------------------------------------===// +// Attribute storage classes +//===----------------------------------------------------------------------===// + +namespace spirv { +namespace detail { +struct VerCapExtAttributeStorage : public AttributeStorage { + using KeyTy = std::tuple; + + VerCapExtAttributeStorage(Attribute version, Attribute capabilities, + Attribute extensions) + : version(version), capabilities(capabilities), extensions(extensions) {} + + bool operator==(const KeyTy &key) const { + return std::get<0>(key) == version && std::get<1>(key) == capabilities && + std::get<2>(key) == extensions; + } + + static VerCapExtAttributeStorage * + construct(AttributeStorageAllocator &allocator, const KeyTy &key) { + return new (allocator.allocate()) + VerCapExtAttributeStorage(std::get<0>(key), std::get<1>(key), + std::get<2>(key)); + } + + Attribute version; + Attribute capabilities; + Attribute extensions; +}; + +struct TargetEnvAttributeStorage : public AttributeStorage { + using KeyTy = std::pair; + + TargetEnvAttributeStorage(Attribute triple, Attribute limits) + : triple(triple), limits(limits) {} + + bool operator==(const KeyTy &key) const { + return key.first == triple && key.second == limits; + } + + static TargetEnvAttributeStorage * + construct(AttributeStorageAllocator &allocator, const KeyTy &key) { + return new (allocator.allocate()) + TargetEnvAttributeStorage(key.first, key.second); + } + + Attribute triple; + Attribute limits; +}; +} // namespace detail +} // namespace spirv +} // namespace mlir + +//===----------------------------------------------------------------------===// +// VerCapExtAttr +//===----------------------------------------------------------------------===// + +spirv::VerCapExtAttr spirv::VerCapExtAttr::get( + spirv::Version version, ArrayRef capabilities, + ArrayRef extensions, MLIRContext *context) { + Builder b(context); + + auto versionAttr = b.getI32IntegerAttr(static_cast(version)); + + SmallVector capAttrs; + capAttrs.reserve(capabilities.size()); + for (spirv::Capability cap : capabilities) + capAttrs.push_back(b.getI32IntegerAttr(static_cast(cap))); + + SmallVector extAttrs; + extAttrs.reserve(extensions.size()); + for (spirv::Extension ext : extensions) + extAttrs.push_back(b.getStringAttr(spirv::stringifyExtension(ext))); + + return get(versionAttr, b.getArrayAttr(capAttrs), b.getArrayAttr(extAttrs)); +} + +spirv::VerCapExtAttr spirv::VerCapExtAttr::get(IntegerAttr version, + ArrayAttr capabilities, + ArrayAttr extensions) { + assert(version && capabilities && extensions); + MLIRContext *context = version.getContext(); + return Base::get(context, spirv::AttrKind::VerCapExt, version, capabilities, + extensions); +} + +StringRef spirv::VerCapExtAttr::getKindName() { return "vce"; } + +spirv::Version spirv::VerCapExtAttr::getVersion() { + return static_cast( + getImpl()->version.cast().getValue().getZExtValue()); +} + +spirv::VerCapExtAttr::ext_iterator::ext_iterator(ArrayAttr::iterator it) + : llvm::mapped_iterator( + it, [](Attribute attr) { + return *symbolizeExtension(attr.cast().getValue()); + }) {} + +spirv::VerCapExtAttr::ext_range spirv::VerCapExtAttr::getExtensions() { + auto range = getExtensionsAttr().getValue(); + return {ext_iterator(range.begin()), ext_iterator(range.end())}; +} + +ArrayAttr spirv::VerCapExtAttr::getExtensionsAttr() { + return getImpl()->extensions.cast(); +} + +spirv::VerCapExtAttr::cap_iterator::cap_iterator(ArrayAttr::iterator it) + : llvm::mapped_iterator( + it, [](Attribute attr) { + return *symbolizeCapability( + attr.cast().getValue().getZExtValue()); + }) {} + +spirv::VerCapExtAttr::cap_range spirv::VerCapExtAttr::getCapabilities() { + auto range = getCapabilitiesAttr().getValue(); + return {cap_iterator(range.begin()), cap_iterator(range.end())}; +} + +ArrayAttr spirv::VerCapExtAttr::getCapabilitiesAttr() { + return getImpl()->capabilities.cast(); +} + +LogicalResult spirv::VerCapExtAttr::verifyConstructionInvariants( + Location loc, IntegerAttr version, ArrayAttr capabilities, + ArrayAttr extensions) { + if (!version.getType().isSignlessInteger(32)) + return emitError(loc, "expected 32-bit integer for version"); + + if (!llvm::all_of(capabilities.getValue(), [](Attribute attr) { + if (auto intAttr = attr.dyn_cast()) + if (spirv::symbolizeCapability(intAttr.getValue().getZExtValue())) + return true; + return false; + })) + return emitError(loc, "unknown capability in capability list"); + + if (!llvm::all_of(extensions.getValue(), [](Attribute attr) { + if (auto strAttr = attr.dyn_cast()) + if (spirv::symbolizeExtension(strAttr.getValue())) + return true; + return false; + })) + return emitError(loc, "unknown extension in extension list"); + + return success(); +} + +//===----------------------------------------------------------------------===// +// TargetEnvAttr +//===----------------------------------------------------------------------===// + +spirv::TargetEnvAttr spirv::TargetEnvAttr::get(spirv::VerCapExtAttr triple, + DictionaryAttr limits) { + assert(triple && limits && "expected valid triple and limits"); + MLIRContext *context = triple.getContext(); + return Base::get(context, spirv::AttrKind::TargetEnv, triple, limits); +} + +StringRef spirv::TargetEnvAttr::getKindName() { return "target_env"; } + +spirv::VerCapExtAttr spirv::TargetEnvAttr::getTripleAttr() { + return getImpl()->triple.cast(); +} + +spirv::Version spirv::TargetEnvAttr::getVersion() { + return getTripleAttr().getVersion(); +} + +spirv::VerCapExtAttr::ext_range spirv::TargetEnvAttr::getExtensions() { + return getTripleAttr().getExtensions(); +} + +ArrayAttr spirv::TargetEnvAttr::getExtensionsAttr() { + return getTripleAttr().getExtensionsAttr(); +} + +spirv::VerCapExtAttr::cap_range spirv::TargetEnvAttr::getCapabilities() { + return getTripleAttr().getCapabilities(); +} + +ArrayAttr spirv::TargetEnvAttr::getCapabilitiesAttr() { + return getTripleAttr().getCapabilitiesAttr(); +} + +spirv::ResourceLimitsAttr spirv::TargetEnvAttr::getResourceLimits() { + return getImpl()->limits.cast(); +} + +LogicalResult spirv::TargetEnvAttr::verifyConstructionInvariants( + Location loc, spirv::VerCapExtAttr triple, DictionaryAttr limits) { + if (!limits.isa()) + return emitError(loc, "expected spirv::ResourceLimitsAttr for limits"); + + return success(); +} diff --git a/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp index b2c1dda..88f3037 100644 --- a/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp +++ b/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp @@ -15,217 +15,6 @@ using namespace mlir; -//===----------------------------------------------------------------------===// -// DictionaryDict derived attributes -//===----------------------------------------------------------------------===// - -namespace mlir { -#include "mlir/Dialect/SPIRV/TargetAndABI.cpp.inc" - -//===----------------------------------------------------------------------===// -// Attribute storage classes -//===----------------------------------------------------------------------===// - -namespace spirv { -namespace detail { -struct VerCapExtAttributeStorage : public AttributeStorage { - using KeyTy = std::tuple; - - VerCapExtAttributeStorage(Attribute version, Attribute capabilities, - Attribute extensions) - : version(version), capabilities(capabilities), extensions(extensions) {} - - bool operator==(const KeyTy &key) const { - return std::get<0>(key) == version && std::get<1>(key) == capabilities && - std::get<2>(key) == extensions; - } - - static VerCapExtAttributeStorage * - construct(AttributeStorageAllocator &allocator, const KeyTy &key) { - return new (allocator.allocate()) - VerCapExtAttributeStorage(std::get<0>(key), std::get<1>(key), - std::get<2>(key)); - } - - Attribute version; - Attribute capabilities; - Attribute extensions; -}; - -struct TargetEnvAttributeStorage : public AttributeStorage { - using KeyTy = std::pair; - - TargetEnvAttributeStorage(Attribute triple, Attribute limits) - : triple(triple), limits(limits) {} - - bool operator==(const KeyTy &key) const { - return key.first == triple && key.second == limits; - } - - static TargetEnvAttributeStorage * - construct(AttributeStorageAllocator &allocator, const KeyTy &key) { - return new (allocator.allocate()) - TargetEnvAttributeStorage(key.first, key.second); - } - - Attribute triple; - Attribute limits; -}; -} // namespace detail -} // namespace spirv -} // namespace mlir - -//===----------------------------------------------------------------------===// -// VerCapExtAttr -//===----------------------------------------------------------------------===// - -spirv::VerCapExtAttr spirv::VerCapExtAttr::get( - spirv::Version version, ArrayRef capabilities, - ArrayRef extensions, MLIRContext *context) { - Builder b(context); - - auto versionAttr = b.getI32IntegerAttr(static_cast(version)); - - SmallVector capAttrs; - capAttrs.reserve(capabilities.size()); - for (spirv::Capability cap : capabilities) - capAttrs.push_back(b.getI32IntegerAttr(static_cast(cap))); - - SmallVector extAttrs; - extAttrs.reserve(extensions.size()); - for (spirv::Extension ext : extensions) - extAttrs.push_back(b.getStringAttr(spirv::stringifyExtension(ext))); - - return get(versionAttr, b.getArrayAttr(capAttrs), b.getArrayAttr(extAttrs)); -} - -spirv::VerCapExtAttr spirv::VerCapExtAttr::get(IntegerAttr version, - ArrayAttr capabilities, - ArrayAttr extensions) { - assert(version && capabilities && extensions); - MLIRContext *context = version.getContext(); - return Base::get(context, spirv::AttrKind::VerCapExt, version, capabilities, - extensions); -} - -StringRef spirv::VerCapExtAttr::getKindName() { return "vce"; } - -spirv::Version spirv::VerCapExtAttr::getVersion() { - return static_cast( - getImpl()->version.cast().getValue().getZExtValue()); -} - -spirv::VerCapExtAttr::ext_iterator::ext_iterator(ArrayAttr::iterator it) - : llvm::mapped_iterator( - it, [](Attribute attr) { - return *symbolizeExtension(attr.cast().getValue()); - }) {} - -spirv::VerCapExtAttr::ext_range spirv::VerCapExtAttr::getExtensions() { - auto range = getExtensionsAttr().getValue(); - return {ext_iterator(range.begin()), ext_iterator(range.end())}; -} - -ArrayAttr spirv::VerCapExtAttr::getExtensionsAttr() { - return getImpl()->extensions.cast(); -} - -spirv::VerCapExtAttr::cap_iterator::cap_iterator(ArrayAttr::iterator it) - : llvm::mapped_iterator( - it, [](Attribute attr) { - return *symbolizeCapability( - attr.cast().getValue().getZExtValue()); - }) {} - -spirv::VerCapExtAttr::cap_range spirv::VerCapExtAttr::getCapabilities() { - auto range = getCapabilitiesAttr().getValue(); - return {cap_iterator(range.begin()), cap_iterator(range.end())}; -} - -ArrayAttr spirv::VerCapExtAttr::getCapabilitiesAttr() { - return getImpl()->capabilities.cast(); -} - -LogicalResult spirv::VerCapExtAttr::verifyConstructionInvariants( - Location loc, IntegerAttr version, ArrayAttr capabilities, - ArrayAttr extensions) { - if (!version.getType().isSignlessInteger(32)) - return emitError(loc, "expected 32-bit integer for version"); - - if (!llvm::all_of(capabilities.getValue(), [](Attribute attr) { - if (auto intAttr = attr.dyn_cast()) - if (spirv::symbolizeCapability(intAttr.getValue().getZExtValue())) - return true; - return false; - })) - return emitError(loc, "unknown capability in capability list"); - - if (!llvm::all_of(extensions.getValue(), [](Attribute attr) { - if (auto strAttr = attr.dyn_cast()) - if (spirv::symbolizeExtension(strAttr.getValue())) - return true; - return false; - })) - return emitError(loc, "unknown extension in extension list"); - - return success(); -} - -//===----------------------------------------------------------------------===// -// TargetEnvAttr -//===----------------------------------------------------------------------===// - -spirv::TargetEnvAttr spirv::TargetEnvAttr::get(spirv::VerCapExtAttr triple, - DictionaryAttr limits) { - assert(triple && limits && "expected valid triple and limits"); - MLIRContext *context = triple.getContext(); - return Base::get(context, spirv::AttrKind::TargetEnv, triple, limits); -} - -StringRef spirv::TargetEnvAttr::getKindName() { return "target_env"; } - -spirv::VerCapExtAttr spirv::TargetEnvAttr::getTripleAttr() { - return getImpl()->triple.cast(); -} - -spirv::Version spirv::TargetEnvAttr::getVersion() { - return getTripleAttr().getVersion(); -} - -spirv::VerCapExtAttr::ext_range spirv::TargetEnvAttr::getExtensions() { - return getTripleAttr().getExtensions(); -} - -ArrayAttr spirv::TargetEnvAttr::getExtensionsAttr() { - return getTripleAttr().getExtensionsAttr(); -} - -spirv::VerCapExtAttr::cap_range spirv::TargetEnvAttr::getCapabilities() { - return getTripleAttr().getCapabilities(); -} - -ArrayAttr spirv::TargetEnvAttr::getCapabilitiesAttr() { - return getTripleAttr().getCapabilitiesAttr(); -} - -spirv::ResourceLimitsAttr spirv::TargetEnvAttr::getResourceLimits() { - return getImpl()->limits.cast(); -} - -LogicalResult spirv::TargetEnvAttr::verifyConstructionInvariants( - Location loc, spirv::VerCapExtAttr triple, DictionaryAttr limits) { - if (!limits.isa()) - return emitError(loc, "expected spirv::ResourceLimitsAttr for limits"); - - return success(); -} - -//===----------------------------------------------------------------------===// -// Utility functions -//===----------------------------------------------------------------------===// - StringRef spirv::getInterfaceVarABIAttrName() { return "spv.interface_var_abi"; }