]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/config/riscv/sfp-machine.h
Update copyright years.
[thirdparty/gcc.git] / libgcc / config / riscv / sfp-machine.h
CommitLineData
0bd99911
PD
1/* Software floating-point machine description for RISC-V.
2
83ffe9cd 3 Copyright (C) 2016-2023 Free Software Foundation, Inc.
0bd99911
PD
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for 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 and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
25
26#if __riscv_xlen == 32
27
28#define _FP_W_TYPE_SIZE 32
29#define _FP_W_TYPE unsigned long
30#define _FP_WS_TYPE signed long
31#define _FP_I_TYPE long
32
33#define _FP_MUL_MEAT_S(R,X,Y) \
34 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
35#define _FP_MUL_MEAT_D(R,X,Y) \
36 _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
37#define _FP_MUL_MEAT_Q(R,X,Y) \
38 _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
39
40#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
41#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
42#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
43
27d68a60 44#define _FP_NANFRAC_H _FP_QNANBIT_H
0bd99911
PD
45#define _FP_NANFRAC_S _FP_QNANBIT_S
46#define _FP_NANFRAC_D _FP_QNANBIT_D, 0
47#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0, 0, 0
48
49#else
50
51#define _FP_W_TYPE_SIZE 64
52#define _FP_W_TYPE unsigned long long
53#define _FP_WS_TYPE signed long long
54#define _FP_I_TYPE long long
55
56#define _FP_MUL_MEAT_S(R,X,Y) \
57 _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
58#define _FP_MUL_MEAT_D(R,X,Y) \
59 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
60#define _FP_MUL_MEAT_Q(R,X,Y) \
61 _FP_MUL_MEAT_2_wide_3mul(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
62
63#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
64#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
65#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
66
27d68a60 67#define _FP_NANFRAC_H _FP_QNANBIT_H
0bd99911
PD
68#define _FP_NANFRAC_S _FP_QNANBIT_S
69#define _FP_NANFRAC_D _FP_QNANBIT_D
70#define _FP_NANFRAC_Q _FP_QNANBIT_Q, 0
71
72#endif
73
74#if __riscv_xlen == 64
75typedef int TItype __attribute__ ((mode (TI)));
76typedef unsigned int UTItype __attribute__ ((mode (TI)));
77#define TI_BITS (__CHAR_BIT__ * (int)sizeof(TItype))
78#endif
79
80/* The type of the result of a floating point comparison. This must
81 match __libgcc_cmp_return__ in GCC for the target. */
82typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
83#define CMPtype __gcc_CMPtype
84
27d68a60 85#define _FP_NANSIGN_H 0
0bd99911
PD
86#define _FP_NANSIGN_S 0
87#define _FP_NANSIGN_D 0
88#define _FP_NANSIGN_Q 0
89
90#define _FP_KEEPNANFRACP 0
91#define _FP_QNANNEGATEDP 0
92
93#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
94 do { \
95 R##_s = _FP_NANSIGN_##fs; \
96 _FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs); \
97 R##_c = FP_CLS_NAN; \
98 } while (0)
99
100#define _FP_DECL_EX int _frm __attribute__ ((unused));
101#define FP_ROUNDMODE _frm
102
103#define FP_RND_NEAREST 0x0
104#define FP_RND_ZERO 0x1
105#define FP_RND_PINF 0x3
106#define FP_RND_MINF 0x2
107
108#define FP_EX_INVALID 0x10
109#define FP_EX_OVERFLOW 0x04
110#define FP_EX_UNDERFLOW 0x02
111#define FP_EX_DIVZERO 0x08
112#define FP_EX_INEXACT 0x01
113
114#define _FP_TININESS_AFTER_ROUNDING 1
115
116#ifdef __riscv_flen
117#define FP_INIT_ROUNDMODE \
118do { \
119 __asm__ volatile ("frrm %0" : "=r" (_frm)); \
120} while (0)
121
122#define FP_HANDLE_EXCEPTIONS \
123do { \
124 if (__builtin_expect (_fex, 0)) \
125 __asm__ volatile ("csrs fflags, %0" : : "rK" (_fex)); \
126} while (0)
127#else
128#define FP_INIT_ROUNDMODE _frm = FP_RND_NEAREST
129#endif
130
131#define __LITTLE_ENDIAN 1234
132#define __BIG_ENDIAN 4321
133
f1af1326
MC
134#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
135#define __BYTE_ORDER __BIG_ENDIAN
136#else
0bd99911 137#define __BYTE_ORDER __LITTLE_ENDIAN
f1af1326 138#endif
0bd99911
PD
139
140
141/* Define ALIASNAME as a strong alias for NAME. */
142# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
143# define _strong_alias(name, aliasname) \
144 extern __typeof (name) aliasname __attribute__ ((alias (#name)));