]>
Commit | Line | Data |
---|---|---|
cce4a958 | 1 | /* HOST_WIDE_INT definitions for the GNU compiler. |
964b104a | 2 | Copyright (C) 1998, 2002 Free Software Foundation, Inc. |
cce4a958 | 3 | |
1322177d | 4 | This file is part of GCC. |
cce4a958 KG |
5 | |
6 | Provide definitions for macros which depend on HOST_BITS_PER_INT | |
19eb1ad7 | 7 | and HOST_BITS_PER_LONG. */ |
cce4a958 | 8 | |
88657302 RH |
9 | #ifndef GCC_HWINT_H |
10 | #define GCC_HWINT_H | |
cce4a958 | 11 | |
75e93faa ZW |
12 | /* This describes the machine the compiler is hosted on. */ |
13 | #define HOST_BITS_PER_CHAR CHAR_BIT | |
14 | #define HOST_BITS_PER_SHORT (CHAR_BIT * SIZEOF_SHORT) | |
15 | #define HOST_BITS_PER_INT (CHAR_BIT * SIZEOF_INT) | |
16 | #define HOST_BITS_PER_LONG (CHAR_BIT * SIZEOF_LONG) | |
17 | ||
18 | #ifdef HAVE_LONG_LONG | |
19 | # define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG) | |
20 | #else | |
964b104a | 21 | #ifdef HAVE___INT64 |
6d08665a RK |
22 | # define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF___INT64) |
23 | #else | |
75e93faa ZW |
24 | /* If we're here and we're GCC, assume this is stage 2+ of a bootstrap |
25 | and 'long long' has the width of the *target*'s long long. */ | |
26 | # if GCC_VERSION > 3000 | |
27 | # define HOST_BITS_PER_LONGLONG LONG_LONG_TYPE_SIZE | |
28 | # endif /* gcc */ | |
6d08665a | 29 | #endif |
75e93faa | 30 | #endif /* no long long */ |
cce4a958 KG |
31 | |
32 | /* Find the largest host integer type and set its size and type. */ | |
33 | ||
4abe9f62 AO |
34 | /* Use long long on the host if the target has a wider long type than |
35 | the host. */ | |
36 | ||
37 | #if ! defined HOST_BITS_PER_WIDE_INT \ | |
38 | && defined HOST_BITS_PER_LONGLONG \ | |
39 | && (HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG) \ | |
40 | && (defined (LONG_LONG_MAX) || defined (LONGLONG_MAX) \ | |
41 | || defined (LLONG_MAX) || defined (__GNUC__)) | |
42 | ||
43 | # ifdef MAX_LONG_TYPE_SIZE | |
44 | # if MAX_LONG_TYPE_SIZE > HOST_BITS_PER_LONG | |
45 | # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG | |
46 | # define HOST_WIDE_INT long long | |
47 | # endif | |
48 | # else | |
49 | # if LONG_TYPE_SIZE > HOST_BITS_PER_LONG | |
50 | # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG | |
51 | # define HOST_WIDE_INT long long | |
52 | # endif | |
53 | # endif | |
54 | ||
55 | #endif | |
56 | ||
cce4a958 KG |
57 | #ifndef HOST_BITS_PER_WIDE_INT |
58 | ||
59 | # if HOST_BITS_PER_LONG > HOST_BITS_PER_INT | |
60 | # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG | |
61 | # define HOST_WIDE_INT long | |
62 | # else | |
63 | # define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT | |
64 | # define HOST_WIDE_INT int | |
65 | # endif | |
66 | ||
67 | #endif /* ! HOST_BITS_PER_WIDE_INT */ | |
68 | ||
cce4a958 KG |
69 | /* Provide defaults for the way to print a HOST_WIDE_INT |
70 | in various manners. */ | |
71 | ||
72 | #ifndef HOST_WIDE_INT_PRINT_DEC | |
73 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
74 | # define HOST_WIDE_INT_PRINT_DEC "%d" | |
bb9b3805 | 75 | # define HOST_WIDE_INT_PRINT_DEC_C "%d" |
c2ae8aef | 76 | # define HOST_WIDE_INT_PRINT_DEC_SPACE "% *d" |
cce4a958 KG |
77 | # else |
78 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG | |
79 | # define HOST_WIDE_INT_PRINT_DEC "%ld" | |
bb9b3805 | 80 | # define HOST_WIDE_INT_PRINT_DEC_C "%ldL" |
c2ae8aef | 81 | # define HOST_WIDE_INT_PRINT_DEC_SPACE "% *ld" |
cce4a958 KG |
82 | # else |
83 | # define HOST_WIDE_INT_PRINT_DEC "%lld" | |
bb9b3805 | 84 | # define HOST_WIDE_INT_PRINT_DEC_C "%lldLL" |
c2ae8aef | 85 | # define HOST_WIDE_INT_PRINT_DEC_SPACE "% *lld" |
cce4a958 KG |
86 | # endif |
87 | # endif | |
88 | #endif /* ! HOST_WIDE_INT_PRINT_DEC */ | |
89 | ||
90 | #ifndef HOST_WIDE_INT_PRINT_UNSIGNED | |
91 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
92 | # define HOST_WIDE_INT_PRINT_UNSIGNED "%u" | |
c2ae8aef | 93 | # define HOST_WIDE_INT_PRINT_UNSIGNED_SPACE "% *u" |
cce4a958 KG |
94 | # else |
95 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG | |
96 | # define HOST_WIDE_INT_PRINT_UNSIGNED "%lu" | |
c2ae8aef | 97 | # define HOST_WIDE_INT_PRINT_UNSIGNED_SPACE "% *lu" |
cce4a958 KG |
98 | # else |
99 | # define HOST_WIDE_INT_PRINT_UNSIGNED "%llu" | |
c2ae8aef | 100 | # define HOST_WIDE_INT_PRINT_UNSIGNED_SPACE "% *llu" |
cce4a958 KG |
101 | # endif |
102 | # endif | |
103 | #endif /* ! HOST_WIDE_INT_PRINT_UNSIGNED */ | |
104 | ||
105 | #ifndef HOST_WIDE_INT_PRINT_HEX | |
106 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
107 | # define HOST_WIDE_INT_PRINT_HEX "0x%x" | |
108 | # else | |
109 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG | |
110 | # define HOST_WIDE_INT_PRINT_HEX "0x%lx" | |
111 | # else | |
112 | # define HOST_WIDE_INT_PRINT_HEX "0x%llx" | |
113 | # endif | |
114 | # endif | |
115 | #endif /* ! HOST_WIDE_INT_PRINT_HEX */ | |
116 | ||
117 | #ifndef HOST_WIDE_INT_PRINT_DOUBLE_HEX | |
118 | # if HOST_BITS_PER_WIDE_INT == 64 | |
119 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
120 | # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%016x" | |
121 | # else | |
122 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG | |
123 | # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx" | |
124 | # else | |
125 | # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx" | |
126 | # endif | |
127 | # endif | |
128 | # else | |
129 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
130 | # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%x%08x" | |
131 | # else | |
132 | # if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG | |
133 | # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx" | |
134 | # else | |
135 | # define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%08llx" | |
136 | # endif | |
137 | # endif | |
138 | # endif | |
139 | #endif /* ! HOST_WIDE_INT_PRINT_DOUBLE_HEX */ | |
140 | ||
75e93faa ZW |
141 | /* Find HOST_WIDEST_INT and set its bit size, type and print macros. |
142 | It will be the largest integer mode supported by the host which may | |
143 | (or may not) be larger than HOST_WIDE_INT. */ | |
144 | ||
145 | #ifndef HOST_WIDEST_INT | |
146 | #if defined HOST_BITS_PER_LONGLONG \ | |
147 | && HOST_BITS_PER_LONGLONG > HOST_BITS_PER_LONG | |
148 | # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG | |
149 | # define HOST_WIDEST_INT long long | |
150 | # define HOST_WIDEST_INT_PRINT_DEC "%lld" | |
c2ae8aef | 151 | # define HOST_WIDEST_INT_PRINT_DEC_SPACE "% *lld" |
75e93faa | 152 | # define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu" |
c2ae8aef | 153 | # define HOST_WIDEST_INT_PRINT_UNSIGNED_SPACE "% *llu" |
75e93faa ZW |
154 | # define HOST_WIDEST_INT_PRINT_HEX "0x%llx" |
155 | # else | |
156 | # define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG | |
157 | # define HOST_WIDEST_INT long | |
158 | # define HOST_WIDEST_INT_PRINT_DEC "%ld" | |
c2ae8aef | 159 | # define HOST_WIDEST_INT_PRINT_DEC_SPACE "% *ld" |
75e93faa | 160 | # define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu" |
c2ae8aef | 161 | # define HOST_WIDEST_INT_PRINT_UNSIGNED_SPACE "% *lu" |
75e93faa ZW |
162 | # define HOST_WIDEST_INT_PRINT_HEX "0x%lx" |
163 | # endif /* long long wider than long */ | |
164 | #endif /* ! HOST_WIDEST_INT */ | |
165 | ||
88657302 | 166 | #endif /* ! GCC_HWINT_H */ |