1 /* Machine mode definitions for GCC; included by rtl.h and tree.h.
2 Copyright (C) 1991-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
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
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef HAVE_MACHINE_MODES
21 #define HAVE_MACHINE_MODES
23 extern CONST_MODE_SIZE
unsigned short mode_size
[NUM_MACHINE_MODES
];
24 extern const unsigned short mode_precision
[NUM_MACHINE_MODES
];
25 extern const unsigned char mode_inner
[NUM_MACHINE_MODES
];
26 extern const unsigned char mode_nunits
[NUM_MACHINE_MODES
];
27 extern CONST_MODE_UNIT_SIZE
unsigned char mode_unit_size
[NUM_MACHINE_MODES
];
28 extern const unsigned short mode_unit_precision
[NUM_MACHINE_MODES
];
29 extern const unsigned char mode_wider
[NUM_MACHINE_MODES
];
30 extern const unsigned char mode_2xwider
[NUM_MACHINE_MODES
];
35 /* For use by the machmode support code only.
37 There are cases in which the machmode support code needs to forcibly
38 convert a machine_mode to a specific mode class T, and in which the
39 context guarantees that this is valid without the need for an assert.
40 This can be done using:
42 return typename mode_traits<T>::from_int (mode);
44 when returning a T and:
46 res = T (typename mode_traits<T>::from_int (mode));
48 when assigning to a value RES that must be assignment-compatible
49 with (but possibly not the same as) T. */
51 /* Allow direct conversion of enums to specific mode classes only
52 when USE_ENUM_MODES is defined. This is only intended for use
53 by gencondmd, so that it can tell more easily when .md conditions
55 typedef machine_mode from_int
;
57 /* Here we use an enum type distinct from machine_mode but with the
58 same range as machine_mode. T should have a constructor that
59 accepts this enum type; it should not have a constructor that
62 We use this somewhat indirect approach to avoid too many constructor
63 calls when the compiler is built with -O0. For example, even in
64 unoptimized code, the return statement above would construct the
65 returned T directly from the numerical value of MODE. */
66 enum from_int
{ dummy
= MAX_MACHINE_MODE
};
71 struct mode_traits
<machine_mode
>
73 /* machine_mode itself needs no conversion. */
74 typedef machine_mode from_int
;
77 /* Get the name of mode MODE as a string. */
79 extern const char * const mode_name
[NUM_MACHINE_MODES
];
80 #define GET_MODE_NAME(MODE) mode_name[MODE]
84 #include "mode-classes.def"
85 #define DEF_MODE_CLASS(M) M
86 enum mode_class
{ MODE_CLASSES
, MAX_MODE_CLASS
};
90 /* Get the general kind of object that mode MODE represents
91 (integer, floating, complex, etc.) */
93 extern const unsigned char mode_class
[NUM_MACHINE_MODES
];
94 #define GET_MODE_CLASS(MODE) ((enum mode_class) mode_class[MODE])
96 /* Nonzero if MODE is an integral mode. */
97 #define INTEGRAL_MODE_P(MODE) \
98 (GET_MODE_CLASS (MODE) == MODE_INT \
99 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \
100 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
101 || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT)
103 /* Nonzero if MODE is a floating-point mode. */
104 #define FLOAT_MODE_P(MODE) \
105 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
106 || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT \
107 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
108 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)
110 /* Nonzero if MODE is a complex mode. */
111 #define COMPLEX_MODE_P(MODE) \
112 (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
113 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)
115 /* Nonzero if MODE is a vector mode. */
116 #define VECTOR_MODE_P(MODE) \
117 (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \
118 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT \
119 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT \
120 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT \
121 || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM \
122 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)
124 /* Nonzero if MODE is a scalar integral mode. */
125 #define SCALAR_INT_MODE_P(MODE) \
126 (GET_MODE_CLASS (MODE) == MODE_INT \
127 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT)
129 /* Nonzero if MODE is a scalar floating point mode. */
130 #define SCALAR_FLOAT_MODE_P(MODE) \
131 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
132 || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
134 /* Nonzero if MODE is a decimal floating point mode. */
135 #define DECIMAL_FLOAT_MODE_P(MODE) \
136 (GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
138 /* Nonzero if MODE is a scalar fract mode. */
139 #define SCALAR_FRACT_MODE_P(MODE) \
140 (GET_MODE_CLASS (MODE) == MODE_FRACT)
142 /* Nonzero if MODE is a scalar ufract mode. */
143 #define SCALAR_UFRACT_MODE_P(MODE) \
144 (GET_MODE_CLASS (MODE) == MODE_UFRACT)
146 /* Nonzero if MODE is a scalar fract or ufract mode. */
147 #define ALL_SCALAR_FRACT_MODE_P(MODE) \
148 (SCALAR_FRACT_MODE_P (MODE) || SCALAR_UFRACT_MODE_P (MODE))
150 /* Nonzero if MODE is a scalar accum mode. */
151 #define SCALAR_ACCUM_MODE_P(MODE) \
152 (GET_MODE_CLASS (MODE) == MODE_ACCUM)
154 /* Nonzero if MODE is a scalar uaccum mode. */
155 #define SCALAR_UACCUM_MODE_P(MODE) \
156 (GET_MODE_CLASS (MODE) == MODE_UACCUM)
158 /* Nonzero if MODE is a scalar accum or uaccum mode. */
159 #define ALL_SCALAR_ACCUM_MODE_P(MODE) \
160 (SCALAR_ACCUM_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
162 /* Nonzero if MODE is a scalar fract or accum mode. */
163 #define SIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \
164 (SCALAR_FRACT_MODE_P (MODE) || SCALAR_ACCUM_MODE_P (MODE))
166 /* Nonzero if MODE is a scalar ufract or uaccum mode. */
167 #define UNSIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \
168 (SCALAR_UFRACT_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
170 /* Nonzero if MODE is a scalar fract, ufract, accum or uaccum mode. */
171 #define ALL_SCALAR_FIXED_POINT_MODE_P(MODE) \
172 (SIGNED_SCALAR_FIXED_POINT_MODE_P (MODE) \
173 || UNSIGNED_SCALAR_FIXED_POINT_MODE_P (MODE))
175 /* Nonzero if MODE is a scalar/vector fract mode. */
176 #define FRACT_MODE_P(MODE) \
177 (GET_MODE_CLASS (MODE) == MODE_FRACT \
178 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT)
180 /* Nonzero if MODE is a scalar/vector ufract mode. */
181 #define UFRACT_MODE_P(MODE) \
182 (GET_MODE_CLASS (MODE) == MODE_UFRACT \
183 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT)
185 /* Nonzero if MODE is a scalar/vector fract or ufract mode. */
186 #define ALL_FRACT_MODE_P(MODE) \
187 (FRACT_MODE_P (MODE) || UFRACT_MODE_P (MODE))
189 /* Nonzero if MODE is a scalar/vector accum mode. */
190 #define ACCUM_MODE_P(MODE) \
191 (GET_MODE_CLASS (MODE) == MODE_ACCUM \
192 || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM)
194 /* Nonzero if MODE is a scalar/vector uaccum mode. */
195 #define UACCUM_MODE_P(MODE) \
196 (GET_MODE_CLASS (MODE) == MODE_UACCUM \
197 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)
199 /* Nonzero if MODE is a scalar/vector accum or uaccum mode. */
200 #define ALL_ACCUM_MODE_P(MODE) \
201 (ACCUM_MODE_P (MODE) || UACCUM_MODE_P (MODE))
203 /* Nonzero if MODE is a scalar/vector fract or accum mode. */
204 #define SIGNED_FIXED_POINT_MODE_P(MODE) \
205 (FRACT_MODE_P (MODE) || ACCUM_MODE_P (MODE))
207 /* Nonzero if MODE is a scalar/vector ufract or uaccum mode. */
208 #define UNSIGNED_FIXED_POINT_MODE_P(MODE) \
209 (UFRACT_MODE_P (MODE) || UACCUM_MODE_P (MODE))
211 /* Nonzero if MODE is a scalar/vector fract, ufract, accum or uaccum mode. */
212 #define ALL_FIXED_POINT_MODE_P(MODE) \
213 (SIGNED_FIXED_POINT_MODE_P (MODE) \
214 || UNSIGNED_FIXED_POINT_MODE_P (MODE))
216 /* Nonzero if CLASS modes can be widened. */
217 #define CLASS_HAS_WIDER_MODES_P(CLASS) \
219 || CLASS == MODE_PARTIAL_INT \
220 || CLASS == MODE_FLOAT \
221 || CLASS == MODE_DECIMAL_FLOAT \
222 || CLASS == MODE_COMPLEX_FLOAT \
223 || CLASS == MODE_FRACT \
224 || CLASS == MODE_UFRACT \
225 || CLASS == MODE_ACCUM \
226 || CLASS == MODE_UACCUM)
228 #define POINTER_BOUNDS_MODE_P(MODE) \
229 (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS)
231 /* An optional T (i.e. a T or nothing), where T is some form of mode class. */
236 enum from_int
{ dummy
= MAX_MACHINE_MODE
};
238 ALWAYS_INLINE
opt_mode () : m_mode (E_VOIDmode
) {}
239 ALWAYS_INLINE
opt_mode (const T
&m
) : m_mode (m
) {}
240 ALWAYS_INLINE
opt_mode (from_int m
) : m_mode (machine_mode (m
)) {}
242 machine_mode
else_void () const;
245 bool exists () const;
246 template<typename U
> bool exists (U
*) const;
252 /* If the object contains a T, return its enum value, otherwise return
256 ALWAYS_INLINE machine_mode
257 opt_mode
<T
>::else_void () const
262 /* Assert that the object contains a T and return it. */
266 opt_mode
<T
>::require () const
268 gcc_checking_assert (m_mode
!= E_VOIDmode
);
269 return typename mode_traits
<T
>::from_int (m_mode
);
272 /* Return true if the object contains a T rather than nothing. */
276 opt_mode
<T
>::exists () const
278 return m_mode
!= E_VOIDmode
;
281 /* Return true if the object contains a T, storing it in *MODE if so. */
286 opt_mode
<T
>::exists (U
*mode
) const
288 if (m_mode
!= E_VOIDmode
)
290 *mode
= T (typename mode_traits
<T
>::from_int (m_mode
));
296 /* A POD version of mode class T. */
301 typedef typename mode_traits
<T
>::from_int from_int
;
304 ALWAYS_INLINE
operator machine_mode () const { return m_mode
; }
305 ALWAYS_INLINE
operator T () const { return from_int (m_mode
); }
306 ALWAYS_INLINE pod_mode
&operator = (const T
&m
) { m_mode
= m
; return *this; }
309 /* Return true if mode M has type T. */
313 is_a (machine_mode m
)
315 return T::includes_p (m
);
318 /* Assert that mode M has type T, and return it in that form. */
322 as_a (machine_mode m
)
324 gcc_checking_assert (T::includes_p (m
));
325 return typename mode_traits
<T
>::from_int (m
);
328 /* Convert M to an opt_mode<T>. */
332 dyn_cast (machine_mode m
)
334 if (T::includes_p (m
))
335 return T (typename mode_traits
<T
>::from_int (m
));
336 return opt_mode
<T
> ();
339 /* Return true if mode M has type T, storing it as a T in *RESULT
342 template<typename T
, typename U
>
344 is_a (machine_mode m
, U
*result
)
346 if (T::includes_p (m
))
348 *result
= T (typename mode_traits
<T
>::from_int (m
));
354 /* Represents a machine mode that is known to be a SCALAR_INT_MODE_P. */
355 class scalar_int_mode
358 typedef mode_traits
<scalar_int_mode
>::from_int from_int
;
360 ALWAYS_INLINE
scalar_int_mode () {}
361 ALWAYS_INLINE
scalar_int_mode (from_int m
) : m_mode (machine_mode (m
)) {}
362 ALWAYS_INLINE
operator machine_mode () const { return m_mode
; }
364 static bool includes_p (machine_mode
);
370 /* Return true if M is a scalar_int_mode. */
373 scalar_int_mode::includes_p (machine_mode m
)
375 return SCALAR_INT_MODE_P (m
);
378 /* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */
379 class scalar_float_mode
382 typedef mode_traits
<scalar_float_mode
>::from_int from_int
;
384 ALWAYS_INLINE
scalar_float_mode () {}
385 ALWAYS_INLINE
scalar_float_mode (from_int m
) : m_mode (machine_mode (m
)) {}
386 ALWAYS_INLINE
operator machine_mode () const { return m_mode
; }
388 static bool includes_p (machine_mode
);
394 /* Return true if M is a scalar_float_mode. */
397 scalar_float_mode::includes_p (machine_mode m
)
399 return SCALAR_FLOAT_MODE_P (m
);
402 /* Return the base GET_MODE_SIZE value for MODE. */
404 ALWAYS_INLINE
unsigned short
405 mode_to_bytes (machine_mode mode
)
407 #if GCC_VERSION >= 4001
408 return (__builtin_constant_p (mode
)
409 ? mode_size_inline (mode
) : mode_size
[mode
]);
411 return mode_size
[mode
];
415 /* Return the base GET_MODE_BITSIZE value for MODE. */
417 ALWAYS_INLINE
unsigned short
418 mode_to_bits (machine_mode mode
)
420 return mode_to_bytes (mode
) * BITS_PER_UNIT
;
423 /* Return the base GET_MODE_PRECISION value for MODE. */
425 ALWAYS_INLINE
unsigned short
426 mode_to_precision (machine_mode mode
)
428 return mode_precision
[mode
];
431 /* Return the base GET_MODE_INNER value for MODE. */
433 ALWAYS_INLINE machine_mode
434 mode_to_inner (machine_mode mode
)
436 #if GCC_VERSION >= 4001
437 return (machine_mode
) (__builtin_constant_p (mode
)
438 ? mode_inner_inline (mode
) : mode_inner
[mode
]);
440 return (machine_mode
) mode_inner
[mode
];
444 /* Return the base GET_MODE_UNIT_SIZE value for MODE. */
446 ALWAYS_INLINE
unsigned char
447 mode_to_unit_size (machine_mode mode
)
449 #if GCC_VERSION >= 4001
450 return (__builtin_constant_p (mode
)
451 ? mode_unit_size_inline (mode
) : mode_unit_size
[mode
]);
453 return mode_unit_size
[mode
];
457 /* Return the base GET_MODE_UNIT_PRECISION value for MODE. */
459 ALWAYS_INLINE
unsigned short
460 mode_to_unit_precision (machine_mode mode
)
462 #if GCC_VERSION >= 4001
463 return (__builtin_constant_p (mode
)
464 ? mode_unit_precision_inline (mode
) : mode_unit_precision
[mode
]);
466 return mode_unit_precision
[mode
];
470 /* Return the base GET_MODE_NUNITS value for MODE. */
472 ALWAYS_INLINE
unsigned short
473 mode_to_nunits (machine_mode mode
)
475 #if GCC_VERSION >= 4001
476 return (__builtin_constant_p (mode
)
477 ? mode_nunits_inline (mode
) : mode_nunits
[mode
]);
479 return mode_nunits
[mode
];
483 /* Get the size in bytes of an object of mode MODE. */
485 #define GET_MODE_SIZE(MODE) (mode_to_bytes (MODE))
487 /* Get the size in bits of an object of mode MODE. */
489 #define GET_MODE_BITSIZE(MODE) (mode_to_bits (MODE))
491 /* Get the number of value bits of an object of mode MODE. */
493 #define GET_MODE_PRECISION(MODE) (mode_to_precision (MODE))
495 /* Get the number of integral bits of an object of mode MODE. */
496 extern CONST_MODE_IBIT
unsigned char mode_ibit
[NUM_MACHINE_MODES
];
497 #define GET_MODE_IBIT(MODE) mode_ibit[MODE]
499 /* Get the number of fractional bits of an object of mode MODE. */
500 extern CONST_MODE_FBIT
unsigned char mode_fbit
[NUM_MACHINE_MODES
];
501 #define GET_MODE_FBIT(MODE) mode_fbit[MODE]
503 /* Get a bitmask containing 1 for all bits in a word
504 that fit within mode MODE. */
506 extern const unsigned HOST_WIDE_INT mode_mask_array
[NUM_MACHINE_MODES
];
508 #define GET_MODE_MASK(MODE) mode_mask_array[MODE]
510 /* Return the mode of the basic parts of MODE. For vector modes this is the
511 mode of the vector elements. For complex modes it is the mode of the real
512 and imaginary parts. For other modes it is MODE itself. */
514 #define GET_MODE_INNER(MODE) (mode_to_inner (MODE))
516 /* Get the size in bytes or bits of the basic parts of an
517 object of mode MODE. */
519 #define GET_MODE_UNIT_SIZE(MODE) mode_to_unit_size (MODE)
521 #define GET_MODE_UNIT_BITSIZE(MODE) \
522 ((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))
524 #define GET_MODE_UNIT_PRECISION(MODE) (mode_to_unit_precision (MODE))
526 /* Get the number of units in an object of mode MODE. This is 2 for
527 complex modes and the number of elements for vector modes. */
529 #define GET_MODE_NUNITS(MODE) (mode_to_nunits (MODE))
531 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */
534 ALWAYS_INLINE opt_mode
<T
>
535 GET_MODE_WIDER_MODE (const T
&m
)
537 return typename opt_mode
<T
>::from_int (mode_wider
[m
]);
540 /* For scalars, this is a mode with twice the precision. For vectors,
541 this is a mode with the same inner mode but with twice the elements. */
544 ALWAYS_INLINE opt_mode
<T
>
545 GET_MODE_2XWIDER_MODE (const T
&m
)
547 return typename opt_mode
<T
>::from_int (mode_2xwider
[m
]);
550 /* Get the complex mode from the component mode. */
551 extern const unsigned char mode_complex
[NUM_MACHINE_MODES
];
552 #define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE])
554 /* Return the mode for data of a given size SIZE and mode class CLASS.
555 If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
556 The value is BLKmode if no other mode is found. */
558 extern machine_mode
mode_for_size (unsigned int, enum mode_class
, int);
560 /* Return the machine mode to use for a MODE_INT of SIZE bits, if one
561 exists. If LIMIT is nonzero, modes wider than MAX_FIXED_MODE_SIZE
564 inline opt_scalar_int_mode
565 int_mode_for_size (unsigned int size
, int limit
)
567 return dyn_cast
<scalar_int_mode
> (mode_for_size (size
, MODE_INT
, limit
));
570 /* Return the machine mode to use for a MODE_FLOAT of SIZE bits, if one
573 inline opt_scalar_float_mode
574 float_mode_for_size (unsigned int size
)
576 return dyn_cast
<scalar_float_mode
> (mode_for_size (size
, MODE_FLOAT
, 0));
579 /* Similar to mode_for_size, but find the smallest mode for a given width. */
581 extern machine_mode
smallest_mode_for_size (unsigned int,
585 /* Return an integer mode of the exact same size as the input mode,
586 or BLKmode on failure. */
588 extern machine_mode
int_mode_for_mode (machine_mode
);
590 extern machine_mode
bitwise_mode_for_mode (machine_mode
);
592 /* Return a mode that is suitable for representing a vector,
593 or BLKmode on failure. */
595 extern machine_mode
mode_for_vector (machine_mode
, unsigned);
597 /* A class for iterating through possible bitfield modes. */
598 class bit_field_mode_iterator
601 bit_field_mode_iterator (HOST_WIDE_INT
, HOST_WIDE_INT
,
602 HOST_WIDE_INT
, HOST_WIDE_INT
,
604 bool next_mode (machine_mode
*);
605 bool prefer_smaller_modes ();
609 /* We use signed values here because the bit position can be negative
610 for invalid input such as gcc.dg/pr48335-8.c. */
611 HOST_WIDE_INT m_bitsize
;
612 HOST_WIDE_INT m_bitpos
;
613 HOST_WIDE_INT m_bitregion_start
;
614 HOST_WIDE_INT m_bitregion_end
;
615 unsigned int m_align
;
620 /* Find the best mode to use to access a bit field. */
622 extern machine_mode
get_best_mode (int, int,
623 unsigned HOST_WIDE_INT
,
624 unsigned HOST_WIDE_INT
,
628 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */
630 extern CONST_MODE_BASE_ALIGN
unsigned short mode_base_align
[NUM_MACHINE_MODES
];
632 extern unsigned get_mode_alignment (machine_mode
);
634 #define GET_MODE_ALIGNMENT(MODE) get_mode_alignment (MODE)
636 /* For each class, get the narrowest mode in that class. */
638 extern const unsigned char class_narrowest_mode
[MAX_MODE_CLASS
];
639 #define GET_CLASS_NARROWEST_MODE(CLASS) \
640 ((machine_mode) class_narrowest_mode[CLASS])
642 /* Return the narrowest mode in T's class. */
646 get_narrowest_mode (T mode
)
648 return typename mode_traits
<T
>::from_int
649 (class_narrowest_mode
[GET_MODE_CLASS (mode
)]);
652 /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD
653 and the mode whose class is Pmode and whose size is POINTER_SIZE. */
655 extern scalar_int_mode byte_mode
;
656 extern scalar_int_mode word_mode
;
657 extern scalar_int_mode ptr_mode
;
659 /* Target-dependent machine mode initialization - in insn-modes.c. */
660 extern void init_adjust_machine_modes (void);
662 #define TRULY_NOOP_TRUNCATION_MODES_P(MODE1, MODE2) \
663 TRULY_NOOP_TRUNCATION (GET_MODE_PRECISION (MODE1), \
664 GET_MODE_PRECISION (MODE2))
666 #define HWI_COMPUTABLE_MODE_P(MODE) \
667 (SCALAR_INT_MODE_P (MODE) \
668 && GET_MODE_PRECISION (MODE) <= HOST_BITS_PER_WIDE_INT)
670 struct int_n_data_t
{
671 /* These parts are initailized by genmodes output */
672 unsigned int bitsize
;
673 scalar_int_mode_pod m
;
674 /* RID_* is RID_INTN_BASE + index into this array */
677 /* This is also in tree.h. genmodes.c guarantees the're sorted from
678 smallest bitsize to largest bitsize. */
679 extern bool int_n_enabled_p
[NUM_INT_N_ENTS
];
680 extern const int_n_data_t int_n_data
[NUM_INT_N_ENTS
];
682 /* Return true if MODE has class MODE_FLOAT, storing it as a
683 scalar_float_mode in *FLOAT_MODE if so. */
687 is_float_mode (machine_mode mode
, T
*float_mode
)
689 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
)
691 *float_mode
= scalar_float_mode (scalar_float_mode::from_int (mode
));
697 namespace mode_iterator
699 /* Start mode iterator *ITER at the first mode in class MCLASS, if any. */
703 start (opt_mode
<T
> *iter
, enum mode_class mclass
)
705 if (GET_CLASS_NARROWEST_MODE (mclass
) == E_VOIDmode
)
706 *iter
= opt_mode
<T
> ();
708 *iter
= as_a
<T
> (GET_CLASS_NARROWEST_MODE (mclass
));
712 start (machine_mode
*iter
, enum mode_class mclass
)
714 *iter
= GET_CLASS_NARROWEST_MODE (mclass
);
717 /* Return true if mode iterator *ITER has not reached the end. */
721 iterate_p (opt_mode
<T
> *iter
)
723 return iter
->exists ();
727 iterate_p (machine_mode
*iter
)
729 return *iter
!= E_VOIDmode
;
732 /* Set mode iterator *ITER to the next widest mode in the same class,
737 get_wider (opt_mode
<T
> *iter
)
739 *iter
= GET_MODE_WIDER_MODE (iter
->require ());
743 get_wider (machine_mode
*iter
)
745 *iter
= GET_MODE_WIDER_MODE (*iter
).else_void ();
748 /* Set mode iterator *ITER to the next widest mode in the same class.
749 Such a mode is known to exist. */
753 get_known_wider (T
*iter
)
755 *iter
= GET_MODE_WIDER_MODE (*iter
).require ();
758 /* Set mode iterator *ITER to the mode that is two times wider than the
759 current one, if such a mode exists. */
762 get_2xwider (machine_mode
*iter
)
764 *iter
= GET_MODE_2XWIDER_MODE (*iter
).else_void ();
768 /* Make ITERATOR iterate over all the modes in mode class CLASS,
769 from narrowest to widest. */
770 #define FOR_EACH_MODE_IN_CLASS(ITERATOR, CLASS) \
771 for (mode_iterator::start (&(ITERATOR), CLASS); \
772 mode_iterator::iterate_p (&(ITERATOR)); \
773 mode_iterator::get_wider (&(ITERATOR)))
775 /* Make ITERATOR iterate over all the modes in the range [START, END),
776 in order of increasing width. */
777 #define FOR_EACH_MODE(ITERATOR, START, END) \
778 for ((ITERATOR) = (START); \
779 (ITERATOR) != (END); \
780 mode_iterator::get_known_wider (&(ITERATOR)))
782 /* Make ITERATOR iterate over START and all wider modes in the same
783 class, in order of increasing width. */
784 #define FOR_EACH_MODE_FROM(ITERATOR, START) \
785 for ((ITERATOR) = (START); \
786 mode_iterator::iterate_p (&(ITERATOR)); \
787 mode_iterator::get_wider (&(ITERATOR)))
789 /* Make ITERATOR iterate over modes in the range [NARROWEST, END)
790 in order of increasing width, where NARROWEST is the narrowest mode
792 #define FOR_EACH_MODE_UNTIL(ITERATOR, END) \
793 FOR_EACH_MODE (ITERATOR, get_narrowest_mode (END), END)
795 /* Make ITERATOR iterate over modes in the same class as MODE, in order
796 of increasing width. Start at the first mode wider than START,
797 or don't iterate at all if there is no wider mode. */
798 #define FOR_EACH_WIDER_MODE(ITERATOR, START) \
799 for ((ITERATOR) = (START), mode_iterator::get_wider (&(ITERATOR)); \
800 mode_iterator::iterate_p (&(ITERATOR)); \
801 mode_iterator::get_wider (&(ITERATOR)))
803 /* Make ITERATOR iterate over modes in the same class as MODE, in order
804 of increasing width, and with each mode being twice the width of the
805 previous mode. Start at the mode that is two times wider than START,
806 or don't iterate at all if there is no such mode. */
807 #define FOR_EACH_2XWIDER_MODE(ITERATOR, START) \
808 for ((ITERATOR) = (START), mode_iterator::get_2xwider (&(ITERATOR)); \
809 mode_iterator::iterate_p (&(ITERATOR)); \
810 mode_iterator::get_2xwider (&(ITERATOR)))
812 #endif /* not HAVE_MACHINE_MODES */