2015-08-21 08:25:37 +08:00
|
|
|
//===-- aeabi_cfcmp.S - EABI cfcmp* implementation ------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "../assembly.h"
|
|
|
|
|
|
|
|
#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
|
|
|
|
#error big endian support not implemented
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define APSR_Z (1 << 30)
|
|
|
|
#define APSR_C (1 << 29)
|
|
|
|
|
|
|
|
// void __aeabi_cfcmpeq(float a, float b) {
|
|
|
|
// if (isnan(a) || isnan(b)) {
|
|
|
|
// Z = 0; C = 1;
|
|
|
|
// } else {
|
|
|
|
// __aeabi_cfcmple(a, b);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
.syntax unified
|
|
|
|
.p2align 2
|
|
|
|
DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmpeq)
|
|
|
|
push {r0-r3, lr}
|
|
|
|
bl __aeabi_cfcmpeq_check_nan
|
|
|
|
cmp r0, #1
|
[builtins][ARM] Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
mode (-mthumb, -marm), it reflect's capability of given CPU.
Due to this:
•use tbumb and thumb2 insteand of __ARM_ARCH_ISA_THUMB
•use '.thumb' directive consistently in all affected files
•decorate all thumb functions using DEFINE_COMPILERRT_THUMB_FUNCTION()
(This is based off Michal's patch https://reviews.llvm.org/D30938)
Reviewers: dim, rengolin, compnerd, strejda
Reviewed By: compnerd
Subscribers: peter.smith, kubamracek, mgorny, javed.absar, kristof.beyls, jamesduley, aemerson, llvm-commits
Differential Revision: https://reviews.llvm.org/D31220
llvm-svn: 310884
2017-08-15 04:48:47 +08:00
|
|
|
#if defined(USE_THUMB_1)
|
2017-01-27 09:21:00 +08:00
|
|
|
beq 1f
|
|
|
|
// NaN has been ruled out, so __aeabi_cfcmple can't trap
|
|
|
|
mov r0, sp
|
|
|
|
ldm r0, {r0-r3}
|
|
|
|
bl __aeabi_cfcmple
|
|
|
|
pop {r0-r3, pc}
|
|
|
|
1:
|
|
|
|
// Z = 0, C = 1
|
|
|
|
movs r0, #0xF
|
|
|
|
lsls r0, r0, #31
|
|
|
|
pop {r0-r3, pc}
|
|
|
|
#else
|
2015-08-21 08:25:37 +08:00
|
|
|
pop {r0-r3, lr}
|
|
|
|
|
|
|
|
// NaN has been ruled out, so __aeabi_cfcmple can't trap
|
[builtins] ARM: Reland fix for assembling builtins in thumb state.
Summary:
clang does not assemble files in thumb mode unless .thumb declaration
is present. Add .thumb/.arm decl to _FUNCTION macros to ensure that
files are assembled correctly.
Also add a fix to ensure that armv7k-watchos can assemble the
aeabi_c{f|d}cmp.S files.
Fixes PR 34715.
Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, efriedma, t.p.northover, fjricci
Reviewed By: compnerd
Subscribers: aemerson, javed.absar, llvm-commits, kristof.beyls
Differential Revision: https://reviews.llvm.org/D38390
llvm-svn: 314718
2017-10-03 04:56:49 +08:00
|
|
|
// Use "it ne" + unconditional branch to guarantee a supported relocation if
|
|
|
|
// __aeabi_cfcmple is in a different section for some builds.
|
|
|
|
IT(ne)
|
2015-08-21 08:25:37 +08:00
|
|
|
bne __aeabi_cfcmple
|
|
|
|
|
[builtins] ARM: Reland fix for assembling builtins in thumb state.
Summary:
clang does not assemble files in thumb mode unless .thumb declaration
is present. Add .thumb/.arm decl to _FUNCTION macros to ensure that
files are assembled correctly.
Also add a fix to ensure that armv7k-watchos can assemble the
aeabi_c{f|d}cmp.S files.
Fixes PR 34715.
Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, efriedma, t.p.northover, fjricci
Reviewed By: compnerd
Subscribers: aemerson, javed.absar, llvm-commits, kristof.beyls
Differential Revision: https://reviews.llvm.org/D38390
llvm-svn: 314718
2017-10-03 04:56:49 +08:00
|
|
|
#if defined(USE_THUMB_2)
|
2017-05-24 23:53:24 +08:00
|
|
|
mov ip, #APSR_C
|
|
|
|
msr APSR_nzcvq, ip
|
|
|
|
#else
|
2015-08-21 08:25:37 +08:00
|
|
|
msr CPSR_f, #APSR_C
|
2017-05-24 23:53:24 +08:00
|
|
|
#endif
|
2015-08-21 08:25:37 +08:00
|
|
|
JMP(lr)
|
2017-01-27 09:21:00 +08:00
|
|
|
#endif
|
2015-08-21 08:25:37 +08:00
|
|
|
END_COMPILERRT_FUNCTION(__aeabi_cfcmpeq)
|
|
|
|
|
|
|
|
|
|
|
|
// void __aeabi_cfcmple(float a, float b) {
|
|
|
|
// if (__aeabi_fcmplt(a, b)) {
|
|
|
|
// Z = 0; C = 0;
|
|
|
|
// } else if (__aeabi_fcmpeq(a, b)) {
|
|
|
|
// Z = 1; C = 1;
|
|
|
|
// } else {
|
|
|
|
// Z = 0; C = 1;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
.syntax unified
|
|
|
|
.p2align 2
|
|
|
|
DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmple)
|
|
|
|
// Per the RTABI, this function must preserve r0-r11.
|
|
|
|
// Save lr in the same instruction for compactness
|
|
|
|
push {r0-r3, lr}
|
|
|
|
|
|
|
|
bl __aeabi_fcmplt
|
|
|
|
cmp r0, #1
|
[builtins][ARM] Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
mode (-mthumb, -marm), it reflect's capability of given CPU.
Due to this:
•use tbumb and thumb2 insteand of __ARM_ARCH_ISA_THUMB
•use '.thumb' directive consistently in all affected files
•decorate all thumb functions using DEFINE_COMPILERRT_THUMB_FUNCTION()
(This is based off Michal's patch https://reviews.llvm.org/D30938)
Reviewers: dim, rengolin, compnerd, strejda
Reviewed By: compnerd
Subscribers: peter.smith, kubamracek, mgorny, javed.absar, kristof.beyls, jamesduley, aemerson, llvm-commits
Differential Revision: https://reviews.llvm.org/D31220
llvm-svn: 310884
2017-08-15 04:48:47 +08:00
|
|
|
#if defined(USE_THUMB_1)
|
2017-01-27 09:21:00 +08:00
|
|
|
bne 1f
|
|
|
|
// Z = 0, C = 0
|
|
|
|
movs r0, #1
|
|
|
|
lsls r0, r0, #1
|
|
|
|
pop {r0-r3, pc}
|
|
|
|
1:
|
|
|
|
mov r0, sp
|
|
|
|
ldm r0, {r0-r3}
|
|
|
|
bl __aeabi_fcmpeq
|
|
|
|
cmp r0, #1
|
|
|
|
bne 2f
|
|
|
|
// Z = 1, C = 1
|
|
|
|
movs r0, #2
|
|
|
|
lsls r0, r0, #31
|
|
|
|
pop {r0-r3, pc}
|
|
|
|
2:
|
|
|
|
// Z = 0, C = 1
|
|
|
|
movs r0, #0xF
|
|
|
|
lsls r0, r0, #31
|
|
|
|
pop {r0-r3, pc}
|
|
|
|
#else
|
2017-05-24 23:53:24 +08:00
|
|
|
ITT(eq)
|
2015-08-21 08:25:37 +08:00
|
|
|
moveq ip, #0
|
|
|
|
beq 1f
|
|
|
|
|
|
|
|
ldm sp, {r0-r3}
|
|
|
|
bl __aeabi_fcmpeq
|
|
|
|
cmp r0, #1
|
2017-05-24 23:53:24 +08:00
|
|
|
ITE(eq)
|
2015-08-21 08:25:37 +08:00
|
|
|
moveq ip, #(APSR_C | APSR_Z)
|
|
|
|
movne ip, #(APSR_C)
|
|
|
|
|
|
|
|
1:
|
2017-05-24 23:53:24 +08:00
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
|
|
|
msr APSR_nzcvq, ip
|
|
|
|
#else
|
2015-08-21 08:25:37 +08:00
|
|
|
msr CPSR_f, ip
|
2017-05-24 23:53:24 +08:00
|
|
|
#endif
|
2015-08-21 08:25:37 +08:00
|
|
|
pop {r0-r3}
|
|
|
|
POP_PC()
|
2017-01-27 09:21:00 +08:00
|
|
|
#endif
|
2015-08-21 08:25:37 +08:00
|
|
|
END_COMPILERRT_FUNCTION(__aeabi_cfcmple)
|
|
|
|
|
|
|
|
// int __aeabi_cfrcmple(float a, float b) {
|
|
|
|
// return __aeabi_cfcmple(b, a);
|
|
|
|
// }
|
|
|
|
|
|
|
|
.syntax unified
|
|
|
|
.p2align 2
|
|
|
|
DEFINE_COMPILERRT_FUNCTION(__aeabi_cfrcmple)
|
|
|
|
// Swap r0 and r1
|
|
|
|
mov ip, r0
|
|
|
|
mov r0, r1
|
|
|
|
mov r1, ip
|
|
|
|
|
|
|
|
b __aeabi_cfcmple
|
|
|
|
END_COMPILERRT_FUNCTION(__aeabi_cfrcmple)
|
|
|
|
|
2016-06-23 06:09:42 +08:00
|
|
|
NO_EXEC_STACK_DIRECTIVE
|
|
|
|
|