Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/builtins-floating-point.c

raw
1 // RUN: %clang_cc1 -triple aarch64-none-linux-android24 -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3 // RUN: %clang_cc1 -triple aarch64-none-linux-android24 -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5 // RUN: %clang_cc1 -triple aarch64-none-linux-android24 -Wno-unused-value -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7
8 float cosf(float f) {
9 return __builtin_cosf(f);
10 // CIR: %{{.*}} = cir.cos %{{.*}} : !cir.float
11 // LLVM: %{{.*}} = call float @llvm.cos.f32(float %{{.*}})
12 // OGCG: %{{.*}} = call float @llvm.cos.f32(float %{{.*}})
13 }
14
15 double cos(double f) {
16 return __builtin_cos(f);
17 // CIR: %{{.*}} = cir.cos %{{.*}} : !cir.double
18 // LLVM: %{{.*}} = call double @llvm.cos.f64(double %{{.*}})
19 // OGCG: %{{.*}} = call double @llvm.cos.f64(double %{{.*}})
20 }
21
22 float ceil(float f) {
23 return __builtin_ceilf(f);
24 // CIR: %{{.*}} = cir.ceil %{{.*}} : !cir.float
25 // LLVM: %{{.*}} = call float @llvm.ceil.f32(float %{{.*}})
26 // OGCG: %{{.*}} = call float @llvm.ceil.f32(float %{{.*}})
27 }
28
29 float expf(float f) {
30 return __builtin_expf(f);
31 // CIR: %{{.*}} = cir.exp {{.*}} : !cir.float
32 // LLVM: %{{.*}} = call float @llvm.exp.f32(float %{{.*}})
33 // OGCG: %{{.*}} = call float @llvm.exp.f32(float %{{.*}})
34 }
35
36 double exp(double f) {
37 return __builtin_exp(f);
38 // CIR: %{{.*}} = cir.exp {{.*}} : !cir.double
39 // LLVM: %{{.*}} = call double @llvm.exp.f64(double %{{.*}})
40 // OGCG: %{{.*}} = call double @llvm.exp.f64(double %{{.*}})
41 }
42
43 long double expl(long double f) {
44 return __builtin_expl(f);
45 // CIR: %{{.*}} = cir.exp {{.*}} : !cir.long_double<!cir.f128>
46 // LLVM: %{{.*}} = call fp128 @llvm.exp.f128(fp128 %{{.*}})
47 // OGCG: %{{.*}} = call fp128 @llvm.exp.f128(fp128 %{{.*}})
48 }
49
50 float exp2f(float f) {
51 return __builtin_exp2f(f);
52 // CIR: %{{.*}} = cir.exp2 {{.*}} : !cir.float
53 // LLVM: %{{.*}} = call float @llvm.exp2.f32(float %{{.*}})
54 // OGCG: %{{.*}} = call float @llvm.exp2.f32(float %{{.*}})
55 }
56
57 double my_exp2(double f) {
58 return __builtin_exp2(f);
59 // CIR: %{{.*}} = cir.exp2 {{.*}} : !cir.double
60 // LLVM: %{{.*}} = call double @llvm.exp2.f64(double %{{.*}})
61 // OGCG: %{{.*}} = call double @llvm.exp2.f64(double %{{.*}})
62 }
63
64 long double my_exp2l(long double f) {
65 return __builtin_exp2l(f);
66 // CIR: %{{.*}} = cir.exp2 {{.*}} : !cir.long_double<!cir.f128>
67 // LLVM: %{{.*}} = call fp128 @llvm.exp2.f128(fp128 %{{.*}})
68 // OGCG: %{{.*}} = call fp128 @llvm.exp2.f128(fp128 %{{.*}})
69 }
70
71 float floorf(float f) {
72 return __builtin_floorf(f);
73 // CIR: %{{.*}} = cir.floor %{{.*}} : !cir.float
74 // LLVM: %{{.*}} = call float @llvm.floor.f32(float %{{.*}})
75 // OGCG: %{{.*}} = call float @llvm.floor.f32(float %{{.*}})
76 }
77
78 double floor(double f) {
79 return __builtin_floor(f);
80 // CIR: %{{.*}} = cir.floor %{{.*}} : !cir.double
81 // LLVM: %{{.*}} = call double @llvm.floor.f64(double %{{.*}})
82 // OGCG: %{{.*}} = call double @llvm.floor.f64(double %{{.*}})
83 }
84
85 long double floorl(long double f) {
86 return __builtin_floorl(f);
87 // CIR: %{{.*}} = cir.floor %{{.*}} : !cir.long_double<!cir.f128>
88 // LLVM: %{{.*}} = call fp128 @llvm.floor.f128(fp128 %{{.*}})
89 // OGCG: %{{.*}} = call fp128 @llvm.floor.f128(fp128 %{{.*}})
90 }