| 1 |
/// Test LoongArch64 ABI rewrite of struct passed and returned by value (BIND(C), VALUE derived types). |
| 2 |
/// This test test cases where the struct must be passed or returned on the stack. |
| 3 |
|
| 4 |
// RUN: tco --target=loongarch64-unknown-linux-gnu %s | FileCheck %s |
| 5 |
|
| 6 |
!ty_int_toobig = !fir.type<int_toobig{i:!fir.array<5xi32>}> |
| 7 |
!ty_int_toobig_align16 = !fir.type<int_toobig_align16{i:i128,j:i8}> |
| 8 |
!ty_fp_toobig = !fir.type<fp_toobig{i:!fir.array<5xf64>}> |
| 9 |
!ty_fp_toobig_align16 = !fir.type<fp_toobig_align16{i:f128,j:f32}> |
| 10 |
|
| 11 |
!ty_i32_f32 = !fir.type<i32_f32{i:i32,j:f32}> |
| 12 |
!ty_nested_toobig = !fir.type<nested_toobig{i:!fir.array<3x!ty_i32_f32>}> |
| 13 |
!ty_badly_aligned = !fir.type<badly_aligned{i:f32,j:f64,k:f32}> |
| 14 |
!ty_logical_toobig = !fir.type<logical_toobig{i:!fir.array<17x!fir.logical<1>>}> |
| 15 |
!ty_cmplx_toobig = !fir.type<cmplx_toobig{i:!fir.array<4xcomplex<f32>>}> |
| 16 |
!ty_char_toobig = !fir.type<char_toobig{i:!fir.array<17x!fir.char<1>>}> |
| 17 |
!ty_cmplx_f128 = !fir.type<cmplx_f128{i:complex<f128>}> |
| 18 |
|
| 19 |
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128", llvm.target_triple = "loongarch64-unknown-linux-gnu"} { |
| 20 |
|
| 21 |
// CHECK: declare void @takes_int_toobig(ptr byval(%int_toobig) align 4) |
| 22 |
func.func private @takes_int_toobig(%arg0: !ty_int_toobig) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 23 |
// CHECK: declare void @return_int_toobig(ptr sret(%int_toobig) align 4) |
| 24 |
func.func private @return_int_toobig() -> !ty_int_toobig attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 25 |
|
| 26 |
// CHECK: declare void @takes_int_toobig_align16(ptr byval(%int_toobig_align16) align 16) |
| 27 |
func.func private @takes_int_toobig_align16(%arg0: !ty_int_toobig_align16) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 28 |
// CHECK: declare void @return_int_toobig_align16(ptr sret(%int_toobig_align16) align 16) |
| 29 |
func.func private @return_int_toobig_align16() -> !ty_int_toobig_align16 attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 30 |
|
| 31 |
// CHECK: declare void @takes_fp_toobig(ptr byval(%fp_toobig) align 8) |
| 32 |
func.func private @takes_fp_toobig(%arg0: !ty_fp_toobig) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 33 |
// CHECK: declare void @return_fp_toobig(ptr sret(%fp_toobig) align 8) |
| 34 |
func.func private @return_fp_toobig() -> !ty_fp_toobig attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 35 |
|
| 36 |
// CHECK: declare void @takes_fp_toobig_align16(ptr byval(%fp_toobig_align16) align 16) |
| 37 |
func.func private @takes_fp_toobig_align16(%arg0: !ty_fp_toobig_align16) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 38 |
// CHECK: declare void @return_fp_toobig_align16(ptr sret(%fp_toobig_align16) align 16) |
| 39 |
func.func private @return_fp_toobig_align16() -> !ty_fp_toobig_align16 attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 40 |
|
| 41 |
// CHECK: declare void @takes_nested_toobig(ptr byval(%nested_toobig) align 4) |
| 42 |
func.func private @takes_nested_toobig(%arg0: !ty_nested_toobig) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 43 |
// CHECK: declare void @return_nested_toobig(ptr sret(%nested_toobig) align 4) |
| 44 |
func.func private @return_nested_toobig() -> !ty_nested_toobig attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 45 |
|
| 46 |
// CHECK: declare void @takes_badly_aligned(ptr byval(%badly_aligned) align 8) |
| 47 |
func.func private @takes_badly_aligned(%arg0: !ty_badly_aligned) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 48 |
// CHECK: declare void @return_badly_aligned(ptr sret(%badly_aligned) align 8) |
| 49 |
func.func private @return_badly_aligned() -> !ty_badly_aligned attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 50 |
|
| 51 |
// CHECK: declare void @takes_logical_toobig(ptr byval(%logical_toobig) align 1) |
| 52 |
func.func private @takes_logical_toobig(%arg0: !ty_logical_toobig) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 53 |
// CHECK: declare void @return_logical_toobig(ptr sret(%logical_toobig) align 1) |
| 54 |
func.func private @return_logical_toobig() -> !ty_logical_toobig attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 55 |
|
| 56 |
// CHECK: declare void @takes_cmplx_toobig(ptr byval(%cmplx_toobig) align 4) |
| 57 |
func.func private @takes_cmplx_toobig(%arg0: !ty_cmplx_toobig) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 58 |
// CHECK: declare void @return_cmplx_toobig(ptr sret(%cmplx_toobig) align 4) |
| 59 |
func.func private @return_cmplx_toobig() -> !ty_cmplx_toobig attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 60 |
|
| 61 |
// CHECK: declare void @takes_char_toobig(ptr byval(%char_toobig) align 1) |
| 62 |
func.func private @takes_char_toobig(%arg0: !ty_char_toobig) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 63 |
// CHECK: declare void @return_char_toobig(ptr sret(%char_toobig) align 1) |
| 64 |
func.func private @return_char_toobig() -> !ty_char_toobig attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 65 |
|
| 66 |
// CHECK: declare { i32, float } @takes_and_return(float, float, float, float, float, float, float, float, ptr byval(%cmplx_f128) align 16) |
| 67 |
func.func private @takes_and_return(%arg0: f32, %arg1: f32, %arg2: f32, %arg3: f32, %arg4: f32, |
| 68 |
%arg5: f32, %arg6: f32, %arg7: f32, %arg8: !ty_cmplx_f128) -> !ty_i32_f32 attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 69 |
|
| 70 |
// CHECK: declare void @takes_and_return2(ptr sret(%cmplx_f128) align 16, i32, i32, i32, i32, i32, i32, i32, i32, i64) |
| 71 |
func.func private @takes_and_return2(%arg0: i32, %arg1: i32, %arg2: i32, %arg3: i32, %arg4: i32, |
| 72 |
%arg5: i32, %arg6: i32, %arg7: i32, %arg8: !ty_i32_f32) -> !ty_cmplx_f128 attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 73 |
|
| 74 |
// CHECK: declare void @takes_multi_byval_arguments(ptr byval(%cmplx_f128) align 16, ptr byval(%cmplx_f128) align 16, ptr byval(%cmplx_f128) align 16, ptr byval(%cmplx_f128) align 16, ptr byval(%cmplx_f128) align 16, ptr byval(%cmplx_f128) align 16, ptr byval(%cmplx_f128) align 16, i32, float, i64) |
| 75 |
func.func private @takes_multi_byval_arguments(%arg0: !ty_cmplx_f128, %arg1: !ty_cmplx_f128, %arg2: !ty_cmplx_f128, %arg3: !ty_cmplx_f128, |
| 76 |
%arg4: !ty_cmplx_f128, %arg5: !ty_cmplx_f128, %arg6: !ty_cmplx_f128, |
| 77 |
%arg7: !ty_i32_f32, %arg8: !ty_i32_f32) attributes {fir.proc_attrs = #fir.proc_attrs<bind_c>} |
| 78 |
} |
| 79 |
|