[PATCH] D80090: [mlir] Add BoolArrayAttr in Tablegen + Builder support
Nicolas Vasilache via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 18 06:57:34 PDT 2020
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03092f2fa7b4: [mlir] Add BoolArrayAttr in Tablegen + Builder support (authored by nicolasvasilache).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80090/new/
https://reviews.llvm.org/D80090
Files:
mlir/include/mlir/IR/Builders.h
mlir/include/mlir/IR/OpBase.td
mlir/lib/IR/Builders.cpp
Index: mlir/lib/IR/Builders.cpp
===================================================================
--- mlir/lib/IR/Builders.cpp
+++ mlir/lib/IR/Builders.cpp
@@ -202,12 +202,17 @@
return SymbolRefAttr::get(value, nestedReferences, getContext());
}
+ArrayAttr Builder::getBoolArrayAttr(ArrayRef<bool> values) {
+ auto attrs = llvm::to_vector<8>(llvm::map_range(
+ values, [this](bool v) -> Attribute { return getBoolAttr(v); }));
+ return getArrayAttr(attrs);
+}
+
ArrayAttr Builder::getI32ArrayAttr(ArrayRef<int32_t> values) {
auto attrs = llvm::to_vector<8>(llvm::map_range(
values, [this](int32_t v) -> Attribute { return getI32IntegerAttr(v); }));
return getArrayAttr(attrs);
}
-
ArrayAttr Builder::getI64ArrayAttr(ArrayRef<int64_t> values) {
auto attrs = llvm::to_vector<8>(llvm::map_range(
values, [this](int64_t v) -> Attribute { return getI64IntegerAttr(v); }));
Index: mlir/include/mlir/IR/OpBase.td
===================================================================
--- mlir/include/mlir/IR/OpBase.td
+++ mlir/include/mlir/IR/OpBase.td
@@ -1346,6 +1346,10 @@
Attr elementAttr = element;
}
+def BoolArrayAttr : TypedArrayAttrBase<BoolAttr,
+ "1-bit boolean array attribute"> {
+ let constBuilderCall = "$_builder.getBoolArrayAttr($0)";
+}
def I32ArrayAttr : TypedArrayAttrBase<I32Attr,
"32-bit integer array attribute"> {
let constBuilderCall = "$_builder.getI32ArrayAttr($0)";
Index: mlir/include/mlir/IR/Builders.h
===================================================================
--- mlir/include/mlir/IR/Builders.h
+++ mlir/include/mlir/IR/Builders.h
@@ -128,6 +128,7 @@
DenseIntElementsAttr getI64TensorAttr(ArrayRef<int64_t> values);
ArrayAttr getAffineMapArrayAttr(ArrayRef<AffineMap> values);
+ ArrayAttr getBoolArrayAttr(ArrayRef<bool> values);
ArrayAttr getI32ArrayAttr(ArrayRef<int32_t> values);
ArrayAttr getI64ArrayAttr(ArrayRef<int64_t> values);
ArrayAttr getIndexArrayAttr(ArrayRef<int64_t> values);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80090.264612.patch
Type: text/x-patch
Size: 2070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/a9c88525/attachment.bin>
More information about the llvm-commits
mailing list