[mlir] make Math dialect depend on Arith dialect
authorAlex Zinenko <zinenko@google.com>
Tue, 11 Apr 2023 08:41:29 +0000 (10:41 +0200)
committerAlex Zinenko <zinenko@google.com>
Tue, 11 Apr 2023 10:34:51 +0000 (12:34 +0200)
Ops from the Math dialect use fastmath attributes defined in Arith.
Therefore Math dialect must declare a dependency on Arith for proper
construction and parsing.

Reviewed By: tpopp

Differential Revision: https://reviews.llvm.org/D147999

mlir/include/mlir/Dialect/Math/IR/MathBase.td
mlir/test/Dialect/Math/dependent-dialect.mlir [new file with mode: 0644]

index 0189fd5..0e606bb 100644 (file)
@@ -30,5 +30,8 @@ def Math_Dialect : Dialect {
     ```
   }];
   let hasConstantMaterializer = 1;
+  let dependentDialects = [
+    "::mlir::arith::ArithDialect"
+  ];
 }
 #endif // MATH_BASE
diff --git a/mlir/test/Dialect/Math/dependent-dialect.mlir b/mlir/test/Dialect/Math/dependent-dialect.mlir
new file mode 100644 (file)
index 0000000..1f88258
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: mlir-opt %s --mlir-print-op-generic | FileCheck %s
+
+// Check that math.atan can be constructed by parsing and the fastmath
+// attribute can be created. This requires math dialect to depend on arith
+// dialect. Note that we don't want other dialects in here as they may
+// transitively depend on arith and load it even if math doesn't.
+
+"test.some_op_with_region"() ({
+^bb0(%arg0: f64):
+  // CHECK: #arith.fastmath<none>
+  math.atan %arg0 : f64
+  "test.possible_terminator"() : () -> ()
+}) : () -> ()