2014-10-01 21:13:18 +08:00
|
|
|
; RUN: llc < %s -mtriple=thumbv7-none-eabi -mcpu=cortex-m3 | FileCheck %s -check-prefix=CHECK -check-prefix=SOFT -check-prefix=NONE
|
|
|
|
; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-m4 | FileCheck %s -check-prefix=CHECK -check-prefix=SOFT -check-prefix=SP
|
|
|
|
; 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
|
[ARM] Replace fp-only-sp and d16 with fp64 and d32.
Those two subtarget features were awkward because their semantics are
reversed: each one indicates the _lack_ of support for something in
the architecture, rather than the presence. As a consequence, you
don't get the behavior you want if you combine two sets of feature
bits.
Each SubtargetFeature for an FP architecture version now comes in four
versions, one for each combination of those options. So you can still
say (for example) '+vfp2' in a feature string and it will mean what
it's always meant, but there's a new string '+vfp2d16sp' meaning the
version without those extra options.
A lot of this change is just mechanically replacing positive checks
for the old features with negative checks for the new ones. But one
more interesting change is that I've rearranged getFPUFeatures() so
that the main FPU feature is appended to the output list *before*
rather than after the features derived from the Restriction field, so
that -fp64 and -d32 can override defaults added by the main feature.
Reviewers: dmgreen, samparker, SjoerdMeijer
Subscribers: srhines, javed.absar, eraman, kristof.beyls, hiraditya, zzheng, Petar.Avramovic, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D60691
llvm-svn: 361845
2019-05-29 00:13:20 +08:00
|
|
|
; RUN: llc < %s -mtriple=thumbv7-none-eabihf -mcpu=cortex-m7 -mattr=-fp64 | FileCheck %s -check-prefix=CHECK -check-prefix=SOFT -check-prefix=SP
|
2014-10-01 21:13:18 +08:00
|
|
|
; 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
|
|
|
|
; 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
|
2014-08-21 20:50:31 +08:00
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.sqrt.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @sqrt_d(double %a) {
|
|
|
|
; CHECK-LABEL: sqrt_d:
|
|
|
|
; SOFT: {{(bl|b)}} sqrt
|
|
|
|
; HARD: vsqrt.f64 d0, d0
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.sqrt.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.powi.f64(double %Val, i32 %power)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @powi_d(double %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: powi_d:
|
|
|
|
; SOFT: {{(bl|b)}} __powidf2
|
2017-01-14 00:25:33 +08:00
|
|
|
; HARD: b __powidf2
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.powi.f64(double %a, i32 %b)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.sin.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @sin_d(double %a) {
|
|
|
|
; CHECK-LABEL: sin_d:
|
|
|
|
; SOFT: {{(bl|b)}} sin
|
2016-09-07 11:17:19 +08:00
|
|
|
; HARD: b sin
|
|
|
|
%1 = call double @llvm.sin.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.cos.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @cos_d(double %a) {
|
|
|
|
; CHECK-LABEL: cos_d:
|
|
|
|
; SOFT: {{(bl|b)}} cos
|
2016-09-07 11:17:19 +08:00
|
|
|
; HARD: b cos
|
|
|
|
%1 = call double @llvm.cos.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.pow.f64(double %Val, double %power)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @pow_d(double %a, double %b) {
|
|
|
|
; CHECK-LABEL: pow_d:
|
|
|
|
; SOFT: {{(bl|b)}} pow
|
2016-09-07 11:17:19 +08:00
|
|
|
; HARD: b pow
|
|
|
|
%1 = call double @llvm.pow.f64(double %a, double %b)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.exp.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @exp_d(double %a) {
|
|
|
|
; CHECK-LABEL: exp_d:
|
|
|
|
; SOFT: {{(bl|b)}} exp
|
2016-09-07 11:17:19 +08:00
|
|
|
; HARD: b exp
|
|
|
|
%1 = call double @llvm.exp.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.exp2.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @exp2_d(double %a) {
|
|
|
|
; CHECK-LABEL: exp2_d:
|
|
|
|
; SOFT: {{(bl|b)}} exp2
|
2016-09-07 11:17:19 +08:00
|
|
|
; HARD: b exp2
|
|
|
|
%1 = call double @llvm.exp2.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.log.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @log_d(double %a) {
|
|
|
|
; CHECK-LABEL: log_d:
|
|
|
|
; SOFT: {{(bl|b)}} log
|
2016-09-07 11:17:19 +08:00
|
|
|
; HARD: b log
|
|
|
|
%1 = call double @llvm.log.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.log10.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @log10_d(double %a) {
|
|
|
|
; CHECK-LABEL: log10_d:
|
|
|
|
; SOFT: {{(bl|b)}} log10
|
2016-09-07 11:17:19 +08:00
|
|
|
; HARD: b log10
|
|
|
|
%1 = call double @llvm.log10.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.log2.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @log2_d(double %a) {
|
|
|
|
; CHECK-LABEL: log2_d:
|
|
|
|
; SOFT: {{(bl|b)}} log2
|
2016-09-07 11:17:19 +08:00
|
|
|
; HARD: b log2
|
|
|
|
%1 = call double @llvm.log2.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.fma.f64(double %a, double %b, double %c)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @fma_d(double %a, double %b, double %c) {
|
|
|
|
; CHECK-LABEL: fma_d:
|
|
|
|
; SOFT: {{(bl|b)}} fma
|
|
|
|
; HARD: vfma.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.fma.f64(double %a, double %b, double %c)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: the FPv4-SP version is less efficient than the no-FPU version
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.fabs.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @abs_d(double %a) {
|
|
|
|
; CHECK-LABEL: abs_d:
|
|
|
|
; NONE: bic r1, r1, #-2147483648
|
LegalizeDAG: Fix and improve FCOPYSIGN/FABS legalization
- Factor out code to query and modify the sign bit of a floatingpoint
value as an integer. This also works if none of the targets integer
types is big enough to hold all bits of the floatingpoint value.
- Legalize FABS(x) as FCOPYSIGN(x, 0.0) if FCOPYSIGN is available,
otherwise perform bit manipulation on the sign bit. The previous code
used "x >u 0 ? x : -x" which is incorrect for x being -0.0! It also
takes 34 instructions on ARM Cortex-M4. With this patch we only
require 5:
vldr d0, LCPI0_0
vmov r2, r3, d0
lsrs r2, r3, #31
bfi r1, r2, #31, #1
bx lr
(This could be further improved if the compiler would recognize that
r2, r3 is zero).
- Only lower FCOPYSIGN(x, y) = sign(x) ? -FABS(x) : FABS(x) if FABS is
available otherwise perform bit manipulation on the sign bit.
- Perform the sign(x) test by masking out the sign bit and comparing
with 0 rather than shifting the sign bit to the highest position and
testing for "<s 0". For x86 copysignl (on 80bit values) this gets us:
testl $32768, %eax
rather than:
shlq $48, %rax
sets %al
testb %al, %al
Differential Revision: http://reviews.llvm.org/D11172
llvm-svn: 252839
2015-11-12 09:02:47 +08:00
|
|
|
; SP: vldr d1, .LCPI{{.*}}
|
|
|
|
; SP: vmov r0, r1, d0
|
|
|
|
; SP: vmov r2, r3, d1
|
|
|
|
; SP: lsrs r2, r3, #31
|
|
|
|
; SP: bfi r1, r2, #31, #1
|
|
|
|
; SP: vmov d0, r0, r1
|
2014-08-21 20:50:31 +08:00
|
|
|
; DP: vabs.f64 d0, d0
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.fabs.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.copysign.f64(double %Mag, double %Sgn)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @copysign_d(double %a, double %b) {
|
|
|
|
; CHECK-LABEL: copysign_d:
|
|
|
|
; SOFT: lsrs [[REG:r[0-9]+]], r3, #31
|
|
|
|
; SOFT: bfi r1, [[REG]], #31, #1
|
2014-10-01 17:02:17 +08:00
|
|
|
; VFP: lsrs [[REG:r[0-9]+]], r3, #31
|
|
|
|
; VFP: bfi r1, [[REG]], #31, #1
|
|
|
|
; NEON: vmov.i32 [[REG:d[0-9]+]], #0x80000000
|
|
|
|
; NEON: vshl.i64 [[REG]], [[REG]], #32
|
|
|
|
; NEON: vbsl [[REG]], d
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.copysign.f64(double %a, double %b)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.floor.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @floor_d(double %a) {
|
|
|
|
; CHECK-LABEL: floor_d:
|
|
|
|
; SOFT: {{(bl|b)}} floor
|
2016-09-07 11:17:19 +08:00
|
|
|
; VFP4: b floor
|
2014-10-01 21:13:18 +08:00
|
|
|
; FP-ARMv8: vrintm.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.floor.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.ceil.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @ceil_d(double %a) {
|
|
|
|
; CHECK-LABEL: ceil_d:
|
|
|
|
; SOFT: {{(bl|b)}} ceil
|
2016-09-07 11:17:19 +08:00
|
|
|
; VFP4: b ceil
|
2014-10-01 21:13:18 +08:00
|
|
|
; FP-ARMv8: vrintp.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.ceil.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.trunc.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @trunc_d(double %a) {
|
|
|
|
; CHECK-LABEL: trunc_d:
|
|
|
|
; SOFT: {{(bl|b)}} trunc
|
2016-09-07 11:17:19 +08:00
|
|
|
; FFP4: b trunc
|
2014-10-01 21:13:18 +08:00
|
|
|
; FP-ARMv8: vrintz.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.trunc.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.rint.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @rint_d(double %a) {
|
|
|
|
; CHECK-LABEL: rint_d:
|
|
|
|
; SOFT: {{(bl|b)}} rint
|
2016-09-07 11:17:19 +08:00
|
|
|
; VFP4: b rint
|
2014-10-01 21:13:18 +08:00
|
|
|
; FP-ARMv8: vrintx.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.rint.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.nearbyint.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @nearbyint_d(double %a) {
|
|
|
|
; CHECK-LABEL: nearbyint_d:
|
|
|
|
; SOFT: {{(bl|b)}} nearbyint
|
2016-09-07 11:17:19 +08:00
|
|
|
; VFP4: b nearbyint
|
2014-10-01 21:13:18 +08:00
|
|
|
; FP-ARMv8: vrintr.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.nearbyint.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.round.f64(double %Val)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @round_d(double %a) {
|
|
|
|
; CHECK-LABEL: round_d:
|
|
|
|
; SOFT: {{(bl|b)}} round
|
2016-09-07 11:17:19 +08:00
|
|
|
; VFP4: b round
|
2014-10-01 21:13:18 +08:00
|
|
|
; FP-ARMv8: vrinta.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.round.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.fmuladd.f64(double %a, double %b, double %c)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @fmuladd_d(double %a, double %b, double %c) {
|
|
|
|
; CHECK-LABEL: fmuladd_d:
|
|
|
|
; SOFT: bl __aeabi_dmul
|
|
|
|
; SOFT: bl __aeabi_dadd
|
2014-10-01 21:13:18 +08:00
|
|
|
; VFP4: vmul.f64
|
|
|
|
; VFP4: vadd.f64
|
|
|
|
; FP-ARMv8: vmla.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.fmuladd.f64(double %a, double %b, double %c)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare i16 @llvm.convert.to.fp16.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
define i16 @d_to_h(double %a) {
|
|
|
|
; CHECK-LABEL: d_to_h:
|
|
|
|
; SOFT: bl __aeabi_d2h
|
2014-10-01 21:13:18 +08:00
|
|
|
; VFP4: bl __aeabi_d2h
|
|
|
|
; FP-ARMv8: vcvt{{[bt]}}.f16.f64
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call i16 @llvm.convert.to.fp16.f64(double %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret i16 %1
|
|
|
|
}
|
|
|
|
|
2016-09-07 11:17:19 +08:00
|
|
|
declare double @llvm.convert.from.fp16.f64(i16 %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
define double @h_to_d(i16 %a) {
|
|
|
|
; CHECK-LABEL: h_to_d:
|
2015-10-08 00:58:49 +08:00
|
|
|
; NONE: bl __aeabi_h2f
|
2014-08-21 20:50:31 +08:00
|
|
|
; NONE: bl __aeabi_f2d
|
2014-10-01 21:13:18 +08:00
|
|
|
; SP: vcvt{{[bt]}}.f32.f16
|
2014-08-21 20:50:31 +08:00
|
|
|
; SP: bl __aeabi_f2d
|
2014-10-01 21:13:18 +08:00
|
|
|
; VFPv4: vcvt{{[bt]}}.f32.f16
|
|
|
|
; VFPv4: vcvt.f64.f32
|
|
|
|
; FP-ARMv8: vcvt{{[bt]}}.f64.f16
|
2016-09-07 11:17:19 +08:00
|
|
|
%1 = call double @llvm.convert.from.fp16.f64(i16 %a)
|
2014-08-21 20:50:31 +08:00
|
|
|
ret double %1
|
|
|
|
}
|