]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/config/loongarch/crtfastmath.c
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / loongarch / crtfastmath.c
CommitLineData
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
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT
13ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15License for more details.
16
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License
22and a copy of the GCC Runtime Library Exception along with this
23program; see the files COPYING3 and COPYING.RUNTIME respectively.
24If 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
41static void __attribute__((constructor))
42set_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 */