Skip gcc.dg/analyzer/pr94688.c on hppa*64*-*-*
[official-gcc.git] / libgcc / config / riscv / sfp-machine.h
blob0ad97081e88474f0fdacb73ae64cbb19ad048afe
1 /* Software floating-point machine description for RISC-V.
3 Copyright (C) 2016-2024 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
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.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 #if __riscv_xlen == 32
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
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)
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)
44 #define _FP_NANFRAC_H _FP_QNANBIT_H
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
49 #else
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
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)
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)
67 #define _FP_NANFRAC_H _FP_QNANBIT_H
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
72 #endif
74 #if __riscv_xlen == 64
75 typedef int TItype __attribute__ ((mode (TI)));
76 typedef unsigned int UTItype __attribute__ ((mode (TI)));
77 #define TI_BITS (__CHAR_BIT__ * (int)sizeof(TItype))
78 #endif
80 /* The type of the result of a floating point comparison. This must
81 match __libgcc_cmp_return__ in GCC for the target. */
82 typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
83 #define CMPtype __gcc_CMPtype
85 #define _FP_NANSIGN_H 0
86 #define _FP_NANSIGN_S 0
87 #define _FP_NANSIGN_D 0
88 #define _FP_NANSIGN_Q 0
90 #define _FP_KEEPNANFRACP 0
91 #define _FP_QNANNEGATEDP 0
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)
100 #define _FP_DECL_EX int _frm __attribute__ ((unused));
101 #define FP_ROUNDMODE _frm
103 #define FP_RND_NEAREST 0x0
104 #define FP_RND_ZERO 0x1
105 #define FP_RND_PINF 0x3
106 #define FP_RND_MINF 0x2
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
114 #define _FP_TININESS_AFTER_ROUNDING 1
116 #if defined(__riscv_flen) || defined(__riscv_zfinx)
117 #define FP_INIT_ROUNDMODE \
118 do { \
119 __asm__ volatile ("frrm %0" : "=r" (_frm)); \
120 } while (0)
122 #define FP_HANDLE_EXCEPTIONS \
123 do { \
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
131 #define __LITTLE_ENDIAN 1234
132 #define __BIG_ENDIAN 4321
134 #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
135 #define __BYTE_ORDER __BIG_ENDIAN
136 #else
137 #define __BYTE_ORDER __LITTLE_ENDIAN
138 #endif
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)));