[PATCH] D78195: [MLIR] Add IndexAttr to primitive attributes kinds in tablegen.

Ulysse Beaugnon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 22:45:09 PDT 2020


ulysseB updated this revision to Diff 257959.
ulysseB marked an inline comment as done.
ulysseB added a comment.

Fix the test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78195/new/

https://reviews.llvm.org/D78195

Files:
  mlir/include/mlir/IR/OpBase.td
  mlir/test/IR/attribute.mlir
  mlir/test/lib/Dialect/Test/TestOps.td


Index: mlir/test/lib/Dialect/Test/TestOps.td
===================================================================
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -199,6 +199,7 @@
 def IntAttrOp : TEST_Op<"int_attrs"> {
   let arguments = (ins
     AnyI32Attr:$any_i32_attr,
+    IndexAttr:$index_attr,
     UI32Attr:$ui32_attr,
     SI32Attr:$si32_attr
   );
Index: mlir/test/IR/attribute.mlir
===================================================================
--- mlir/test/IR/attribute.mlir
+++ mlir/test/IR/attribute.mlir
@@ -8,6 +8,8 @@
   "test.int_attrs"() {
     // CHECK: any_i32_attr = 5 : ui32
     any_i32_attr = 5 : ui32,
+    // CHECK-SAME: index_attr = 8 : index
+    index_attr = 8 : index,
     // CHECK-SAME: si32_attr = 7 : si32
     si32_attr = 7 : si32,
     // CHECK-SAME: ui32_attr = 6 : ui32
Index: mlir/include/mlir/IR/OpBase.td
===================================================================
--- mlir/include/mlir/IR/OpBase.td
+++ mlir/include/mlir/IR/OpBase.td
@@ -845,6 +845,16 @@
   let constBuilderCall = "$_builder.getBoolAttr($0)";
 }
 
+// Index attribute.
+def IndexAttr :
+    TypedAttrBase<
+      Index, "IntegerAttr",
+      And<[CPred<"$_self.isa<IntegerAttr>()">,
+           CPred<"$_self.cast<IntegerAttr>().getType().isa<IndexType>()">]>,
+      "index attribute"> {
+  let returnType = [{ APInt }];
+}
+
 // Base class for any integer (regardless of signedness semantics) attributes
 // of fixed width.
 class AnyIntegerAttrBase<AnyI attrValType, string descr> :


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78195.257959.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/5b74ff77/attachment.bin>


More information about the llvm-commits mailing list