1 // RUN: %clang_cc1 -triple x86_64-linux-android -emit-llvm -O -o - %s \
2 // RUN: | FileCheck %s --check-prefix=ANDROID --check-prefix=CHECK
3 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -O -o - %s \
4 // RUN: | FileCheck %s --check-prefix=GNU --check-prefix=CHECK
5 // RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \
6 // RUN: | FileCheck %s --check-prefix=GNU --check-prefix=CHECK
7 // NaCl is an example of a target for which long double is the same as double.
8 // RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -O -o - %s \
9 // RUN: | FileCheck %s --check-prefix=NACL --check-prefix=CHECK
11 // Android uses fp128 for long double but other x86_64 targets use x86_fp80.
13 long double dataLD
= 1.0L;
14 // ANDROID: @dataLD ={{.*}} local_unnamed_addr global fp128 0xL00000000000000003FFF000000000000, align 16
15 // GNU: @dataLD ={{.*}} local_unnamed_addr global x86_fp80 0xK3FFF8000000000000000, align 16
17 long double _Complex dataLDC
= {1.0L, 1.0L};
18 // ANDROID: @dataLDC ={{.*}} local_unnamed_addr global { fp128, fp128 } { fp128 0xL00000000000000003FFF000000000000, fp128 0xL00000000000000003FFF000000000000 }, align 16
19 // GNU: @dataLDC ={{.*}} local_unnamed_addr global { x86_fp80, x86_fp80 } { x86_fp80 0xK3FFF8000000000000000, x86_fp80 0xK3FFF8000000000000000 }, align 16
21 long double TestLD(long double x
) {
23 // ANDROID: define{{.*}} fp128 @TestLD(fp128 noundef %x)
24 // GNU: define{{.*}} x86_fp80 @TestLD(x86_fp80 noundef %x)
25 // NACL: define{{.*}} double @TestLD(double noundef %x)
28 long double _Complex
TestLDC(long double _Complex x
) {
30 // ANDROID: define{{.*}} void @TestLDC(ptr {{.*}}, ptr {{.*}} %x)
31 // GNU: define{{.*}} { x86_fp80, x86_fp80 } @TestLDC(ptr {{.*}} %x)
32 // NACL: define{{.*}} { double, double } @TestLDC(double noundef %x{{.*}}, double noundef %x{{.*}})
35 typedef __builtin_va_list
va_list;
37 int TestGetVarInt(va_list ap
) {
38 return __builtin_va_arg(ap
, int);
39 // Since int can be passed in memory or register there are two branches.
40 // CHECK: define{{.*}} i32 @TestGetVarInt(
47 double TestGetVarDouble(va_list ap
) {
48 return __builtin_va_arg(ap
, double);
49 // Since double can be passed in memory or register there are two branches.
50 // CHECK: define{{.*}} double @TestGetVarDouble(
57 long double TestGetVarLD(va_list ap
) {
58 return __builtin_va_arg(ap
, long double);
59 // fp128 and double can be passed in memory or in register, but x86_fp80 is in
61 // ANDROID: define{{.*}} fp128 @TestGetVarLD(
62 // GNU: define{{.*}} x86_fp80 @TestGetVarLD(
63 // NACL: define{{.*}} double @TestGetVarLD(
75 long double _Complex
TestGetVarLDC(va_list ap
) {
76 return __builtin_va_arg(ap
, long double _Complex
);
77 // Pair of fp128 or x86_fp80 are passed as struct in memory.
78 // ANDROID: define{{.*}} void @TestGetVarLDC(ptr {{.*}}, ptr
79 // GNU: define{{.*}} { x86_fp80, x86_fp80 } @TestGetVarLDC(
80 // Pair of double can go in SSE registers or memory
81 // NACL: define{{.*}} { double, double } @TestGetVarLDC(
89 // GNU: ret { x86_fp80, x86_fp80 }
90 // NACL: ret { double, double }
93 void TestVarArg(const char *s
, ...);
95 void TestPassVarInt(int x
) {
97 // CHECK: define{{.*}} void @TestPassVarInt(i32 noundef %x)
98 // CHECK: call {{.*}} @TestVarArg(ptr {{.*}}, i32 noundef %x)
101 void TestPassVarFloat(float x
) {
103 // CHECK: define{{.*}} void @TestPassVarFloat(float noundef %x)
104 // CHECK: call {{.*}} @TestVarArg(ptr {{.*}}, double noundef %
107 void TestPassVarDouble(double x
) {
109 // CHECK: define{{.*}} void @TestPassVarDouble(double noundef %x)
110 // CHECK: call {{.*}} @TestVarArg(ptr {{.*}}, double noundef %x
113 void TestPassVarLD(long double x
) {
115 // ANDROID: define{{.*}} void @TestPassVarLD(fp128 noundef %x)
116 // ANDROID: call {{.*}} @TestVarArg(ptr {{.*}}, fp128 noundef %x
117 // GNU: define{{.*}} void @TestPassVarLD(x86_fp80 noundef %x)
118 // GNU: call {{.*}} @TestVarArg(ptr {{.*}}, x86_fp80 noundef %x
119 // NACL: define{{.*}} void @TestPassVarLD(double noundef %x)
120 // NACL: call {{.*}} @TestVarArg(ptr {{.*}}, double noundef %x
123 void TestPassVarLDC(long double _Complex x
) {
125 // ANDROID: define{{.*}} void @TestPassVarLDC(ptr {{.*}} %x)
126 // ANDROID: store fp128 %{{.*}}, ptr %
127 // ANDROID-NEXT: store fp128 %{{.*}}, ptr %
128 // ANDROID-NEXT: call {{.*}} @TestVarArg(ptr {{.*}}, ptr {{.*}} %
129 // GNU: define{{.*}} void @TestPassVarLDC(ptr {{.*}} %x)
130 // GNU: store x86_fp80 %{{.*}}, ptr %
131 // GNU-NEXT: store x86_fp80 %{{.*}}, ptr %
132 // GNU-NEXT: call {{.*}} @TestVarArg(ptr {{.*}}, ptr {{.*}} %
133 // NACL: define{{.*}} void @TestPassVarLDC(double noundef %x{{.*}}, double noundef %x{{.*}})
134 // NACL: call {{.*}} @TestVarArg(ptr {{.*}}, double noundef %x{{.*}}, double noundef %x{{.*}})