// Test AArch64 ABI rewrite of struct returned by value (BIND(C), VALUE derived types). // RUN: fir-opt --target-rewrite="target=aarch64-unknown-linux-gnu" %s | FileCheck %s !composite = !fir.type // CHECK-LABEL: func.func private @test_composite() -> !fir.array<2xi64> func.func private @test_composite() -> !composite // CHECK-LABEL: func.func @test_call_composite( // CHECK-SAME: %[[ARG0:.*]]: !fir.ref>) func.func @test_call_composite(%arg0 : !fir.ref) { // CHECK: %[[OUT:.*]] = fir.call @test_composite() : () -> !fir.array<2xi64> // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.array<2xi64> // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref>) -> !fir.ref> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr %out = fir.call @test_composite() : () -> !composite // CHECK: fir.store %[[LD]] to %[[ARG0]] : !fir.ref> fir.store %out to %arg0 : !fir.ref // CHECK: return return } !hfa_f16 = !fir.type // CHECK-LABEL: func.func private @test_hfa_f16() -> !fir.type func.func private @test_hfa_f16() -> !hfa_f16 // CHECK-LABEL: func.func @test_call_hfa_f16( // CHECK-SAME: %[[ARG0:.*]]: !fir.ref>) { func.func @test_call_hfa_f16(%arg0 : !fir.ref) { // CHECK: %[[OUT:.*]] = fir.call @test_hfa_f16() : () -> !fir.type // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref>) -> !fir.ref> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr %out = fir.call @test_hfa_f16() : () -> !hfa_f16 // CHECK: fir.store %[[LD]] to %[[ARG0]] : !fir.ref> fir.store %out to %arg0 : !fir.ref return } !hfa_f32 = !fir.type // CHECK-LABEL: func.func private @test_hfa_f32() -> !fir.type func.func private @test_hfa_f32() -> !hfa_f32 // CHECK-LABEL: func.func @test_call_hfa_f32( // CHECK-SAME: %[[ARG0:.*]]: !fir.ref>) { func.func @test_call_hfa_f32(%arg0 : !fir.ref) { // CHECK: %[[OUT:.*]] = fir.call @test_hfa_f32() : () -> !fir.type // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref>) -> !fir.ref> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr %out = fir.call @test_hfa_f32() : () -> !hfa_f32 // CHECK: fir.store %[[LD]] to %[[ARG0]] : !fir.ref> fir.store %out to %arg0 : !fir.ref return } !hfa_f64 = !fir.type // CHECK-LABEL: func.func private @test_hfa_f64() -> !fir.type func.func private @test_hfa_f64() -> !hfa_f64 // CHECK-LABEL: func.func @test_call_hfa_f64( // CHECK-SAME: %[[ARG0:.*]]: !fir.ref>) func.func @test_call_hfa_f64(%arg0 : !fir.ref) { // CHECK: %[[OUT:.*]] = fir.call @test_hfa_f64() : () -> !fir.type // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref>) -> !fir.ref> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr %out = fir.call @test_hfa_f64() : () -> !hfa_f64 // CHECK: fir.store %[[LD]] to %[[ARG0]] : !fir.ref> fir.store %out to %arg0 : !fir.ref return } !hfa_f128 = !fir.type // CHECK-LABEL: func.func private @test_hfa_f128() -> !fir.type func.func private @test_hfa_f128() -> !hfa_f128 // CHECK-LABEL: func.func @test_call_hfa_f128( // CHECK-SAME: %[[ARG0:.*]]: !fir.ref>) { func.func @test_call_hfa_f128(%arg0 : !fir.ref) { // CHECK: %[[OUT:.*]] = fir.call @test_hfa_f128() : () -> !fir.type // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref>) -> !fir.ref> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr %out = fir.call @test_hfa_f128() : () -> !hfa_f128 // CHECK: fir.store %[[LD]] to %[[ARG0]] : !fir.ref> fir.store %out to %arg0 : !fir.ref return } !hfa_bf16 = !fir.type // CHECK-LABEL: func.func private @test_hfa_bf16() -> !fir.type func.func private @test_hfa_bf16() -> !hfa_bf16 // CHECK-LABEL: func.func @test_call_hfa_bf16( // CHECK-SAME: %[[ARG0:.*]]: !fir.ref>) { func.func @test_call_hfa_bf16(%arg0 : !fir.ref) { // CHECK: %[[OUT:.*]] = fir.call @test_hfa_bf16() : () -> !fir.type // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref>) -> !fir.ref> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr %out = fir.call @test_hfa_bf16() : () -> !hfa_bf16 // CHECK: fir.store %[[LD]] to %[[ARG0]] : !fir.ref> fir.store %out to %arg0 : !fir.ref return } !too_big = !fir.type // CHECK-LABEL: func.func private @test_too_big(!fir.ref> // CHECK-SAME: {llvm.align = 8 : i32, llvm.sret = !fir.type}) func.func private @test_too_big() -> !too_big // CHECK-LABEL: func.func @test_call_too_big( // CHECK-SAME: %[[ARG0:.*]]: !fir.ref>) { func.func @test_call_too_big(%arg0 : !fir.ref) { // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARG:.*]] = fir.alloca !fir.type // CHECK: fir.call @test_too_big(%[[ARG]]) : (!fir.ref> {llvm.align = 8 : i32, llvm.sret = !fir.type}) -> () // CHECK: %[[CVT:.*]] = fir.convert %[[ARG]] : (!fir.ref>) -> !fir.ref> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr %out = fir.call @test_too_big() : () -> !too_big // CHECK: fir.store %[[LD]] to %[[ARG0]] : !fir.ref> fir.store %out to %arg0 : !fir.ref return } !too_big_hfa = !fir.type}> // CHECK-LABEL: func.func private @test_too_big_hfa(!fir.ref}>> // CHECK-SAME: {llvm.align = 8 : i32, llvm.sret = !fir.type}>}) func.func private @test_too_big_hfa() -> !too_big_hfa // CHECK-LABEL: func.func @test_call_too_big_hfa( // CHECK-SAME: %[[ARG0:.*]]: !fir.ref}>>) { func.func @test_call_too_big_hfa(%arg0 : !fir.ref) { // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARG:.*]] = fir.alloca !fir.type}> // CHECK: fir.call @test_too_big_hfa(%[[ARG]]) : (!fir.ref}>> {llvm.align = 8 : i32, llvm.sret = !fir.type}>}) -> () // CHECK: %[[CVT:.*]] = fir.convert %[[ARG]] : (!fir.ref}>>) -> !fir.ref}>> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref}>> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr %out = fir.call @test_too_big_hfa() : () -> !too_big_hfa // CHECK: fir.store %[[LD]] to %[[ARG0]] : !fir.ref}>> fir.store %out to %arg0 : !fir.ref return } !nested_hfa_first = !fir.type // CHECK-LABEL: func.func private @test_nested_hfa_first() -> !fir.type,c:f16}> func.func private @test_nested_hfa_first() -> !nested_hfa_first // CHECK-LABEL: func.func @test_call_nested_hfa_first(%arg0: !fir.ref,c:f16}>>) { func.func @test_call_nested_hfa_first(%arg0 : !fir.ref) { %out = fir.call @test_nested_hfa_first() : () -> !nested_hfa_first // CHECK: %[[OUT:.*]] = fir.call @test_nested_hfa_first() : () -> !fir.type,c:f16}> // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type,c:f16}> // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref,c:f16}>> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref,c:f16}>> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref,c:f16}>> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr fir.store %out to %arg0 : !fir.ref // CHECK fir.store %[[LD]] to %[[ARG0]] : !fir.ref,c:f16}>> return } !nested_hfa_middle = !fir.type // CHECK-LABEL: func.func private @test_nested_hfa_middle() -> !fir.type,c:f16}> func.func private @test_nested_hfa_middle() -> !nested_hfa_middle // CHECK-LABEL: func.func @test_call_nested_hfa_middle(%arg0: !fir.ref,c:f16}>>) { func.func @test_call_nested_hfa_middle(%arg0 : !fir.ref) { %out = fir.call @test_nested_hfa_middle() : () -> !nested_hfa_middle // CHECK: %[[OUT:.*]] = fir.call @test_nested_hfa_middle() : () -> !fir.type,c:f16}> // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type,c:f16}> // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref,c:f16}>> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref,c:f16}>> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref,c:f16}>> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr fir.store %out to %arg0 : !fir.ref // CHECK fir.store %[[LD]] to %[[ARG0]] : !fir.ref,c:f16}>> return } !nested_hfa_end = !fir.type // CHECK-LABEL: func.func private @test_nested_hfa_end() -> !fir.type}> func.func private @test_nested_hfa_end() -> !nested_hfa_end // CHECK-LABEL: func.func @test_call_nested_hfa_end(%arg0: !fir.ref}>>) { func.func @test_call_nested_hfa_end(%arg0 : !fir.ref) { %out = fir.call @test_nested_hfa_end() : () -> !nested_hfa_end // CHECK: %[[OUT:.*]] = fir.call @test_nested_hfa_end() : () -> !fir.type}> // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type}> // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref}>> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref}>> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref}>> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr fir.store %out to %arg0 : !fir.ref // CHECK fir.store %[[LD]] to %[[ARG0]] : !fir.ref}>> return } !nested_hfa_array = !fir.type,b:f32}> // CHECK-LABEL: func.func private @test_nested_hfa_array() -> !fir.type,b:f32}> func.func private @test_nested_hfa_array() -> !nested_hfa_array // CHECK-LABEL: func.func @test_call_nested_hfa_array(%arg0: !fir.ref,b:f32}> func.func @test_call_nested_hfa_array(%arg0 : !fir.ref) { %out = fir.call @test_nested_hfa_array() : () -> !nested_hfa_array // CHECK: %[[OUT:.*]] = fir.call @test_nested_hfa_array() : () -> !fir.type,b:f32}> // CHECK: %[[STACK:.*]] = llvm.intr.stacksave : !llvm.ptr // CHECK: %[[ARR:.*]] = fir.alloca !fir.type,b:f32}> // CHECK: fir.store %[[OUT]] to %[[ARR]] : !fir.ref,b:f32}> // CHECK: %[[CVT:.*]] = fir.convert %[[ARR]] : (!fir.ref,b:f32}> // CHECK: %[[LD:.*]] = fir.load %[[CVT]] : !fir.ref,b:f32}> // CHECK: llvm.intr.stackrestore %[[STACK]] : !llvm.ptr fir.store %out to %arg0 : !fir.ref // CHECK fir.store %[[LD]] to %[[ARG0]] : !fir.ref,b:f32}> return }