[PATCH] D80180: [mlir] Add custom assembly formats to shape.witness ops.

Theodore Popp via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 21:40:52 PDT 2020


tpopp created this revision.
tpopp added a reviewer: herhut.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, Joonsoo, stephenneuendorffer, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle.
Herald added a reviewer: jpienaar.
Herald added a reviewer: silvas.
Herald added a project: LLVM.

The assembly formats are essentially the generic forms without
quotations and type information.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80180

Files:
  mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
  mlir/test/Dialect/Shape/ops.mlir


Index: mlir/test/Dialect/Shape/ops.mlir
===================================================================
--- mlir/test/Dialect/Shape/ops.mlir
+++ mlir/test/Dialect/Shape/ops.mlir
@@ -71,12 +71,12 @@
 func @test_constraints() {
   %0 = shape.const_shape []
   %1 = shape.const_shape [1, 2, 3]
-  %w0 = "shape.cstr_broadcastable"(%0, %1) : (!shape.shape, !shape.shape) -> !shape.witness
-  %w1 = "shape.cstr_eq"(%0, %1) : (!shape.shape, !shape.shape) -> !shape.witness
-  %w3 = "shape.assuming_all"(%w0, %w1) : (!shape.witness, !shape.witness) -> !shape.witness
+  %w0 = shape.cstr_broadcastable(%0, %1)
+  %w1 = shape.cstr_eq(%0, %1)
+  %w3 = shape.assuming_all(%w0, %w1)
   "shape.assuming"(%w3) ( {
-    %2 = "shape.any"(%0, %1)  : (!shape.shape, !shape.shape) -> !shape.shape
-    "shape.assuming_yield"(%2) : (!shape.shape) -> ()
+    %2 = shape.any(%0, %1)
+    shape.assuming_yield %2 : !shape.shape
   }) : (!shape.witness) -> !shape.shape
   return
 }
Index: mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
===================================================================
--- mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
+++ mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
@@ -363,6 +363,8 @@
 
   let arguments = (ins Variadic<Shape_ShapeType>:$inputs);
   let results = (outs Shape_ShapeType:$result);
+
+  let assemblyFormat = "`(` $inputs `)` attr-dict";
 }
 
 def Shape_AssumingAllOp : Shape_Op<"assuming_all", []> {
@@ -381,13 +383,15 @@
       %w0 = shape.cstr_broadcastable([2,2], [3,1,2]) // Success
       %w1 = shape.cstr_broadcastable([2,2], [3,2])    // Failure
       %w2 = shape.cstr_eq([1,2], [1,2], [1,2]) // Success
-      %wf = shape.assume_all(%w0, %w1) // Failure
-      %wt = shape.assume_all(%w0, %w2) // Success
+      %wf = shape.assuming_all(%w0, %w1) // Failure
+      %wt = shape.assuming_all(%w0, %w2) // Success
     ```
   }];
 
   let arguments = (ins Variadic<Shape_WitnessType>:$inputs);
   let results = (outs Shape_WitnessType:$result);
+
+  let assemblyFormat = "`(` $inputs `)` attr-dict";
 }
 
 def Shape_AssumingOp : Shape_Op<"assuming",
@@ -417,6 +421,8 @@
   }];
 
   let arguments = (ins Variadic<AnyType>:$operands);
+
+  let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
 }
 
 def Shape_CstrBroadcastableOp : Shape_Op<"cstr_broadcastable", []> {
@@ -436,6 +442,8 @@
 
   let arguments = (ins Shape_ShapeType:$lhs, Shape_ShapeType:$rhs);
   let results = (outs Shape_WitnessType:$result);
+
+  let assemblyFormat = "`(` $lhs `,` $rhs `)` attr-dict";
 }
 
 def Shape_CstrEqOp : Shape_Op<"cstr_eq", []> {
@@ -453,6 +461,8 @@
   }];
   let arguments = (ins Variadic<Shape_ShapeType>:$inputs);
   let results = (outs Shape_WitnessType:$result);
+
+  let assemblyFormat = "`(` $inputs `)` attr-dict";
 }
 
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80180.264788.patch
Type: text/x-patch
Size: 2778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200519/05ab9211/attachment.bin>


More information about the llvm-commits mailing list