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