[Mlir-commits] [mlir] [mlir][arith] Add printing regression tests (PR #98184)

Jacob Yu llvmlistbot at llvm.org
Thu Jul 11 09:09:23 PDT 2024


https://github.com/pingshiyu updated https://github.com/llvm/llvm-project/pull/98184

>From a5e7d258fe5f2fa4f3f4f2b9e400ba08e379c8a5 Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Tue, 9 Jul 2024 17:01:35 +0100
Subject: [PATCH 1/2] added printing fns in the new format

---
 .../Integration/Dialect/Arith/CPU/print.mlir  | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 mlir/test/Integration/Dialect/Arith/CPU/print.mlir

diff --git a/mlir/test/Integration/Dialect/Arith/CPU/print.mlir b/mlir/test/Integration/Dialect/Arith/CPU/print.mlir
new file mode 100644
index 0000000000000..d322c23952bab
--- /dev/null
+++ b/mlir/test/Integration/Dialect/Arith/CPU/print.mlir
@@ -0,0 +1,47 @@
+// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \
+// RUN:             --convert-func-to-llvm --convert-arith-to-llvm | \
+// RUN:   mlir-cpu-runner -e entry -entry-point-result=void \
+// RUN:                   --shared-libs=%mlir_c_runner_utils | \
+// RUN:   FileCheck %s --match-full-lines
+
+func.func @i1() {
+    // printing i1 values
+    // print(0 : i1) = '0'; print(1 : i1) = '1'; print(-1 : i1) = '1'
+    // CHECK:      0
+    // CHECK-NEXT: 1
+    // CHECK-NEXT: 1
+    %false = arith.constant false
+    %true = arith.constant 1 : i1
+    %true_as_n1 = arith.constant -1 : i1
+    vector.print %false : i1
+    vector.print %true : i1
+    vector.print %true_as_n1 : i1
+    return
+}
+
+func.func @index() {
+    // printing index values
+    // print(0 : index) = '0'; print(1 : index) = '1'; print(-1 : index) = '2^w - 1'
+    // index constants are printed as unsigned
+    // vector.print(arith.constant(x)) ~= toUnsignedRepr x
+    // CHECK-NEXT: 0
+    // CHECK-NEXT: 1
+    // CHECK-NEXT: 18446744073709551615
+    // CHECK-NEXT: 63
+    %c0 = arith.constant 0 : index
+    %c1 = arith.constant 1 : index
+    %cn1 = arith.constant -1 : index
+    %c63 = arith.constant 63 : index
+
+    vector.print %c0 : index
+    vector.print %c1 : index
+    vector.print %cn1 : index
+    vector.print %c63 : index
+    return
+}
+
+func.func @entry() {
+    func.call @i1() : () -> ()
+    func.call @index() : () -> ()
+    return
+}

>From 77676a3db8b46d40d0ad3b7f9ff1177985f1068a Mon Sep 17 00:00:00 2001
From: pingshiyu <pingshiyu at gmail.com>
Date: Thu, 11 Jul 2024 17:09:12 +0100
Subject: [PATCH 2/2] reindented

---
 .../Integration/Dialect/Arith/CPU/print.mlir  | 64 +++++++++----------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/mlir/test/Integration/Dialect/Arith/CPU/print.mlir b/mlir/test/Integration/Dialect/Arith/CPU/print.mlir
index d322c23952bab..b5f6bf4f9674e 100644
--- a/mlir/test/Integration/Dialect/Arith/CPU/print.mlir
+++ b/mlir/test/Integration/Dialect/Arith/CPU/print.mlir
@@ -5,43 +5,43 @@
 // RUN:   FileCheck %s --match-full-lines
 
 func.func @i1() {
-    // printing i1 values
-    // print(0 : i1) = '0'; print(1 : i1) = '1'; print(-1 : i1) = '1'
-    // CHECK:      0
-    // CHECK-NEXT: 1
-    // CHECK-NEXT: 1
-    %false = arith.constant false
-    %true = arith.constant 1 : i1
-    %true_as_n1 = arith.constant -1 : i1
-    vector.print %false : i1
-    vector.print %true : i1
-    vector.print %true_as_n1 : i1
-    return
+  // printing i1 values
+  // print(0 : i1) = '0'; print(1 : i1) = '1'; print(-1 : i1) = '1'
+  // CHECK:      0
+  // CHECK-NEXT: 1
+  // CHECK-NEXT: 1
+  %false = arith.constant false
+  %true = arith.constant 1 : i1
+  %true_as_n1 = arith.constant -1 : i1
+  vector.print %false : i1
+  vector.print %true : i1
+  vector.print %true_as_n1 : i1
+  return
 }
 
 func.func @index() {
-    // printing index values
-    // print(0 : index) = '0'; print(1 : index) = '1'; print(-1 : index) = '2^w - 1'
-    // index constants are printed as unsigned
-    // vector.print(arith.constant(x)) ~= toUnsignedRepr x
-    // CHECK-NEXT: 0
-    // CHECK-NEXT: 1
-    // CHECK-NEXT: 18446744073709551615
-    // CHECK-NEXT: 63
-    %c0 = arith.constant 0 : index
-    %c1 = arith.constant 1 : index
-    %cn1 = arith.constant -1 : index
-    %c63 = arith.constant 63 : index
+  // printing index values
+  // print(0 : index) = '0'; print(1 : index) = '1'; print(-1 : index) = '2^w - 1'
+  // index constants are printed as unsigned
+  // vector.print(arith.constant(x)) ~= toUnsignedRepr x
+  // CHECK-NEXT: 0
+  // CHECK-NEXT: 1
+  // CHECK-NEXT: 18446744073709551615
+  // CHECK-NEXT: 63
+  %c0 = arith.constant 0 : index
+  %c1 = arith.constant 1 : index
+  %cn1 = arith.constant -1 : index
+  %c63 = arith.constant 63 : index
 
-    vector.print %c0 : index
-    vector.print %c1 : index
-    vector.print %cn1 : index
-    vector.print %c63 : index
-    return
+  vector.print %c0 : index
+  vector.print %c1 : index
+  vector.print %cn1 : index
+  vector.print %c63 : index
+  return
 }
 
 func.func @entry() {
-    func.call @i1() : () -> ()
-    func.call @index() : () -> ()
-    return
+  func.call @i1() : () -> ()
+  func.call @index() : () -> ()
+  return
 }



More information about the Mlir-commits mailing list