rtl.texi (Machine Modes): Document QQ...
[gcc.git] / gcc / machmode.h
1 /* Machine mode definitions for GCC; included by rtl.h and tree.h.
2 Copyright (C) 1991, 1993, 1994, 1996, 1998, 1999, 2000, 2001, 2003
3 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA. */
21
22 #ifndef HAVE_MACHINE_MODES
23 #define HAVE_MACHINE_MODES
24
25 /* Make an enum class that gives all the machine modes. */
26 #include "insn-modes.h"
27
28 /* Get the name of mode MODE as a string. */
29
30 extern const char * const mode_name[NUM_MACHINE_MODES];
31 #define GET_MODE_NAME(MODE) mode_name[MODE]
32
33 /* Mode classes. */
34
35 #include "mode-classes.def"
36 #define DEF_MODE_CLASS(M) M
37 enum mode_class { MODE_CLASSES, MAX_MODE_CLASS };
38 #undef DEF_MODE_CLASS
39 #undef MODE_CLASSES
40
41 /* Get the general kind of object that mode MODE represents
42 (integer, floating, complex, etc.) */
43
44 extern const unsigned char mode_class[NUM_MACHINE_MODES];
45 #define GET_MODE_CLASS(MODE) mode_class[MODE]
46
47 /* Nonzero if MODE is an integral mode. */
48 #define INTEGRAL_MODE_P(MODE) \
49 (GET_MODE_CLASS (MODE) == MODE_INT \
50 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \
51 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
52 || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT)
53
54 /* Nonzero if MODE is a floating-point mode. */
55 #define FLOAT_MODE_P(MODE) \
56 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
57 || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT \
58 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
59 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)
60
61 /* Nonzero if MODE is a complex mode. */
62 #define COMPLEX_MODE_P(MODE) \
63 (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
64 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)
65
66 /* Nonzero if MODE is a vector mode. */
67 #define VECTOR_MODE_P(MODE) \
68 (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \
69 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT \
70 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT \
71 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT \
72 || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM \
73 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)
74
75 /* Nonzero if MODE is a scalar integral mode. */
76 #define SCALAR_INT_MODE_P(MODE) \
77 (GET_MODE_CLASS (MODE) == MODE_INT \
78 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT)
79
80 /* Nonzero if MODE is a scalar floating point mode. */
81 #define SCALAR_FLOAT_MODE_P(MODE) \
82 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
83 || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
84
85 /* Nonzero if MODE is a decimal floating point mode. */
86 #define DECIMAL_FLOAT_MODE_P(MODE) \
87 (GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
88
89 /* Nonzero if MODE is a scalar fract mode. */
90 #define SCALAR_FRACT_MODE_P(MODE) \
91 (GET_MODE_CLASS (MODE) == MODE_FRACT)
92
93 /* Nonzero if MODE is a scalar ufract mode. */
94 #define SCALAR_UFRACT_MODE_P(MODE) \
95 (GET_MODE_CLASS (MODE) == MODE_UFRACT)
96
97 /* Nonzero if MODE is a scalar fract or ufract mode. */
98 #define ALL_SCALAR_FRACT_MODE_P(MODE) \
99 (SCALAR_FRACT_MODE_P (MODE) || SCALAR_UFRACT_MODE_P (MODE))
100
101 /* Nonzero if MODE is a scalar accum mode. */
102 #define SCALAR_ACCUM_MODE_P(MODE) \
103 (GET_MODE_CLASS (MODE) == MODE_ACCUM)
104
105 /* Nonzero if MODE is a scalar uaccum mode. */
106 #define SCALAR_UACCUM_MODE_P(MODE) \
107 (GET_MODE_CLASS (MODE) == MODE_UACCUM)
108
109 /* Nonzero if MODE is a scalar accum or uaccum mode. */
110 #define ALL_SCALAR_ACCUM_MODE_P(MODE) \
111 (SCALAR_ACCUM_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
112
113 /* Nonzero if MODE is a scalar fract or accum mode. */
114 #define SIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \
115 (SCALAR_FRACT_MODE_P (MODE) || SCALAR_ACCUM_MODE_P (MODE))
116
117 /* Nonzero if MODE is a scalar ufract or uaccum mode. */
118 #define UNSIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \
119 (SCALAR_UFRACT_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
120
121 /* Nonzero if MODE is a scalar fract, ufract, accum or uaccum mode. */
122 #define ALL_SCALAR_FIXED_POINT_MODE_P(MODE) \
123 (SIGNED_SCALAR_FIXED_POINT_MODE_P (MODE) \
124 || UNSIGNED_SCALAR_FIXED_POINT_MODE_P (MODE))
125
126 /* Nonzero if MODE is a scalar/vector fract mode. */
127 #define FRACT_MODE_P(MODE) \
128 (GET_MODE_CLASS (MODE) == MODE_FRACT \
129 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT)
130
131 /* Nonzero if MODE is a scalar/vector ufract mode. */
132 #define UFRACT_MODE_P(MODE) \
133 (GET_MODE_CLASS (MODE) == MODE_UFRACT \
134 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT)
135
136 /* Nonzero if MODE is a scalar/vector fract or ufract mode. */
137 #define ALL_FRACT_MODE_P(MODE) \
138 (FRACT_MODE_P (MODE) || UFRACT_MODE_P (MODE))
139
140 /* Nonzero if MODE is a scalar/vector accum mode. */
141 #define ACCUM_MODE_P(MODE) \
142 (GET_MODE_CLASS (MODE) == MODE_ACCUM \
143 || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM)
144
145 /* Nonzero if MODE is a scalar/vector uaccum mode. */
146 #define UACCUM_MODE_P(MODE) \
147 (GET_MODE_CLASS (MODE) == MODE_UACCUM \
148 || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)
149
150 /* Nonzero if MODE is a scalar/vector accum or uaccum mode. */
151 #define ALL_ACCUM_MODE_P(MODE) \
152 (ACCUM_MODE_P (MODE) || UACCUM_MODE_P (MODE))
153
154 /* Nonzero if MODE is a scalar/vector fract or accum mode. */
155 #define SIGNED_FIXED_POINT_MODE_P(MODE) \
156 (FRACT_MODE_P (MODE) || ACCUM_MODE_P (MODE))
157
158 /* Nonzero if MODE is a scalar/vector ufract or uaccum mode. */
159 #define UNSIGNED_FIXED_POINT_MODE_P(MODE) \
160 (UFRACT_MODE_P (MODE) || UACCUM_MODE_P (MODE))
161
162 /* Nonzero if MODE is a scalar/vector fract, ufract, accum or uaccum mode. */
163 #define ALL_FIXED_POINT_MODE_P(MODE) \
164 (SIGNED_FIXED_POINT_MODE_P (MODE) \
165 || UNSIGNED_FIXED_POINT_MODE_P (MODE))
166
167 /* Nonzero if CLASS modes can be widened. */
168 #define CLASS_HAS_WIDER_MODES_P(CLASS) \
169 (CLASS == MODE_INT \
170 || CLASS == MODE_FLOAT \
171 || CLASS == MODE_DECIMAL_FLOAT \
172 || CLASS == MODE_COMPLEX_FLOAT \
173 || CLASS == MODE_FRACT \
174 || CLASS == MODE_UFRACT \
175 || CLASS == MODE_ACCUM \
176 || CLASS == MODE_UACCUM)
177
178 /* Get the size in bytes and bits of an object of mode MODE. */
179
180 extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES];
181 #define GET_MODE_SIZE(MODE) ((unsigned short) mode_size[MODE])
182 #define GET_MODE_BITSIZE(MODE) ((unsigned short) (GET_MODE_SIZE (MODE) * BITS_PER_UNIT))
183
184 /* Get the number of value bits of an object of mode MODE. */
185 extern const unsigned short mode_precision[NUM_MACHINE_MODES];
186 #define GET_MODE_PRECISION(MODE) mode_precision[MODE]
187
188 /* Get the number of integral bits of an object of mode MODE. */
189 extern CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES];
190 #define GET_MODE_IBIT(MODE) mode_ibit[MODE]
191
192 /* Get the number of fractional bits of an object of mode MODE. */
193 extern CONST_MODE_FBIT unsigned char mode_fbit[NUM_MACHINE_MODES];
194 #define GET_MODE_FBIT(MODE) mode_fbit[MODE]
195
196 /* Get a bitmask containing 1 for all bits in a word
197 that fit within mode MODE. */
198
199 extern const unsigned HOST_WIDE_INT mode_mask_array[NUM_MACHINE_MODES];
200
201 #define GET_MODE_MASK(MODE) mode_mask_array[MODE]
202
203 /* Return the mode of the inner elements in a vector. */
204
205 extern const unsigned char mode_inner[NUM_MACHINE_MODES];
206 #define GET_MODE_INNER(MODE) mode_inner[MODE]
207
208 /* Get the size in bytes of the basic parts of an object of mode MODE. */
209
210 #define GET_MODE_UNIT_SIZE(MODE) \
211 (GET_MODE_INNER (MODE) == VOIDmode \
212 ? GET_MODE_SIZE (MODE) \
213 : GET_MODE_SIZE (GET_MODE_INNER (MODE)))
214
215 /* Get the number of units in the object. */
216
217 extern const unsigned char mode_nunits[NUM_MACHINE_MODES];
218 #define GET_MODE_NUNITS(MODE) mode_nunits[MODE]
219
220 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */
221
222 extern const unsigned char mode_wider[NUM_MACHINE_MODES];
223 #define GET_MODE_WIDER_MODE(MODE) mode_wider[MODE]
224
225 extern const unsigned char mode_2xwider[NUM_MACHINE_MODES];
226 #define GET_MODE_2XWIDER_MODE(MODE) mode_2xwider[MODE]
227
228 /* Return the mode for data of a given size SIZE and mode class CLASS.
229 If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
230 The value is BLKmode if no other mode is found. */
231
232 extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int);
233
234 /* Similar, but find the smallest mode for a given width. */
235
236 extern enum machine_mode smallest_mode_for_size (unsigned int,
237 enum mode_class);
238
239
240 /* Return an integer mode of the exact same size as the input mode,
241 or BLKmode on failure. */
242
243 extern enum machine_mode int_mode_for_mode (enum machine_mode);
244
245 /* Find the best mode to use to access a bit field. */
246
247 extern enum machine_mode get_best_mode (int, int, unsigned int,
248 enum machine_mode, int);
249
250 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */
251
252 extern CONST_MODE_BASE_ALIGN unsigned char mode_base_align[NUM_MACHINE_MODES];
253
254 extern unsigned get_mode_alignment (enum machine_mode);
255
256 #define GET_MODE_ALIGNMENT(MODE) get_mode_alignment (MODE)
257
258 /* For each class, get the narrowest mode in that class. */
259
260 extern const unsigned char class_narrowest_mode[MAX_MODE_CLASS];
261 #define GET_CLASS_NARROWEST_MODE(CLASS) class_narrowest_mode[CLASS]
262
263 /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD
264 and the mode whose class is Pmode and whose size is POINTER_SIZE. */
265
266 extern enum machine_mode byte_mode;
267 extern enum machine_mode word_mode;
268 extern enum machine_mode ptr_mode;
269
270 /* Target-dependent machine mode initialization - in insn-modes.c. */
271 extern void init_adjust_machine_modes (void);
272
273 #endif /* not HAVE_MACHINE_MODES */