1 // RUN: %clang_cc1 -no-opaque-pointers -triple powerpc64le-linux-gnu -emit-llvm -o - %s \
2 // RUN:   -mabi=ieeelongdouble | FileCheck --check-prefix=IEEE128 %s
3 // RUN: %clang_cc1 -no-opaque-pointers -triple powerpc64le-linux-gnu -emit-llvm -o - %s \
4 // RUN:   | FileCheck --check-prefix=PPC128 %s
5 
6 long double x;
7 char buf[20];
8 
9 // IEEE128-LABEL: define dso_local void @test_printf
10 // IEEE128: call signext i32 (i8*, ...) @__printfieee128
11 // PPC128-LABEL: define dso_local void @test_printf
12 // PPC128: call signext i32 (i8*, ...) @printf
test_printf(void)13 void test_printf(void) {
14   __builtin_printf("%.Lf", x);
15 }
16 
17 // IEEE128-LABEL: define dso_local void @test_vsnprintf
18 // IEEE128: call signext i32 @__vsnprintfieee128
19 // PPC128-LABEL: define dso_local void @test_vsnprintf
20 // PPC128: call signext i32 @vsnprintf
test_vsnprintf(int n,...)21 void test_vsnprintf(int n, ...) {
22   __builtin_va_list va;
23   __builtin_va_start(va, n);
24   __builtin_vsnprintf(buf, 20, "%.Lf", va);
25   __builtin_va_end(va);
26 }
27 
28 // IEEE128-LABEL: define dso_local void @test_vsprintf
29 // IEEE128: call signext i32 @__vsprintfieee128
30 // PPC128-LABEL: define dso_local void @test_vsprintf
31 // PPC128: call signext i32 @vsprintf
test_vsprintf(int n,...)32 void test_vsprintf(int n, ...) {
33   __builtin_va_list va;
34   __builtin_va_start(va, n);
35   __builtin_vsprintf(buf, "%.Lf", va);
36   __builtin_va_end(va);
37 }
38 
39 // IEEE128-LABEL: define dso_local void @test_sprintf
40 // IEEE128: call signext i32 (i8*, i8*, ...) @__sprintfieee128
41 // PPC128-LABEL: define dso_local void @test_sprintf
42 // PPC128: call signext i32 (i8*, i8*, ...) @sprintf
test_sprintf(void)43 void test_sprintf(void) {
44   __builtin_sprintf(buf, "%.Lf", x);
45 }
46 
47 // IEEE128-LABEL: define dso_local void @test_snprintf
48 // IEEE128: call signext i32 (i8*, i64, i8*, ...) @__snprintfieee128
49 // PPC128-LABEL: define dso_local void @test_snprintf
50 // PPC128: call signext i32 (i8*, i64, i8*, ...) @snprintf
test_snprintf(void)51 void test_snprintf(void) {
52   __builtin_snprintf(buf, 20, "%.Lf", x);
53 }
54 
55 // GLIBC has special handling of 'nexttoward'
56 
57 // IEEE128-LABEL: define dso_local fp128 @test_nexttoward
58 // IEEE128: call fp128 @__nexttowardieee128
59 // PPC128-LABEL: define dso_local ppc_fp128 @test_nexttoward
60 // PPC128: call ppc_fp128 @nexttowardl
test_nexttoward(long double a,long double b)61 long double test_nexttoward(long double a, long double b) {
62   return __builtin_nexttowardl(a, b);
63 }
64