]>
Commit | Line | Data |
---|---|---|
bccafa26 | 1 | /* Machine mode definitions for GCC; included by rtl.h and tree.h. |
f1717362 | 2 | Copyright (C) 1991-2016 Free Software Foundation, Inc. |
2da5aba8 | 3 | |
f12b58b3 | 4 | This file is part of GCC. |
2da5aba8 | 5 | |
f12b58b3 | 6 | GCC is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free | |
8c4c00c1 | 8 | Software Foundation; either version 3, or (at your option) any later |
f12b58b3 | 9 | version. |
2da5aba8 | 10 | |
f12b58b3 | 11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | for more details. | |
2da5aba8 | 15 | |
16 | You should have received a copy of the GNU General Public License | |
8c4c00c1 | 17 | along with GCC; see the file COPYING3. If not see |
18 | <http://www.gnu.org/licenses/>. */ | |
2da5aba8 | 19 | |
2da5aba8 | 20 | #ifndef HAVE_MACHINE_MODES |
ff1f285d | 21 | #define HAVE_MACHINE_MODES |
22 | ||
2da5aba8 | 23 | /* Make an enum class that gives all the machine modes. */ |
47a2c1d4 | 24 | #include "insn-modes.h" |
2da5aba8 | 25 | |
26 | /* Get the name of mode MODE as a string. */ | |
27 | ||
1af5f160 | 28 | extern const char * const mode_name[NUM_MACHINE_MODES]; |
47a2c1d4 | 29 | #define GET_MODE_NAME(MODE) mode_name[MODE] |
30 | ||
31 | /* Mode classes. */ | |
2da5aba8 | 32 | |
47a2c1d4 | 33 | #include "mode-classes.def" |
34 | #define DEF_MODE_CLASS(M) M | |
35 | enum mode_class { MODE_CLASSES, MAX_MODE_CLASS }; | |
36 | #undef DEF_MODE_CLASS | |
37 | #undef MODE_CLASSES | |
2da5aba8 | 38 | |
39 | /* Get the general kind of object that mode MODE represents | |
40 | (integer, floating, complex, etc.) */ | |
41 | ||
47a2c1d4 | 42 | extern const unsigned char mode_class[NUM_MACHINE_MODES]; |
b9c74b4d | 43 | #define GET_MODE_CLASS(MODE) ((enum mode_class) mode_class[MODE]) |
2da5aba8 | 44 | |
eef261c6 | 45 | /* Nonzero if MODE is an integral mode. */ |
46 | #define INTEGRAL_MODE_P(MODE) \ | |
47 | (GET_MODE_CLASS (MODE) == MODE_INT \ | |
48 | || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \ | |
35a03fc8 | 49 | || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \ |
50 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT) | |
eef261c6 | 51 | |
52 | /* Nonzero if MODE is a floating-point mode. */ | |
53 | #define FLOAT_MODE_P(MODE) \ | |
54 | (GET_MODE_CLASS (MODE) == MODE_FLOAT \ | |
3c28f41a | 55 | || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT \ |
35a03fc8 | 56 | || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \ |
57 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT) | |
eef261c6 | 58 | |
30e521fa | 59 | /* Nonzero if MODE is a complex mode. */ |
60 | #define COMPLEX_MODE_P(MODE) \ | |
61 | (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \ | |
62 | || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) | |
63 | ||
35a03fc8 | 64 | /* Nonzero if MODE is a vector mode. */ |
65 | #define VECTOR_MODE_P(MODE) \ | |
66 | (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ | |
c559c639 | 67 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT \ |
68 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT \ | |
69 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT \ | |
70 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM \ | |
71 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM) | |
35a03fc8 | 72 | |
dd067362 | 73 | /* Nonzero if MODE is a scalar integral mode. */ |
74 | #define SCALAR_INT_MODE_P(MODE) \ | |
75 | (GET_MODE_CLASS (MODE) == MODE_INT \ | |
76 | || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT) | |
77 | ||
248c3c28 | 78 | /* Nonzero if MODE is a scalar floating point mode. */ |
79 | #define SCALAR_FLOAT_MODE_P(MODE) \ | |
3c28f41a | 80 | (GET_MODE_CLASS (MODE) == MODE_FLOAT \ |
81 | || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT) | |
82 | ||
83 | /* Nonzero if MODE is a decimal floating point mode. */ | |
84 | #define DECIMAL_FLOAT_MODE_P(MODE) \ | |
85 | (GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT) | |
248c3c28 | 86 | |
c559c639 | 87 | /* Nonzero if MODE is a scalar fract mode. */ |
88 | #define SCALAR_FRACT_MODE_P(MODE) \ | |
89 | (GET_MODE_CLASS (MODE) == MODE_FRACT) | |
90 | ||
91 | /* Nonzero if MODE is a scalar ufract mode. */ | |
92 | #define SCALAR_UFRACT_MODE_P(MODE) \ | |
93 | (GET_MODE_CLASS (MODE) == MODE_UFRACT) | |
94 | ||
95 | /* Nonzero if MODE is a scalar fract or ufract mode. */ | |
96 | #define ALL_SCALAR_FRACT_MODE_P(MODE) \ | |
97 | (SCALAR_FRACT_MODE_P (MODE) || SCALAR_UFRACT_MODE_P (MODE)) | |
98 | ||
99 | /* Nonzero if MODE is a scalar accum mode. */ | |
100 | #define SCALAR_ACCUM_MODE_P(MODE) \ | |
101 | (GET_MODE_CLASS (MODE) == MODE_ACCUM) | |
102 | ||
103 | /* Nonzero if MODE is a scalar uaccum mode. */ | |
104 | #define SCALAR_UACCUM_MODE_P(MODE) \ | |
105 | (GET_MODE_CLASS (MODE) == MODE_UACCUM) | |
106 | ||
107 | /* Nonzero if MODE is a scalar accum or uaccum mode. */ | |
108 | #define ALL_SCALAR_ACCUM_MODE_P(MODE) \ | |
109 | (SCALAR_ACCUM_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE)) | |
110 | ||
111 | /* Nonzero if MODE is a scalar fract or accum mode. */ | |
112 | #define SIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \ | |
113 | (SCALAR_FRACT_MODE_P (MODE) || SCALAR_ACCUM_MODE_P (MODE)) | |
114 | ||
115 | /* Nonzero if MODE is a scalar ufract or uaccum mode. */ | |
116 | #define UNSIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \ | |
117 | (SCALAR_UFRACT_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE)) | |
118 | ||
119 | /* Nonzero if MODE is a scalar fract, ufract, accum or uaccum mode. */ | |
120 | #define ALL_SCALAR_FIXED_POINT_MODE_P(MODE) \ | |
121 | (SIGNED_SCALAR_FIXED_POINT_MODE_P (MODE) \ | |
122 | || UNSIGNED_SCALAR_FIXED_POINT_MODE_P (MODE)) | |
123 | ||
124 | /* Nonzero if MODE is a scalar/vector fract mode. */ | |
125 | #define FRACT_MODE_P(MODE) \ | |
126 | (GET_MODE_CLASS (MODE) == MODE_FRACT \ | |
127 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT) | |
128 | ||
129 | /* Nonzero if MODE is a scalar/vector ufract mode. */ | |
130 | #define UFRACT_MODE_P(MODE) \ | |
131 | (GET_MODE_CLASS (MODE) == MODE_UFRACT \ | |
132 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT) | |
133 | ||
134 | /* Nonzero if MODE is a scalar/vector fract or ufract mode. */ | |
135 | #define ALL_FRACT_MODE_P(MODE) \ | |
136 | (FRACT_MODE_P (MODE) || UFRACT_MODE_P (MODE)) | |
137 | ||
138 | /* Nonzero if MODE is a scalar/vector accum mode. */ | |
139 | #define ACCUM_MODE_P(MODE) \ | |
140 | (GET_MODE_CLASS (MODE) == MODE_ACCUM \ | |
141 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM) | |
142 | ||
143 | /* Nonzero if MODE is a scalar/vector uaccum mode. */ | |
144 | #define UACCUM_MODE_P(MODE) \ | |
145 | (GET_MODE_CLASS (MODE) == MODE_UACCUM \ | |
146 | || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM) | |
147 | ||
148 | /* Nonzero if MODE is a scalar/vector accum or uaccum mode. */ | |
149 | #define ALL_ACCUM_MODE_P(MODE) \ | |
150 | (ACCUM_MODE_P (MODE) || UACCUM_MODE_P (MODE)) | |
151 | ||
152 | /* Nonzero if MODE is a scalar/vector fract or accum mode. */ | |
153 | #define SIGNED_FIXED_POINT_MODE_P(MODE) \ | |
154 | (FRACT_MODE_P (MODE) || ACCUM_MODE_P (MODE)) | |
155 | ||
156 | /* Nonzero if MODE is a scalar/vector ufract or uaccum mode. */ | |
157 | #define UNSIGNED_FIXED_POINT_MODE_P(MODE) \ | |
158 | (UFRACT_MODE_P (MODE) || UACCUM_MODE_P (MODE)) | |
159 | ||
160 | /* Nonzero if MODE is a scalar/vector fract, ufract, accum or uaccum mode. */ | |
161 | #define ALL_FIXED_POINT_MODE_P(MODE) \ | |
162 | (SIGNED_FIXED_POINT_MODE_P (MODE) \ | |
163 | || UNSIGNED_FIXED_POINT_MODE_P (MODE)) | |
164 | ||
ba592904 | 165 | /* Nonzero if CLASS modes can be widened. */ |
166 | #define CLASS_HAS_WIDER_MODES_P(CLASS) \ | |
167 | (CLASS == MODE_INT \ | |
c8076084 | 168 | || CLASS == MODE_PARTIAL_INT \ |
ba592904 | 169 | || CLASS == MODE_FLOAT \ |
3c28f41a | 170 | || CLASS == MODE_DECIMAL_FLOAT \ |
c559c639 | 171 | || CLASS == MODE_COMPLEX_FLOAT \ |
172 | || CLASS == MODE_FRACT \ | |
173 | || CLASS == MODE_UFRACT \ | |
174 | || CLASS == MODE_ACCUM \ | |
175 | || CLASS == MODE_UACCUM) | |
ba592904 | 176 | |
058a1b7a | 177 | #define POINTER_BOUNDS_MODE_P(MODE) \ |
178 | (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS) | |
179 | ||
7c0390e7 | 180 | /* Get the size in bytes and bits of an object of mode MODE. */ |
2da5aba8 | 181 | |
f58875bf | 182 | extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES]; |
e2ec52ca | 183 | #if GCC_VERSION >= 4001 |
184 | #define GET_MODE_SIZE(MODE) \ | |
185 | ((unsigned short) (__builtin_constant_p (MODE) \ | |
186 | ? mode_size_inline (MODE) : mode_size[MODE])) | |
187 | #else | |
7c0390e7 | 188 | #define GET_MODE_SIZE(MODE) ((unsigned short) mode_size[MODE]) |
e2ec52ca | 189 | #endif |
49db198b | 190 | #define GET_MODE_BITSIZE(MODE) \ |
191 | ((unsigned short) (GET_MODE_SIZE (MODE) * BITS_PER_UNIT)) | |
2da5aba8 | 192 | |
7c0390e7 | 193 | /* Get the number of value bits of an object of mode MODE. */ |
194 | extern const unsigned short mode_precision[NUM_MACHINE_MODES]; | |
195 | #define GET_MODE_PRECISION(MODE) mode_precision[MODE] | |
2da5aba8 | 196 | |
c559c639 | 197 | /* Get the number of integral bits of an object of mode MODE. */ |
198 | extern CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES]; | |
199 | #define GET_MODE_IBIT(MODE) mode_ibit[MODE] | |
200 | ||
201 | /* Get the number of fractional bits of an object of mode MODE. */ | |
202 | extern CONST_MODE_FBIT unsigned char mode_fbit[NUM_MACHINE_MODES]; | |
203 | #define GET_MODE_FBIT(MODE) mode_fbit[MODE] | |
204 | ||
2da5aba8 | 205 | /* Get a bitmask containing 1 for all bits in a word |
206 | that fit within mode MODE. */ | |
207 | ||
1af5f160 | 208 | extern const unsigned HOST_WIDE_INT mode_mask_array[NUM_MACHINE_MODES]; |
33685f56 | 209 | |
47a2c1d4 | 210 | #define GET_MODE_MASK(MODE) mode_mask_array[MODE] |
2da5aba8 | 211 | |
d145b68b | 212 | /* Return the mode of the basic parts of MODE. For vector modes this is the |
213 | mode of the vector elements. For complex modes it is the mode of the real | |
214 | and imaginary parts. For other modes it is MODE itself. */ | |
886cfd4f | 215 | |
b8bc42e9 | 216 | extern const unsigned char mode_inner[NUM_MACHINE_MODES]; |
e2ec52ca | 217 | #if GCC_VERSION >= 4001 |
218 | #define GET_MODE_INNER(MODE) \ | |
3754d046 | 219 | ((machine_mode) (__builtin_constant_p (MODE) \ |
e2ec52ca | 220 | ? mode_inner_inline (MODE) : mode_inner[MODE])) |
221 | #else | |
3754d046 | 222 | #define GET_MODE_INNER(MODE) ((machine_mode) mode_inner[MODE]) |
e2ec52ca | 223 | #endif |
886cfd4f | 224 | |
d145b68b | 225 | /* Get the size in bytes or bits of the basic parts of an |
49db198b | 226 | object of mode MODE. */ |
b8bc42e9 | 227 | |
a0509d0e | 228 | extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES]; |
229 | #if GCC_VERSION >= 4001 | |
230 | #define GET_MODE_UNIT_SIZE(MODE) \ | |
231 | ((unsigned char) (__builtin_constant_p (MODE) \ | |
232 | ? mode_unit_size_inline (MODE) : mode_unit_size[MODE])) | |
233 | #else | |
234 | #define GET_MODE_UNIT_SIZE(MODE) mode_unit_size[MODE] | |
235 | #endif | |
b8bc42e9 | 236 | |
49db198b | 237 | #define GET_MODE_UNIT_BITSIZE(MODE) \ |
238 | ((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT)) | |
239 | ||
a0509d0e | 240 | extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES]; |
241 | #if GCC_VERSION >= 4001 | |
242 | #define GET_MODE_UNIT_PRECISION(MODE) \ | |
243 | ((unsigned short) (__builtin_constant_p (MODE) \ | |
244 | ? mode_unit_precision_inline (MODE)\ | |
245 | : mode_unit_precision[MODE])) | |
246 | #else | |
247 | #define GET_MODE_UNIT_PRECISION(MODE) mode_unit_precision[MODE] | |
248 | #endif | |
249 | ||
615bdf5c | 250 | |
b8bc42e9 | 251 | /* Get the number of units in the object. */ |
252 | ||
253 | extern const unsigned char mode_nunits[NUM_MACHINE_MODES]; | |
e2ec52ca | 254 | #if GCC_VERSION >= 4001 |
255 | #define GET_MODE_NUNITS(MODE) \ | |
256 | ((unsigned char) (__builtin_constant_p (MODE) \ | |
257 | ? mode_nunits_inline (MODE) : mode_nunits[MODE])) | |
258 | #else | |
b8bc42e9 | 259 | #define GET_MODE_NUNITS(MODE) mode_nunits[MODE] |
e2ec52ca | 260 | #endif |
b8bc42e9 | 261 | |
2da5aba8 | 262 | /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */ |
263 | ||
47a2c1d4 | 264 | extern const unsigned char mode_wider[NUM_MACHINE_MODES]; |
3754d046 | 265 | #define GET_MODE_WIDER_MODE(MODE) ((machine_mode) mode_wider[MODE]) |
2da5aba8 | 266 | |
de44e2b0 | 267 | /* For scalars, this is a mode with twice the precision. For vectors, |
268 | this is a mode with the same inner mode but with twice the elements. */ | |
06633980 | 269 | extern const unsigned char mode_2xwider[NUM_MACHINE_MODES]; |
3754d046 | 270 | #define GET_MODE_2XWIDER_MODE(MODE) ((machine_mode) mode_2xwider[MODE]) |
06633980 | 271 | |
21df55ae | 272 | /* Return the mode for data of a given size SIZE and mode class CLASS. |
273 | If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE. | |
274 | The value is BLKmode if no other mode is found. */ | |
275 | ||
3754d046 | 276 | extern machine_mode mode_for_size (unsigned int, enum mode_class, int); |
21df55ae | 277 | |
bbceecb6 | 278 | /* Similar, but find the smallest mode for a given width. */ |
279 | ||
3754d046 | 280 | extern machine_mode smallest_mode_for_size (unsigned int, |
3ad4992f | 281 | enum mode_class); |
bbceecb6 | 282 | |
283 | ||
86cde393 | 284 | /* Return an integer mode of the exact same size as the input mode, |
285 | or BLKmode on failure. */ | |
286 | ||
3754d046 | 287 | extern machine_mode int_mode_for_mode (machine_mode); |
86cde393 | 288 | |
3754d046 | 289 | extern machine_mode bitwise_mode_for_mode (machine_mode); |
ac875fa4 | 290 | |
c4740c5d | 291 | /* Return a mode that is suitable for representing a vector, |
292 | or BLKmode on failure. */ | |
293 | ||
3754d046 | 294 | extern machine_mode mode_for_vector (machine_mode, unsigned); |
c4740c5d | 295 | |
0a1f5755 | 296 | /* A class for iterating through possible bitfield modes. */ |
297 | class bit_field_mode_iterator | |
298 | { | |
299 | public: | |
300 | bit_field_mode_iterator (HOST_WIDE_INT, HOST_WIDE_INT, | |
301 | HOST_WIDE_INT, HOST_WIDE_INT, | |
302 | unsigned int, bool); | |
3754d046 | 303 | bool next_mode (machine_mode *); |
0a1f5755 | 304 | bool prefer_smaller_modes (); |
305 | ||
306 | private: | |
3754d046 | 307 | machine_mode m_mode; |
0a1f5755 | 308 | /* We use signed values here because the bit position can be negative |
309 | for invalid input such as gcc.dg/pr48335-8.c. */ | |
ae84f584 | 310 | HOST_WIDE_INT m_bitsize; |
311 | HOST_WIDE_INT m_bitpos; | |
312 | HOST_WIDE_INT m_bitregion_start; | |
313 | HOST_WIDE_INT m_bitregion_end; | |
314 | unsigned int m_align; | |
315 | bool m_volatilep; | |
316 | int m_count; | |
0a1f5755 | 317 | }; |
318 | ||
2da5aba8 | 319 | /* Find the best mode to use to access a bit field. */ |
320 | ||
3754d046 | 321 | extern machine_mode get_best_mode (int, int, |
4bb60ec7 | 322 | unsigned HOST_WIDE_INT, |
323 | unsigned HOST_WIDE_INT, | |
324 | unsigned int, | |
3754d046 | 325 | machine_mode, bool); |
2da5aba8 | 326 | |
327 | /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */ | |
328 | ||
f58875bf | 329 | extern CONST_MODE_BASE_ALIGN unsigned char mode_base_align[NUM_MACHINE_MODES]; |
47a2c1d4 | 330 | |
3754d046 | 331 | extern unsigned get_mode_alignment (machine_mode); |
3ce66181 | 332 | |
333 | #define GET_MODE_ALIGNMENT(MODE) get_mode_alignment (MODE) | |
2da5aba8 | 334 | |
2d066017 | 335 | /* For each class, get the narrowest mode in that class. */ |
336 | ||
47a2c1d4 | 337 | extern const unsigned char class_narrowest_mode[MAX_MODE_CLASS]; |
b9c74b4d | 338 | #define GET_CLASS_NARROWEST_MODE(CLASS) \ |
3754d046 | 339 | ((machine_mode) class_narrowest_mode[CLASS]) |
2d066017 | 340 | |
92b1938f | 341 | /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD |
342 | and the mode whose class is Pmode and whose size is POINTER_SIZE. */ | |
2d066017 | 343 | |
3754d046 | 344 | extern machine_mode byte_mode; |
345 | extern machine_mode word_mode; | |
346 | extern machine_mode ptr_mode; | |
2d066017 | 347 | |
f58875bf | 348 | /* Target-dependent machine mode initialization - in insn-modes.c. */ |
349 | extern void init_adjust_machine_modes (void); | |
350 | ||
396f2130 | 351 | #define TRULY_NOOP_TRUNCATION_MODES_P(MODE1, MODE2) \ |
352 | TRULY_NOOP_TRUNCATION (GET_MODE_PRECISION (MODE1), \ | |
353 | GET_MODE_PRECISION (MODE2)) | |
354 | ||
f179ee60 | 355 | #define HWI_COMPUTABLE_MODE_P(MODE) \ |
356 | (SCALAR_INT_MODE_P (MODE) \ | |
357 | && GET_MODE_PRECISION (MODE) <= HOST_BITS_PER_WIDE_INT) | |
358 | ||
6dc50383 | 359 | struct int_n_data_t { |
9f75f026 | 360 | /* These parts are initailized by genmodes output */ |
361 | unsigned int bitsize; | |
3754d046 | 362 | machine_mode m; |
9f75f026 | 363 | /* RID_* is RID_INTN_BASE + index into this array */ |
6dc50383 | 364 | }; |
9f75f026 | 365 | |
366 | /* This is also in tree.h. genmodes.c guarantees the're sorted from | |
367 | smallest bitsize to largest bitsize. */ | |
368 | extern bool int_n_enabled_p[NUM_INT_N_ENTS]; | |
369 | extern const int_n_data_t int_n_data[NUM_INT_N_ENTS]; | |
370 | ||
08985aff | 371 | #endif /* not HAVE_MACHINE_MODES */ |