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