xref: /openbsd-src/gnu/gcc/gcc/machmode.h (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert /* Machine mode definitions for GCC; included by rtl.h and tree.h.
2*404b540aSrobert    Copyright (C) 1991, 1993, 1994, 1996, 1998, 1999, 2000, 2001, 2003
3*404b540aSrobert    Free Software Foundation, Inc.
4*404b540aSrobert 
5*404b540aSrobert This file is part of GCC.
6*404b540aSrobert 
7*404b540aSrobert GCC is free software; you can redistribute it and/or modify it under
8*404b540aSrobert the terms of the GNU General Public License as published by the Free
9*404b540aSrobert Software Foundation; either version 2, or (at your option) any later
10*404b540aSrobert version.
11*404b540aSrobert 
12*404b540aSrobert GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13*404b540aSrobert WARRANTY; without even the implied warranty of MERCHANTABILITY or
14*404b540aSrobert FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15*404b540aSrobert for more details.
16*404b540aSrobert 
17*404b540aSrobert You should have received a copy of the GNU General Public License
18*404b540aSrobert along with GCC; see the file COPYING.  If not, write to the Free
19*404b540aSrobert Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20*404b540aSrobert 02110-1301, USA.  */
21*404b540aSrobert 
22*404b540aSrobert #ifndef HAVE_MACHINE_MODES
23*404b540aSrobert #define HAVE_MACHINE_MODES
24*404b540aSrobert 
25*404b540aSrobert /* Make an enum class that gives all the machine modes.  */
26*404b540aSrobert #include "insn-modes.h"
27*404b540aSrobert 
28*404b540aSrobert /* Get the name of mode MODE as a string.  */
29*404b540aSrobert 
30*404b540aSrobert extern const char * const mode_name[NUM_MACHINE_MODES];
31*404b540aSrobert #define GET_MODE_NAME(MODE)  mode_name[MODE]
32*404b540aSrobert 
33*404b540aSrobert /* Mode classes.  */
34*404b540aSrobert 
35*404b540aSrobert #include "mode-classes.def"
36*404b540aSrobert #define DEF_MODE_CLASS(M) M
37*404b540aSrobert enum mode_class { MODE_CLASSES, MAX_MODE_CLASS };
38*404b540aSrobert #undef DEF_MODE_CLASS
39*404b540aSrobert #undef MODE_CLASSES
40*404b540aSrobert 
41*404b540aSrobert /* Get the general kind of object that mode MODE represents
42*404b540aSrobert    (integer, floating, complex, etc.)  */
43*404b540aSrobert 
44*404b540aSrobert extern const unsigned char mode_class[NUM_MACHINE_MODES];
45*404b540aSrobert #define GET_MODE_CLASS(MODE)  mode_class[MODE]
46*404b540aSrobert 
47*404b540aSrobert /* Nonzero if MODE is an integral mode.  */
48*404b540aSrobert #define INTEGRAL_MODE_P(MODE)			\
49*404b540aSrobert   (GET_MODE_CLASS (MODE) == MODE_INT		\
50*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \
51*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
52*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT)
53*404b540aSrobert 
54*404b540aSrobert /* Nonzero if MODE is a floating-point mode.  */
55*404b540aSrobert #define FLOAT_MODE_P(MODE)		\
56*404b540aSrobert   (GET_MODE_CLASS (MODE) == MODE_FLOAT	\
57*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT \
58*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
59*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)
60*404b540aSrobert 
61*404b540aSrobert /* Nonzero if MODE is a complex mode.  */
62*404b540aSrobert #define COMPLEX_MODE_P(MODE)			\
63*404b540aSrobert   (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT	\
64*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)
65*404b540aSrobert 
66*404b540aSrobert /* Nonzero if MODE is a vector mode.  */
67*404b540aSrobert #define VECTOR_MODE_P(MODE)			\
68*404b540aSrobert   (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT	\
69*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)
70*404b540aSrobert 
71*404b540aSrobert /* Nonzero if MODE is a scalar integral mode.  */
72*404b540aSrobert #define SCALAR_INT_MODE_P(MODE)			\
73*404b540aSrobert   (GET_MODE_CLASS (MODE) == MODE_INT		\
74*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT)
75*404b540aSrobert 
76*404b540aSrobert /* Nonzero if MODE is a scalar floating point mode.  */
77*404b540aSrobert #define SCALAR_FLOAT_MODE_P(MODE)		\
78*404b540aSrobert   (GET_MODE_CLASS (MODE) == MODE_FLOAT		\
79*404b540aSrobert    || GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
80*404b540aSrobert 
81*404b540aSrobert /* Nonzero if MODE is a decimal floating point mode.  */
82*404b540aSrobert #define DECIMAL_FLOAT_MODE_P(MODE)		\
83*404b540aSrobert   (GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
84*404b540aSrobert 
85*404b540aSrobert /* Nonzero if CLASS modes can be widened.  */
86*404b540aSrobert #define CLASS_HAS_WIDER_MODES_P(CLASS)         \
87*404b540aSrobert   (CLASS == MODE_INT                           \
88*404b540aSrobert    || CLASS == MODE_FLOAT                      \
89*404b540aSrobert    || CLASS == MODE_DECIMAL_FLOAT              \
90*404b540aSrobert    || CLASS == MODE_COMPLEX_FLOAT)
91*404b540aSrobert 
92*404b540aSrobert /* Get the size in bytes and bits of an object of mode MODE.  */
93*404b540aSrobert 
94*404b540aSrobert extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES];
95*404b540aSrobert #define GET_MODE_SIZE(MODE)    ((unsigned short) mode_size[MODE])
96*404b540aSrobert #define GET_MODE_BITSIZE(MODE) ((unsigned short) (GET_MODE_SIZE (MODE) * BITS_PER_UNIT))
97*404b540aSrobert 
98*404b540aSrobert /* Get the number of value bits of an object of mode MODE.  */
99*404b540aSrobert extern const unsigned short mode_precision[NUM_MACHINE_MODES];
100*404b540aSrobert #define GET_MODE_PRECISION(MODE)  mode_precision[MODE]
101*404b540aSrobert 
102*404b540aSrobert /* Get a bitmask containing 1 for all bits in a word
103*404b540aSrobert    that fit within mode MODE.  */
104*404b540aSrobert 
105*404b540aSrobert extern const unsigned HOST_WIDE_INT mode_mask_array[NUM_MACHINE_MODES];
106*404b540aSrobert 
107*404b540aSrobert #define GET_MODE_MASK(MODE) mode_mask_array[MODE]
108*404b540aSrobert 
109*404b540aSrobert /* Return the mode of the inner elements in a vector.  */
110*404b540aSrobert 
111*404b540aSrobert extern const unsigned char mode_inner[NUM_MACHINE_MODES];
112*404b540aSrobert #define GET_MODE_INNER(MODE) mode_inner[MODE]
113*404b540aSrobert 
114*404b540aSrobert /* Get the size in bytes of the basic parts of an object of mode MODE.  */
115*404b540aSrobert 
116*404b540aSrobert #define GET_MODE_UNIT_SIZE(MODE)		\
117*404b540aSrobert   (GET_MODE_INNER (MODE) == VOIDmode		\
118*404b540aSrobert    ? GET_MODE_SIZE (MODE)			\
119*404b540aSrobert    : GET_MODE_SIZE (GET_MODE_INNER (MODE)))
120*404b540aSrobert 
121*404b540aSrobert /* Get the number of units in the object.  */
122*404b540aSrobert 
123*404b540aSrobert extern const unsigned char mode_nunits[NUM_MACHINE_MODES];
124*404b540aSrobert #define GET_MODE_NUNITS(MODE)  mode_nunits[MODE]
125*404b540aSrobert 
126*404b540aSrobert /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI).  */
127*404b540aSrobert 
128*404b540aSrobert extern const unsigned char mode_wider[NUM_MACHINE_MODES];
129*404b540aSrobert #define GET_MODE_WIDER_MODE(MODE) mode_wider[MODE]
130*404b540aSrobert 
131*404b540aSrobert extern const unsigned char mode_2xwider[NUM_MACHINE_MODES];
132*404b540aSrobert #define GET_MODE_2XWIDER_MODE(MODE) mode_2xwider[MODE]
133*404b540aSrobert 
134*404b540aSrobert /* Return the mode for data of a given size SIZE and mode class CLASS.
135*404b540aSrobert    If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
136*404b540aSrobert    The value is BLKmode if no other mode is found.  */
137*404b540aSrobert 
138*404b540aSrobert extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int);
139*404b540aSrobert 
140*404b540aSrobert /* Similar, but find the smallest mode for a given width.  */
141*404b540aSrobert 
142*404b540aSrobert extern enum machine_mode smallest_mode_for_size (unsigned int,
143*404b540aSrobert 						 enum mode_class);
144*404b540aSrobert 
145*404b540aSrobert 
146*404b540aSrobert /* Return an integer mode of the exact same size as the input mode,
147*404b540aSrobert    or BLKmode on failure.  */
148*404b540aSrobert 
149*404b540aSrobert extern enum machine_mode int_mode_for_mode (enum machine_mode);
150*404b540aSrobert 
151*404b540aSrobert /* Find the best mode to use to access a bit field.  */
152*404b540aSrobert 
153*404b540aSrobert extern enum machine_mode get_best_mode (int, int, unsigned int,
154*404b540aSrobert 					enum machine_mode, int);
155*404b540aSrobert 
156*404b540aSrobert /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT.  */
157*404b540aSrobert 
158*404b540aSrobert extern CONST_MODE_BASE_ALIGN unsigned char mode_base_align[NUM_MACHINE_MODES];
159*404b540aSrobert 
160*404b540aSrobert extern unsigned get_mode_alignment (enum machine_mode);
161*404b540aSrobert 
162*404b540aSrobert #define GET_MODE_ALIGNMENT(MODE) get_mode_alignment (MODE)
163*404b540aSrobert 
164*404b540aSrobert /* For each class, get the narrowest mode in that class.  */
165*404b540aSrobert 
166*404b540aSrobert extern const unsigned char class_narrowest_mode[MAX_MODE_CLASS];
167*404b540aSrobert #define GET_CLASS_NARROWEST_MODE(CLASS) class_narrowest_mode[CLASS]
168*404b540aSrobert 
169*404b540aSrobert /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD
170*404b540aSrobert    and the mode whose class is Pmode and whose size is POINTER_SIZE.  */
171*404b540aSrobert 
172*404b540aSrobert extern enum machine_mode byte_mode;
173*404b540aSrobert extern enum machine_mode word_mode;
174*404b540aSrobert extern enum machine_mode ptr_mode;
175*404b540aSrobert 
176*404b540aSrobert /* Target-dependent machine mode initialization - in insn-modes.c.  */
177*404b540aSrobert extern void init_adjust_machine_modes (void);
178*404b540aSrobert 
179*404b540aSrobert #endif /* not HAVE_MACHINE_MODES */
180