aeabi_asm_float.S revision 273088
1273088Sandrew/* 2273088Sandrew * Copyright (C) 2014 Andrew Turner 3273088Sandrew * All rights reserved. 4273088Sandrew * 5273088Sandrew * Redistribution and use in source and binary forms, with or without 6273088Sandrew * modification, are permitted provided that the following conditions 7273088Sandrew * are met: 8273088Sandrew * 1. Redistributions of source code must retain the above copyright 9273088Sandrew * notice, this list of conditions and the following disclaimer. 10273088Sandrew * 2. Redistributions in binary form must reproduce the above copyright 11273088Sandrew * notice, this list of conditions and the following disclaimer in the 12273088Sandrew * documentation and/or other materials provided with the distribution. 13273088Sandrew * 14273088Sandrew * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15273088Sandrew * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16273088Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17273088Sandrew * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18273088Sandrew * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19273088Sandrew * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20273088Sandrew * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21273088Sandrew * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22273088Sandrew * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23273088Sandrew * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24273088Sandrew * SUCH DAMAGE. 25273088Sandrew * 26273088Sandrew */ 27273088Sandrew 28273088Sandrew#include <machine/asm.h> 29273088Sandrew__FBSDID("$FreeBSD: head/lib/libc/arm/aeabi/aeabi_asm_float.S 273088 2014-10-14 14:27:51Z andrew $"); 30273088Sandrew 31273088Sandrew#define PCR_Z (1 << 30) 32273088Sandrew#define PCR_C (1 << 29) 33273088Sandrew 34273088Sandrew/* 35273088Sandrew * These functions return the result in the CPSR register. 36273088Sandrew * 37273088Sandrew * For __aeabi_cfcmple: 38273088Sandrew * Z C 39273088Sandrew * LT 0 0 40273088Sandrew * EQ 1 1 41273088Sandrew * else 0 1 42273088Sandrew * 43273088Sandrew * __aeabi_cfrcmple is the same as __aeabi_cfcmple, however the arguments 44273088Sandrew * have been swapped. 45273088Sandrew */ 46273088SandrewENTRY(__aeabi_cfcmple) 47273088Sandrew push {r4, r5, ip, lr} 48273088Sandrew 49273088Sandrew /* Backup the input registers */ 50273088Sandrew mov r4, r0 51273088Sandrew mov r5, r1 52273088Sandrew /* Is it less than? */ 53273088Sandrew bl __aeabi_fcmplt 54273088Sandrew cmp r0, #1 55273088Sandrew bne 1f 56273088Sandrew /* Yes, clear Z and C */ 57273088Sandrew msr cpsr_c, #(0) 58273088Sandrew b 99f 59273088Sandrew 60273088Sandrew1: 61273088Sandrew /* Restore the input regsters for the next function call */ 62273088Sandrew mov r0, r4 63273088Sandrew mov r1, r5 64273088Sandrew /* Is it equal? */ 65273088Sandrew bl __aeabi_fcmpeq 66273088Sandrew cmp r0, #1 67273088Sandrew bne 2f 68273088Sandrew /* Yes, set Z and C */ 69273088Sandrew msr cpsr_c, #(PCR_Z | PCR_C) 70273088Sandrew b 99f 71273088Sandrew 72273088Sandrew2: 73273088Sandrew /* Not less than or equal, set C and clear Z */ 74273088Sandrew msr cpsr_c, #(PCR_C) 75273088Sandrew 76273088Sandrew99: 77273088Sandrew pop {r4, r5, ip, pc} 78273088SandrewEND(__aeabi_cfcmple) 79273088Sandrew 80273088SandrewENTRY(__aeabi_cfrcmple) 81273088Sandrew /* Swap the arguments */ 82273088Sandrew mov ip, r0 83273088Sandrew mov r0, r1 84273088Sandrew mov r1, ip 85273088Sandrew 86273088Sandrew b __aeabi_cfcmple 87273088SandrewEND(__aeabi_cfrcmple) 88273088Sandrew 89273088Sandrew/* 90273088Sandrew * This is just like __aeabi_cfcmple except it will not throw an exception 91273088Sandrew * in the presence of a quiet NaN. If either argument is a signalling NaN we 92273088Sandrew * will still signal. 93273088Sandrew */ 94273088SandrewENTRY(__aeabi_cfcmpeq) 95273088Sandrew /* Check if we can call __aeabi_cfcmple safely */ 96273088Sandrew push {r0, r1, r2, lr} 97273088Sandrew bl __aeabi_cfcmpeq_helper 98273088Sandrew cmp r0, #1 99273088Sandrew pop {r0, r1, r2, lr} 100273088Sandrew beq 1f 101273088Sandrew 102273088Sandrew bl __aeabi_cfcmple 103273088Sandrew RET 104273088Sandrew 105273088Sandrew1: 106273088Sandrew msreq cpsr_c, #(PCR_C) 107273088Sandrew RET 108273088SandrewEND(__aeabi_cfcmpeq) 109