1*7c3d14c8STreehugger Robot//===-- aeabi_cfcmp.S - EABI cfcmp* implementation ------------------------===// 2*7c3d14c8STreehugger Robot// 3*7c3d14c8STreehugger Robot// The LLVM Compiler Infrastructure 4*7c3d14c8STreehugger Robot// 5*7c3d14c8STreehugger Robot// This file is dual licensed under the MIT and the University of Illinois Open 6*7c3d14c8STreehugger Robot// Source Licenses. See LICENSE.TXT for details. 7*7c3d14c8STreehugger Robot// 8*7c3d14c8STreehugger Robot//===----------------------------------------------------------------------===// 9*7c3d14c8STreehugger Robot 10*7c3d14c8STreehugger Robot#include "../assembly.h" 11*7c3d14c8STreehugger Robot 12*7c3d14c8STreehugger Robot#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ 13*7c3d14c8STreehugger Robot#error big endian support not implemented 14*7c3d14c8STreehugger Robot#endif 15*7c3d14c8STreehugger Robot 16*7c3d14c8STreehugger Robot#define APSR_Z (1 << 30) 17*7c3d14c8STreehugger Robot#define APSR_C (1 << 29) 18*7c3d14c8STreehugger Robot 19*7c3d14c8STreehugger Robot// void __aeabi_cfcmpeq(float a, float b) { 20*7c3d14c8STreehugger Robot// if (isnan(a) || isnan(b)) { 21*7c3d14c8STreehugger Robot// Z = 0; C = 1; 22*7c3d14c8STreehugger Robot// } else { 23*7c3d14c8STreehugger Robot// __aeabi_cfcmple(a, b); 24*7c3d14c8STreehugger Robot// } 25*7c3d14c8STreehugger Robot// } 26*7c3d14c8STreehugger Robot 27*7c3d14c8STreehugger Robot .syntax unified 28*7c3d14c8STreehugger Robot .p2align 2 29*7c3d14c8STreehugger RobotDEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmpeq) 30*7c3d14c8STreehugger Robot push {r0-r3, lr} 31*7c3d14c8STreehugger Robot bl __aeabi_cfcmpeq_check_nan 32*7c3d14c8STreehugger Robot cmp r0, #1 33*7c3d14c8STreehugger Robot pop {r0-r3, lr} 34*7c3d14c8STreehugger Robot 35*7c3d14c8STreehugger Robot // NaN has been ruled out, so __aeabi_cfcmple can't trap 36*7c3d14c8STreehugger Robot bne __aeabi_cfcmple 37*7c3d14c8STreehugger Robot 38*7c3d14c8STreehugger Robot msr CPSR_f, #APSR_C 39*7c3d14c8STreehugger Robot JMP(lr) 40*7c3d14c8STreehugger RobotEND_COMPILERRT_FUNCTION(__aeabi_cfcmpeq) 41*7c3d14c8STreehugger Robot 42*7c3d14c8STreehugger Robot 43*7c3d14c8STreehugger Robot// void __aeabi_cfcmple(float a, float b) { 44*7c3d14c8STreehugger Robot// if (__aeabi_fcmplt(a, b)) { 45*7c3d14c8STreehugger Robot// Z = 0; C = 0; 46*7c3d14c8STreehugger Robot// } else if (__aeabi_fcmpeq(a, b)) { 47*7c3d14c8STreehugger Robot// Z = 1; C = 1; 48*7c3d14c8STreehugger Robot// } else { 49*7c3d14c8STreehugger Robot// Z = 0; C = 1; 50*7c3d14c8STreehugger Robot// } 51*7c3d14c8STreehugger Robot// } 52*7c3d14c8STreehugger Robot 53*7c3d14c8STreehugger Robot .syntax unified 54*7c3d14c8STreehugger Robot .p2align 2 55*7c3d14c8STreehugger RobotDEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmple) 56*7c3d14c8STreehugger Robot // Per the RTABI, this function must preserve r0-r11. 57*7c3d14c8STreehugger Robot // Save lr in the same instruction for compactness 58*7c3d14c8STreehugger Robot push {r0-r3, lr} 59*7c3d14c8STreehugger Robot 60*7c3d14c8STreehugger Robot bl __aeabi_fcmplt 61*7c3d14c8STreehugger Robot cmp r0, #1 62*7c3d14c8STreehugger Robot moveq ip, #0 63*7c3d14c8STreehugger Robot beq 1f 64*7c3d14c8STreehugger Robot 65*7c3d14c8STreehugger Robot ldm sp, {r0-r3} 66*7c3d14c8STreehugger Robot bl __aeabi_fcmpeq 67*7c3d14c8STreehugger Robot cmp r0, #1 68*7c3d14c8STreehugger Robot moveq ip, #(APSR_C | APSR_Z) 69*7c3d14c8STreehugger Robot movne ip, #(APSR_C) 70*7c3d14c8STreehugger Robot 71*7c3d14c8STreehugger Robot1: 72*7c3d14c8STreehugger Robot msr CPSR_f, ip 73*7c3d14c8STreehugger Robot pop {r0-r3} 74*7c3d14c8STreehugger Robot POP_PC() 75*7c3d14c8STreehugger RobotEND_COMPILERRT_FUNCTION(__aeabi_cfcmple) 76*7c3d14c8STreehugger Robot 77*7c3d14c8STreehugger Robot// int __aeabi_cfrcmple(float a, float b) { 78*7c3d14c8STreehugger Robot// return __aeabi_cfcmple(b, a); 79*7c3d14c8STreehugger Robot// } 80*7c3d14c8STreehugger Robot 81*7c3d14c8STreehugger Robot .syntax unified 82*7c3d14c8STreehugger Robot .p2align 2 83*7c3d14c8STreehugger RobotDEFINE_COMPILERRT_FUNCTION(__aeabi_cfrcmple) 84*7c3d14c8STreehugger Robot // Swap r0 and r1 85*7c3d14c8STreehugger Robot mov ip, r0 86*7c3d14c8STreehugger Robot mov r0, r1 87*7c3d14c8STreehugger Robot mov r1, ip 88*7c3d14c8STreehugger Robot 89*7c3d14c8STreehugger Robot b __aeabi_cfcmple 90*7c3d14c8STreehugger RobotEND_COMPILERRT_FUNCTION(__aeabi_cfrcmple) 91*7c3d14c8STreehugger Robot 92*7c3d14c8STreehugger RobotNO_EXEC_STACK_DIRECTIVE 93*7c3d14c8STreehugger Robot 94