xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/arm/aeabi_fcmp.S (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1//===-- aeabi_fcmp.S - EABI fcmp* 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_fcmp{eq,lt,le,ge,gt}(float a, float b) {
12//   int result = __{eq,lt,le,ge,gt}sf2(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_FCMP_ARGS_TO_SF2_ARGS                    \
22        vmov      s0, r0                         SEPARATOR \
23        vmov      s1, r1
24#else
25#  define CONVERT_FCMP_ARGS_TO_SF2_ARGS
26#endif
27
28#define DEFINE_AEABI_FCMP(cond)                            \
29        .syntax unified                          SEPARATOR \
30        .p2align 2                               SEPARATOR \
31DEFINE_COMPILERRT_FUNCTION(__aeabi_fcmp ## cond)           \
32        push      { r4, lr }                     SEPARATOR \
33        CONVERT_FCMP_ARGS_TO_SF2_ARGS            SEPARATOR \
34        bl        SYMBOL_NAME(__ ## cond ## sf2) 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_fcmp ## cond)
43
44DEFINE_AEABI_FCMP(eq)
45DEFINE_AEABI_FCMP(lt)
46DEFINE_AEABI_FCMP(le)
47DEFINE_AEABI_FCMP(ge)
48DEFINE_AEABI_FCMP(gt)
49
50NO_EXEC_STACK_DIRECTIVE
51
52