[PATCH] D75484: [mlir][spirv] Add get() method to TargetEnvAttr taking raw values
Lei Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 14:56:39 PST 2020
antiagainst created this revision.
antiagainst added a reviewer: denis13.
Herald added subscribers: llvm-commits, bader, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: mravishankar.
Herald added a project: LLVM.
Also make the getResourceLimits() method more explicit about its return type.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75484
Files:
mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
Index: mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
===================================================================
--- mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
+++ mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
@@ -48,6 +48,27 @@
} // namespace spirv
} // namespace mlir
+spirv::TargetEnvAttr spirv::TargetEnvAttr::get(
+ spirv::Version version, ArrayRef<spirv::Extension> extensions,
+ ArrayRef<spirv::Capability> capabilities, DictionaryAttr limits) {
+ Builder b(limits.getContext());
+
+ auto versionAttr = b.getI32IntegerAttr(static_cast<uint32_t>(version));
+
+ SmallVector<Attribute, 4> extAttrs;
+ extAttrs.reserve(extensions.size());
+ for (spirv::Extension ext : extensions)
+ extAttrs.push_back(b.getStringAttr(spirv::stringifyExtension(ext)));
+
+ SmallVector<Attribute, 4> capAttrs;
+ capAttrs.reserve(capabilities.size());
+ for (spirv::Capability cap : capabilities)
+ capAttrs.push_back(b.getI32IntegerAttr(static_cast<uint32_t>(cap)));
+
+ return get(versionAttr, b.getArrayAttr(extAttrs), b.getArrayAttr(capAttrs),
+ limits);
+}
+
spirv::TargetEnvAttr spirv::TargetEnvAttr::get(IntegerAttr version,
ArrayAttr extensions,
ArrayAttr capabilities,
@@ -98,8 +119,8 @@
return getImpl()->capabilities.cast<ArrayAttr>();
}
-DictionaryAttr spirv::TargetEnvAttr::getResourceLimits() {
- return getImpl()->limits.cast<DictionaryAttr>();
+spirv::ResourceLimitsAttr spirv::TargetEnvAttr::getResourceLimits() {
+ return getImpl()->limits.cast<spirv::ResourceLimitsAttr>();
}
LogicalResult spirv::TargetEnvAttr::verifyConstructionInvariants(
Index: mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
===================================================================
--- mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
+++ mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
@@ -52,6 +52,9 @@
using Base::Base;
/// Gets a TargetEnvAttr instance.
+ static TargetEnvAttr get(Version version, ArrayRef<Extension> extensions,
+ ArrayRef<Capability> capabilities,
+ DictionaryAttr limits);
static TargetEnvAttr get(IntegerAttr version, ArrayAttr extensions,
ArrayAttr capabilities, DictionaryAttr limits);
@@ -86,7 +89,7 @@
ArrayAttr getCapabilitiesAttr();
/// Returns the target resource limits.
- DictionaryAttr getResourceLimits();
+ ResourceLimitsAttr getResourceLimits();
static bool kindof(unsigned kind) { return kind == AttrKind::TargetEnv; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75484.247730.patch
Type: text/x-patch
Size: 2590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200302/6496d44d/attachment.bin>
More information about the llvm-commits
mailing list