xref: /llvm-project/clang/test/CodeGen/AArch64/args-hfa.c (revision 207e5ccceec8d3cc3f32723e78f2a142bc61b07d)
1*207e5cccSFangrui Song // RUN: %clang_cc1 -triple aarch64 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-AAPCS
2*207e5cccSFangrui Song // RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-abi darwinpcs -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DARWIN
3*207e5cccSFangrui Song // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | FileCheck %s --check-prefixes=CHECK,CHECK-AAPCS
4*207e5cccSFangrui Song 
5*207e5cccSFangrui Song typedef struct {
6*207e5cccSFangrui Song   float v[2];
7*207e5cccSFangrui Song } S0;
8*207e5cccSFangrui Song 
9*207e5cccSFangrui Song // CHECK-AAPCS:  define{{.*}} float @f0([2 x float] alignstack(8) %h.coerce)
10*207e5cccSFangrui Song // CHECK-DARWIN: define{{.*}} float @f0([2 x float] %h.coerce)
11*207e5cccSFangrui Song float f0(S0 h) {
12*207e5cccSFangrui Song   return h.v[0];
13*207e5cccSFangrui Song }
14*207e5cccSFangrui Song 
15*207e5cccSFangrui Song // CHECK: define{{.*}} float @f0_call()
16*207e5cccSFangrui Song // CHECK-AAPCS: %call = call float @f0([2 x float] alignstack(8) %0)
17*207e5cccSFangrui Song // CHECK-DARWIN: %call = call float @f0([2 x float] %0)
18*207e5cccSFangrui Song float f0_call(void) {
19*207e5cccSFangrui Song   S0 h = {1.0f, 2.0f};
20*207e5cccSFangrui Song   return f0(h);
21*207e5cccSFangrui Song }
22*207e5cccSFangrui Song typedef struct {
23*207e5cccSFangrui Song   double v[2];
24*207e5cccSFangrui Song } S1;
25*207e5cccSFangrui Song // CHECK-AAPCS: define{{.*}} double @f1([2 x double] alignstack(8) %h.coerce)
26*207e5cccSFangrui Song // CHECK-DARWIN: define{{.*}} double @f1([2 x double] %h.coerce)
27*207e5cccSFangrui Song double f1(S1 h) {
28*207e5cccSFangrui Song   return h.v[0];
29*207e5cccSFangrui Song }
30*207e5cccSFangrui Song 
31*207e5cccSFangrui Song // CHECK: define{{.*}} double @f1_call()
32*207e5cccSFangrui Song // CHECK-AAPCS: %call = call double @f1([2 x double] alignstack(8) %0
33*207e5cccSFangrui Song // CHECK-DARWIN: %call = call double @f1([2 x double] %0
34*207e5cccSFangrui Song double f1_call(void) {
35*207e5cccSFangrui Song   S1 h = {1.0, 2.0};
36*207e5cccSFangrui Song   return f1(h);
37*207e5cccSFangrui Song }
38*207e5cccSFangrui Song typedef struct {
39*207e5cccSFangrui Song   __attribute__((__aligned__(16))) double v[2];
40*207e5cccSFangrui Song } S2;
41*207e5cccSFangrui Song 
42*207e5cccSFangrui Song // CHECK-AAPCS:  define{{.*}} double @f2([2 x double] alignstack(16) %h.coerce)
43*207e5cccSFangrui Song // CHECK-DARWIN: define{{.*}} double @f2([2 x double] %h.coerce)
44*207e5cccSFangrui Song double f2(S2 h) {
45*207e5cccSFangrui Song   return h.v[0];
46*207e5cccSFangrui Song }
47*207e5cccSFangrui Song 
48*207e5cccSFangrui Song // CHECK: define{{.*}} double @f2_call()
49*207e5cccSFangrui Song // CHECK-AAPCS:  %call = call double @f2([2 x double] alignstack(16) %0)
50*207e5cccSFangrui Song // CHECK-DARWIN: %call = call double @f2([2 x double] %0
51*207e5cccSFangrui Song double f2_call(void) {
52*207e5cccSFangrui Song   S2 h = {1.0, 2.0};
53*207e5cccSFangrui Song   return f2(h);
54*207e5cccSFangrui Song }
55*207e5cccSFangrui Song 
56*207e5cccSFangrui Song typedef struct {
57*207e5cccSFangrui Song   __attribute__((__aligned__(32))) double v[4];
58*207e5cccSFangrui Song } S3;
59*207e5cccSFangrui Song 
60*207e5cccSFangrui Song // CHECK-AAPCS:  define{{.*}} double @f3([4 x double] alignstack(16) %h.coerce)
61*207e5cccSFangrui Song // CHECK-DARWIN: define{{.*}} double @f3([4 x double] %h.coerce)
62*207e5cccSFangrui Song double f3(S3 h) {
63*207e5cccSFangrui Song   return h.v[0];
64*207e5cccSFangrui Song }
65*207e5cccSFangrui Song 
66*207e5cccSFangrui Song // CHECK: define{{.*}} double @f3_call()
67*207e5cccSFangrui Song // CHECK-AAPCS:  %call = call double @f3([4 x double] alignstack(16) %0)
68*207e5cccSFangrui Song // CHECK-DARWIN: %call = call double @f3([4 x double] %0
69*207e5cccSFangrui Song double f3_call(void) {
70*207e5cccSFangrui Song   S3 h = {1.0, 2.0};
71*207e5cccSFangrui Song   return f3(h);
72*207e5cccSFangrui Song }
73