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