[Mlir-commits] [mlir] [mlir][arith] Add printing regression tests (PR #98184)
Jacob Yu
llvmlistbot at llvm.org
Tue Jul 9 09:05:32 PDT 2024
https://github.com/pingshiyu created https://github.com/llvm/llvm-project/pull/98184
Printing operations regression tests, from the original larger PR that has been broken down: https://github.com/llvm/llvm-project/pull/92272
>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] 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
+}
More information about the Mlir-commits
mailing list