[PATCH] D80090: [mlir] Add BoolArrayAttr in Tablegen + Builder support
Nicolas Vasilache via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 17 12:47:21 PDT 2020
nicolasvasilache created this revision.
nicolasvasilache added reviewers: mehdi_amini, antiagainst, ftynse.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, Joonsoo, stephenneuendorffer, liufengdb, lucyrfox, mgester, arpith-jacob, shauheen, jpienaar, rriddle.
Herald added a reviewer: rriddle.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
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.264508.patch
Type: text/x-patch
Size: 2070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200517/c54ac8cf/attachment.bin>
More information about the llvm-commits
mailing list