Add powerpc embedded targets to --with-cpu=n.
[official-gcc.git] / gcc / machmode.h
blobf1f146f2ecf73b733461afdf5506bfcffecbf165
1 /* Machine mode definitions for GNU C-Compiler; included by rtl.h and tree.h.
2 Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #ifndef HAVE_MACHINE_MODES
22 #define HAVE_MACHINE_MODES
24 #include "gansidecl.h"
26 /* Strictly speaking, this isn't the proper place to include these definitions,
27 but this file is included by every GCC file.
29 Some systems define these in, e.g., param.h. We undefine these names
30 here to avoid the warnings. We prefer to use our definitions since we
31 know they are correct. */
33 #undef MIN
34 #undef MAX
36 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
37 #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
39 /* Find the largest host integer type and set its size and type. */
41 #ifndef HOST_BITS_PER_WIDE_INT
43 #if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
44 #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
45 #define HOST_WIDE_INT long
46 #else
47 #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
48 #define HOST_WIDE_INT int
49 #endif
51 #endif
53 /* Provide a default way to print an address in hex via printf. */
55 #ifndef HOST_PTR_PRINTF
56 #define HOST_PTR_PRINTF \
57 (sizeof (int) == sizeof (char *) ? "%x" \
58 : sizeof (long) == sizeof (char *) ? "%lx" : "%llx")
59 #endif
61 /* Provide defaults for the way to print a HOST_WIDE_INT
62 in various manners. */
64 #ifndef HOST_WIDE_INT_PRINT_DEC
65 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
66 #define HOST_WIDE_INT_PRINT_DEC "%d"
67 #else
68 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
69 #define HOST_WIDE_INT_PRINT_DEC "%ld"
70 #else
71 #define HOST_WIDE_INT_PRINT_DEC "%lld"
72 #endif
73 #endif
74 #endif
76 #ifndef HOST_WIDE_INT_PRINT_UNSIGNED
77 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
78 #define HOST_WIDE_INT_PRINT_UNSIGNED "%u"
79 #else
80 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
81 #define HOST_WIDE_INT_PRINT_UNSIGNED "%lu"
82 #else
83 #define HOST_WIDE_INT_PRINT_UNSIGNED "%llu"
84 #endif
85 #endif
86 #endif
88 #ifndef HOST_WIDE_INT_PRINT_HEX
89 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
90 #define HOST_WIDE_INT_PRINT_HEX "0x%x"
91 #else
92 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
93 #define HOST_WIDE_INT_PRINT_HEX "0x%lx"
94 #else
95 #define HOST_WIDE_INT_PRINT_HEX "0x%llx"
96 #endif
97 #endif
98 #endif
100 #ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX
101 #if HOST_BITS_PER_WIDE_INT == 64
102 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
103 #define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x"
104 #else
105 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
106 #define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
107 #else
108 #define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
109 #endif
110 #endif
111 #else
112 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
113 #define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x"
114 #else
115 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
116 #define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
117 #else
118 #define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx"
119 #endif
120 #endif
121 #endif
122 #endif
124 /* Make an enum class that gives all the machine modes. */
126 #define DEF_MACHMODE(SYM, NAME, TYPE, SIZE, UNIT, WIDER) SYM,
128 enum machine_mode {
129 #include "machmode.def"
131 #ifdef EXTRA_CC_MODES
132 EXTRA_CC_MODES,
133 #endif
134 MAX_MACHINE_MODE };
136 #undef DEF_MACHMODE
138 #ifndef NUM_MACHINE_MODES
139 #define NUM_MACHINE_MODES (int) MAX_MACHINE_MODE
140 #endif
142 /* Get the name of mode MODE as a string. */
144 extern char *mode_name[];
145 #define GET_MODE_NAME(MODE) (mode_name[(int) (MODE)])
147 enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC,
148 MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS};
150 /* Get the general kind of object that mode MODE represents
151 (integer, floating, complex, etc.) */
153 extern enum mode_class mode_class[];
154 #define GET_MODE_CLASS(MODE) (mode_class[(int) (MODE)])
156 /* Nonzero if MODE is an integral mode. */
157 #define INTEGRAL_MODE_P(MODE) \
158 (GET_MODE_CLASS (MODE) == MODE_INT \
159 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \
160 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT)
162 /* Nonzero if MODE is a floating-point mode. */
163 #define FLOAT_MODE_P(MODE) \
164 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
165 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)
167 /* Get the size in bytes of an object of mode MODE. */
169 extern int mode_size[];
170 #define GET_MODE_SIZE(MODE) (mode_size[(int) (MODE)])
172 /* Get the size in bytes of the basic parts of an object of mode MODE. */
174 extern int mode_unit_size[];
175 #define GET_MODE_UNIT_SIZE(MODE) (mode_unit_size[(int) (MODE)])
177 /* Get the number of units in the object. */
179 #define GET_MODE_NUNITS(MODE) \
180 ((GET_MODE_UNIT_SIZE ((MODE)) == 0) ? 0 \
181 : (GET_MODE_SIZE ((MODE)) / GET_MODE_UNIT_SIZE ((MODE))))
183 /* Get the size in bits of an object of mode MODE. */
185 #define GET_MODE_BITSIZE(MODE) (BITS_PER_UNIT * mode_size[(int) (MODE)])
187 /* Get a bitmask containing 1 for all bits in a word
188 that fit within mode MODE. */
190 #define GET_MODE_MASK(MODE) \
191 ((GET_MODE_BITSIZE (MODE) >= HOST_BITS_PER_WIDE_INT) \
192 ?(HOST_WIDE_INT) ~0 : (((HOST_WIDE_INT) 1 << GET_MODE_BITSIZE (MODE)) - 1))
194 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */
196 extern enum machine_mode mode_wider_mode[];
197 #define GET_MODE_WIDER_MODE(MODE) (mode_wider_mode[(int) (MODE)])
199 /* Return the mode for data of a given size SIZE and mode class CLASS.
200 If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
201 The value is BLKmode if no other mode is found. */
203 extern enum machine_mode mode_for_size PROTO((unsigned int, enum mode_class, int));
205 /* Find the best mode to use to access a bit field. */
207 extern enum machine_mode get_best_mode PROTO((int, int, int, enum machine_mode, int));
209 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */
211 #define GET_MODE_ALIGNMENT(MODE) \
212 MIN (BIGGEST_ALIGNMENT, \
213 MAX (1, (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT)))
215 /* For each class, get the narrowest mode in that class. */
217 extern enum machine_mode class_narrowest_mode[];
218 #define GET_CLASS_NARROWEST_MODE(CLASS) class_narrowest_mode[(int) (CLASS)]
220 /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD
221 and the mode whose class is Pmode and whose size is POINTER_SIZE. */
223 extern enum machine_mode byte_mode;
224 extern enum machine_mode word_mode;
225 extern enum machine_mode ptr_mode;
227 #endif /* not HAVE_MACHINE_MODES */