annotate gcc/machmode.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Machine mode definitions for GCC; included by rtl.h and tree.h.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 1991-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #ifndef HAVE_MACHINE_MODES
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #define HAVE_MACHINE_MODES
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
111
kono
parents: 67
diff changeset
23 typedef opt_mode<machine_mode> opt_machine_mode;
kono
parents: 67
diff changeset
24
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
25 extern CONST_MODE_SIZE poly_uint16_pod mode_size[NUM_MACHINE_MODES];
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
26 extern CONST_MODE_PRECISION poly_uint16_pod mode_precision[NUM_MACHINE_MODES];
111
kono
parents: 67
diff changeset
27 extern const unsigned char mode_inner[NUM_MACHINE_MODES];
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
28 extern CONST_MODE_NUNITS poly_uint16_pod mode_nunits[NUM_MACHINE_MODES];
111
kono
parents: 67
diff changeset
29 extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES];
kono
parents: 67
diff changeset
30 extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];
kono
parents: 67
diff changeset
31 extern const unsigned char mode_wider[NUM_MACHINE_MODES];
kono
parents: 67
diff changeset
32 extern const unsigned char mode_2xwider[NUM_MACHINE_MODES];
kono
parents: 67
diff changeset
33
kono
parents: 67
diff changeset
34 template<typename T>
kono
parents: 67
diff changeset
35 struct mode_traits
kono
parents: 67
diff changeset
36 {
kono
parents: 67
diff changeset
37 /* For use by the machmode support code only.
kono
parents: 67
diff changeset
38
kono
parents: 67
diff changeset
39 There are cases in which the machmode support code needs to forcibly
kono
parents: 67
diff changeset
40 convert a machine_mode to a specific mode class T, and in which the
kono
parents: 67
diff changeset
41 context guarantees that this is valid without the need for an assert.
kono
parents: 67
diff changeset
42 This can be done using:
kono
parents: 67
diff changeset
43
kono
parents: 67
diff changeset
44 return typename mode_traits<T>::from_int (mode);
kono
parents: 67
diff changeset
45
kono
parents: 67
diff changeset
46 when returning a T and:
kono
parents: 67
diff changeset
47
kono
parents: 67
diff changeset
48 res = T (typename mode_traits<T>::from_int (mode));
kono
parents: 67
diff changeset
49
kono
parents: 67
diff changeset
50 when assigning to a value RES that must be assignment-compatible
kono
parents: 67
diff changeset
51 with (but possibly not the same as) T. */
kono
parents: 67
diff changeset
52 #ifdef USE_ENUM_MODES
kono
parents: 67
diff changeset
53 /* Allow direct conversion of enums to specific mode classes only
kono
parents: 67
diff changeset
54 when USE_ENUM_MODES is defined. This is only intended for use
kono
parents: 67
diff changeset
55 by gencondmd, so that it can tell more easily when .md conditions
kono
parents: 67
diff changeset
56 are always false. */
kono
parents: 67
diff changeset
57 typedef machine_mode from_int;
kono
parents: 67
diff changeset
58 #else
kono
parents: 67
diff changeset
59 /* Here we use an enum type distinct from machine_mode but with the
kono
parents: 67
diff changeset
60 same range as machine_mode. T should have a constructor that
kono
parents: 67
diff changeset
61 accepts this enum type; it should not have a constructor that
kono
parents: 67
diff changeset
62 accepts machine_mode.
kono
parents: 67
diff changeset
63
kono
parents: 67
diff changeset
64 We use this somewhat indirect approach to avoid too many constructor
kono
parents: 67
diff changeset
65 calls when the compiler is built with -O0. For example, even in
kono
parents: 67
diff changeset
66 unoptimized code, the return statement above would construct the
kono
parents: 67
diff changeset
67 returned T directly from the numerical value of MODE. */
kono
parents: 67
diff changeset
68 enum from_int { dummy = MAX_MACHINE_MODE };
kono
parents: 67
diff changeset
69 #endif
kono
parents: 67
diff changeset
70 };
kono
parents: 67
diff changeset
71
kono
parents: 67
diff changeset
72 template<>
kono
parents: 67
diff changeset
73 struct mode_traits<machine_mode>
kono
parents: 67
diff changeset
74 {
kono
parents: 67
diff changeset
75 /* machine_mode itself needs no conversion. */
kono
parents: 67
diff changeset
76 typedef machine_mode from_int;
kono
parents: 67
diff changeset
77 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
79 /* Always treat machine modes as fixed-size while compiling code specific
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
80 to targets that have no variable-size modes. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
81 #if defined (IN_TARGET_CODE) && NUM_POLY_INT_COEFFS == 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
82 #define ONLY_FIXED_SIZE_MODES 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
83 #else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
84 #define ONLY_FIXED_SIZE_MODES 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
85 #endif
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
86
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 /* Get the name of mode MODE as a string. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 extern const char * const mode_name[NUM_MACHINE_MODES];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 #define GET_MODE_NAME(MODE) mode_name[MODE]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 /* Mode classes. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 #include "mode-classes.def"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 #define DEF_MODE_CLASS(M) M
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 enum mode_class { MODE_CLASSES, MAX_MODE_CLASS };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 #undef DEF_MODE_CLASS
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 #undef MODE_CLASSES
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 /* Get the general kind of object that mode MODE represents
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 (integer, floating, complex, etc.) */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 extern const unsigned char mode_class[NUM_MACHINE_MODES];
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
104 #define GET_MODE_CLASS(MODE) ((enum mode_class) mode_class[MODE])
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 /* Nonzero if MODE is an integral mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 #define INTEGRAL_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 (GET_MODE_CLASS (MODE) == MODE_INT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
111 || GET_MODE_CLASS (MODE) == MODE_VECTOR_BOOL \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 /* Nonzero if MODE is a floating-point mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 #define FLOAT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 /* Nonzero if MODE is a complex mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 #define COMPLEX_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 /* Nonzero if MODE is a vector mode. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
127 #define VECTOR_MODE_P(MODE) \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
128 (GET_MODE_CLASS (MODE) == MODE_VECTOR_BOOL \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
129 || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 /* Nonzero if MODE is a scalar integral mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 #define SCALAR_INT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 (GET_MODE_CLASS (MODE) == MODE_INT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 /* Nonzero if MODE is a scalar floating point mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 #define SCALAR_FLOAT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 /* Nonzero if MODE is a decimal floating point mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 #define DECIMAL_FLOAT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 (GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 /* Nonzero if MODE is a scalar fract mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 #define SCALAR_FRACT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 (GET_MODE_CLASS (MODE) == MODE_FRACT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 /* Nonzero if MODE is a scalar ufract mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 #define SCALAR_UFRACT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 (GET_MODE_CLASS (MODE) == MODE_UFRACT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 /* Nonzero if MODE is a scalar fract or ufract mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 #define ALL_SCALAR_FRACT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 (SCALAR_FRACT_MODE_P (MODE) || SCALAR_UFRACT_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 /* Nonzero if MODE is a scalar accum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 #define SCALAR_ACCUM_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 (GET_MODE_CLASS (MODE) == MODE_ACCUM)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 /* Nonzero if MODE is a scalar uaccum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 #define SCALAR_UACCUM_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 (GET_MODE_CLASS (MODE) == MODE_UACCUM)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 /* Nonzero if MODE is a scalar accum or uaccum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 #define ALL_SCALAR_ACCUM_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 (SCALAR_ACCUM_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 /* Nonzero if MODE is a scalar fract or accum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 #define SIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 (SCALAR_FRACT_MODE_P (MODE) || SCALAR_ACCUM_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 /* Nonzero if MODE is a scalar ufract or uaccum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 #define UNSIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 (SCALAR_UFRACT_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 /* Nonzero if MODE is a scalar fract, ufract, accum or uaccum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 #define ALL_SCALAR_FIXED_POINT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 (SIGNED_SCALAR_FIXED_POINT_MODE_P (MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 || UNSIGNED_SCALAR_FIXED_POINT_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 /* Nonzero if MODE is a scalar/vector fract mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 #define FRACT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 (GET_MODE_CLASS (MODE) == MODE_FRACT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 /* Nonzero if MODE is a scalar/vector ufract mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 #define UFRACT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 (GET_MODE_CLASS (MODE) == MODE_UFRACT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 /* Nonzero if MODE is a scalar/vector fract or ufract mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 #define ALL_FRACT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 (FRACT_MODE_P (MODE) || UFRACT_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 /* Nonzero if MODE is a scalar/vector accum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 #define ACCUM_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 (GET_MODE_CLASS (MODE) == MODE_ACCUM \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 /* Nonzero if MODE is a scalar/vector uaccum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 #define UACCUM_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 (GET_MODE_CLASS (MODE) == MODE_UACCUM \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 /* Nonzero if MODE is a scalar/vector accum or uaccum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 #define ALL_ACCUM_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 (ACCUM_MODE_P (MODE) || UACCUM_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 /* Nonzero if MODE is a scalar/vector fract or accum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 #define SIGNED_FIXED_POINT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 (FRACT_MODE_P (MODE) || ACCUM_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 /* Nonzero if MODE is a scalar/vector ufract or uaccum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 #define UNSIGNED_FIXED_POINT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 (UFRACT_MODE_P (MODE) || UACCUM_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 /* Nonzero if MODE is a scalar/vector fract, ufract, accum or uaccum mode. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 #define ALL_FIXED_POINT_MODE_P(MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 (SIGNED_FIXED_POINT_MODE_P (MODE) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 || UNSIGNED_FIXED_POINT_MODE_P (MODE))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 /* Nonzero if CLASS modes can be widened. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 #define CLASS_HAS_WIDER_MODES_P(CLASS) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 (CLASS == MODE_INT \
111
kono
parents: 67
diff changeset
231 || CLASS == MODE_PARTIAL_INT \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 || CLASS == MODE_FLOAT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 || CLASS == MODE_DECIMAL_FLOAT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 || CLASS == MODE_COMPLEX_FLOAT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 || CLASS == MODE_FRACT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 || CLASS == MODE_UFRACT \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 || CLASS == MODE_ACCUM \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 || CLASS == MODE_UACCUM)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239
111
kono
parents: 67
diff changeset
240 /* An optional T (i.e. a T or nothing), where T is some form of mode class. */
kono
parents: 67
diff changeset
241 template<typename T>
kono
parents: 67
diff changeset
242 class opt_mode
kono
parents: 67
diff changeset
243 {
kono
parents: 67
diff changeset
244 public:
kono
parents: 67
diff changeset
245 enum from_int { dummy = MAX_MACHINE_MODE };
kono
parents: 67
diff changeset
246
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
247 ALWAYS_INLINE CONSTEXPR opt_mode () : m_mode (E_VOIDmode) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
248 ALWAYS_INLINE CONSTEXPR opt_mode (const T &m) : m_mode (m) {}
111
kono
parents: 67
diff changeset
249 template<typename U>
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
250 ALWAYS_INLINE CONSTEXPR opt_mode (const U &m) : m_mode (T (m)) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
251 ALWAYS_INLINE CONSTEXPR opt_mode (from_int m) : m_mode (machine_mode (m)) {}
111
kono
parents: 67
diff changeset
252
kono
parents: 67
diff changeset
253 machine_mode else_void () const;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
254 machine_mode else_blk () const { return else_mode (BLKmode); }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
255 machine_mode else_mode (machine_mode) const;
111
kono
parents: 67
diff changeset
256 T require () const;
kono
parents: 67
diff changeset
257
kono
parents: 67
diff changeset
258 bool exists () const;
kono
parents: 67
diff changeset
259 template<typename U> bool exists (U *) const;
kono
parents: 67
diff changeset
260
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
261 bool operator== (const T &m) const { return m_mode == m; }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
262 bool operator!= (const T &m) const { return m_mode != m; }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
263
111
kono
parents: 67
diff changeset
264 private:
kono
parents: 67
diff changeset
265 machine_mode m_mode;
kono
parents: 67
diff changeset
266 };
kono
parents: 67
diff changeset
267
kono
parents: 67
diff changeset
268 /* If the object contains a T, return its enum value, otherwise return
kono
parents: 67
diff changeset
269 E_VOIDmode. */
kono
parents: 67
diff changeset
270
kono
parents: 67
diff changeset
271 template<typename T>
kono
parents: 67
diff changeset
272 ALWAYS_INLINE machine_mode
kono
parents: 67
diff changeset
273 opt_mode<T>::else_void () const
kono
parents: 67
diff changeset
274 {
kono
parents: 67
diff changeset
275 return m_mode;
kono
parents: 67
diff changeset
276 }
kono
parents: 67
diff changeset
277
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
278 /* If the T exists, return its enum value, otherwise return FALLBACK. */
111
kono
parents: 67
diff changeset
279
kono
parents: 67
diff changeset
280 template<typename T>
kono
parents: 67
diff changeset
281 inline machine_mode
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
282 opt_mode<T>::else_mode (machine_mode fallback) const
111
kono
parents: 67
diff changeset
283 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
284 return m_mode == E_VOIDmode ? fallback : m_mode;
111
kono
parents: 67
diff changeset
285 }
kono
parents: 67
diff changeset
286
kono
parents: 67
diff changeset
287 /* Assert that the object contains a T and return it. */
kono
parents: 67
diff changeset
288
kono
parents: 67
diff changeset
289 template<typename T>
kono
parents: 67
diff changeset
290 inline T
kono
parents: 67
diff changeset
291 opt_mode<T>::require () const
kono
parents: 67
diff changeset
292 {
kono
parents: 67
diff changeset
293 gcc_checking_assert (m_mode != E_VOIDmode);
kono
parents: 67
diff changeset
294 return typename mode_traits<T>::from_int (m_mode);
kono
parents: 67
diff changeset
295 }
kono
parents: 67
diff changeset
296
kono
parents: 67
diff changeset
297 /* Return true if the object contains a T rather than nothing. */
kono
parents: 67
diff changeset
298
kono
parents: 67
diff changeset
299 template<typename T>
kono
parents: 67
diff changeset
300 ALWAYS_INLINE bool
kono
parents: 67
diff changeset
301 opt_mode<T>::exists () const
kono
parents: 67
diff changeset
302 {
kono
parents: 67
diff changeset
303 return m_mode != E_VOIDmode;
kono
parents: 67
diff changeset
304 }
kono
parents: 67
diff changeset
305
kono
parents: 67
diff changeset
306 /* Return true if the object contains a T, storing it in *MODE if so. */
kono
parents: 67
diff changeset
307
kono
parents: 67
diff changeset
308 template<typename T>
kono
parents: 67
diff changeset
309 template<typename U>
kono
parents: 67
diff changeset
310 inline bool
kono
parents: 67
diff changeset
311 opt_mode<T>::exists (U *mode) const
kono
parents: 67
diff changeset
312 {
kono
parents: 67
diff changeset
313 if (m_mode != E_VOIDmode)
kono
parents: 67
diff changeset
314 {
kono
parents: 67
diff changeset
315 *mode = T (typename mode_traits<T>::from_int (m_mode));
kono
parents: 67
diff changeset
316 return true;
kono
parents: 67
diff changeset
317 }
kono
parents: 67
diff changeset
318 return false;
kono
parents: 67
diff changeset
319 }
kono
parents: 67
diff changeset
320
kono
parents: 67
diff changeset
321 /* A POD version of mode class T. */
kono
parents: 67
diff changeset
322
kono
parents: 67
diff changeset
323 template<typename T>
kono
parents: 67
diff changeset
324 struct pod_mode
kono
parents: 67
diff changeset
325 {
kono
parents: 67
diff changeset
326 typedef typename mode_traits<T>::from_int from_int;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
327 typedef typename T::measurement_type measurement_type;
111
kono
parents: 67
diff changeset
328
kono
parents: 67
diff changeset
329 machine_mode m_mode;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
330 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
331 operator machine_mode () const { return m_mode; }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
332
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
333 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
334 operator T () const { return from_int (m_mode); }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335
111
kono
parents: 67
diff changeset
336 ALWAYS_INLINE pod_mode &operator = (const T &m) { m_mode = m; return *this; }
kono
parents: 67
diff changeset
337 };
kono
parents: 67
diff changeset
338
kono
parents: 67
diff changeset
339 /* Return true if mode M has type T. */
kono
parents: 67
diff changeset
340
kono
parents: 67
diff changeset
341 template<typename T>
kono
parents: 67
diff changeset
342 inline bool
kono
parents: 67
diff changeset
343 is_a (machine_mode m)
kono
parents: 67
diff changeset
344 {
kono
parents: 67
diff changeset
345 return T::includes_p (m);
kono
parents: 67
diff changeset
346 }
kono
parents: 67
diff changeset
347
kono
parents: 67
diff changeset
348 template<typename T, typename U>
kono
parents: 67
diff changeset
349 inline bool
kono
parents: 67
diff changeset
350 is_a (const opt_mode<U> &m)
kono
parents: 67
diff changeset
351 {
kono
parents: 67
diff changeset
352 return T::includes_p (m.else_void ());
kono
parents: 67
diff changeset
353 }
kono
parents: 67
diff changeset
354
kono
parents: 67
diff changeset
355 /* Assert that mode M has type T, and return it in that form. */
kono
parents: 67
diff changeset
356
kono
parents: 67
diff changeset
357 template<typename T>
kono
parents: 67
diff changeset
358 inline T
kono
parents: 67
diff changeset
359 as_a (machine_mode m)
kono
parents: 67
diff changeset
360 {
kono
parents: 67
diff changeset
361 gcc_checking_assert (T::includes_p (m));
kono
parents: 67
diff changeset
362 return typename mode_traits<T>::from_int (m);
kono
parents: 67
diff changeset
363 }
kono
parents: 67
diff changeset
364
kono
parents: 67
diff changeset
365 template<typename T, typename U>
kono
parents: 67
diff changeset
366 inline T
kono
parents: 67
diff changeset
367 as_a (const opt_mode<U> &m)
kono
parents: 67
diff changeset
368 {
kono
parents: 67
diff changeset
369 return as_a <T> (m.else_void ());
kono
parents: 67
diff changeset
370 }
kono
parents: 67
diff changeset
371
kono
parents: 67
diff changeset
372 /* Convert M to an opt_mode<T>. */
kono
parents: 67
diff changeset
373
kono
parents: 67
diff changeset
374 template<typename T>
kono
parents: 67
diff changeset
375 inline opt_mode<T>
kono
parents: 67
diff changeset
376 dyn_cast (machine_mode m)
kono
parents: 67
diff changeset
377 {
kono
parents: 67
diff changeset
378 if (T::includes_p (m))
kono
parents: 67
diff changeset
379 return T (typename mode_traits<T>::from_int (m));
kono
parents: 67
diff changeset
380 return opt_mode<T> ();
kono
parents: 67
diff changeset
381 }
kono
parents: 67
diff changeset
382
kono
parents: 67
diff changeset
383 template<typename T, typename U>
kono
parents: 67
diff changeset
384 inline opt_mode<T>
kono
parents: 67
diff changeset
385 dyn_cast (const opt_mode<U> &m)
kono
parents: 67
diff changeset
386 {
kono
parents: 67
diff changeset
387 return dyn_cast <T> (m.else_void ());
kono
parents: 67
diff changeset
388 }
kono
parents: 67
diff changeset
389
kono
parents: 67
diff changeset
390 /* Return true if mode M has type T, storing it as a T in *RESULT
kono
parents: 67
diff changeset
391 if so. */
kono
parents: 67
diff changeset
392
kono
parents: 67
diff changeset
393 template<typename T, typename U>
kono
parents: 67
diff changeset
394 inline bool
kono
parents: 67
diff changeset
395 is_a (machine_mode m, U *result)
kono
parents: 67
diff changeset
396 {
kono
parents: 67
diff changeset
397 if (T::includes_p (m))
kono
parents: 67
diff changeset
398 {
kono
parents: 67
diff changeset
399 *result = T (typename mode_traits<T>::from_int (m));
kono
parents: 67
diff changeset
400 return true;
kono
parents: 67
diff changeset
401 }
kono
parents: 67
diff changeset
402 return false;
kono
parents: 67
diff changeset
403 }
kono
parents: 67
diff changeset
404
kono
parents: 67
diff changeset
405 /* Represents a machine mode that is known to be a SCALAR_INT_MODE_P. */
kono
parents: 67
diff changeset
406 class scalar_int_mode
kono
parents: 67
diff changeset
407 {
kono
parents: 67
diff changeset
408 public:
kono
parents: 67
diff changeset
409 typedef mode_traits<scalar_int_mode>::from_int from_int;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
410 typedef unsigned short measurement_type;
111
kono
parents: 67
diff changeset
411
kono
parents: 67
diff changeset
412 ALWAYS_INLINE scalar_int_mode () {}
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
413
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
414 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
415 scalar_int_mode (from_int m) : m_mode (machine_mode (m)) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
416
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
417 ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; }
111
kono
parents: 67
diff changeset
418
kono
parents: 67
diff changeset
419 static bool includes_p (machine_mode);
kono
parents: 67
diff changeset
420
kono
parents: 67
diff changeset
421 protected:
kono
parents: 67
diff changeset
422 machine_mode m_mode;
kono
parents: 67
diff changeset
423 };
kono
parents: 67
diff changeset
424
kono
parents: 67
diff changeset
425 /* Return true if M is a scalar_int_mode. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
111
kono
parents: 67
diff changeset
427 inline bool
kono
parents: 67
diff changeset
428 scalar_int_mode::includes_p (machine_mode m)
kono
parents: 67
diff changeset
429 {
kono
parents: 67
diff changeset
430 return SCALAR_INT_MODE_P (m);
kono
parents: 67
diff changeset
431 }
kono
parents: 67
diff changeset
432
kono
parents: 67
diff changeset
433 /* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */
kono
parents: 67
diff changeset
434 class scalar_float_mode
kono
parents: 67
diff changeset
435 {
kono
parents: 67
diff changeset
436 public:
kono
parents: 67
diff changeset
437 typedef mode_traits<scalar_float_mode>::from_int from_int;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
438 typedef unsigned short measurement_type;
111
kono
parents: 67
diff changeset
439
kono
parents: 67
diff changeset
440 ALWAYS_INLINE scalar_float_mode () {}
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
441
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
442 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
443 scalar_float_mode (from_int m) : m_mode (machine_mode (m)) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
444
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
445 ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; }
111
kono
parents: 67
diff changeset
446
kono
parents: 67
diff changeset
447 static bool includes_p (machine_mode);
kono
parents: 67
diff changeset
448
kono
parents: 67
diff changeset
449 protected:
kono
parents: 67
diff changeset
450 machine_mode m_mode;
kono
parents: 67
diff changeset
451 };
kono
parents: 67
diff changeset
452
kono
parents: 67
diff changeset
453 /* Return true if M is a scalar_float_mode. */
kono
parents: 67
diff changeset
454
kono
parents: 67
diff changeset
455 inline bool
kono
parents: 67
diff changeset
456 scalar_float_mode::includes_p (machine_mode m)
kono
parents: 67
diff changeset
457 {
kono
parents: 67
diff changeset
458 return SCALAR_FLOAT_MODE_P (m);
kono
parents: 67
diff changeset
459 }
kono
parents: 67
diff changeset
460
kono
parents: 67
diff changeset
461 /* Represents a machine mode that is known to be scalar. */
kono
parents: 67
diff changeset
462 class scalar_mode
kono
parents: 67
diff changeset
463 {
kono
parents: 67
diff changeset
464 public:
kono
parents: 67
diff changeset
465 typedef mode_traits<scalar_mode>::from_int from_int;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
466 typedef unsigned short measurement_type;
111
kono
parents: 67
diff changeset
467
kono
parents: 67
diff changeset
468 ALWAYS_INLINE scalar_mode () {}
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
469
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
470 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
471 scalar_mode (from_int m) : m_mode (machine_mode (m)) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
472
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
473 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
474 scalar_mode (const scalar_int_mode &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
475
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
476 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
477 scalar_mode (const scalar_float_mode &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
478
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
479 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
480 scalar_mode (const scalar_int_mode_pod &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
481
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
482 ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; }
111
kono
parents: 67
diff changeset
483
kono
parents: 67
diff changeset
484 static bool includes_p (machine_mode);
kono
parents: 67
diff changeset
485
kono
parents: 67
diff changeset
486 protected:
kono
parents: 67
diff changeset
487 machine_mode m_mode;
kono
parents: 67
diff changeset
488 };
kono
parents: 67
diff changeset
489
kono
parents: 67
diff changeset
490 /* Return true if M represents some kind of scalar value. */
kono
parents: 67
diff changeset
491
kono
parents: 67
diff changeset
492 inline bool
kono
parents: 67
diff changeset
493 scalar_mode::includes_p (machine_mode m)
kono
parents: 67
diff changeset
494 {
kono
parents: 67
diff changeset
495 switch (GET_MODE_CLASS (m))
kono
parents: 67
diff changeset
496 {
kono
parents: 67
diff changeset
497 case MODE_INT:
kono
parents: 67
diff changeset
498 case MODE_PARTIAL_INT:
kono
parents: 67
diff changeset
499 case MODE_FRACT:
kono
parents: 67
diff changeset
500 case MODE_UFRACT:
kono
parents: 67
diff changeset
501 case MODE_ACCUM:
kono
parents: 67
diff changeset
502 case MODE_UACCUM:
kono
parents: 67
diff changeset
503 case MODE_FLOAT:
kono
parents: 67
diff changeset
504 case MODE_DECIMAL_FLOAT:
kono
parents: 67
diff changeset
505 return true;
kono
parents: 67
diff changeset
506 default:
kono
parents: 67
diff changeset
507 return false;
kono
parents: 67
diff changeset
508 }
kono
parents: 67
diff changeset
509 }
kono
parents: 67
diff changeset
510
kono
parents: 67
diff changeset
511 /* Represents a machine mode that is known to be a COMPLEX_MODE_P. */
kono
parents: 67
diff changeset
512 class complex_mode
kono
parents: 67
diff changeset
513 {
kono
parents: 67
diff changeset
514 public:
kono
parents: 67
diff changeset
515 typedef mode_traits<complex_mode>::from_int from_int;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
516 typedef unsigned short measurement_type;
111
kono
parents: 67
diff changeset
517
kono
parents: 67
diff changeset
518 ALWAYS_INLINE complex_mode () {}
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
519
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
520 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
521 complex_mode (from_int m) : m_mode (machine_mode (m)) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
522
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
523 ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; }
111
kono
parents: 67
diff changeset
524
kono
parents: 67
diff changeset
525 static bool includes_p (machine_mode);
kono
parents: 67
diff changeset
526
kono
parents: 67
diff changeset
527 protected:
kono
parents: 67
diff changeset
528 machine_mode m_mode;
kono
parents: 67
diff changeset
529 };
kono
parents: 67
diff changeset
530
kono
parents: 67
diff changeset
531 /* Return true if M is a complex_mode. */
kono
parents: 67
diff changeset
532
kono
parents: 67
diff changeset
533 inline bool
kono
parents: 67
diff changeset
534 complex_mode::includes_p (machine_mode m)
kono
parents: 67
diff changeset
535 {
kono
parents: 67
diff changeset
536 return COMPLEX_MODE_P (m);
kono
parents: 67
diff changeset
537 }
kono
parents: 67
diff changeset
538
kono
parents: 67
diff changeset
539 /* Return the base GET_MODE_SIZE value for MODE. */
kono
parents: 67
diff changeset
540
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
541 ALWAYS_INLINE poly_uint16
111
kono
parents: 67
diff changeset
542 mode_to_bytes (machine_mode mode)
kono
parents: 67
diff changeset
543 {
kono
parents: 67
diff changeset
544 #if GCC_VERSION >= 4001
kono
parents: 67
diff changeset
545 return (__builtin_constant_p (mode)
kono
parents: 67
diff changeset
546 ? mode_size_inline (mode) : mode_size[mode]);
kono
parents: 67
diff changeset
547 #else
kono
parents: 67
diff changeset
548 return mode_size[mode];
kono
parents: 67
diff changeset
549 #endif
kono
parents: 67
diff changeset
550 }
kono
parents: 67
diff changeset
551
kono
parents: 67
diff changeset
552 /* Return the base GET_MODE_BITSIZE value for MODE. */
kono
parents: 67
diff changeset
553
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
554 ALWAYS_INLINE poly_uint16
111
kono
parents: 67
diff changeset
555 mode_to_bits (machine_mode mode)
kono
parents: 67
diff changeset
556 {
kono
parents: 67
diff changeset
557 return mode_to_bytes (mode) * BITS_PER_UNIT;
kono
parents: 67
diff changeset
558 }
kono
parents: 67
diff changeset
559
kono
parents: 67
diff changeset
560 /* Return the base GET_MODE_PRECISION value for MODE. */
kono
parents: 67
diff changeset
561
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
562 ALWAYS_INLINE poly_uint16
111
kono
parents: 67
diff changeset
563 mode_to_precision (machine_mode mode)
kono
parents: 67
diff changeset
564 {
kono
parents: 67
diff changeset
565 return mode_precision[mode];
kono
parents: 67
diff changeset
566 }
kono
parents: 67
diff changeset
567
kono
parents: 67
diff changeset
568 /* Return the base GET_MODE_INNER value for MODE. */
kono
parents: 67
diff changeset
569
kono
parents: 67
diff changeset
570 ALWAYS_INLINE scalar_mode
kono
parents: 67
diff changeset
571 mode_to_inner (machine_mode mode)
kono
parents: 67
diff changeset
572 {
kono
parents: 67
diff changeset
573 #if GCC_VERSION >= 4001
kono
parents: 67
diff changeset
574 return scalar_mode::from_int (__builtin_constant_p (mode)
kono
parents: 67
diff changeset
575 ? mode_inner_inline (mode)
kono
parents: 67
diff changeset
576 : mode_inner[mode]);
kono
parents: 67
diff changeset
577 #else
kono
parents: 67
diff changeset
578 return scalar_mode::from_int (mode_inner[mode]);
kono
parents: 67
diff changeset
579 #endif
kono
parents: 67
diff changeset
580 }
kono
parents: 67
diff changeset
581
kono
parents: 67
diff changeset
582 /* Return the base GET_MODE_UNIT_SIZE value for MODE. */
kono
parents: 67
diff changeset
583
kono
parents: 67
diff changeset
584 ALWAYS_INLINE unsigned char
kono
parents: 67
diff changeset
585 mode_to_unit_size (machine_mode mode)
kono
parents: 67
diff changeset
586 {
kono
parents: 67
diff changeset
587 #if GCC_VERSION >= 4001
kono
parents: 67
diff changeset
588 return (__builtin_constant_p (mode)
kono
parents: 67
diff changeset
589 ? mode_unit_size_inline (mode) : mode_unit_size[mode]);
kono
parents: 67
diff changeset
590 #else
kono
parents: 67
diff changeset
591 return mode_unit_size[mode];
kono
parents: 67
diff changeset
592 #endif
kono
parents: 67
diff changeset
593 }
kono
parents: 67
diff changeset
594
kono
parents: 67
diff changeset
595 /* Return the base GET_MODE_UNIT_PRECISION value for MODE. */
kono
parents: 67
diff changeset
596
kono
parents: 67
diff changeset
597 ALWAYS_INLINE unsigned short
kono
parents: 67
diff changeset
598 mode_to_unit_precision (machine_mode mode)
kono
parents: 67
diff changeset
599 {
kono
parents: 67
diff changeset
600 #if GCC_VERSION >= 4001
kono
parents: 67
diff changeset
601 return (__builtin_constant_p (mode)
kono
parents: 67
diff changeset
602 ? mode_unit_precision_inline (mode) : mode_unit_precision[mode]);
kono
parents: 67
diff changeset
603 #else
kono
parents: 67
diff changeset
604 return mode_unit_precision[mode];
kono
parents: 67
diff changeset
605 #endif
kono
parents: 67
diff changeset
606 }
kono
parents: 67
diff changeset
607
kono
parents: 67
diff changeset
608 /* Return the base GET_MODE_NUNITS value for MODE. */
kono
parents: 67
diff changeset
609
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
610 ALWAYS_INLINE poly_uint16
111
kono
parents: 67
diff changeset
611 mode_to_nunits (machine_mode mode)
kono
parents: 67
diff changeset
612 {
kono
parents: 67
diff changeset
613 #if GCC_VERSION >= 4001
kono
parents: 67
diff changeset
614 return (__builtin_constant_p (mode)
kono
parents: 67
diff changeset
615 ? mode_nunits_inline (mode) : mode_nunits[mode]);
kono
parents: 67
diff changeset
616 #else
kono
parents: 67
diff changeset
617 return mode_nunits[mode];
kono
parents: 67
diff changeset
618 #endif
kono
parents: 67
diff changeset
619 }
kono
parents: 67
diff changeset
620
kono
parents: 67
diff changeset
621 /* Get the size in bytes of an object of mode MODE. */
kono
parents: 67
diff changeset
622
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
623 #if ONLY_FIXED_SIZE_MODES
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
624 #define GET_MODE_SIZE(MODE) ((unsigned short) mode_to_bytes (MODE).coeffs[0])
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
625 #else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
626 ALWAYS_INLINE poly_uint16
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
627 GET_MODE_SIZE (machine_mode mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
628 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
629 return mode_to_bytes (mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
630 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
631
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
632 template<typename T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
633 ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
634 GET_MODE_SIZE (const T &mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
635 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
636 return mode_to_bytes (mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
637 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
638
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
639 template<typename T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
640 ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
641 GET_MODE_SIZE (const T &mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
642 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
643 return mode_to_bytes (mode).coeffs[0];
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
644 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
645 #endif
111
kono
parents: 67
diff changeset
646
kono
parents: 67
diff changeset
647 /* Get the size in bits of an object of mode MODE. */
kono
parents: 67
diff changeset
648
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
649 #if ONLY_FIXED_SIZE_MODES
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
650 #define GET_MODE_BITSIZE(MODE) ((unsigned short) mode_to_bits (MODE).coeffs[0])
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
651 #else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
652 ALWAYS_INLINE poly_uint16
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
653 GET_MODE_BITSIZE (machine_mode mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
654 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
655 return mode_to_bits (mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
656 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
657
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
658 template<typename T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
659 ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
660 GET_MODE_BITSIZE (const T &mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
661 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
662 return mode_to_bits (mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
663 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
664
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
665 template<typename T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
666 ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
667 GET_MODE_BITSIZE (const T &mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
668 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
669 return mode_to_bits (mode).coeffs[0];
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
670 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
671 #endif
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 /* Get the number of value bits of an object of mode MODE. */
111
kono
parents: 67
diff changeset
674
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
675 #if ONLY_FIXED_SIZE_MODES
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
676 #define GET_MODE_PRECISION(MODE) \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
677 ((unsigned short) mode_to_precision (MODE).coeffs[0])
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
678 #else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
679 ALWAYS_INLINE poly_uint16
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
680 GET_MODE_PRECISION (machine_mode mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
681 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
682 return mode_to_precision (mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
683 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
684
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
685 template<typename T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
686 ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
687 GET_MODE_PRECISION (const T &mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
688 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
689 return mode_to_precision (mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
690 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
691
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
692 template<typename T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
693 ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
694 GET_MODE_PRECISION (const T &mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
695 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
696 return mode_to_precision (mode).coeffs[0];
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
697 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
698 #endif
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 /* Get the number of integral bits of an object of mode MODE. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 extern CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 #define GET_MODE_IBIT(MODE) mode_ibit[MODE]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 /* Get the number of fractional bits of an object of mode MODE. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 extern CONST_MODE_FBIT unsigned char mode_fbit[NUM_MACHINE_MODES];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 #define GET_MODE_FBIT(MODE) mode_fbit[MODE]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 /* Get a bitmask containing 1 for all bits in a word
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 that fit within mode MODE. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 extern const unsigned HOST_WIDE_INT mode_mask_array[NUM_MACHINE_MODES];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 #define GET_MODE_MASK(MODE) mode_mask_array[MODE]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
714
111
kono
parents: 67
diff changeset
715 /* Return the mode of the basic parts of MODE. For vector modes this is the
kono
parents: 67
diff changeset
716 mode of the vector elements. For complex modes it is the mode of the real
kono
parents: 67
diff changeset
717 and imaginary parts. For other modes it is MODE itself. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
718
111
kono
parents: 67
diff changeset
719 #define GET_MODE_INNER(MODE) (mode_to_inner (MODE))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720
111
kono
parents: 67
diff changeset
721 /* Get the size in bytes or bits of the basic parts of an
kono
parents: 67
diff changeset
722 object of mode MODE. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723
111
kono
parents: 67
diff changeset
724 #define GET_MODE_UNIT_SIZE(MODE) mode_to_unit_size (MODE)
kono
parents: 67
diff changeset
725
kono
parents: 67
diff changeset
726 #define GET_MODE_UNIT_BITSIZE(MODE) \
kono
parents: 67
diff changeset
727 ((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728
111
kono
parents: 67
diff changeset
729 #define GET_MODE_UNIT_PRECISION(MODE) (mode_to_unit_precision (MODE))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
730
111
kono
parents: 67
diff changeset
731 /* Get the number of units in an object of mode MODE. This is 2 for
kono
parents: 67
diff changeset
732 complex modes and the number of elements for vector modes. */
kono
parents: 67
diff changeset
733
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
734 #if ONLY_FIXED_SIZE_MODES
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
735 #define GET_MODE_NUNITS(MODE) (mode_to_nunits (MODE).coeffs[0])
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
736 #else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
737 ALWAYS_INLINE poly_uint16
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
738 GET_MODE_NUNITS (machine_mode mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
739 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
740 return mode_to_nunits (mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
741 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
742
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
743 template<typename T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
744 ALWAYS_INLINE typename if_poly<typename T::measurement_type>::type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
745 GET_MODE_NUNITS (const T &mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
746 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
747 return mode_to_nunits (mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
748 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
749
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
750 template<typename T>
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
751 ALWAYS_INLINE typename if_nonpoly<typename T::measurement_type>::type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
752 GET_MODE_NUNITS (const T &mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
753 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
754 return mode_to_nunits (mode).coeffs[0];
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
755 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
756 #endif
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759
111
kono
parents: 67
diff changeset
760 template<typename T>
kono
parents: 67
diff changeset
761 ALWAYS_INLINE opt_mode<T>
kono
parents: 67
diff changeset
762 GET_MODE_WIDER_MODE (const T &m)
kono
parents: 67
diff changeset
763 {
kono
parents: 67
diff changeset
764 return typename opt_mode<T>::from_int (mode_wider[m]);
kono
parents: 67
diff changeset
765 }
kono
parents: 67
diff changeset
766
kono
parents: 67
diff changeset
767 /* For scalars, this is a mode with twice the precision. For vectors,
kono
parents: 67
diff changeset
768 this is a mode with the same inner mode but with twice the elements. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
769
111
kono
parents: 67
diff changeset
770 template<typename T>
kono
parents: 67
diff changeset
771 ALWAYS_INLINE opt_mode<T>
kono
parents: 67
diff changeset
772 GET_MODE_2XWIDER_MODE (const T &m)
kono
parents: 67
diff changeset
773 {
kono
parents: 67
diff changeset
774 return typename opt_mode<T>::from_int (mode_2xwider[m]);
kono
parents: 67
diff changeset
775 }
kono
parents: 67
diff changeset
776
kono
parents: 67
diff changeset
777 /* Get the complex mode from the component mode. */
kono
parents: 67
diff changeset
778 extern const unsigned char mode_complex[NUM_MACHINE_MODES];
kono
parents: 67
diff changeset
779 #define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE])
kono
parents: 67
diff changeset
780
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
781 /* Represents a machine mode that must have a fixed size. The main
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
782 use of this class is to represent the modes of objects that always
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
783 have static storage duration, such as constant pool entries.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
784 (No current target supports the concept of variable-size static data.) */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
785 class fixed_size_mode
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
786 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
787 public:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
788 typedef mode_traits<fixed_size_mode>::from_int from_int;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
789 typedef unsigned short measurement_type;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
790
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
791 ALWAYS_INLINE fixed_size_mode () {}
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
792
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
793 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
794 fixed_size_mode (from_int m) : m_mode (machine_mode (m)) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
795
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
796 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
797 fixed_size_mode (const scalar_mode &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
798
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
799 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
800 fixed_size_mode (const scalar_int_mode &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
801
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
802 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
803 fixed_size_mode (const scalar_float_mode &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
804
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
805 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
806 fixed_size_mode (const scalar_mode_pod &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
807
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
808 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
809 fixed_size_mode (const scalar_int_mode_pod &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
810
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
811 ALWAYS_INLINE CONSTEXPR
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
812 fixed_size_mode (const complex_mode &m) : m_mode (m) {}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
813
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
814 ALWAYS_INLINE CONSTEXPR operator machine_mode () const { return m_mode; }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
815
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
816 static bool includes_p (machine_mode);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
817
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
818 protected:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
819 machine_mode m_mode;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
820 };
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
821
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
822 /* Return true if MODE has a fixed size. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
823
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
824 inline bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
825 fixed_size_mode::includes_p (machine_mode mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
826 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
827 return mode_to_bytes (mode).is_constant ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
828 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
829
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
830 /* Wrapper for mode arguments to target macros, so that if a target
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
831 doesn't need polynomial-sized modes, its header file can continue
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
832 to treat everything as fixed_size_mode. This should go away once
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
833 macros are moved to target hooks. It shouldn't be used in other
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
834 contexts. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
835 #if NUM_POLY_INT_COEFFS == 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
836 #define MACRO_MODE(MODE) (as_a <fixed_size_mode> (MODE))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
837 #else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
838 #define MACRO_MODE(MODE) (MODE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
839 #endif
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
840
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
841 extern opt_machine_mode mode_for_size (poly_uint64, enum mode_class, int);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842
111
kono
parents: 67
diff changeset
843 /* Return the machine mode to use for a MODE_INT of SIZE bits, if one
kono
parents: 67
diff changeset
844 exists. If LIMIT is nonzero, modes wider than MAX_FIXED_MODE_SIZE
kono
parents: 67
diff changeset
845 will not be used. */
kono
parents: 67
diff changeset
846
kono
parents: 67
diff changeset
847 inline opt_scalar_int_mode
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
848 int_mode_for_size (poly_uint64 size, int limit)
111
kono
parents: 67
diff changeset
849 {
kono
parents: 67
diff changeset
850 return dyn_cast <scalar_int_mode> (mode_for_size (size, MODE_INT, limit));
kono
parents: 67
diff changeset
851 }
kono
parents: 67
diff changeset
852
kono
parents: 67
diff changeset
853 /* Return the machine mode to use for a MODE_FLOAT of SIZE bits, if one
kono
parents: 67
diff changeset
854 exists. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855
111
kono
parents: 67
diff changeset
856 inline opt_scalar_float_mode
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
857 float_mode_for_size (poly_uint64 size)
111
kono
parents: 67
diff changeset
858 {
kono
parents: 67
diff changeset
859 return dyn_cast <scalar_float_mode> (mode_for_size (size, MODE_FLOAT, 0));
kono
parents: 67
diff changeset
860 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
861
111
kono
parents: 67
diff changeset
862 /* Likewise for MODE_DECIMAL_FLOAT. */
kono
parents: 67
diff changeset
863
kono
parents: 67
diff changeset
864 inline opt_scalar_float_mode
kono
parents: 67
diff changeset
865 decimal_float_mode_for_size (unsigned int size)
kono
parents: 67
diff changeset
866 {
kono
parents: 67
diff changeset
867 return dyn_cast <scalar_float_mode>
kono
parents: 67
diff changeset
868 (mode_for_size (size, MODE_DECIMAL_FLOAT, 0));
kono
parents: 67
diff changeset
869 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
871 extern machine_mode smallest_mode_for_size (poly_uint64, enum mode_class);
111
kono
parents: 67
diff changeset
872
kono
parents: 67
diff changeset
873 /* Find the narrowest integer mode that contains at least SIZE bits.
kono
parents: 67
diff changeset
874 Such a mode must exist. */
kono
parents: 67
diff changeset
875
kono
parents: 67
diff changeset
876 inline scalar_int_mode
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
877 smallest_int_mode_for_size (poly_uint64 size)
111
kono
parents: 67
diff changeset
878 {
kono
parents: 67
diff changeset
879 return as_a <scalar_int_mode> (smallest_mode_for_size (size, MODE_INT));
kono
parents: 67
diff changeset
880 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881
111
kono
parents: 67
diff changeset
882 extern opt_scalar_int_mode int_mode_for_mode (machine_mode);
kono
parents: 67
diff changeset
883 extern opt_machine_mode bitwise_mode_for_mode (machine_mode);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
884 extern opt_machine_mode mode_for_vector (scalar_mode, poly_uint64);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
885 extern opt_machine_mode related_vector_mode (machine_mode, scalar_mode,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
886 poly_uint64 = 0);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
887 extern opt_machine_mode related_int_vector_mode (machine_mode);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888
111
kono
parents: 67
diff changeset
889 /* A class for iterating through possible bitfield modes. */
kono
parents: 67
diff changeset
890 class bit_field_mode_iterator
kono
parents: 67
diff changeset
891 {
kono
parents: 67
diff changeset
892 public:
kono
parents: 67
diff changeset
893 bit_field_mode_iterator (HOST_WIDE_INT, HOST_WIDE_INT,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
894 poly_int64, poly_int64,
111
kono
parents: 67
diff changeset
895 unsigned int, bool);
kono
parents: 67
diff changeset
896 bool next_mode (scalar_int_mode *);
kono
parents: 67
diff changeset
897 bool prefer_smaller_modes ();
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
898
111
kono
parents: 67
diff changeset
899 private:
kono
parents: 67
diff changeset
900 opt_scalar_int_mode m_mode;
kono
parents: 67
diff changeset
901 /* We use signed values here because the bit position can be negative
kono
parents: 67
diff changeset
902 for invalid input such as gcc.dg/pr48335-8.c. */
kono
parents: 67
diff changeset
903 HOST_WIDE_INT m_bitsize;
kono
parents: 67
diff changeset
904 HOST_WIDE_INT m_bitpos;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
905 poly_int64 m_bitregion_start;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
906 poly_int64 m_bitregion_end;
111
kono
parents: 67
diff changeset
907 unsigned int m_align;
kono
parents: 67
diff changeset
908 bool m_volatilep;
kono
parents: 67
diff changeset
909 int m_count;
kono
parents: 67
diff changeset
910 };
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
911
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 /* Find the best mode to use to access a bit field. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
913
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
914 extern bool get_best_mode (int, int, poly_uint64, poly_uint64, unsigned int,
111
kono
parents: 67
diff changeset
915 unsigned HOST_WIDE_INT, bool, scalar_int_mode *);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
917 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
918
111
kono
parents: 67
diff changeset
919 extern CONST_MODE_BASE_ALIGN unsigned short mode_base_align[NUM_MACHINE_MODES];
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
920
111
kono
parents: 67
diff changeset
921 extern unsigned get_mode_alignment (machine_mode);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
922
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 #define GET_MODE_ALIGNMENT(MODE) get_mode_alignment (MODE)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
924
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
925 /* For each class, get the narrowest mode in that class. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
926
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
927 extern const unsigned char class_narrowest_mode[MAX_MODE_CLASS];
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
928 #define GET_CLASS_NARROWEST_MODE(CLASS) \
111
kono
parents: 67
diff changeset
929 ((machine_mode) class_narrowest_mode[CLASS])
kono
parents: 67
diff changeset
930
kono
parents: 67
diff changeset
931 /* The narrowest full integer mode available on the target. */
kono
parents: 67
diff changeset
932
kono
parents: 67
diff changeset
933 #define NARROWEST_INT_MODE \
kono
parents: 67
diff changeset
934 (scalar_int_mode \
kono
parents: 67
diff changeset
935 (scalar_int_mode::from_int (class_narrowest_mode[MODE_INT])))
kono
parents: 67
diff changeset
936
kono
parents: 67
diff changeset
937 /* Return the narrowest mode in T's class. */
kono
parents: 67
diff changeset
938
kono
parents: 67
diff changeset
939 template<typename T>
kono
parents: 67
diff changeset
940 inline T
kono
parents: 67
diff changeset
941 get_narrowest_mode (T mode)
kono
parents: 67
diff changeset
942 {
kono
parents: 67
diff changeset
943 return typename mode_traits<T>::from_int
kono
parents: 67
diff changeset
944 (class_narrowest_mode[GET_MODE_CLASS (mode)]);
kono
parents: 67
diff changeset
945 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
946
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 and the mode whose class is Pmode and whose size is POINTER_SIZE. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
949
111
kono
parents: 67
diff changeset
950 extern scalar_int_mode byte_mode;
kono
parents: 67
diff changeset
951 extern scalar_int_mode word_mode;
kono
parents: 67
diff changeset
952 extern scalar_int_mode ptr_mode;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
953
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
954 /* Target-dependent machine mode initialization - in insn-modes.c. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 extern void init_adjust_machine_modes (void);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
956
111
kono
parents: 67
diff changeset
957 #define TRULY_NOOP_TRUNCATION_MODES_P(MODE1, MODE2) \
kono
parents: 67
diff changeset
958 (targetm.truly_noop_truncation (GET_MODE_PRECISION (MODE1), \
kono
parents: 67
diff changeset
959 GET_MODE_PRECISION (MODE2)))
kono
parents: 67
diff changeset
960
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
961 /* Return true if MODE is a scalar integer mode that fits in a
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
962 HOST_WIDE_INT. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
963
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
964 inline bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
965 HWI_COMPUTABLE_MODE_P (machine_mode mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
966 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
967 machine_mode mme = mode;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
968 return (SCALAR_INT_MODE_P (mme)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
969 && mode_to_precision (mme).coeffs[0] <= HOST_BITS_PER_WIDE_INT);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
970 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
971
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
972 inline bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
973 HWI_COMPUTABLE_MODE_P (scalar_int_mode mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
974 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
975 return GET_MODE_PRECISION (mode) <= HOST_BITS_PER_WIDE_INT;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
976 }
111
kono
parents: 67
diff changeset
977
kono
parents: 67
diff changeset
978 struct int_n_data_t {
kono
parents: 67
diff changeset
979 /* These parts are initailized by genmodes output */
kono
parents: 67
diff changeset
980 unsigned int bitsize;
kono
parents: 67
diff changeset
981 scalar_int_mode_pod m;
kono
parents: 67
diff changeset
982 /* RID_* is RID_INTN_BASE + index into this array */
kono
parents: 67
diff changeset
983 };
kono
parents: 67
diff changeset
984
kono
parents: 67
diff changeset
985 /* This is also in tree.h. genmodes.c guarantees the're sorted from
kono
parents: 67
diff changeset
986 smallest bitsize to largest bitsize. */
kono
parents: 67
diff changeset
987 extern bool int_n_enabled_p[NUM_INT_N_ENTS];
kono
parents: 67
diff changeset
988 extern const int_n_data_t int_n_data[NUM_INT_N_ENTS];
kono
parents: 67
diff changeset
989
kono
parents: 67
diff changeset
990 /* Return true if MODE has class MODE_INT, storing it as a scalar_int_mode
kono
parents: 67
diff changeset
991 in *INT_MODE if so. */
kono
parents: 67
diff changeset
992
kono
parents: 67
diff changeset
993 template<typename T>
kono
parents: 67
diff changeset
994 inline bool
kono
parents: 67
diff changeset
995 is_int_mode (machine_mode mode, T *int_mode)
kono
parents: 67
diff changeset
996 {
kono
parents: 67
diff changeset
997 if (GET_MODE_CLASS (mode) == MODE_INT)
kono
parents: 67
diff changeset
998 {
kono
parents: 67
diff changeset
999 *int_mode = scalar_int_mode (scalar_int_mode::from_int (mode));
kono
parents: 67
diff changeset
1000 return true;
kono
parents: 67
diff changeset
1001 }
kono
parents: 67
diff changeset
1002 return false;
kono
parents: 67
diff changeset
1003 }
kono
parents: 67
diff changeset
1004
kono
parents: 67
diff changeset
1005 /* Return true if MODE has class MODE_FLOAT, storing it as a
kono
parents: 67
diff changeset
1006 scalar_float_mode in *FLOAT_MODE if so. */
kono
parents: 67
diff changeset
1007
kono
parents: 67
diff changeset
1008 template<typename T>
kono
parents: 67
diff changeset
1009 inline bool
kono
parents: 67
diff changeset
1010 is_float_mode (machine_mode mode, T *float_mode)
kono
parents: 67
diff changeset
1011 {
kono
parents: 67
diff changeset
1012 if (GET_MODE_CLASS (mode) == MODE_FLOAT)
kono
parents: 67
diff changeset
1013 {
kono
parents: 67
diff changeset
1014 *float_mode = scalar_float_mode (scalar_float_mode::from_int (mode));
kono
parents: 67
diff changeset
1015 return true;
kono
parents: 67
diff changeset
1016 }
kono
parents: 67
diff changeset
1017 return false;
kono
parents: 67
diff changeset
1018 }
kono
parents: 67
diff changeset
1019
kono
parents: 67
diff changeset
1020 /* Return true if MODE has class MODE_COMPLEX_INT, storing it as
kono
parents: 67
diff changeset
1021 a complex_mode in *CMODE if so. */
kono
parents: 67
diff changeset
1022
kono
parents: 67
diff changeset
1023 template<typename T>
kono
parents: 67
diff changeset
1024 inline bool
kono
parents: 67
diff changeset
1025 is_complex_int_mode (machine_mode mode, T *cmode)
kono
parents: 67
diff changeset
1026 {
kono
parents: 67
diff changeset
1027 if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
kono
parents: 67
diff changeset
1028 {
kono
parents: 67
diff changeset
1029 *cmode = complex_mode (complex_mode::from_int (mode));
kono
parents: 67
diff changeset
1030 return true;
kono
parents: 67
diff changeset
1031 }
kono
parents: 67
diff changeset
1032 return false;
kono
parents: 67
diff changeset
1033 }
kono
parents: 67
diff changeset
1034
kono
parents: 67
diff changeset
1035 /* Return true if MODE has class MODE_COMPLEX_FLOAT, storing it as
kono
parents: 67
diff changeset
1036 a complex_mode in *CMODE if so. */
kono
parents: 67
diff changeset
1037
kono
parents: 67
diff changeset
1038 template<typename T>
kono
parents: 67
diff changeset
1039 inline bool
kono
parents: 67
diff changeset
1040 is_complex_float_mode (machine_mode mode, T *cmode)
kono
parents: 67
diff changeset
1041 {
kono
parents: 67
diff changeset
1042 if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
kono
parents: 67
diff changeset
1043 {
kono
parents: 67
diff changeset
1044 *cmode = complex_mode (complex_mode::from_int (mode));
kono
parents: 67
diff changeset
1045 return true;
kono
parents: 67
diff changeset
1046 }
kono
parents: 67
diff changeset
1047 return false;
kono
parents: 67
diff changeset
1048 }
kono
parents: 67
diff changeset
1049
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1050 /* Return true if MODE is a scalar integer mode with a precision
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1051 smaller than LIMIT's precision. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1052
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1053 inline bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1054 is_narrower_int_mode (machine_mode mode, scalar_int_mode limit)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1055 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1056 scalar_int_mode int_mode;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1057 return (is_a <scalar_int_mode> (mode, &int_mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1058 && GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (limit));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1059 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1060
111
kono
parents: 67
diff changeset
1061 namespace mode_iterator
kono
parents: 67
diff changeset
1062 {
kono
parents: 67
diff changeset
1063 /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */
kono
parents: 67
diff changeset
1064
kono
parents: 67
diff changeset
1065 template<typename T>
kono
parents: 67
diff changeset
1066 inline void
kono
parents: 67
diff changeset
1067 start (opt_mode<T> *iter, enum mode_class mclass)
kono
parents: 67
diff changeset
1068 {
kono
parents: 67
diff changeset
1069 if (GET_CLASS_NARROWEST_MODE (mclass) == E_VOIDmode)
kono
parents: 67
diff changeset
1070 *iter = opt_mode<T> ();
kono
parents: 67
diff changeset
1071 else
kono
parents: 67
diff changeset
1072 *iter = as_a<T> (GET_CLASS_NARROWEST_MODE (mclass));
kono
parents: 67
diff changeset
1073 }
kono
parents: 67
diff changeset
1074
kono
parents: 67
diff changeset
1075 inline void
kono
parents: 67
diff changeset
1076 start (machine_mode *iter, enum mode_class mclass)
kono
parents: 67
diff changeset
1077 {
kono
parents: 67
diff changeset
1078 *iter = GET_CLASS_NARROWEST_MODE (mclass);
kono
parents: 67
diff changeset
1079 }
kono
parents: 67
diff changeset
1080
kono
parents: 67
diff changeset
1081 /* Return true if mode iterator *ITER has not reached the end. */
kono
parents: 67
diff changeset
1082
kono
parents: 67
diff changeset
1083 template<typename T>
kono
parents: 67
diff changeset
1084 inline bool
kono
parents: 67
diff changeset
1085 iterate_p (opt_mode<T> *iter)
kono
parents: 67
diff changeset
1086 {
kono
parents: 67
diff changeset
1087 return iter->exists ();
kono
parents: 67
diff changeset
1088 }
kono
parents: 67
diff changeset
1089
kono
parents: 67
diff changeset
1090 inline bool
kono
parents: 67
diff changeset
1091 iterate_p (machine_mode *iter)
kono
parents: 67
diff changeset
1092 {
kono
parents: 67
diff changeset
1093 return *iter != E_VOIDmode;
kono
parents: 67
diff changeset
1094 }
kono
parents: 67
diff changeset
1095
kono
parents: 67
diff changeset
1096 /* Set mode iterator *ITER to the next widest mode in the same class,
kono
parents: 67
diff changeset
1097 if any. */
kono
parents: 67
diff changeset
1098
kono
parents: 67
diff changeset
1099 template<typename T>
kono
parents: 67
diff changeset
1100 inline void
kono
parents: 67
diff changeset
1101 get_wider (opt_mode<T> *iter)
kono
parents: 67
diff changeset
1102 {
kono
parents: 67
diff changeset
1103 *iter = GET_MODE_WIDER_MODE (iter->require ());
kono
parents: 67
diff changeset
1104 }
kono
parents: 67
diff changeset
1105
kono
parents: 67
diff changeset
1106 inline void
kono
parents: 67
diff changeset
1107 get_wider (machine_mode *iter)
kono
parents: 67
diff changeset
1108 {
kono
parents: 67
diff changeset
1109 *iter = GET_MODE_WIDER_MODE (*iter).else_void ();
kono
parents: 67
diff changeset
1110 }
kono
parents: 67
diff changeset
1111
kono
parents: 67
diff changeset
1112 /* Set mode iterator *ITER to the next widest mode in the same class.
kono
parents: 67
diff changeset
1113 Such a mode is known to exist. */
kono
parents: 67
diff changeset
1114
kono
parents: 67
diff changeset
1115 template<typename T>
kono
parents: 67
diff changeset
1116 inline void
kono
parents: 67
diff changeset
1117 get_known_wider (T *iter)
kono
parents: 67
diff changeset
1118 {
kono
parents: 67
diff changeset
1119 *iter = GET_MODE_WIDER_MODE (*iter).require ();
kono
parents: 67
diff changeset
1120 }
kono
parents: 67
diff changeset
1121
kono
parents: 67
diff changeset
1122 /* Set mode iterator *ITER to the mode that is two times wider than the
kono
parents: 67
diff changeset
1123 current one, if such a mode exists. */
kono
parents: 67
diff changeset
1124
kono
parents: 67
diff changeset
1125 template<typename T>
kono
parents: 67
diff changeset
1126 inline void
kono
parents: 67
diff changeset
1127 get_2xwider (opt_mode<T> *iter)
kono
parents: 67
diff changeset
1128 {
kono
parents: 67
diff changeset
1129 *iter = GET_MODE_2XWIDER_MODE (iter->require ());
kono
parents: 67
diff changeset
1130 }
kono
parents: 67
diff changeset
1131
kono
parents: 67
diff changeset
1132 inline void
kono
parents: 67
diff changeset
1133 get_2xwider (machine_mode *iter)
kono
parents: 67
diff changeset
1134 {
kono
parents: 67
diff changeset
1135 *iter = GET_MODE_2XWIDER_MODE (*iter).else_void ();
kono
parents: 67
diff changeset
1136 }
kono
parents: 67
diff changeset
1137 }
kono
parents: 67
diff changeset
1138
kono
parents: 67
diff changeset
1139 /* Make ITERATOR iterate over all the modes in mode class CLASS,
kono
parents: 67
diff changeset
1140 from narrowest to widest. */
kono
parents: 67
diff changeset
1141 #define FOR_EACH_MODE_IN_CLASS(ITERATOR, CLASS) \
kono
parents: 67
diff changeset
1142 for (mode_iterator::start (&(ITERATOR), CLASS); \
kono
parents: 67
diff changeset
1143 mode_iterator::iterate_p (&(ITERATOR)); \
kono
parents: 67
diff changeset
1144 mode_iterator::get_wider (&(ITERATOR)))
kono
parents: 67
diff changeset
1145
kono
parents: 67
diff changeset
1146 /* Make ITERATOR iterate over all the modes in the range [START, END),
kono
parents: 67
diff changeset
1147 in order of increasing width. */
kono
parents: 67
diff changeset
1148 #define FOR_EACH_MODE(ITERATOR, START, END) \
kono
parents: 67
diff changeset
1149 for ((ITERATOR) = (START); \
kono
parents: 67
diff changeset
1150 (ITERATOR) != (END); \
kono
parents: 67
diff changeset
1151 mode_iterator::get_known_wider (&(ITERATOR)))
kono
parents: 67
diff changeset
1152
kono
parents: 67
diff changeset
1153 /* Make ITERATOR iterate over START and all wider modes in the same
kono
parents: 67
diff changeset
1154 class, in order of increasing width. */
kono
parents: 67
diff changeset
1155 #define FOR_EACH_MODE_FROM(ITERATOR, START) \
kono
parents: 67
diff changeset
1156 for ((ITERATOR) = (START); \
kono
parents: 67
diff changeset
1157 mode_iterator::iterate_p (&(ITERATOR)); \
kono
parents: 67
diff changeset
1158 mode_iterator::get_wider (&(ITERATOR)))
kono
parents: 67
diff changeset
1159
kono
parents: 67
diff changeset
1160 /* Make ITERATOR iterate over modes in the range [NARROWEST, END)
kono
parents: 67
diff changeset
1161 in order of increasing width, where NARROWEST is the narrowest mode
kono
parents: 67
diff changeset
1162 in END's class. */
kono
parents: 67
diff changeset
1163 #define FOR_EACH_MODE_UNTIL(ITERATOR, END) \
kono
parents: 67
diff changeset
1164 FOR_EACH_MODE (ITERATOR, get_narrowest_mode (END), END)
kono
parents: 67
diff changeset
1165
kono
parents: 67
diff changeset
1166 /* Make ITERATOR iterate over modes in the same class as MODE, in order
kono
parents: 67
diff changeset
1167 of increasing width. Start at the first mode wider than START,
kono
parents: 67
diff changeset
1168 or don't iterate at all if there is no wider mode. */
kono
parents: 67
diff changeset
1169 #define FOR_EACH_WIDER_MODE(ITERATOR, START) \
kono
parents: 67
diff changeset
1170 for ((ITERATOR) = (START), mode_iterator::get_wider (&(ITERATOR)); \
kono
parents: 67
diff changeset
1171 mode_iterator::iterate_p (&(ITERATOR)); \
kono
parents: 67
diff changeset
1172 mode_iterator::get_wider (&(ITERATOR)))
kono
parents: 67
diff changeset
1173
kono
parents: 67
diff changeset
1174 /* Make ITERATOR iterate over modes in the same class as MODE, in order
kono
parents: 67
diff changeset
1175 of increasing width, and with each mode being twice the width of the
kono
parents: 67
diff changeset
1176 previous mode. Start at the mode that is two times wider than START,
kono
parents: 67
diff changeset
1177 or don't iterate at all if there is no such mode. */
kono
parents: 67
diff changeset
1178 #define FOR_EACH_2XWIDER_MODE(ITERATOR, START) \
kono
parents: 67
diff changeset
1179 for ((ITERATOR) = (START), mode_iterator::get_2xwider (&(ITERATOR)); \
kono
parents: 67
diff changeset
1180 mode_iterator::iterate_p (&(ITERATOR)); \
kono
parents: 67
diff changeset
1181 mode_iterator::get_2xwider (&(ITERATOR)))
kono
parents: 67
diff changeset
1182
kono
parents: 67
diff changeset
1183 template<typename T>
kono
parents: 67
diff changeset
1184 void
kono
parents: 67
diff changeset
1185 gt_ggc_mx (pod_mode<T> *)
kono
parents: 67
diff changeset
1186 {
kono
parents: 67
diff changeset
1187 }
kono
parents: 67
diff changeset
1188
kono
parents: 67
diff changeset
1189 template<typename T>
kono
parents: 67
diff changeset
1190 void
kono
parents: 67
diff changeset
1191 gt_pch_nx (pod_mode<T> *)
kono
parents: 67
diff changeset
1192 {
kono
parents: 67
diff changeset
1193 }
kono
parents: 67
diff changeset
1194
kono
parents: 67
diff changeset
1195 template<typename T>
kono
parents: 67
diff changeset
1196 void
kono
parents: 67
diff changeset
1197 gt_pch_nx (pod_mode<T> *, void (*) (void *, void *), void *)
kono
parents: 67
diff changeset
1198 {
kono
parents: 67
diff changeset
1199 }
kono
parents: 67
diff changeset
1200
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1201 #endif /* not HAVE_MACHINE_MODES */