1a06918a3SAndrew Turner/* 2a06918a3SAndrew Turner * Copyright (C) 2013 Andrew Turner 3a06918a3SAndrew Turner * All rights reserved. 4a06918a3SAndrew Turner * 5a06918a3SAndrew Turner * Redistribution and use in source and binary forms, with or without 6a06918a3SAndrew Turner * modification, are permitted provided that the following conditions 7a06918a3SAndrew Turner * are met: 8a06918a3SAndrew Turner * 1. Redistributions of source code must retain the above copyright 9a06918a3SAndrew Turner * notice, this list of conditions and the following disclaimer. 10a06918a3SAndrew Turner * 2. Redistributions in binary form must reproduce the above copyright 11a06918a3SAndrew Turner * notice, this list of conditions and the following disclaimer in the 12a06918a3SAndrew Turner * documentation and/or other materials provided with the distribution. 13a06918a3SAndrew Turner * 14a06918a3SAndrew Turner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15a06918a3SAndrew Turner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16a06918a3SAndrew Turner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17a06918a3SAndrew Turner * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18a06918a3SAndrew Turner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19a06918a3SAndrew Turner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20a06918a3SAndrew Turner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21a06918a3SAndrew Turner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22a06918a3SAndrew Turner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23a06918a3SAndrew Turner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24a06918a3SAndrew Turner * SUCH DAMAGE. 25a06918a3SAndrew Turner * 26a06918a3SAndrew Turner */ 27a06918a3SAndrew Turner 28a06918a3SAndrew Turner#include <machine/asm.h> 29a06918a3SAndrew Turner#include "aeabi_vfp.h" 30a06918a3SAndrew Turner 31a06918a3SAndrew Turner.fpu vfp 32a06918a3SAndrew Turner.syntax unified 33a06918a3SAndrew Turner 34cb8bcafaSAndrew Turner/* void __aeabi_cfcmpeq(float, float) */ 35cb8bcafaSAndrew TurnerAEABI_ENTRY(cfcmpeq) 36cb8bcafaSAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 37cb8bcafaSAndrew Turner vcmp.f32 s0, s1 38cb8bcafaSAndrew Turner vmrs APSR_nzcv, fpscr 39cb8bcafaSAndrew Turner RET 40cb8bcafaSAndrew TurnerAEABI_END(cfcmpeq) 41cb8bcafaSAndrew Turner 42cb8bcafaSAndrew Turner/* void __aeabi_cfcmple(float, float) */ 43cb8bcafaSAndrew TurnerAEABI_ENTRY(cfcmple) 44cb8bcafaSAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 45cb8bcafaSAndrew Turner vcmpe.f32 s0, s1 46cb8bcafaSAndrew Turner vmrs APSR_nzcv, fpscr 47cb8bcafaSAndrew Turner RET 48cb8bcafaSAndrew TurnerAEABI_END(cfcmple) 49cb8bcafaSAndrew Turner 50cb8bcafaSAndrew Turner/* void __aeabi_cfrcmple(float, float) */ 51cb8bcafaSAndrew TurnerAEABI_ENTRY(cfrcmple) 52cb8bcafaSAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 53cb8bcafaSAndrew Turner vcmpe.f32 s1, s0 54cb8bcafaSAndrew Turner vmrs APSR_nzcv, fpscr 55cb8bcafaSAndrew Turner RET 56cb8bcafaSAndrew TurnerAEABI_END(cfrcmple) 57cb8bcafaSAndrew Turner 58a06918a3SAndrew Turner/* int __aeabi_fcmpeq(float, float) */ 59a06918a3SAndrew TurnerAEABI_ENTRY(fcmpeq) 60a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 61a06918a3SAndrew Turner vcmp.f32 s0, s1 62a06918a3SAndrew Turner vmrs APSR_nzcv, fpscr 632b6a6357SAndrew Turner ite ne 64a06918a3SAndrew Turner movne r0, #0 65a06918a3SAndrew Turner moveq r0, #1 66a06918a3SAndrew Turner RET 67a06918a3SAndrew TurnerAEABI_END(fcmpeq) 68a06918a3SAndrew Turner 69a06918a3SAndrew Turner/* int __aeabi_fcmplt(float, float) */ 70a06918a3SAndrew TurnerAEABI_ENTRY(fcmplt) 71a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 72a06918a3SAndrew Turner vcmp.f32 s0, s1 73a06918a3SAndrew Turner vmrs APSR_nzcv, fpscr 742b6a6357SAndrew Turner ite cs 75a06918a3SAndrew Turner movcs r0, #0 762b6a6357SAndrew Turner movcc r0, #1 77a06918a3SAndrew Turner RET 78a06918a3SAndrew TurnerAEABI_END(fcmplt) 79a06918a3SAndrew Turner 80a06918a3SAndrew Turner/* int __aeabi_fcmple(float, float) */ 81a06918a3SAndrew TurnerAEABI_ENTRY(fcmple) 82a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 83a06918a3SAndrew Turner vcmp.f32 s0, s1 84a06918a3SAndrew Turner vmrs APSR_nzcv, fpscr 852b6a6357SAndrew Turner ite hi 86a06918a3SAndrew Turner movhi r0, #0 87a06918a3SAndrew Turner movls r0, #1 88a06918a3SAndrew Turner RET 89a06918a3SAndrew TurnerAEABI_END(fcmple) 90a06918a3SAndrew Turner 91a06918a3SAndrew Turner/* int __aeabi_fcmpge(float, float) */ 92a06918a3SAndrew TurnerAEABI_ENTRY(fcmpge) 93a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 94a06918a3SAndrew Turner vcmp.f32 s0, s1 95a06918a3SAndrew Turner vmrs APSR_nzcv, fpscr 962b6a6357SAndrew Turner ite lt 97a06918a3SAndrew Turner movlt r0, #0 98a06918a3SAndrew Turner movge r0, #1 99a06918a3SAndrew Turner RET 100a06918a3SAndrew TurnerAEABI_END(fcmpge) 101a06918a3SAndrew Turner 102a06918a3SAndrew Turner/* int __aeabi_fcmpgt(float, float) */ 103a06918a3SAndrew TurnerAEABI_ENTRY(fcmpgt) 104a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 105a06918a3SAndrew Turner vcmp.f32 s0, s1 106a06918a3SAndrew Turner vmrs APSR_nzcv, fpscr 1072b6a6357SAndrew Turner ite le 108a06918a3SAndrew Turner movle r0, #0 109a06918a3SAndrew Turner movgt r0, #1 110a06918a3SAndrew Turner RET 111a06918a3SAndrew TurnerAEABI_END(fcmpgt) 112a06918a3SAndrew Turner 113a06918a3SAndrew Turner/* int __aeabi_fcmpun(float, float) */ 114a06918a3SAndrew TurnerAEABI_ENTRY(fcmpun) 115a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 116a06918a3SAndrew Turner vcmp.f32 s0, s1 117a06918a3SAndrew Turner vmrs APSR_nzcv, fpscr 1182b6a6357SAndrew Turner ite vc 119a06918a3SAndrew Turner movvc r0, #0 120a06918a3SAndrew Turner movvs r0, #1 121a06918a3SAndrew Turner RET 122a06918a3SAndrew TurnerAEABI_END(fcmpun) 123a06918a3SAndrew Turner 124a06918a3SAndrew Turner/* int __aeabi_f2iz(float) */ 125a06918a3SAndrew TurnerAEABI_ENTRY(f2iz) 126a06918a3SAndrew Turner LOAD_SREG(s0, r0) 127a06918a3SAndrew Turner#if 0 128a06918a3SAndrew Turner /* 129a06918a3SAndrew Turner * This should be the correct instruction, but binutils incorrectly 130a06918a3SAndrew Turner * encodes it as the version that used FPSCR to determine the rounding. 131a06918a3SAndrew Turner * When binutils is fixed we can use this again. 132a06918a3SAndrew Turner */ 133a06918a3SAndrew Turner vcvt.s32.f32 s0, s0 134a06918a3SAndrew Turner#else 135a06918a3SAndrew Turner ftosizs s0, s0 136a06918a3SAndrew Turner#endif 137a06918a3SAndrew Turner vmov r0, s0 138a06918a3SAndrew Turner RET 139a06918a3SAndrew TurnerAEABI_END(f2iz) 140a06918a3SAndrew Turner 141a06918a3SAndrew Turner/* double __aeabi_f2d(float) */ 142a06918a3SAndrew TurnerAEABI_ENTRY(f2d) 143a06918a3SAndrew Turner LOAD_SREG(s0, r0) 144a06918a3SAndrew Turner vcvt.f64.f32 d0, s0 145a06918a3SAndrew Turner UNLOAD_DREG(r0, r1, d0) 146a06918a3SAndrew Turner RET 147a06918a3SAndrew TurnerAEABI_END(f2d) 148a06918a3SAndrew Turner 149a06918a3SAndrew Turner/* float __aeabi_i2f(int) */ 150a06918a3SAndrew TurnerAEABI_ENTRY(i2f) 151a06918a3SAndrew Turner vmov s0, r0 152a06918a3SAndrew Turner vcvt.f32.s32 s0, s0 153a06918a3SAndrew Turner UNLOAD_SREG(r0, s0) 154a06918a3SAndrew Turner RET 155a06918a3SAndrew TurnerAEABI_END(i2f) 156a06918a3SAndrew Turner 157a06918a3SAndrew Turner/* float __aeabi_fadd(float, float) */ 158a06918a3SAndrew TurnerAEABI_ENTRY(fadd) 159a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 160a06918a3SAndrew Turner vadd.f32 s0, s0, s1 161a06918a3SAndrew Turner UNLOAD_SREG(r0, s0) 162a06918a3SAndrew Turner RET 163a06918a3SAndrew TurnerAEABI_END(fadd) 164a06918a3SAndrew Turner 165a06918a3SAndrew Turner/* float __aeabi_fmul(float, float) */ 166a06918a3SAndrew TurnerAEABI_ENTRY(fdiv) 167a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 168a06918a3SAndrew Turner vdiv.f32 s0, s0, s1 169a06918a3SAndrew Turner UNLOAD_SREG(r0, s0) 170a06918a3SAndrew Turner RET 171a06918a3SAndrew TurnerAEABI_END(fdiv) 172a06918a3SAndrew Turner 173a06918a3SAndrew Turner/* float __aeabi_fmul(float, float) */ 174a06918a3SAndrew TurnerAEABI_ENTRY(fmul) 175a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 176a06918a3SAndrew Turner vmul.f32 s0, s0, s1 177a06918a3SAndrew Turner UNLOAD_SREG(r0, s0) 178a06918a3SAndrew Turner RET 179a06918a3SAndrew TurnerAEABI_END(fmul) 180a06918a3SAndrew Turner 181a06918a3SAndrew Turner/* float __aeabi_fsub(float, float) */ 182a06918a3SAndrew TurnerAEABI_ENTRY(fsub) 183a06918a3SAndrew Turner LOAD_SREGS(s0, s1, r0, r1) 184a06918a3SAndrew Turner vsub.f32 s0, s0, s1 185a06918a3SAndrew Turner UNLOAD_SREG(r0, s0) 186a06918a3SAndrew Turner RET 187a06918a3SAndrew TurnerAEABI_END(fsub) 188a06918a3SAndrew Turner 189*96cdb0abSKonstantin Belousov .section .note.GNU-stack,"",%progbits 190