brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 21dabdd Raw
75 lines · plain
1// RUN: mlir-runner %s %if target={{s390x-.*}} %{ -argext-abi-check=false %} \2// RUN:   | FileCheck %s3// RUN: mlir-runner %s -e foo %if target={{s390x-.*}} %{ -argext-abi-check=false %} \4// RUN:   | FileCheck -check-prefix=NOMAIN %s5// RUN: mlir-runner %s --entry-point-result=i32 -e int32_main %if target={{s390x-.*}} \6// RUN:   %{ -argext-abi-check=false %} | FileCheck -check-prefix=INT32MAIN %s7// RUN: mlir-runner %s --entry-point-result=i64 -e int64_main %if target={{s390x-.*}} \8// RUN:   %{ -argext-abi-check=false %} | FileCheck -check-prefix=INT64MAIN %s9// RUN: mlir-runner %s -O3 %if target={{s390x-.*}} %{ -argext-abi-check=false %} \10// RUN:   | FileCheck %s11 12// RUN: cp %s %t13// RUN: mlir-runner %t -dump-object-file %if target={{s390x-.*}} \14// RUN:   %{ -argext-abi-check=false %} | FileCheck %t15// RUN: ls %t.o16// RUN: rm %t.o17 18// RUN: mlir-runner %s -dump-object-file -object-filename=%t.o \19// RUN:   %if target={{s390x-.*}} %{ -argext-abi-check=false %} | FileCheck %s20// RUN: ls %t.o21// RUN: rm %t.o22 23// Declarations of C library functions.24llvm.func @logbf(f32) -> f3225llvm.func @malloc(i64) -> !llvm.ptr26llvm.func @free(!llvm.ptr)27 28// Check that a simple function with a nested call works.29llvm.func @main() -> f32 {30  %0 = llvm.mlir.constant(-4.200000e+02 : f32) : f3231  %1 = llvm.call @logbf(%0) : (f32) -> f3232  llvm.return %1 : f3233}34// CHECK: 8.000000e+0035 36// Helper typed functions wrapping calls to "malloc" and "free".37llvm.func @allocation() -> !llvm.ptr {38  %0 = llvm.mlir.constant(4 : index) : i6439  %1 = llvm.call @malloc(%0) : (i64) -> !llvm.ptr40  llvm.return %1 : !llvm.ptr41}42llvm.func @deallocation(%arg0: !llvm.ptr) {43  llvm.call @free(%arg0) : (!llvm.ptr) -> ()44  llvm.return45}46 47// Check that allocation and deallocation works, and that a custom entry point48// works.49llvm.func @foo() -> f32 {50  %0 = llvm.call @allocation() : () -> !llvm.ptr51  %1 = llvm.mlir.constant(0 : index) : i6452  %2 = llvm.mlir.constant(1.234000e+03 : f32) : f3253  %3 = llvm.getelementptr %0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f3254  llvm.store %2, %3 : f32, !llvm.ptr55  %4 = llvm.getelementptr %0[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f3256  %5 = llvm.load %4 : !llvm.ptr -> f3257  llvm.call @deallocation(%0) : (!llvm.ptr) -> ()58  llvm.return %5 : f3259}60// NOMAIN: 1.234000e+0361 62// Check that i32 return type works63llvm.func @int32_main() -> i32 {64  %0 = llvm.mlir.constant(42 : i32) : i3265  llvm.return %0 : i3266}67// INT32MAIN: 4268 69// Check that i64 return type works70llvm.func @int64_main() -> i64 {71  %0 = llvm.mlir.constant(42 : i64) : i6472  llvm.return %0 : i6473}74// INT64MAIN: 4275