Skip to content

Commit

Permalink
Fix arg exts for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JonPsson1 committed Nov 15, 2024
1 parent 5300ba7 commit 3addf3c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
4 changes: 4 additions & 0 deletions mlir/test/CAPI/execution_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 7 additions & 7 deletions mlir/test/mlir-cpu-runner/simple.mlir
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 21 additions & 0 deletions mlir/unittests/ExecutionEngine/Invoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 } {
Expand All @@ -267,6 +286,8 @@ TEST(NativeMemRefJit, MAYBE_JITCallback) {
return
}
)mlir";
#endif

DialectRegistry registry;
registerAllDialects(registry);
registerBuiltinDialectTranslation(registry);
Expand Down

0 comments on commit 3addf3c

Please sign in to comment.