[Mlir-commits] [mlir] 56a275b - [mlir] make Math dialect depend on Arith dialect

Alex Zinenko llvmlistbot at llvm.org
Tue Apr 11 03:34:59 PDT 2023


Author: Alex Zinenko
Date: 2023-04-11T12:34:51+02:00
New Revision: 56a275b99902ef8423a5e2fb3f827bfbfbd7df80

URL: https://github.com/llvm/llvm-project/commit/56a275b99902ef8423a5e2fb3f827bfbfbd7df80
DIFF: https://github.com/llvm/llvm-project/commit/56a275b99902ef8423a5e2fb3f827bfbfbd7df80.diff

LOG: [mlir] make Math dialect depend on Arith dialect

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

Added: 
    mlir/test/Dialect/Math/dependent-dialect.mlir

Modified: 
    mlir/include/mlir/Dialect/Math/IR/MathBase.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Math/IR/MathBase.td b/mlir/include/mlir/Dialect/Math/IR/MathBase.td
index 0189fd538b496..0e606bb9b63dd 100644
--- a/mlir/include/mlir/Dialect/Math/IR/MathBase.td
+++ b/mlir/include/mlir/Dialect/Math/IR/MathBase.td
@@ -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
index 0000000000000..1f88258a349c8
--- /dev/null
+++ b/mlir/test/Dialect/Math/dependent-dialect.mlir
@@ -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"() : () -> ()
+}) : () -> ()


        


More information about the Mlir-commits mailing list