xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/arm/aeabi_dcmp.S (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1//===-- aeabi_dcmp.S - EABI dcmp* implementation ---------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "../assembly.h"
10
11// int __aeabi_dcmp{eq,lt,le,ge,gt}(double a, double b) {
12//   int result = __{eq,lt,le,ge,gt}df2(a, b);
13//   if (result {==,<,<=,>=,>} 0) {
14//     return 1;
15//   } else {
16//     return 0;
17//   }
18// }
19
20#if defined(COMPILER_RT_ARMHF_TARGET)
21#  define CONVERT_DCMP_ARGS_TO_DF2_ARGS                    \
22        vmov      d0, r0, r1                     SEPARATOR \
23        vmov      d1, r2, r3
24#else
25#  define CONVERT_DCMP_ARGS_TO_DF2_ARGS
26#endif
27
28#define DEFINE_AEABI_DCMP(cond)                            \
29        .syntax unified                          SEPARATOR \
30        .p2align 2                               SEPARATOR \
31DEFINE_COMPILERRT_FUNCTION(__aeabi_dcmp ## cond)           \
32        push      { r4, lr }                     SEPARATOR \
33        CONVERT_DCMP_ARGS_TO_DF2_ARGS            SEPARATOR \
34        bl        SYMBOL_NAME(__ ## cond ## df2) SEPARATOR \
35        cmp       r0, #0                         SEPARATOR \
36        b ## cond 1f                             SEPARATOR \
37        movs      r0, #0                         SEPARATOR \
38        pop       { r4, pc }                     SEPARATOR \
391:                                               SEPARATOR \
40        movs      r0, #1                         SEPARATOR \
41        pop       { r4, pc }                     SEPARATOR \
42END_COMPILERRT_FUNCTION(__aeabi_dcmp ## cond)
43
44DEFINE_AEABI_DCMP(eq)
45DEFINE_AEABI_DCMP(lt)
46DEFINE_AEABI_DCMP(le)
47DEFINE_AEABI_DCMP(ge)
48DEFINE_AEABI_DCMP(gt)
49
50NO_EXEC_STACK_DIRECTIVE
51
52