Skip to content

Commit 0d9dc42

Browse files
authored
[MLIR] Add SystemZ arg extensions for some tests (#116314)
The SystemZ ABI requires that i32 values should be extended when passed between functions. This patch fixes some tests that were lacking this, either by adding some SystemZ specific inlinings of test functions or by disabling the verification of this with the CL option controlling this. Fixes #115564
1 parent 30fad6a commit 0d9dc42

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

mlir/test/CAPI/execution_engine.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ void testSimpleExecution(void) {
5555
ctx, mlirStringRefCreateFromCString(
5656
// clang-format off
5757
"module { \n"
58+
#ifdef __s390__
59+
" func.func @add(%arg0 : i32) -> (i32 {llvm.signext}) attributes { llvm.emit_c_interface } { \n"
60+
#else
5861
" func.func @add(%arg0 : i32) -> i32 attributes { llvm.emit_c_interface } { \n"
62+
#endif
5963
" %res = arith.addi %arg0, %arg0 : i32 \n"
6064
" return %res : i32 \n"
6165
" } \n"

mlir/test/mlir-cpu-runner/simple.mlir

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
// RUN: mlir-cpu-runner %s | FileCheck %s
2-
// RUN: mlir-cpu-runner %s -e foo | FileCheck -check-prefix=NOMAIN %s
3-
// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main | FileCheck -check-prefix=INT32MAIN %s
4-
// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main | FileCheck -check-prefix=INT64MAIN %s
5-
// RUN: mlir-cpu-runner %s -O3 | FileCheck %s
1+
// RUN: mlir-cpu-runner %s %if target={{s390x-.*}} %{ -argext-abi-check=false %} \
2+
// RUN: | FileCheck %s
3+
// RUN: mlir-cpu-runner %s -e foo %if target={{s390x-.*}} %{ -argext-abi-check=false %} \
4+
// RUN: | FileCheck -check-prefix=NOMAIN %s
5+
// RUN: mlir-cpu-runner %s --entry-point-result=i32 -e int32_main %if target={{s390x-.*}} \
6+
// RUN: %{ -argext-abi-check=false %} | FileCheck -check-prefix=INT32MAIN %s
7+
// RUN: mlir-cpu-runner %s --entry-point-result=i64 -e int64_main %if target={{s390x-.*}} \
8+
// RUN: %{ -argext-abi-check=false %} | FileCheck -check-prefix=INT64MAIN %s
9+
// RUN: mlir-cpu-runner %s -O3 %if target={{s390x-.*}} %{ -argext-abi-check=false %} \
10+
// RUN: | FileCheck %s
611

712
// RUN: cp %s %t
8-
// RUN: mlir-cpu-runner %t -dump-object-file | FileCheck %t
13+
// RUN: mlir-cpu-runner %t -dump-object-file %if target={{s390x-.*}} \
14+
// RUN: %{ -argext-abi-check=false %} | FileCheck %t
915
// RUN: ls %t.o
1016
// RUN: rm %t.o
1117

12-
// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o | FileCheck %s
18+
// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o \
19+
// RUN: %if target={{s390x-.*}} %{ -argext-abi-check=false %} | FileCheck %s
1320
// RUN: ls %T/test.o
1421
// RUN: rm %T/test.o
1522

mlir/unittests/ExecutionEngine/Invoke.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,21 @@ static LogicalResult lowerToLLVMDialect(ModuleOp module) {
6161
}
6262

6363
TEST(MLIRExecutionEngine, SKIP_WITHOUT_JIT(AddInteger)) {
64+
#ifdef __s390__
65+
std::string moduleStr = R"mlir(
66+
func.func @foo(%arg0 : i32 {llvm.signext}) -> (i32 {llvm.signext}) attributes { llvm.emit_c_interface } {
67+
%res = arith.addi %arg0, %arg0 : i32
68+
return %res : i32
69+
}
70+
)mlir";
71+
#else
6472
std::string moduleStr = R"mlir(
6573
func.func @foo(%arg0 : i32) -> i32 attributes { llvm.emit_c_interface } {
6674
%res = arith.addi %arg0, %arg0 : i32
6775
return %res : i32
6876
}
6977
)mlir";
78+
#endif
7079
DialectRegistry registry;
7180
registerAllDialects(registry);
7281
registerBuiltinDialectTranslation(registry);
@@ -259,6 +268,16 @@ TEST(NativeMemRefJit, MAYBE_JITCallback) {
259268
for (float &elt : *a)
260269
elt = count++;
261270

271+
#ifdef __s390__
272+
std::string moduleStr = R"mlir(
273+
func.func private @callback(%arg0: memref<?x?xf32>, %coefficient: i32 {llvm.signext}) attributes { llvm.emit_c_interface }
274+
func.func @caller_for_callback(%arg0: memref<?x?xf32>, %coefficient: i32 {llvm.signext}) attributes { llvm.emit_c_interface } {
275+
%unranked = memref.cast %arg0: memref<?x?xf32> to memref<*xf32>
276+
call @callback(%arg0, %coefficient) : (memref<?x?xf32>, i32) -> ()
277+
return
278+
}
279+
)mlir";
280+
#else
262281
std::string moduleStr = R"mlir(
263282
func.func private @callback(%arg0: memref<?x?xf32>, %coefficient: i32) attributes { llvm.emit_c_interface }
264283
func.func @caller_for_callback(%arg0: memref<?x?xf32>, %coefficient: i32) attributes { llvm.emit_c_interface } {
@@ -267,6 +286,8 @@ TEST(NativeMemRefJit, MAYBE_JITCallback) {
267286
return
268287
}
269288
)mlir";
289+
#endif
290+
270291
DialectRegistry registry;
271292
registerAllDialects(registry);
272293
registerBuiltinDialectTranslation(registry);

0 commit comments

Comments
 (0)