]> gcc.gnu.org Git - gcc.git/blame - gcc/machmode.h
Daily bump.
[gcc.git] / gcc / machmode.h
CommitLineData
fc152a4b 1/* Machine mode definitions for GNU C-Compiler; included by rtl.h and tree.h.
70c75d9f 2 Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc.
fc152a4b
RK
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
a35311b0
RK
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
fc152a4b 20
fc152a4b 21#ifndef HAVE_MACHINE_MODES
70c75d9f
DE
22#define HAVE_MACHINE_MODES
23
fc152a4b
RK
24/* Strictly speaking, this isn't the proper place to include these definitions,
25 but this file is included by every GCC file.
26
27 Some systems define these in, e.g., param.h. We undefine these names
28 here to avoid the warnings. We prefer to use our definitions since we
29 know they are correct. */
30
31#undef MIN
32#undef MAX
33
34#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
35#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
36
5f4f0e22
CH
37/* Find the largest host integer type and set its size and type. */
38
39#ifndef HOST_BITS_PER_WIDE_INT
40
41#if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
42#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
43#define HOST_WIDE_INT long
44#else
45#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
46#define HOST_WIDE_INT int
47#endif
48
49#endif
50
5f4f0e22
CH
51/* Provide a default way to print an address in hex via printf. */
52
53#ifndef HOST_PTR_PRINTF
092f7be3
KG
54# ifdef HAVE_PRINTF_PTR
55# define HOST_PTR_PRINTF "%p"
56# else
57# define HOST_PTR_PRINTF \
58 (sizeof (int) == sizeof (char *) ? "%x" \
59 : sizeof (long) == sizeof (char *) ? "%lx" : "%llx")
60# endif
61#endif /* ! HOST_PTR_PRINTF */
29cad4a4
RK
62
63/* Provide defaults for the way to print a HOST_WIDE_INT
64 in various manners. */
65
66#ifndef HOST_WIDE_INT_PRINT_DEC
67#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
68#define HOST_WIDE_INT_PRINT_DEC "%d"
69#else
70#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
71#define HOST_WIDE_INT_PRINT_DEC "%ld"
72#else
73#define HOST_WIDE_INT_PRINT_DEC "%lld"
74#endif
75#endif
76#endif
77
78#ifndef HOST_WIDE_INT_PRINT_UNSIGNED
79#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
80#define HOST_WIDE_INT_PRINT_UNSIGNED "%u"
81#else
82#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
83#define HOST_WIDE_INT_PRINT_UNSIGNED "%lu"
84#else
85#define HOST_WIDE_INT_PRINT_UNSIGNED "%llu"
86#endif
87#endif
88#endif
89
90#ifndef HOST_WIDE_INT_PRINT_HEX
91#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
92#define HOST_WIDE_INT_PRINT_HEX "0x%x"
93#else
94#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
95#define HOST_WIDE_INT_PRINT_HEX "0x%lx"
96#else
97#define HOST_WIDE_INT_PRINT_HEX "0x%llx"
98#endif
99#endif
100#endif
101
102#ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX
103#if HOST_BITS_PER_WIDE_INT == 64
104#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
105#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x"
106#else
107#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
108#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
109#else
110#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
111#endif
112#endif
113#else
114#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
115#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x"
116#else
117#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
118#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
119#else
120#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx"
121#endif
122#endif
123#endif
5f4f0e22
CH
124#endif
125
fc152a4b
RK
126/* Make an enum class that gives all the machine modes. */
127
128#define DEF_MACHMODE(SYM, NAME, TYPE, SIZE, UNIT, WIDER) SYM,
129
130enum machine_mode {
131#include "machmode.def"
132
133#ifdef EXTRA_CC_MODES
134 EXTRA_CC_MODES,
135#endif
136MAX_MACHINE_MODE };
137
138#undef DEF_MACHMODE
139
fc152a4b
RK
140#ifndef NUM_MACHINE_MODES
141#define NUM_MACHINE_MODES (int) MAX_MACHINE_MODE
142#endif
143
144/* Get the name of mode MODE as a string. */
145
146extern char *mode_name[];
0f41302f 147#define GET_MODE_NAME(MODE) (mode_name[(int) (MODE)])
fc152a4b
RK
148
149enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC,
4a39a918 150 MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS};
fc152a4b
RK
151
152/* Get the general kind of object that mode MODE represents
153 (integer, floating, complex, etc.) */
154
155extern enum mode_class mode_class[];
0f41302f 156#define GET_MODE_CLASS(MODE) (mode_class[(int) (MODE)])
fc152a4b 157
ae1ae48c
RK
158/* Nonzero if MODE is an integral mode. */
159#define INTEGRAL_MODE_P(MODE) \
160 (GET_MODE_CLASS (MODE) == MODE_INT \
161 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \
162 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT)
163
164/* Nonzero if MODE is a floating-point mode. */
165#define FLOAT_MODE_P(MODE) \
166 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
167 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)
168
76080169
RH
169/* Nonzero if MODE is a complex mode. */
170#define COMPLEX_MODE_P(MODE) \
171 (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
172 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)
173
fc152a4b
RK
174/* Get the size in bytes of an object of mode MODE. */
175
176extern int mode_size[];
0f41302f 177#define GET_MODE_SIZE(MODE) (mode_size[(int) (MODE)])
fc152a4b
RK
178
179/* Get the size in bytes of the basic parts of an object of mode MODE. */
180
181extern int mode_unit_size[];
0f41302f 182#define GET_MODE_UNIT_SIZE(MODE) (mode_unit_size[(int) (MODE)])
fc152a4b
RK
183
184/* Get the number of units in the object. */
185
186#define GET_MODE_NUNITS(MODE) \
fa45b1eb
RS
187 ((GET_MODE_UNIT_SIZE ((MODE)) == 0) ? 0 \
188 : (GET_MODE_SIZE ((MODE)) / GET_MODE_UNIT_SIZE ((MODE))))
fc152a4b
RK
189
190/* Get the size in bits of an object of mode MODE. */
191
0f41302f 192#define GET_MODE_BITSIZE(MODE) (BITS_PER_UNIT * mode_size[(int) (MODE)])
fc152a4b
RK
193
194/* Get a bitmask containing 1 for all bits in a word
195 that fit within mode MODE. */
196
abef8789 197extern unsigned HOST_WIDE_INT mode_mask_array[];
913f68c1
JC
198
199#define GET_MODE_MASK(MODE) mode_mask_array[(int) (MODE)]
fc152a4b
RK
200
201/* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */
202
913f68c1
JC
203extern unsigned char mode_wider_mode[];
204#define GET_MODE_WIDER_MODE(MODE) ((enum machine_mode)mode_wider_mode[(int) (MODE)])
fc152a4b 205
c92c981a
RK
206/* Return the mode for data of a given size SIZE and mode class CLASS.
207 If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
208 The value is BLKmode if no other mode is found. */
209
521f2d6f 210extern enum machine_mode mode_for_size PROTO((unsigned int, enum mode_class, int));
c92c981a 211
d006aa54
RH
212/* Return an integer mode of the exact same size as the input mode,
213 or BLKmode on failure. */
214
215extern enum machine_mode int_mode_for_mode PROTO((enum machine_mode));
216
fc152a4b
RK
217/* Find the best mode to use to access a bit field. */
218
521f2d6f 219extern enum machine_mode get_best_mode PROTO((int, int, int, enum machine_mode, int));
fc152a4b
RK
220
221/* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */
222
223#define GET_MODE_ALIGNMENT(MODE) \
224 MIN (BIGGEST_ALIGNMENT, \
225 MAX (1, (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT)))
226
4a39a918
RK
227/* For each class, get the narrowest mode in that class. */
228
229extern enum machine_mode class_narrowest_mode[];
0f41302f 230#define GET_CLASS_NARROWEST_MODE(CLASS) class_narrowest_mode[(int) (CLASS)]
4a39a918 231
6c164c81
RK
232/* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD
233 and the mode whose class is Pmode and whose size is POINTER_SIZE. */
4a39a918
RK
234
235extern enum machine_mode byte_mode;
236extern enum machine_mode word_mode;
6c164c81 237extern enum machine_mode ptr_mode;
4a39a918 238
fc152a4b 239#endif /* not HAVE_MACHINE_MODES */
This page took 0.643026 seconds and 5 git commands to generate.