1 // RUN: mlir-cpu-runner %s %if target={{s390x-.*}} %{ -argext-abi-check=false %} \
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
13 // RUN: mlir-cpu-runner %t -dump-object-file %if target={{s390x-.*}} \
14 // RUN: %{ -argext-abi-check=false %} | FileCheck %t
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
23 // Declarations of C library functions.
24 llvm.func @logbf(f32) -> f32
25 llvm.func @malloc(i64) -> !llvm.ptr
26 llvm.func @free(!llvm.ptr)
28 // Check that a simple function with a nested call works.
29 llvm.func @main() -> f32 {
30 %0 = llvm.mlir.constant(-4.200000e+02 : f32) : f32
31 %1 = llvm.call @logbf(%0) : (f32) -> f32
34 // CHECK: 8.000000e+00
36 // Helper typed functions wrapping calls to "malloc" and "free".
37 llvm.func @allocation() -> !llvm.ptr {
38 %0 = llvm.mlir.constant(4 : index) : i64
39 %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr
40 llvm.return %1 : !llvm.ptr
42 llvm.func @deallocation(%arg0: !llvm.ptr) {
43 llvm.call @free(%arg0) : (!llvm.ptr) -> ()
47 // Check that allocation and deallocation works, and that a custom entry point
49 llvm.func @foo() -> f32 {
50 %0 = llvm.call @allocation() : () -> !llvm.ptr
51 %1 = llvm.mlir.constant(0 : index) : i64
52 %2 = llvm.mlir.constant(1.234000e+03 : f32) : f32
53 %3 = llvm.getelementptr %0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32
54 llvm.store %2, %3 : f32, !llvm.ptr
55 %4 = llvm.getelementptr %0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32
56 %5 = llvm.load %4 : !llvm.ptr -> f32
57 llvm.call @deallocation(%0) : (!llvm.ptr) -> ()
60 // NOMAIN: 1.234000e+03
62 // Check that i32 return type works
63 llvm.func @int32_main() -> i32 {
64 %0 = llvm.mlir.constant(42 : i32) : i32
69 // Check that i64 return type works
70 llvm.func @int64_main() -> i64 {
71 %0 = llvm.mlir.constant(42 : i64) : i64