[8833] | 1 | /* Machine mode definitions for GNU C-Compiler; included by rtl.h and tree.h. |
---|
[11287] | 2 | Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc. |
---|
[8833] | 3 | |
---|
| 4 | This file is part of GNU CC. |
---|
| 5 | |
---|
| 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. |
---|
| 10 | |
---|
| 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. |
---|
| 15 | |
---|
| 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. */ |
---|
| 20 | |
---|
[11287] | 21 | #ifndef HAVE_MACHINE_MODES |
---|
| 22 | #define HAVE_MACHINE_MODES |
---|
[8833] | 23 | |
---|
[11287] | 24 | #include "gansidecl.h" |
---|
[8833] | 25 | |
---|
| 26 | /* Strictly speaking, this isn't the proper place to include these definitions, |
---|
| 27 | but this file is included by every GCC file. |
---|
| 28 | |
---|
| 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. */ |
---|
| 32 | |
---|
| 33 | #undef MIN |
---|
| 34 | #undef MAX |
---|
| 35 | |
---|
| 36 | #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) |
---|
| 37 | #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) |
---|
| 38 | |
---|
| 39 | /* Find the largest host integer type and set its size and type. */ |
---|
| 40 | |
---|
| 41 | #ifndef HOST_BITS_PER_WIDE_INT |
---|
| 42 | |
---|
| 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 |
---|
| 50 | |
---|
| 51 | #endif |
---|
| 52 | |
---|
| 53 | /* Provide a default way to print an address in hex via printf. */ |
---|
| 54 | |
---|
| 55 | #ifndef HOST_PTR_PRINTF |
---|
[11287] | 56 | #define HOST_PTR_PRINTF \ |
---|
| 57 | (sizeof (int) == sizeof (char *) ? "%x" \ |
---|
| 58 | : sizeof (long) == sizeof (char *) ? "%lx" : "%llx") |
---|
[8833] | 59 | #endif |
---|
| 60 | |
---|
[11287] | 61 | /* Provide defaults for the way to print a HOST_WIDE_INT |
---|
| 62 | in various manners. */ |
---|
| 63 | |
---|
| 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 |
---|
| 75 | |
---|
| 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 |
---|
| 87 | |
---|
| 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 |
---|
| 99 | |
---|
| 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 |
---|
| 123 | |
---|
[8833] | 124 | /* Make an enum class that gives all the machine modes. */ |
---|
| 125 | |
---|
| 126 | #define DEF_MACHMODE(SYM, NAME, TYPE, SIZE, UNIT, WIDER) SYM, |
---|
| 127 | |
---|
| 128 | enum machine_mode { |
---|
| 129 | #include "machmode.def" |
---|
| 130 | |
---|
| 131 | #ifdef EXTRA_CC_MODES |
---|
| 132 | EXTRA_CC_MODES, |
---|
| 133 | #endif |
---|
| 134 | MAX_MACHINE_MODE }; |
---|
| 135 | |
---|
| 136 | #undef DEF_MACHMODE |
---|
| 137 | |
---|
| 138 | #ifndef NUM_MACHINE_MODES |
---|
| 139 | #define NUM_MACHINE_MODES (int) MAX_MACHINE_MODE |
---|
| 140 | #endif |
---|
| 141 | |
---|
| 142 | /* Get the name of mode MODE as a string. */ |
---|
| 143 | |
---|
| 144 | extern char *mode_name[]; |
---|
[11287] | 145 | #define GET_MODE_NAME(MODE) (mode_name[(int) (MODE)]) |
---|
[8833] | 146 | |
---|
| 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}; |
---|
| 149 | |
---|
| 150 | /* Get the general kind of object that mode MODE represents |
---|
| 151 | (integer, floating, complex, etc.) */ |
---|
| 152 | |
---|
| 153 | extern enum mode_class mode_class[]; |
---|
[11287] | 154 | #define GET_MODE_CLASS(MODE) (mode_class[(int) (MODE)]) |
---|
[8833] | 155 | |
---|
| 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) |
---|
| 161 | |
---|
| 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) |
---|
| 166 | |
---|
| 167 | /* Get the size in bytes of an object of mode MODE. */ |
---|
| 168 | |
---|
| 169 | extern int mode_size[]; |
---|
[11287] | 170 | #define GET_MODE_SIZE(MODE) (mode_size[(int) (MODE)]) |
---|
[8833] | 171 | |
---|
| 172 | /* Get the size in bytes of the basic parts of an object of mode MODE. */ |
---|
| 173 | |
---|
| 174 | extern int mode_unit_size[]; |
---|
[11287] | 175 | #define GET_MODE_UNIT_SIZE(MODE) (mode_unit_size[(int) (MODE)]) |
---|
[8833] | 176 | |
---|
| 177 | /* Get the number of units in the object. */ |
---|
| 178 | |
---|
| 179 | #define GET_MODE_NUNITS(MODE) \ |
---|
| 180 | ((GET_MODE_UNIT_SIZE ((MODE)) == 0) ? 0 \ |
---|
| 181 | : (GET_MODE_SIZE ((MODE)) / GET_MODE_UNIT_SIZE ((MODE)))) |
---|
| 182 | |
---|
| 183 | /* Get the size in bits of an object of mode MODE. */ |
---|
| 184 | |
---|
[11287] | 185 | #define GET_MODE_BITSIZE(MODE) (BITS_PER_UNIT * mode_size[(int) (MODE)]) |
---|
[8833] | 186 | |
---|
| 187 | /* Get a bitmask containing 1 for all bits in a word |
---|
| 188 | that fit within mode MODE. */ |
---|
| 189 | |
---|
| 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)) |
---|
| 193 | |
---|
| 194 | /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */ |
---|
| 195 | |
---|
| 196 | extern enum machine_mode mode_wider_mode[]; |
---|
[11287] | 197 | #define GET_MODE_WIDER_MODE(MODE) (mode_wider_mode[(int) (MODE)]) |
---|
[8833] | 198 | |
---|
| 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. */ |
---|
| 202 | |
---|
| 203 | extern enum machine_mode mode_for_size PROTO((unsigned int, enum mode_class, int)); |
---|
| 204 | |
---|
| 205 | /* Find the best mode to use to access a bit field. */ |
---|
| 206 | |
---|
| 207 | extern enum machine_mode get_best_mode PROTO((int, int, int, enum machine_mode, int)); |
---|
| 208 | |
---|
| 209 | /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */ |
---|
| 210 | |
---|
| 211 | #define GET_MODE_ALIGNMENT(MODE) \ |
---|
| 212 | MIN (BIGGEST_ALIGNMENT, \ |
---|
| 213 | MAX (1, (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))) |
---|
| 214 | |
---|
| 215 | /* For each class, get the narrowest mode in that class. */ |
---|
| 216 | |
---|
| 217 | extern enum machine_mode class_narrowest_mode[]; |
---|
[11287] | 218 | #define GET_CLASS_NARROWEST_MODE(CLASS) class_narrowest_mode[(int) (CLASS)] |
---|
[8833] | 219 | |
---|
| 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. */ |
---|
| 222 | |
---|
| 223 | extern enum machine_mode byte_mode; |
---|
| 224 | extern enum machine_mode word_mode; |
---|
| 225 | extern enum machine_mode ptr_mode; |
---|
| 226 | |
---|
| 227 | #endif /* not HAVE_MACHINE_MODES */ |
---|