blob: b34a69cdb508f2aa78a5bdc6c94d30301cfa377d [file] [log] [blame]
Oliver Stannard51b1d462014-08-21 12:50:31 +00001; RUN: llc < %s -mtriple=thumbv7-none-eabi -mcpu=cortex-m3 | FileCheck %s -check-prefix=CHECK -check-prefix=SOFT -check-prefix=NONE
2; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-m4 | FileCheck %s -check-prefix=CHECK -check-prefix=SOFT -check-prefix=SP
3; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-a7 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=DP
4
5declare double @llvm.sqrt.f64(double %Val)
6define double @sqrt_d(double %a) {
7; CHECK-LABEL: sqrt_d:
8; SOFT: {{(bl|b)}} sqrt
9; HARD: vsqrt.f64 d0, d0
10 %1 = call double @llvm.sqrt.f64(double %a)
11 ret double %1
12}
13
14declare double @llvm.powi.f64(double %Val, i32 %power)
15define double @powi_d(double %a, i32 %b) {
16; CHECK-LABEL: powi_d:
17; SOFT: {{(bl|b)}} __powidf2
18; HARD: b __powidf2
19 %1 = call double @llvm.powi.f64(double %a, i32 %b)
20 ret double %1
21}
22
23declare double @llvm.sin.f64(double %Val)
24define double @sin_d(double %a) {
25; CHECK-LABEL: sin_d:
26; SOFT: {{(bl|b)}} sin
27; HARD: b sin
28 %1 = call double @llvm.sin.f64(double %a)
29 ret double %1
30}
31
32declare double @llvm.cos.f64(double %Val)
33define double @cos_d(double %a) {
34; CHECK-LABEL: cos_d:
35; SOFT: {{(bl|b)}} cos
36; HARD: b cos
37 %1 = call double @llvm.cos.f64(double %a)
38 ret double %1
39}
40
41declare double @llvm.pow.f64(double %Val, double %power)
42define double @pow_d(double %a, double %b) {
43; CHECK-LABEL: pow_d:
44; SOFT: {{(bl|b)}} pow
45; HARD: b pow
46 %1 = call double @llvm.pow.f64(double %a, double %b)
47 ret double %1
48}
49
50declare double @llvm.exp.f64(double %Val)
51define double @exp_d(double %a) {
52; CHECK-LABEL: exp_d:
53; SOFT: {{(bl|b)}} exp
54; HARD: b exp
55 %1 = call double @llvm.exp.f64(double %a)
56 ret double %1
57}
58
59declare double @llvm.exp2.f64(double %Val)
60define double @exp2_d(double %a) {
61; CHECK-LABEL: exp2_d:
62; SOFT: {{(bl|b)}} exp2
63; HARD: b exp2
64 %1 = call double @llvm.exp2.f64(double %a)
65 ret double %1
66}
67
68declare double @llvm.log.f64(double %Val)
69define double @log_d(double %a) {
70; CHECK-LABEL: log_d:
71; SOFT: {{(bl|b)}} log
72; HARD: b log
73 %1 = call double @llvm.log.f64(double %a)
74 ret double %1
75}
76
77declare double @llvm.log10.f64(double %Val)
78define double @log10_d(double %a) {
79; CHECK-LABEL: log10_d:
80; SOFT: {{(bl|b)}} log10
81; HARD: b log10
82 %1 = call double @llvm.log10.f64(double %a)
83 ret double %1
84}
85
86declare double @llvm.log2.f64(double %Val)
87define double @log2_d(double %a) {
88; CHECK-LABEL: log2_d:
89; SOFT: {{(bl|b)}} log2
90; HARD: b log2
91 %1 = call double @llvm.log2.f64(double %a)
92 ret double %1
93}
94
95declare double @llvm.fma.f64(double %a, double %b, double %c)
96define double @fma_d(double %a, double %b, double %c) {
97; CHECK-LABEL: fma_d:
98; SOFT: {{(bl|b)}} fma
99; HARD: vfma.f64
100 %1 = call double @llvm.fma.f64(double %a, double %b, double %c)
101 ret double %1
102}
103
104; FIXME: the FPv4-SP version is less efficient than the no-FPU version
105declare double @llvm.fabs.f64(double %Val)
106define double @abs_d(double %a) {
107; CHECK-LABEL: abs_d:
108; NONE: bic r1, r1, #-2147483648
109; SP: bl __aeabi_dcmpgt
110; SP: bl __aeabi_dcmpun
111; SP: bl __aeabi_dsub
112; DP: vabs.f64 d0, d0
113 %1 = call double @llvm.fabs.f64(double %a)
114 ret double %1
115}
116
117declare double @llvm.copysign.f64(double %Mag, double %Sgn)
118define double @copysign_d(double %a, double %b) {
119; CHECK-LABEL: copysign_d:
120; SOFT: lsrs [[REG:r[0-9]+]], r3, #31
121; SOFT: bfi r1, [[REG]], #31, #1
122; HARD: vmov.i32 [[REG:d[0-9]+]], #0x80000000
123; HARD: vshl.i64 [[REG]], [[REG]], #32
124; HARD: vbsl [[REG]], d
125 %1 = call double @llvm.copysign.f64(double %a, double %b)
126 ret double %1
127}
128
129declare double @llvm.floor.f64(double %Val)
130define double @floor_d(double %a) {
131; CHECK-LABEL: floor_d:
132; SOFT: {{(bl|b)}} floor
133; HARD: b floor
134 %1 = call double @llvm.floor.f64(double %a)
135 ret double %1
136}
137
138declare double @llvm.ceil.f64(double %Val)
139define double @ceil_d(double %a) {
140; CHECK-LABEL: ceil_d:
141; SOFT: {{(bl|b)}} ceil
142; HARD: b ceil
143 %1 = call double @llvm.ceil.f64(double %a)
144 ret double %1
145}
146
147declare double @llvm.trunc.f64(double %Val)
148define double @trunc_d(double %a) {
149; CHECK-LABEL: trunc_d:
150; SOFT: {{(bl|b)}} trunc
151; HARD: b trunc
152 %1 = call double @llvm.trunc.f64(double %a)
153 ret double %1
154}
155
156declare double @llvm.rint.f64(double %Val)
157define double @rint_d(double %a) {
158; CHECK-LABEL: rint_d:
159; SOFT: {{(bl|b)}} rint
160; HARD: b rint
161 %1 = call double @llvm.rint.f64(double %a)
162 ret double %1
163}
164
165declare double @llvm.nearbyint.f64(double %Val)
166define double @nearbyint_d(double %a) {
167; CHECK-LABEL: nearbyint_d:
168; SOFT: {{(bl|b)}} nearbyint
169; HARD: b nearbyint
170 %1 = call double @llvm.nearbyint.f64(double %a)
171 ret double %1
172}
173
174declare double @llvm.round.f64(double %Val)
175define double @round_d(double %a) {
176; CHECK-LABEL: round_d:
177; SOFT: {{(bl|b)}} round
178; HARD: b round
179 %1 = call double @llvm.round.f64(double %a)
180 ret double %1
181}
182
183declare double @llvm.fmuladd.f64(double %a, double %b, double %c)
184define double @fmuladd_d(double %a, double %b, double %c) {
185; CHECK-LABEL: fmuladd_d:
186; SOFT: bl __aeabi_dmul
187; SOFT: bl __aeabi_dadd
188; HARD: vmul.f64
189; HARD: vadd.f64
190 %1 = call double @llvm.fmuladd.f64(double %a, double %b, double %c)
191 ret double %1
192}
193
194declare i16 @llvm.convert.to.fp16.f64(double %a)
195define i16 @d_to_h(double %a) {
196; CHECK-LABEL: d_to_h:
197; SOFT: bl __aeabi_d2h
198; HARD: bl __aeabi_d2h
199 %1 = call i16 @llvm.convert.to.fp16.f64(double %a)
200 ret i16 %1
201}
202
203declare double @llvm.convert.from.fp16.f64(i16 %a)
204define double @h_to_d(i16 %a) {
205; CHECK-LABEL: h_to_d:
206; NONE: bl __gnu_h2f_ieee
207; NONE: bl __aeabi_f2d
208; SP: vcvtb.f32.f16
209; SP: bl __aeabi_f2d
210; DP: vcvtb.f32.f16
211; DP: vcvt.f64.f32
212 %1 = call double @llvm.convert.from.fp16.f64(i16 %a)
213 ret double %1
214}