1 //===-- aeabi_cdcmp.S - EABI cdcmp* implementation ------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "../assembly.h"
11 #if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
12 #error big endian support not implemented
15 #define APSR_Z (1 << 30)
16 #define APSR_C (1 << 29)
18 // void __aeabi_cdcmpeq(double a, double b) {
19 // if (isnan(a) || isnan(b)) {
22 // __aeabi_cdcmple(a, b);
28 DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmpeq)
30 bl __aeabi_cdcmpeq_check_nan
32 #if defined(USE_THUMB_1)
34 // NaN has been ruled out, so __aeabi_cdcmple can't trap
47 // NaN has been ruled out, so __aeabi_cdcmple can't trap
48 // Use "it ne" + unconditional branch to guarantee a supported relocation if
49 // __aeabi_cdcmple is in a different section for some builds.
53 #if defined(USE_THUMB_2)
57 msr APSR_nzcvq, #APSR_C
61 END_COMPILERRT_FUNCTION(__aeabi_cdcmpeq)
64 // void __aeabi_cdcmple(double a, double b) {
65 // if (__aeabi_dcmplt(a, b)) {
67 // } else if (__aeabi_dcmpeq(a, b)) {
76 DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmple)
77 // Per the RTABI, this function must preserve r0-r11.
78 // Save lr in the same instruction for compactness
83 #if defined(USE_THUMB_1)
113 moveq ip, #(APSR_C | APSR_Z)
121 END_COMPILERRT_FUNCTION(__aeabi_cdcmple)
123 // int __aeabi_cdrcmple(double a, double b) {
124 // return __aeabi_cdcmple(b, a);
129 DEFINE_COMPILERRT_FUNCTION(__aeabi_cdrcmple)
141 END_COMPILERRT_FUNCTION(__aeabi_cdrcmple)
143 NO_EXEC_STACK_DIRECTIVE