1*0b57cec5SDimitry Andric//===-- aeabi_fcmp.S - EABI fcmp* implementation ---------------------------===// 2*0b57cec5SDimitry Andric// 3*0b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric// 7*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric#include "../assembly.h" 10*0b57cec5SDimitry Andric 11*0b57cec5SDimitry Andric// int __aeabi_fcmp{eq,lt,le,ge,gt}(float a, float b) { 12*0b57cec5SDimitry Andric// int result = __{eq,lt,le,ge,gt}sf2(a, b); 13*0b57cec5SDimitry Andric// if (result {==,<,<=,>=,>} 0) { 14*0b57cec5SDimitry Andric// return 1; 15*0b57cec5SDimitry Andric// } else { 16*0b57cec5SDimitry Andric// return 0; 17*0b57cec5SDimitry Andric// } 18*0b57cec5SDimitry Andric// } 19*0b57cec5SDimitry Andric 20*0b57cec5SDimitry Andric#if defined(COMPILER_RT_ARMHF_TARGET) 21*0b57cec5SDimitry Andric# define CONVERT_FCMP_ARGS_TO_SF2_ARGS \ 22*0b57cec5SDimitry Andric vmov s0, r0 SEPARATOR \ 23*0b57cec5SDimitry Andric vmov s1, r1 24*0b57cec5SDimitry Andric#else 25*0b57cec5SDimitry Andric# define CONVERT_FCMP_ARGS_TO_SF2_ARGS 26*0b57cec5SDimitry Andric#endif 27*0b57cec5SDimitry Andric 28*0b57cec5SDimitry Andric#define DEFINE_AEABI_FCMP(cond) \ 29*0b57cec5SDimitry Andric .syntax unified SEPARATOR \ 30*0b57cec5SDimitry Andric .p2align 2 SEPARATOR \ 31*0b57cec5SDimitry AndricDEFINE_COMPILERRT_FUNCTION(__aeabi_fcmp ## cond) \ 32*0b57cec5SDimitry Andric push { r4, lr } SEPARATOR \ 33*0b57cec5SDimitry Andric CONVERT_FCMP_ARGS_TO_SF2_ARGS SEPARATOR \ 34*0b57cec5SDimitry Andric bl SYMBOL_NAME(__ ## cond ## sf2) SEPARATOR \ 35*0b57cec5SDimitry Andric cmp r0, #0 SEPARATOR \ 36*0b57cec5SDimitry Andric b ## cond 1f SEPARATOR \ 37*0b57cec5SDimitry Andric movs r0, #0 SEPARATOR \ 38*0b57cec5SDimitry Andric pop { r4, pc } SEPARATOR \ 39*0b57cec5SDimitry Andric1: SEPARATOR \ 40*0b57cec5SDimitry Andric movs r0, #1 SEPARATOR \ 41*0b57cec5SDimitry Andric pop { r4, pc } SEPARATOR \ 42*0b57cec5SDimitry AndricEND_COMPILERRT_FUNCTION(__aeabi_fcmp ## cond) 43*0b57cec5SDimitry Andric 44*0b57cec5SDimitry AndricDEFINE_AEABI_FCMP(eq) 45*0b57cec5SDimitry AndricDEFINE_AEABI_FCMP(lt) 46*0b57cec5SDimitry AndricDEFINE_AEABI_FCMP(le) 47*0b57cec5SDimitry AndricDEFINE_AEABI_FCMP(ge) 48*0b57cec5SDimitry AndricDEFINE_AEABI_FCMP(gt) 49*0b57cec5SDimitry Andric 50*0b57cec5SDimitry AndricNO_EXEC_STACK_DIRECTIVE 51*0b57cec5SDimitry Andric 52