Skip to content

[mlir][doc] Remove duplicate syntax formats #73343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2023
Merged

[mlir][doc] Remove duplicate syntax formats #73343

merged 1 commit into from
Nov 25, 2023

Conversation

rikhuijzer
Copy link
Member

Some operations defined their syntax both in the documentation and via assemblyFormat. This leads to two Syntax: subheadings in the documentation, see for example the documentation for arith.maximumf. Since the assemblyFormat is used to generate the actual parsers and printer implementations, this PR suggest to remove the manual syntax descriptions.

@llvmbot
Copy link
Member

llvmbot commented Nov 24, 2023

@llvm/pr-subscribers-mlir-vector

@llvm/pr-subscribers-mlir-arith

Author: Rik Huijzer (rikhuijzer)

Changes

Some operations defined their syntax both in the documentation and via assemblyFormat. This leads to two Syntax: subheadings in the documentation, see for example the documentation for arith.maximumf. Since the assemblyFormat is used to generate the actual parsers and printer implementations, this PR suggest to remove the manual syntax descriptions.


Full diff: https://github.com/llvm/llvm-project/pull/73343.diff

4 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Arith/IR/ArithOps.td (-24)
  • (modified) mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td (-6)
  • (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (-6)
  • (modified) mlir/include/mlir/Dialect/Vector/IR/VectorOps.td (-6)
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
index 58e5385bf3ff268..e382f18340856ff 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
@@ -838,12 +838,6 @@ def Arith_SubFOp : Arith_FloatBinaryOp<"subf"> {
 def Arith_MaximumFOp : Arith_FloatBinaryOp<"maximumf", [Commutative]> {
   let summary = "floating-point maximum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.maximumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the maximum of the two arguments, treating -0.0 as less than +0.0.
     If one of the arguments is NaN, then the result is also NaN.
 
@@ -864,12 +858,6 @@ def Arith_MaximumFOp : Arith_FloatBinaryOp<"maximumf", [Commutative]> {
 def Arith_MaxNumFOp : Arith_FloatBinaryOp<"maxnumf", [Commutative]> {
   let summary = "floating-point maximum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.maxnumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the maximum of the two arguments.
     If the arguments are -0.0 and +0.0, then the result is either of them.
     If one of the arguments is NaN, then the result is the other argument.
@@ -910,12 +898,6 @@ def Arith_MaxUIOp : Arith_TotalIntBinaryOp<"maxui", [Commutative]> {
 def Arith_MinimumFOp : Arith_FloatBinaryOp<"minimumf", [Commutative]> {
   let summary = "floating-point minimum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.minimumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the minimum of the two arguments, treating -0.0 as less than +0.0.
     If one of the arguments is NaN, then the result is also NaN.
 
@@ -936,12 +918,6 @@ def Arith_MinimumFOp : Arith_FloatBinaryOp<"minimumf", [Commutative]> {
 def Arith_MinNumFOp : Arith_FloatBinaryOp<"minnumf", [Commutative]> {
   let summary = "floating-point minimum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.minnumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the minimum of the two arguments.
     If the arguments are -0.0 and +0.0, then the result is either of them.
     If one of the arguments is NaN, then the result is the other argument.
diff --git a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
index a829fa88efa893e..ada6c14b5b71354 100644
--- a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
+++ b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
@@ -280,12 +280,6 @@ def ExpOp : ComplexUnaryOp<"exp", [SameOperandsAndResultType]> {
 def Expm1Op : ComplexUnaryOp<"expm1", [SameOperandsAndResultType]> {
   let summary = "computes exponential of a complex number minus 1";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `complex.expm1` ssa-use `:` type
-    ```
-
     complex.expm1(x) := complex.exp(x) - 1
 
     Example:
diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
index 657f601aad2f5a1..c71517666b609c2 100644
--- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
+++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
@@ -447,12 +447,6 @@ def MemRef_CastOp : MemRef_Op<"cast", [
     ]> {
   let summary = "memref cast operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `memref.cast` ssa-use `:` type `to` type
-    ```
-
     The `memref.cast` operation converts a memref from one type to an equivalent
     type with a compatible shape. The source and destination types are
     compatible if:
diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
index 1397d4caf1d9d61..afc9d532f6e31bb 100644
--- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
@@ -2203,12 +2203,6 @@ def Vector_TypeCastOp :
     super-vectorization operational. It can be seen as a special case of the
     `view` operation but scoped in the super-vectorization context.
 
-    Syntax:
-
-    ```
-    operation ::= `vector.type_cast` ssa-use : memref-type to memref-type
-    ```
-
     Example:
 
     ```mlir

@llvmbot
Copy link
Member

llvmbot commented Nov 24, 2023

@llvm/pr-subscribers-mlir

Author: Rik Huijzer (rikhuijzer)

Changes

Some operations defined their syntax both in the documentation and via assemblyFormat. This leads to two Syntax: subheadings in the documentation, see for example the documentation for arith.maximumf. Since the assemblyFormat is used to generate the actual parsers and printer implementations, this PR suggest to remove the manual syntax descriptions.


Full diff: https://github.com/llvm/llvm-project/pull/73343.diff

4 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Arith/IR/ArithOps.td (-24)
  • (modified) mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td (-6)
  • (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (-6)
  • (modified) mlir/include/mlir/Dialect/Vector/IR/VectorOps.td (-6)
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
index 58e5385bf3ff268..e382f18340856ff 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
@@ -838,12 +838,6 @@ def Arith_SubFOp : Arith_FloatBinaryOp<"subf"> {
 def Arith_MaximumFOp : Arith_FloatBinaryOp<"maximumf", [Commutative]> {
   let summary = "floating-point maximum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.maximumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the maximum of the two arguments, treating -0.0 as less than +0.0.
     If one of the arguments is NaN, then the result is also NaN.
 
@@ -864,12 +858,6 @@ def Arith_MaximumFOp : Arith_FloatBinaryOp<"maximumf", [Commutative]> {
 def Arith_MaxNumFOp : Arith_FloatBinaryOp<"maxnumf", [Commutative]> {
   let summary = "floating-point maximum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.maxnumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the maximum of the two arguments.
     If the arguments are -0.0 and +0.0, then the result is either of them.
     If one of the arguments is NaN, then the result is the other argument.
@@ -910,12 +898,6 @@ def Arith_MaxUIOp : Arith_TotalIntBinaryOp<"maxui", [Commutative]> {
 def Arith_MinimumFOp : Arith_FloatBinaryOp<"minimumf", [Commutative]> {
   let summary = "floating-point minimum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.minimumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the minimum of the two arguments, treating -0.0 as less than +0.0.
     If one of the arguments is NaN, then the result is also NaN.
 
@@ -936,12 +918,6 @@ def Arith_MinimumFOp : Arith_FloatBinaryOp<"minimumf", [Commutative]> {
 def Arith_MinNumFOp : Arith_FloatBinaryOp<"minnumf", [Commutative]> {
   let summary = "floating-point minimum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.minnumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the minimum of the two arguments.
     If the arguments are -0.0 and +0.0, then the result is either of them.
     If one of the arguments is NaN, then the result is the other argument.
diff --git a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
index a829fa88efa893e..ada6c14b5b71354 100644
--- a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
+++ b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
@@ -280,12 +280,6 @@ def ExpOp : ComplexUnaryOp<"exp", [SameOperandsAndResultType]> {
 def Expm1Op : ComplexUnaryOp<"expm1", [SameOperandsAndResultType]> {
   let summary = "computes exponential of a complex number minus 1";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `complex.expm1` ssa-use `:` type
-    ```
-
     complex.expm1(x) := complex.exp(x) - 1
 
     Example:
diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
index 657f601aad2f5a1..c71517666b609c2 100644
--- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
+++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
@@ -447,12 +447,6 @@ def MemRef_CastOp : MemRef_Op<"cast", [
     ]> {
   let summary = "memref cast operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `memref.cast` ssa-use `:` type `to` type
-    ```
-
     The `memref.cast` operation converts a memref from one type to an equivalent
     type with a compatible shape. The source and destination types are
     compatible if:
diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
index 1397d4caf1d9d61..afc9d532f6e31bb 100644
--- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
@@ -2203,12 +2203,6 @@ def Vector_TypeCastOp :
     super-vectorization operational. It can be seen as a special case of the
     `view` operation but scoped in the super-vectorization context.
 
-    Syntax:
-
-    ```
-    operation ::= `vector.type_cast` ssa-use : memref-type to memref-type
-    ```
-
     Example:
 
     ```mlir

@llvmbot
Copy link
Member

llvmbot commented Nov 24, 2023

@llvm/pr-subscribers-mlir-memref

Author: Rik Huijzer (rikhuijzer)

Changes

Some operations defined their syntax both in the documentation and via assemblyFormat. This leads to two Syntax: subheadings in the documentation, see for example the documentation for arith.maximumf. Since the assemblyFormat is used to generate the actual parsers and printer implementations, this PR suggest to remove the manual syntax descriptions.


Full diff: https://github.com/llvm/llvm-project/pull/73343.diff

4 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Arith/IR/ArithOps.td (-24)
  • (modified) mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td (-6)
  • (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (-6)
  • (modified) mlir/include/mlir/Dialect/Vector/IR/VectorOps.td (-6)
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
index 58e5385bf3ff268..e382f18340856ff 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
@@ -838,12 +838,6 @@ def Arith_SubFOp : Arith_FloatBinaryOp<"subf"> {
 def Arith_MaximumFOp : Arith_FloatBinaryOp<"maximumf", [Commutative]> {
   let summary = "floating-point maximum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.maximumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the maximum of the two arguments, treating -0.0 as less than +0.0.
     If one of the arguments is NaN, then the result is also NaN.
 
@@ -864,12 +858,6 @@ def Arith_MaximumFOp : Arith_FloatBinaryOp<"maximumf", [Commutative]> {
 def Arith_MaxNumFOp : Arith_FloatBinaryOp<"maxnumf", [Commutative]> {
   let summary = "floating-point maximum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.maxnumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the maximum of the two arguments.
     If the arguments are -0.0 and +0.0, then the result is either of them.
     If one of the arguments is NaN, then the result is the other argument.
@@ -910,12 +898,6 @@ def Arith_MaxUIOp : Arith_TotalIntBinaryOp<"maxui", [Commutative]> {
 def Arith_MinimumFOp : Arith_FloatBinaryOp<"minimumf", [Commutative]> {
   let summary = "floating-point minimum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.minimumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the minimum of the two arguments, treating -0.0 as less than +0.0.
     If one of the arguments is NaN, then the result is also NaN.
 
@@ -936,12 +918,6 @@ def Arith_MinimumFOp : Arith_FloatBinaryOp<"minimumf", [Commutative]> {
 def Arith_MinNumFOp : Arith_FloatBinaryOp<"minnumf", [Commutative]> {
   let summary = "floating-point minimum operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `arith.minnumf` ssa-use `,` ssa-use `:` type
-    ```
-
     Returns the minimum of the two arguments.
     If the arguments are -0.0 and +0.0, then the result is either of them.
     If one of the arguments is NaN, then the result is the other argument.
diff --git a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
index a829fa88efa893e..ada6c14b5b71354 100644
--- a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
+++ b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
@@ -280,12 +280,6 @@ def ExpOp : ComplexUnaryOp<"exp", [SameOperandsAndResultType]> {
 def Expm1Op : ComplexUnaryOp<"expm1", [SameOperandsAndResultType]> {
   let summary = "computes exponential of a complex number minus 1";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `complex.expm1` ssa-use `:` type
-    ```
-
     complex.expm1(x) := complex.exp(x) - 1
 
     Example:
diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
index 657f601aad2f5a1..c71517666b609c2 100644
--- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
+++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
@@ -447,12 +447,6 @@ def MemRef_CastOp : MemRef_Op<"cast", [
     ]> {
   let summary = "memref cast operation";
   let description = [{
-    Syntax:
-
-    ```
-    operation ::= ssa-id `=` `memref.cast` ssa-use `:` type `to` type
-    ```
-
     The `memref.cast` operation converts a memref from one type to an equivalent
     type with a compatible shape. The source and destination types are
     compatible if:
diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
index 1397d4caf1d9d61..afc9d532f6e31bb 100644
--- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
+++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
@@ -2203,12 +2203,6 @@ def Vector_TypeCastOp :
     super-vectorization operational. It can be seen as a special case of the
     `view` operation but scoped in the super-vectorization context.
 
-    Syntax:
-
-    ```
-    operation ::= `vector.type_cast` ssa-use : memref-type to memref-type
-    ```
-
     Example:
 
     ```mlir

@kuhar
Copy link
Member

kuhar commented Nov 24, 2023

Good idea, we should also do something similar in the SPIR-V dialect. @antiagainst @qedawkins

@rikhuijzer rikhuijzer merged commit c8f6bb4 into llvm:main Nov 25, 2023
@rikhuijzer rikhuijzer deleted the rh/rm-duplicate-syntax-descr branch November 25, 2023 08:33
rikhuijzer added a commit that referenced this pull request Nov 27, 2023
Some operations defined their syntax both in the documentation and via
`assemblyFormat`. This leads to two syntax descriptions in the
documentation for SPIR-V, see for example the documentation for
[`spirv.mlir.yield`](https://mlir.llvm.org/docs/Dialects/SPIR-V/#spirvmliryield-spirvyieldop).
Since the `assemblyFormat` is used to generate the actual parsers and
printer implementations, this PR removes the manual syntax descriptions.
(Similar to #73343.)

The strategy that I used to find the duplicates was pretty
uncomplicated. I scrolled through the [SPIR-V
Dialect](https://mlir.llvm.org/docs/Dialects/SPIR-V) to find all
duplicates and then remove the duplicate text from the `td` file.

Note that the `Syntax:` block in the docs is a good proxy for whether
`assemblyFormat` is defined because it will only be generated if the op
has defined `assemblyFormat` (`op.hasAssemblyFormat()`):


https://github.com/llvm/llvm-project/blob/e970652776bd07dbe42be557bf98722749230653/mlir/tools/mlir-tblgen/OpDocGen.cpp#L108-L124


https://github.com/llvm/llvm-project/blob/e970652776bd07dbe42be557bf98722749230653/mlir/tools/mlir-tblgen/OpDocGen.cpp#L197-L199

Related issue #73359.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants