| 1 |
/* Copyright (C) 2010-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
This file is part of GCC. |
| 4 |
|
| 5 |
GCC is free software; you can redistribute it and/or modify it |
| 6 |
under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 3, or (at your option) |
| 8 |
any later version. |
| 9 |
|
| 10 |
GCC is distributed in the hope that it will be useful, but WITHOUT |
| 11 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 12 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 13 |
License for more details. |
| 14 |
|
| 15 |
Under Section 7 of GPL version 3, you are granted additional |
| 16 |
permissions described in the GCC Runtime Library Exception, version |
| 17 |
3.1, as published by the Free Software Foundation. |
| 18 |
|
| 19 |
You should have received a copy of the GNU General Public License |
| 20 |
and a copy of the GCC Runtime Library Exception along with this |
| 21 |
program; see the files COPYING3 and COPYING.RUNTIME respectively. |
| 22 |
If not, see <http://www.gnu.org/licenses/>. */ |
| 23 |
|
| 24 |
#ifdef __mips_hard_float |
| 25 |
|
| 26 |
/* Flush denormalized numbers to zero. */ |
| 27 |
#define _FPU_FLUSH_TZ 0x1000000 |
| 28 |
|
| 29 |
/* Rounding control. */ |
| 30 |
#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */ |
| 31 |
#define _FPU_RC_ZERO 0x1 |
| 32 |
#define _FPU_RC_UP 0x2 |
| 33 |
#define _FPU_RC_DOWN 0x3 |
| 34 |
|
| 35 |
/* Enable interrupts for IEEE exceptions. */ |
| 36 |
#define _FPU_IEEE 0x00000F80 |
| 37 |
|
| 38 |
/* Macros for accessing the hardware control word. */ |
| 39 |
#define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw)) |
| 40 |
#define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw)) |
| 41 |
|
| 42 |
static void __attribute__((constructor,nomips16)) |
| 43 |
set_fast_math (void) |
| 44 |
{ |
| 45 |
unsigned int fcr; |
| 46 |
|
| 47 |
/* Flush to zero, round to nearest, IEEE exceptions disabled. */ |
| 48 |
fcr = _FPU_FLUSH_TZ | _FPU_RC_NEAREST; |
| 49 |
|
| 50 |
_FPU_SETCW(fcr); |
| 51 |
} |
| 52 |
|
| 53 |
#endif /* __mips_hard_float */ |