Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / builtins / arm / aeabi_fcmp.S
blobcd311b417096adad7d02aece3ead4f0cc49e0df2
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 //===----------------------------------------------------------------------===//
9 #include "../assembly.h"
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 // }
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
28 #define DEFINE_AEABI_FCMP(cond)                            \
29         .syntax unified                          SEPARATOR \
30         .p2align 2                               SEPARATOR \
31 DEFINE_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 \
39 1:                                               SEPARATOR \
40         movs      r0, #1                         SEPARATOR \
41         pop       { r4, pc }                     SEPARATOR \
42 END_COMPILERRT_FUNCTION(__aeabi_fcmp ## cond)
44 DEFINE_AEABI_FCMP(eq)
45 DEFINE_AEABI_FCMP(lt)
46 DEFINE_AEABI_FCMP(le)
47 DEFINE_AEABI_FCMP(ge)
48 DEFINE_AEABI_FCMP(gt)
50 NO_EXEC_STACK_DIRECTIVE