1 1.1 mrg /* 2 1.1.1.11 mrg * Copyright (C) 2012-2024 Free Software Foundation, Inc. 3 1.1 mrg * 4 1.1 mrg * This file is free software; you can redistribute it and/or modify it 5 1.1 mrg * under the terms of the GNU General Public License as published by the 6 1.1 mrg * Free Software Foundation; either version 3, or (at your option) any 7 1.1 mrg * later version. 8 1.1 mrg * 9 1.1 mrg * This file is distributed in the hope that it will be useful, but 10 1.1 mrg * WITHOUT ANY WARRANTY; without even the implied warranty of 11 1.1 mrg * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 1.1 mrg * General Public License for more details. 13 1.1 mrg * 14 1.1 mrg * Under Section 7 of GPL version 3, you are granted additional 15 1.1 mrg * permissions described in the GCC Runtime Library Exception, version 16 1.1 mrg * 3.1, as published by the Free Software Foundation. 17 1.1 mrg * 18 1.1 mrg * You should have received a copy of the GNU General Public License and 19 1.1 mrg * a copy of the GCC Runtime Library Exception along with this program; 20 1.1 mrg * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 21 1.1 mrg * <http://www.gnu.org/licenses/>. 22 1.1 mrg */ 23 1.1 mrg 24 1.1 mrg #include "sfp-machine.h" 25 1.1 mrg 26 1.1 mrg void 27 1.1 mrg __sfp_handle_exceptions (int _fex) 28 1.1 mrg { 29 1.1 mrg double d; 30 1.1 mrg 31 1.1 mrg if (_fex & FP_EX_INVALID) 32 1.1 mrg { 33 1.1 mrg asm volatile ("frcpa.s0 %0, p1 = f0, f0" : "=f" (d) : : "p1"); 34 1.1 mrg } 35 1.1 mrg if (_fex & FP_EX_DIVZERO) 36 1.1 mrg { 37 1.1 mrg asm volatile ("frcpa.s0 %0, p1 = f1, f0" : "=f" (d) : : "p1"); 38 1.1 mrg } 39 1.1 mrg if (_fex & FP_EX_OVERFLOW) 40 1.1 mrg { 41 1.1 mrg d = __DBL_MAX__; 42 1.1 mrg asm volatile ("fadd.d.s0 %0 = %0, %0" : "+f" (d)); 43 1.1 mrg } 44 1.1 mrg if (_fex & FP_EX_UNDERFLOW) 45 1.1 mrg { 46 1.1 mrg d = __DBL_MIN__; 47 1.1 mrg asm volatile ("fnma.d.s0 %0 = %0, %0, f0" : "+f" (d)); 48 1.1 mrg } 49 1.1 mrg if (_fex & FP_EX_INEXACT) 50 1.1 mrg { 51 1.1 mrg d = __DBL_MAX__; 52 1.1 mrg asm volatile ("fsub.d.s0 %0 = %0, f1" : "+f" (d)); 53 1.1 mrg } 54 1.1 mrg } 55