blob: 38d04d30b878936e22db8149012ccec322072c85 [file] [log] [blame]
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +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-m7 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=DP -check-prefix=VFP -check-prefix=FP-ARMv8
4; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-m7 -mattr=+fp-only-sp | FileCheck %s -check-prefix=CHECK -check-prefix=SOFT -check-prefix=SP
5; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-a7 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=DP -check-prefix=NEON -check-prefix=VFP4
6; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-a57 | FileCheck %s -check-prefix=CHECK -check-prefix=HARD -check-prefix=DP -check-prefix=NEON -check-prefix=FP-ARMv8
Oliver Stannard51b1d462014-08-21 12:50:31 +00007
8declare double @llvm.sqrt.f64(double %Val)
9define double @sqrt_d(double %a) {
10; CHECK-LABEL: sqrt_d:
11; SOFT: {{(bl|b)}} sqrt
12; HARD: vsqrt.f64 d0, d0
13 %1 = call double @llvm.sqrt.f64(double %a)
14 ret double %1
15}
16
17declare double @llvm.powi.f64(double %Val, i32 %power)
18define double @powi_d(double %a, i32 %b) {
19; CHECK-LABEL: powi_d:
20; SOFT: {{(bl|b)}} __powidf2
21; HARD: b __powidf2
22 %1 = call double @llvm.powi.f64(double %a, i32 %b)
23 ret double %1
24}
25
26declare double @llvm.sin.f64(double %Val)
27define double @sin_d(double %a) {
28; CHECK-LABEL: sin_d:
29; SOFT: {{(bl|b)}} sin
30; HARD: b sin
31 %1 = call double @llvm.sin.f64(double %a)
32 ret double %1
33}
34
35declare double @llvm.cos.f64(double %Val)
36define double @cos_d(double %a) {
37; CHECK-LABEL: cos_d:
38; SOFT: {{(bl|b)}} cos
39; HARD: b cos
40 %1 = call double @llvm.cos.f64(double %a)
41 ret double %1
42}
43
44declare double @llvm.pow.f64(double %Val, double %power)
45define double @pow_d(double %a, double %b) {
46; CHECK-LABEL: pow_d:
47; SOFT: {{(bl|b)}} pow
48; HARD: b pow
49 %1 = call double @llvm.pow.f64(double %a, double %b)
50 ret double %1
51}
52
53declare double @llvm.exp.f64(double %Val)
54define double @exp_d(double %a) {
55; CHECK-LABEL: exp_d:
56; SOFT: {{(bl|b)}} exp
57; HARD: b exp
58 %1 = call double @llvm.exp.f64(double %a)
59 ret double %1
60}
61
62declare double @llvm.exp2.f64(double %Val)
63define double @exp2_d(double %a) {
64; CHECK-LABEL: exp2_d:
65; SOFT: {{(bl|b)}} exp2
66; HARD: b exp2
67 %1 = call double @llvm.exp2.f64(double %a)
68 ret double %1
69}
70
71declare double @llvm.log.f64(double %Val)
72define double @log_d(double %a) {
73; CHECK-LABEL: log_d:
74; SOFT: {{(bl|b)}} log
75; HARD: b log
76 %1 = call double @llvm.log.f64(double %a)
77 ret double %1
78}
79
80declare double @llvm.log10.f64(double %Val)
81define double @log10_d(double %a) {
82; CHECK-LABEL: log10_d:
83; SOFT: {{(bl|b)}} log10
84; HARD: b log10
85 %1 = call double @llvm.log10.f64(double %a)
86 ret double %1
87}
88
89declare double @llvm.log2.f64(double %Val)
90define double @log2_d(double %a) {
91; CHECK-LABEL: log2_d:
92; SOFT: {{(bl|b)}} log2
93; HARD: b log2
94 %1 = call double @llvm.log2.f64(double %a)
95 ret double %1
96}
97
98declare double @llvm.fma.f64(double %a, double %b, double %c)
99define double @fma_d(double %a, double %b, double %c) {
100; CHECK-LABEL: fma_d:
101; SOFT: {{(bl|b)}} fma
102; HARD: vfma.f64
103 %1 = call double @llvm.fma.f64(double %a, double %b, double %c)
104 ret double %1
105}
106
107; FIXME: the FPv4-SP version is less efficient than the no-FPU version
108declare double @llvm.fabs.f64(double %Val)
109define double @abs_d(double %a) {
110; CHECK-LABEL: abs_d:
111; NONE: bic r1, r1, #-2147483648
Matthias Braun75e668e2015-07-14 02:09:57 +0000112; SP: bl __aeabi_dsub
Alexey Bataevb9288602015-07-15 08:39:35 +0000113; SP: bl __aeabi_dcmple
Oliver Stannard51b1d462014-08-21 12:50:31 +0000114; DP: vabs.f64 d0, d0
115 %1 = call double @llvm.fabs.f64(double %a)
116 ret double %1
117}
118
119declare double @llvm.copysign.f64(double %Mag, double %Sgn)
120define double @copysign_d(double %a, double %b) {
121; CHECK-LABEL: copysign_d:
122; SOFT: lsrs [[REG:r[0-9]+]], r3, #31
123; SOFT: bfi r1, [[REG]], #31, #1
Oliver Stannard37e4daa2014-10-01 09:02:17 +0000124; VFP: lsrs [[REG:r[0-9]+]], r3, #31
125; VFP: bfi r1, [[REG]], #31, #1
126; NEON: vmov.i32 [[REG:d[0-9]+]], #0x80000000
127; NEON: vshl.i64 [[REG]], [[REG]], #32
128; NEON: vbsl [[REG]], d
Oliver Stannard51b1d462014-08-21 12:50:31 +0000129 %1 = call double @llvm.copysign.f64(double %a, double %b)
130 ret double %1
131}
132
133declare double @llvm.floor.f64(double %Val)
134define double @floor_d(double %a) {
135; CHECK-LABEL: floor_d:
136; SOFT: {{(bl|b)}} floor
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000137; VFP4: b floor
138; FP-ARMv8: vrintm.f64
Oliver Stannard51b1d462014-08-21 12:50:31 +0000139 %1 = call double @llvm.floor.f64(double %a)
140 ret double %1
141}
142
143declare double @llvm.ceil.f64(double %Val)
144define double @ceil_d(double %a) {
145; CHECK-LABEL: ceil_d:
146; SOFT: {{(bl|b)}} ceil
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000147; VFP4: b ceil
148; FP-ARMv8: vrintp.f64
Oliver Stannard51b1d462014-08-21 12:50:31 +0000149 %1 = call double @llvm.ceil.f64(double %a)
150 ret double %1
151}
152
153declare double @llvm.trunc.f64(double %Val)
154define double @trunc_d(double %a) {
155; CHECK-LABEL: trunc_d:
156; SOFT: {{(bl|b)}} trunc
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000157; FFP4: b trunc
158; FP-ARMv8: vrintz.f64
Oliver Stannard51b1d462014-08-21 12:50:31 +0000159 %1 = call double @llvm.trunc.f64(double %a)
160 ret double %1
161}
162
163declare double @llvm.rint.f64(double %Val)
164define double @rint_d(double %a) {
165; CHECK-LABEL: rint_d:
166; SOFT: {{(bl|b)}} rint
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000167; VFP4: b rint
168; FP-ARMv8: vrintx.f64
Oliver Stannard51b1d462014-08-21 12:50:31 +0000169 %1 = call double @llvm.rint.f64(double %a)
170 ret double %1
171}
172
173declare double @llvm.nearbyint.f64(double %Val)
174define double @nearbyint_d(double %a) {
175; CHECK-LABEL: nearbyint_d:
176; SOFT: {{(bl|b)}} nearbyint
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000177; VFP4: b nearbyint
178; FP-ARMv8: vrintr.f64
Oliver Stannard51b1d462014-08-21 12:50:31 +0000179 %1 = call double @llvm.nearbyint.f64(double %a)
180 ret double %1
181}
182
183declare double @llvm.round.f64(double %Val)
184define double @round_d(double %a) {
185; CHECK-LABEL: round_d:
186; SOFT: {{(bl|b)}} round
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000187; VFP4: b round
188; FP-ARMv8: vrinta.f64
Oliver Stannard51b1d462014-08-21 12:50:31 +0000189 %1 = call double @llvm.round.f64(double %a)
190 ret double %1
191}
192
193declare double @llvm.fmuladd.f64(double %a, double %b, double %c)
194define double @fmuladd_d(double %a, double %b, double %c) {
195; CHECK-LABEL: fmuladd_d:
196; SOFT: bl __aeabi_dmul
197; SOFT: bl __aeabi_dadd
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000198; VFP4: vmul.f64
199; VFP4: vadd.f64
200; FP-ARMv8: vmla.f64
Oliver Stannard51b1d462014-08-21 12:50:31 +0000201 %1 = call double @llvm.fmuladd.f64(double %a, double %b, double %c)
202 ret double %1
203}
204
205declare i16 @llvm.convert.to.fp16.f64(double %a)
206define i16 @d_to_h(double %a) {
207; CHECK-LABEL: d_to_h:
208; SOFT: bl __aeabi_d2h
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000209; VFP4: bl __aeabi_d2h
210; FP-ARMv8: vcvt{{[bt]}}.f16.f64
Oliver Stannard51b1d462014-08-21 12:50:31 +0000211 %1 = call i16 @llvm.convert.to.fp16.f64(double %a)
212 ret i16 %1
213}
214
215declare double @llvm.convert.from.fp16.f64(i16 %a)
216define double @h_to_d(i16 %a) {
217; CHECK-LABEL: h_to_d:
218; NONE: bl __gnu_h2f_ieee
219; NONE: bl __aeabi_f2d
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000220; SP: vcvt{{[bt]}}.f32.f16
Oliver Stannard51b1d462014-08-21 12:50:31 +0000221; SP: bl __aeabi_f2d
Oliver Stannardd4e0a4f2014-10-01 13:13:18 +0000222; VFPv4: vcvt{{[bt]}}.f32.f16
223; VFPv4: vcvt.f64.f32
224; FP-ARMv8: vcvt{{[bt]}}.f64.f16
Oliver Stannard51b1d462014-08-21 12:50:31 +0000225 %1 = call double @llvm.convert.from.fp16.f64(i16 %a)
226 ret double %1
227}