[Mlir-commits] [mlir] [MLIR] Add SystemZ arg extensions for some tests (PR #116314)
Jonas Paulsson
llvmlistbot at llvm.org
Tue Nov 19 08:28:04 PST 2024
https://github.com/JonPsson1 updated https://github.com/llvm/llvm-project/pull/116314
>From 1c500363c6d7f737480be17a580e612873de1e97 Mon Sep 17 00:00:00 2001
From: Jonas Paulsson <paulson1 at linux.ibm.com>
Date: Fri, 15 Nov 2024 01:44:36 +0100
Subject: [PATCH 1/3] Fix arg exts for tests
---
mlir/test/CAPI/execution_engine.c | 4 ++++
mlir/test/mlir-cpu-runner/simple.mlir | 14 +++++++-------
mlir/unittests/ExecutionEngine/Invoke.cpp | 21 +++++++++++++++++++++
3 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/mlir/test/CAPI/execution_engine.c b/mlir/test/CAPI/execution_engine.c
index 18120c6ec802801..4751288c3ee4bd1 100644
--- a/mlir/test/CAPI/execution_engine.c
+++ b/mlir/test/CAPI/execution_engine.c
@@ -55,7 +55,11 @@ void testSimpleExecution(void) {
ctx, mlirStringRefCreateFromCString(
// clang-format off
"module { \n"
+#ifdef __s390__
+" func.func @add(%arg0 : i32) -> (i32 {llvm.signext}) attributes { llvm.emit_c_interface } { \n"
+#else
" func.func @add(%arg0 : i32) -> i32 attributes { llvm.emit_c_interface } { \n"
+#endif
" %res = arith.addi %arg0, %arg0 : i32 \n"
" return %res : i32 \n"
" } \n"
diff --git a/mlir/test/mlir-cpu-runner/simple.mlir b/mlir/test/mlir-cpu-runner/simple.mlir
index 38d9dcaf553714f..dc283e76219f092 100644
--- a/mlir/test/mlir-cpu-runner/simple.mlir
+++ b/mlir/test/mlir-cpu-runner/simple.mlir
@@ -1,15 +1,15 @@
-// RUN: mlir-cpu-runner %s | FileCheck %s
-// RUN: mlir-cpu-runner %s -e foo | FileCheck -check-prefix=NOMAIN %s
-// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main | FileCheck -check-prefix=INT32MAIN %s
-// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main | FileCheck -check-prefix=INT64MAIN %s
-// RUN: mlir-cpu-runner %s -O3 | FileCheck %s
+// RUN: mlir-cpu-runner %s -argext-abi-check=false | FileCheck %s
+// RUN: mlir-cpu-runner %s -e foo -argext-abi-check=false | FileCheck -check-prefix=NOMAIN %s
+// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main -argext-abi-check=false | FileCheck -check-prefix=INT32MAIN %s
+// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main -argext-abi-check=false | FileCheck -check-prefix=INT64MAIN %s
+// RUN: mlir-cpu-runner %s -O3 -argext-abi-check=false | FileCheck %s
// RUN: cp %s %t
-// RUN: mlir-cpu-runner %t -dump-object-file | FileCheck %t
+// RUN: mlir-cpu-runner %t -dump-object-file -argext-abi-check=false | FileCheck %t
// RUN: ls %t.o
// RUN: rm %t.o
-// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o | FileCheck %s
+// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o -argext-abi-check=false | FileCheck %s
// RUN: ls %T/test.o
// RUN: rm %T/test.o
diff --git a/mlir/unittests/ExecutionEngine/Invoke.cpp b/mlir/unittests/ExecutionEngine/Invoke.cpp
index ff87fc9fad805ab..887db227cfc4b2e 100644
--- a/mlir/unittests/ExecutionEngine/Invoke.cpp
+++ b/mlir/unittests/ExecutionEngine/Invoke.cpp
@@ -61,12 +61,21 @@ static LogicalResult lowerToLLVMDialect(ModuleOp module) {
}
TEST(MLIRExecutionEngine, SKIP_WITHOUT_JIT(AddInteger)) {
+#ifdef __s390__
+ std::string moduleStr = R"mlir(
+ func.func @foo(%arg0 : i32 {llvm.signext}) -> (i32 {llvm.signext}) attributes { llvm.emit_c_interface } {
+ %res = arith.addi %arg0, %arg0 : i32
+ return %res : i32
+ }
+ )mlir";
+#else
std::string moduleStr = R"mlir(
func.func @foo(%arg0 : i32) -> i32 attributes { llvm.emit_c_interface } {
%res = arith.addi %arg0, %arg0 : i32
return %res : i32
}
)mlir";
+#endif
DialectRegistry registry;
registerAllDialects(registry);
registerBuiltinDialectTranslation(registry);
@@ -259,6 +268,16 @@ TEST(NativeMemRefJit, MAYBE_JITCallback) {
for (float &elt : *a)
elt = count++;
+#ifdef __s390__
+ std::string moduleStr = R"mlir(
+ func.func private @callback(%arg0: memref<?x?xf32>, %coefficient: i32 {llvm.signext}) attributes { llvm.emit_c_interface }
+ func.func @caller_for_callback(%arg0: memref<?x?xf32>, %coefficient: i32 {llvm.signext}) attributes { llvm.emit_c_interface } {
+ %unranked = memref.cast %arg0: memref<?x?xf32> to memref<*xf32>
+ call @callback(%arg0, %coefficient) : (memref<?x?xf32>, i32) -> ()
+ return
+ }
+ )mlir";
+#else
std::string moduleStr = R"mlir(
func.func private @callback(%arg0: memref<?x?xf32>, %coefficient: i32) attributes { llvm.emit_c_interface }
func.func @caller_for_callback(%arg0: memref<?x?xf32>, %coefficient: i32) attributes { llvm.emit_c_interface } {
@@ -267,6 +286,8 @@ TEST(NativeMemRefJit, MAYBE_JITCallback) {
return
}
)mlir";
+#endif
+
DialectRegistry registry;
registerAllDialects(registry);
registerBuiltinDialectTranslation(registry);
>From 67e3a565f9d962231623de46acf3257d1704702f Mon Sep 17 00:00:00 2001
From: Jonas Paulsson <paulson1 at linux.ibm.com>
Date: Mon, 18 Nov 2024 13:08:32 -0600
Subject: [PATCH 2/3] Use %if in simple.mlir
---
mlir/test/mlir-cpu-runner/simple.mlir | 48 ++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 8 deletions(-)
diff --git a/mlir/test/mlir-cpu-runner/simple.mlir b/mlir/test/mlir-cpu-runner/simple.mlir
index dc283e76219f092..d1cb1cfe5d6517d 100644
--- a/mlir/test/mlir-cpu-runner/simple.mlir
+++ b/mlir/test/mlir-cpu-runner/simple.mlir
@@ -1,15 +1,47 @@
-// RUN: mlir-cpu-runner %s -argext-abi-check=false | FileCheck %s
-// RUN: mlir-cpu-runner %s -e foo -argext-abi-check=false | FileCheck -check-prefix=NOMAIN %s
-// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main -argext-abi-check=false | FileCheck -check-prefix=INT32MAIN %s
-// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main -argext-abi-check=false | FileCheck -check-prefix=INT64MAIN %s
-// RUN: mlir-cpu-runner %s -O3 -argext-abi-check=false | FileCheck %s
+// RUN: %if target={{s390x-.*}} %{ \
+// RUN: mlir-cpu-runner %s -argext-abi-check=false | FileCheck %s \
+// RUN: %} %else %{ \
+// RUN: mlir-cpu-runner %s | FileCheck %s \
+// RUN: %}
+
+// RUN: %if target={{s390x-.*}} %{ \
+// RUN: mlir-cpu-runner %s -e foo -argext-abi-check=false | FileCheck -check-prefix=NOMAIN %s \
+// RUN: %} %else %{ \
+// RUN: mlir-cpu-runner %s -e foo | FileCheck -check-prefix=NOMAIN %s \
+// RUN: %}
+
+// RUN: %if target={{s390x-.*}} %{ \
+// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main -argext-abi-check=false | FileCheck -check-prefix=INT32MAIN %s \
+// RUN: %} %else %{ \
+// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main | FileCheck -check-prefix=INT32MAIN %s \
+// RUN: %}
+
+// RUN: %if target={{s390x-.*}} %{ \
+// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main -argext-abi-check=false | FileCheck -check-prefix=INT64MAIN %s \
+// RUN: %} %else %{ \
+// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main | FileCheck -check-prefix=INT64MAIN %s \
+// RUN: %}
+
+// RUN: %if target={{s390x-.*}} %{ \
+// RUN: mlir-cpu-runner %s -O3 -argext-abi-check=false | FileCheck %s \
+// RUN: %} %else %{ \
+// RUN: mlir-cpu-runner %s -O3 | FileCheck %s \
+// RUN: %}
// RUN: cp %s %t
-// RUN: mlir-cpu-runner %t -dump-object-file -argext-abi-check=false | FileCheck %t
+// RUN: %if target={{s390x-.*}} %{ \
+// RUN: mlir-cpu-runner %t -dump-object-file -argext-abi-check=false | FileCheck %t \
+// RUN: %} %else %{ \
+// RUN: mlir-cpu-runner %t -dump-object-file | FileCheck %t \
+// RUN: %}
+
// RUN: ls %t.o
// RUN: rm %t.o
-
-// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o -argext-abi-check=false | FileCheck %s
+// RUN: %if target={{s390x-.*}} %{ \
+// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o -argext-abi-check=false | FileCheck %s \
+// RUN: %} %else %{ \
+// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o | FileCheck %s \
+// RUN: %}
// RUN: ls %T/test.o
// RUN: rm %T/test.o
>From f6bf3e0329c6b08d6689a789d84cc143191de7e5 Mon Sep 17 00:00:00 2001
From: Jonas Paulsson <paulson1 at linux.ibm.com>
Date: Tue, 19 Nov 2024 10:25:24 -0600
Subject: [PATCH 3/3] Rework uses of %if
---
mlir/test/mlir-cpu-runner/simple.mlir | 55 ++++++++-------------------
1 file changed, 15 insertions(+), 40 deletions(-)
diff --git a/mlir/test/mlir-cpu-runner/simple.mlir b/mlir/test/mlir-cpu-runner/simple.mlir
index d1cb1cfe5d6517d..f7f73d17d8282b2 100644
--- a/mlir/test/mlir-cpu-runner/simple.mlir
+++ b/mlir/test/mlir-cpu-runner/simple.mlir
@@ -1,47 +1,22 @@
-// RUN: %if target={{s390x-.*}} %{ \
-// RUN: mlir-cpu-runner %s -argext-abi-check=false | FileCheck %s \
-// RUN: %} %else %{ \
-// RUN: mlir-cpu-runner %s | FileCheck %s \
-// RUN: %}
-
-// RUN: %if target={{s390x-.*}} %{ \
-// RUN: mlir-cpu-runner %s -e foo -argext-abi-check=false | FileCheck -check-prefix=NOMAIN %s \
-// RUN: %} %else %{ \
-// RUN: mlir-cpu-runner %s -e foo | FileCheck -check-prefix=NOMAIN %s \
-// RUN: %}
-
-// RUN: %if target={{s390x-.*}} %{ \
-// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main -argext-abi-check=false | FileCheck -check-prefix=INT32MAIN %s \
-// RUN: %} %else %{ \
-// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main | FileCheck -check-prefix=INT32MAIN %s \
-// RUN: %}
-
-// RUN: %if target={{s390x-.*}} %{ \
-// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main -argext-abi-check=false | FileCheck -check-prefix=INT64MAIN %s \
-// RUN: %} %else %{ \
-// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main | FileCheck -check-prefix=INT64MAIN %s \
-// RUN: %}
-
-// RUN: %if target={{s390x-.*}} %{ \
-// RUN: mlir-cpu-runner %s -O3 -argext-abi-check=false | FileCheck %s \
-// RUN: %} %else %{ \
-// RUN: mlir-cpu-runner %s -O3 | FileCheck %s \
-// RUN: %}
+// RUN: mlir-cpu-runner %s %if target={{s390x-.*}} %{ -argext-abi-check=false %} \
+// RUN: | FileCheck %s
+// RUN: mlir-cpu-runner %s -e foo %if target={{s390x-.*}} %{ -argext-abi-check=false %} \
+// RUN: | FileCheck -check-prefix=NOMAIN %s
+// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main %if target={{s390x-.*}} \
+// RUN: %{ -argext-abi-check=false %} | FileCheck -check-prefix=INT32MAIN %s
+// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main %if target={{s390x-.*}} \
+// RUN: %{ -argext-abi-check=false %} | FileCheck -check-prefix=INT64MAIN %s
+// RUN: mlir-cpu-runner %s -O3 %if target={{s390x-.*}} %{ -argext-abi-check=false %} \
+// RUN: | FileCheck %s
// RUN: cp %s %t
-// RUN: %if target={{s390x-.*}} %{ \
-// RUN: mlir-cpu-runner %t -dump-object-file -argext-abi-check=false | FileCheck %t \
-// RUN: %} %else %{ \
-// RUN: mlir-cpu-runner %t -dump-object-file | FileCheck %t \
-// RUN: %}
-
+// RUN: mlir-cpu-runner %t -dump-object-file %if target={{s390x-.*}} \
+// RUN: %{ -argext-abi-check=false %} | FileCheck %t
// RUN: ls %t.o
// RUN: rm %t.o
-// RUN: %if target={{s390x-.*}} %{ \
-// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o -argext-abi-check=false | FileCheck %s \
-// RUN: %} %else %{ \
-// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o | FileCheck %s \
-// RUN: %}
+
+// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o \
+// RUN: %if target={{s390x-.*}} %{ -argext-abi-check=false %} | FileCheck %s
// RUN: ls %T/test.o
// RUN: rm %T/test.o
More information about the Mlir-commits
mailing list