Fix atomic operations on PA-RISC 2.0 processors.
[official-gcc.git] / libgcc / config / pa / sfp-machine.h
blobfef9314cbf6c0b1321f2e6b399e1a9281eb64947
1 /* softfp machine description for PA-RISC.
2 Copyright (C) 2009-2022 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 #ifdef __LP64__
26 #define _FP_W_TYPE_SIZE 64
27 #define _FP_W_TYPE unsigned long
28 #define _FP_WS_TYPE signed long
29 #define _FP_I_TYPE long
31 typedef int TItype __attribute__ ((mode (TI)));
32 typedef unsigned int UTItype __attribute__ ((mode (TI)));
33 #define TI_BITS (__CHAR_BIT__ * (int) sizeof (TItype))
35 #define _FP_MUL_MEAT_S(R,X,Y) \
36 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
37 #define _FP_MUL_MEAT_D(R,X,Y) \
38 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
39 #define _FP_MUL_MEAT_Q(R,X,Y) \
40 _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
42 #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
43 #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
44 #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
46 #define _FP_NANFRAC_S (_FP_QNANBIT_S - 1)
47 #define _FP_NANFRAC_D (_FP_QNANBIT_D - 1)
48 #define _FP_NANFRAC_Q (_FP_QNANBIT_Q - 1), -1
49 #else
50 #define _FP_W_TYPE_SIZE 32
51 #define _FP_W_TYPE unsigned int
52 #define _FP_WS_TYPE signed int
53 #define _FP_I_TYPE int
55 #define _FP_MUL_MEAT_S(R,X,Y) \
56 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
57 #define _FP_MUL_MEAT_D(R,X,Y) \
58 _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
59 #define _FP_MUL_MEAT_Q(R,X,Y) \
60 _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
62 #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
63 #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
64 #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
66 #define _FP_NANFRAC_S (_FP_QNANBIT_S - 1)
67 #define _FP_NANFRAC_D (_FP_QNANBIT_D - 1), -1
68 #define _FP_NANFRAC_Q (_FP_QNANBIT_Q - 1), -1, -1, -1
69 #endif
71 /* The type of the result of a floating point comparison. This must
72 match __libgcc_cmp_return__ in GCC for the target. */
73 typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
74 #define CMPtype __gcc_CMPtype
76 #define _FP_NANSIGN_S 0
77 #define _FP_NANSIGN_D 0
78 #define _FP_NANSIGN_Q 0
80 #define _FP_KEEPNANFRACP 1
81 #define _FP_QNANNEGATEDP 1
83 /* Comment from glibc: */
84 /* From my experiments it seems X is chosen unless one of the
85 NaNs is sNaN, in which case the result is NANSIGN/NANFRAC. */
86 # define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
87 do { \
88 if ((_FP_FRAC_HIGH_RAW_##fs(X) | \
89 _FP_FRAC_HIGH_RAW_##fs(Y)) & _FP_QNANBIT_##fs) \
90 { \
91 R##_s = _FP_NANSIGN_##fs; \
92 _FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs); \
93 } \
94 else \
95 { \
96 R##_s = X##_s; \
97 _FP_FRAC_COPY_##wc(R,X); \
98 } \
99 R##_c = FP_CLS_NAN; \
100 } while (0)
102 #define FP_RND_NEAREST (0 << 9)
103 #define FP_RND_ZERO (1 << 9)
104 #define FP_RND_PINF (2 << 9)
105 #define FP_RND_MINF (3 << 9)
106 #define FP_RND_MASK (3 << 9)
108 #define FP_EX_INEXACT 0x01
109 #define FP_EX_UNDERFLOW 0x02
110 #define FP_EX_OVERFLOW 0x04
111 #define FP_EX_DIVZERO 0x08
112 #define FP_EX_INVALID 0x10
113 #define FP_EX_ALL 0x1F
114 #define FP_EX_SHIFT 27
116 #define _FP_TININESS_AFTER_ROUNDING 1
118 #define _FP_DECL_EX \
119 unsigned int _fcsr __attribute__ ((unused)) = FP_RND_NEAREST
121 /* Get floating-point status. */
122 #define _FPU_GETCW(cw) \
123 ({ \
124 union { unsigned long long __fpreg; \
125 unsigned int __halfreg[2]; } __fullfp; \
126 /* Get the current status word. */ \
127 __asm__ ("fstd %%fr0,0(%1)\n\t" \
128 "fldd 0(%1),%%fr0\n\t" \
129 : "=m" (__fullfp.__fpreg) \
130 : "r" (&__fullfp.__fpreg) \
131 : "%r0"); \
132 cw = __fullfp.__halfreg[0]; \
135 #define FP_INIT_ROUNDMODE _FPU_GETCW(_fcsr)
136 #define FP_ROUNDMODE (_fcsr & FP_RND_MASK)
137 #define FP_TRAPPING_EXCEPTIONS (_fcsr & FP_EX_ALL)
139 void __sfp_handle_exceptions (int);
141 #define FP_HANDLE_EXCEPTIONS \
142 do { \
143 if (__builtin_expect (_fex, 0)) \
144 __sfp_handle_exceptions (_fex); \
145 } while (0)
147 #define __LITTLE_ENDIAN 1234
148 #define __BIG_ENDIAN 4321
150 #define __BYTE_ORDER __BIG_ENDIAN
152 /* Define ALIASNAME as a strong alias for NAME. */
153 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
154 # define _strong_alias(name, aliasname) \
155 extern __typeof (name) aliasname __attribute__ ((alias (#name)));