Path: blob/main/lib/libc/arm/aeabi/aeabi_asm_float.S
39562 views
/*1* Copyright (C) 2014 Andrew Turner2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*25*/2627#include <machine/asm.h>28#define PCR_Z (1 << 30)29#define PCR_C (1 << 29)3031/*32* These functions return the result in the CPSR register.33*34* For __aeabi_cfcmple:35* Z C36* LT 0 037* EQ 1 138* else 0 139*40* __aeabi_cfrcmple is the same as __aeabi_cfcmple, however the arguments41* have been swapped.42*/43ENTRY(__aeabi_cfcmple)44push {r4, r5, ip, lr}4546/* Backup the input registers */47mov r4, r048mov r5, r149/* Is it less than? */50bl __aeabi_fcmplt51cmp r0, #152bne 1f53/* Yes, clear Z and C */54mov ip, #(0)55b 99f56571:58/* Restore the input regsters for the next function call */59mov r0, r460mov r1, r561/* Is it equal? */62bl __aeabi_fcmpeq63cmp r0, #164bne 2f65/* Yes, set Z and C */66mov ip, #(PCR_Z | PCR_C)67b 99f68692:70/* Not less than or equal, set C and clear Z */71mov ip, #(PCR_C)727399:74msr cpsr_c, ip75pop {r4, r5, ip, pc}76END(__aeabi_cfcmple)7778ENTRY(__aeabi_cfrcmple)79/* Swap the arguments */80mov ip, r081mov r0, r182mov r1, ip8384b __aeabi_cfcmple85END(__aeabi_cfrcmple)8687/*88* This is just like __aeabi_cfcmple except it will not throw an exception89* in the presence of a quiet NaN. If either argument is a signalling NaN we90* will still signal.91*/92ENTRY(__aeabi_cfcmpeq)93/* Check if we can call __aeabi_cfcmple safely */94push {r0, r1, r2, lr}95bl __aeabi_cfcmpeq_helper96cmp r0, #197pop {r0, r1, r2, lr}98beq 1f99100bl __aeabi_cfcmple101RET1021031:104mov ip, #(PCR_C)105msr cpsr_c, ip106RET107END(__aeabi_cfcmpeq)108109.section .note.GNU-stack,"",%progbits110111112