Path: blob/main/lib/libc/arm/aeabi/aeabi_asm_double.S
39507 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_cdcmple:35* Z C36* LT 0 037* EQ 1 138* else 0 139*40* __aeabi_cdrcmple is the same as __aeabi_cdcmple, however the arguments41* have been swapped.42*/43ENTRY(__aeabi_cdcmple)44push {r4, r5, r6, r7, ip, lr}4546/* Backup the input registers */47mov r4, r048mov r5, r149mov r6, r250mov r7, r351/* Is it less than? */52bl __aeabi_dcmplt53cmp r0, #154bne 1f55/* Yes, clear Z and C */56mov ip, #(0)57b 99f58591:60/* Restore the input regsters for the next function call */61mov r0, r462mov r1, r563mov r2, r664mov r3, r765/* Is it equal? */66bl __aeabi_dcmpeq67cmp r0, #168bne 2f69/* Yes, set Z and C */70mov ip, #(PCR_Z | PCR_C)71b 99f72732:74/* Not less than or equal, set C and clear Z */75mov ip, #(PCR_C)767799:78msr cpsr_c, ip79pop {r4, r5, r6, r7, ip, pc}80END(__aeabi_cdcmple)8182ENTRY(__aeabi_cdrcmple)83/* Swap the first half of the arguments */84mov ip, r085mov r0, r286mov r2, ip8788/* And the second half */89mov ip, r190mov r1, r391mov r3, ip9293b __aeabi_cdcmple94END(__aeabi_cdrcmple)9596/*97* This is just like __aeabi_cdcmple except it will not throw an exception98* in the presence of a quiet NaN. If either argument is a signalling NaN we99* will still signal.100*/101ENTRY(__aeabi_cdcmpeq)102/* Check if we can call __aeabi_cfcmple safely */103push {r0, r1, r2, r3, r4, lr}104bl __aeabi_cdcmpeq_helper105cmp r0, #1106pop {r0, r1, r2, r3, r4, lr}107beq 1f108109bl __aeabi_cdcmple110RET1111121:113mov ip, #(PCR_C)114msr cpsr_c, ip115RET116END(__aeabi_cdcmpeq)117118.section .note.GNU-stack,"",%progbits119120121