]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/hwint.h
* bitmap.c, bitmap.h, builtin-attrs.def, cfglayout.h,
[thirdparty/gcc.git] / gcc / hwint.h
CommitLineData
09017a04 1/* HOST_WIDE_INT definitions for the GNU compiler.
0ba508e4 2 Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc.
09017a04 3
f12b58b3 4 This file is part of GCC.
09017a04 5
6 Provide definitions for macros which depend on HOST_BITS_PER_INT
ab6d34f7 7 and HOST_BITS_PER_LONG. */
09017a04 8
2a281353 9#ifndef GCC_HWINT_H
10#define GCC_HWINT_H
09017a04 11
02be28b3 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
805e22b2 18/* If HAVE_LONG_LONG and SIZEOF_LONG_LONG aren't defined, but
19 GCC_VERSION >= 3000, assume this is the second or later stage of a
20 bootstrap, we do have long long, and it's 64 bits. (This is
21 required by C99; we do have some ports that violate that assumption
22 but they're all cross-compile-only.) Just in case, force a
23 constraint violation if that assumption is incorrect. */
24#if !defined HAVE_LONG_LONG
25# if GCC_VERSION >= 3000
26# define HAVE_LONG_LONG 1
27# define SIZEOF_LONG_LONG 8
28extern char sizeof_long_long_must_be_8[sizeof(long long) == 8 ? 1 : -1];
29# endif
30#endif
31
02be28b3 32#ifdef HAVE_LONG_LONG
33# define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG)
805e22b2 34#endif
2e4dc2ea 35#ifdef HAVE___INT64
805e22b2 36# define HOST_BITS_PER___INT64 (CHAR_BIT * SIZEOF___INT64)
e1bc04ba 37#endif
09017a04 38
805e22b2 39/* Set HOST_WIDE_INT. This should be the widest efficient host
40 integer type. It can be 32 or 64 bits, except that if we are
41 targeting a machine with 64-bit size_t then it has to be 64 bits.
09017a04 42
805e22b2 43 With a sane ABI, 'long' is the largest efficient host integer type.
44 Thus, we use that unless we have to use 'long long' or '__int64'
45 because we're targeting a 64-bit machine from a 32-bit host. */
31ee5761 46
805e22b2 47#if HOST_BITS_PER_LONG >= 64 || !defined NEED_64BIT_HOST_WIDE_INT
48# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
49# define HOST_WIDE_INT long
50#else
51# if HOST_BITS_PER_LONGLONG >= 64
31ee5761 52# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
53# define HOST_WIDE_INT long long
09017a04 54# else
805e22b2 55# if HOST_BITS_PER___INT64 >= 64
56# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER___INT64
57# define HOST_WIDE_INT __int64
09017a04 58# else
805e22b2 59 #error "Unable to find a suitable type for HOST_WIDE_INT"
09017a04 60# endif
61# endif
805e22b2 62#endif
09017a04 63
805e22b2 64/* Various printf format strings for HOST_WIDE_INT. */
65
66#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
c4cf1b46 67# define HOST_WIDE_INT_PRINT "l"
68# define HOST_WIDE_INT_PRINT_C "L"
805e22b2 69 /* 'long' might be 32 or 64 bits, and the number of leading zeroes
70 must be tweaked accordingly. */
71# if HOST_BITS_PER_WIDE_INT == 64
72# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%016lx"
09017a04 73# else
805e22b2 74# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%lx%08lx"
09017a04 75# endif
805e22b2 76#else
c4cf1b46 77# define HOST_WIDE_INT_PRINT "ll"
78# define HOST_WIDE_INT_PRINT_C "LL"
805e22b2 79 /* We can assume that 'long long' is at least 64 bits. */
80# define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
c4cf1b46 81#endif /* HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG */
82
83#define HOST_WIDE_INT_PRINT_DEC "%" HOST_WIDE_INT_PRINT "d"
84#define HOST_WIDE_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC HOST_WIDE_INT_PRINT_C
85#define HOST_WIDE_INT_PRINT_UNSIGNED "%" HOST_WIDE_INT_PRINT "u"
86#define HOST_WIDE_INT_PRINT_HEX "0x%" HOST_WIDE_INT_PRINT "x"
09017a04 87
7b382543 88/* Set HOST_WIDEST_INT. This is a 64-bit type unless the compiler
89 in use has no 64-bit type at all; in that case it's 32 bits. */
805e22b2 90
7b382543 91#if HOST_BITS_PER_WIDE_INT >= 64 \
92 || (HOST_BITS_PER_LONGLONG < 64 && HOST_BITS_PER___INT64 < 64)
805e22b2 93# define HOST_WIDEST_INT HOST_WIDE_INT
94# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_WIDE_INT
95# define HOST_WIDEST_INT_PRINT_DEC HOST_WIDE_INT_PRINT_DEC
96# define HOST_WIDEST_INT_PRINT_DEC_C HOST_WIDE_INT_PRINT_DEC_C
805e22b2 97# define HOST_WIDEST_INT_PRINT_UNSIGNED HOST_WIDE_INT_PRINT_UNSIGNED
805e22b2 98# define HOST_WIDEST_INT_PRINT_HEX HOST_WIDE_INT_PRINT_HEX
99# define HOST_WIDEST_INT_PRINT_DOUBLE_HEX HOST_WIDE_INT_PRINT_DOUBLE_HEX
100#else
101# if HOST_BITS_PER_LONGLONG >= 64
102# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONGLONG
103# define HOST_WIDEST_INT long long
09017a04 104# else
805e22b2 105# if HOST_BITS_PER___INT64 >= 64
106# define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER___INT64
107# define HOST_WIDEST_INT __int64
09017a04 108# else
7b382543 109 #error "This line should be impossible to reach"
09017a04 110# endif
111# endif
805e22b2 112# define HOST_WIDEST_INT_PRINT_DEC "%lld"
113# define HOST_WIDEST_INT_PRINT_DEC_C "%lldLL"
805e22b2 114# define HOST_WIDEST_INT_PRINT_UNSIGNED "%llu"
805e22b2 115# define HOST_WIDEST_INT_PRINT_HEX "0x%llx"
116# define HOST_WIDEST_INT_PRINT_DOUBLE_HEX "0x%llx%016llx"
117#endif
02be28b3 118
3f28a032 119/* Define HOST_WIDEST_FAST_INT to the widest integer type supported
120 efficiently in hardware. (That is, the widest integer type that fits
121 in a hardware register.) Normally this is "long" but on some hosts it
122 should be "long long" or "__int64". This is no convenient way to
123 autodect this, so such systems must set a flag in config.host; see there
124 for details. */
125
126#ifdef USE_LONG_LONG_FOR_WIDEST_FAST_INT
127# ifdef HAVE_LONG_LONG
128# define HOST_WIDEST_FAST_INT long long
129# define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER_LONGLONG
130# elif defined (HAVE___INT64)
131# define HOST_WIDEST_FAST_INT __int64
132# define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER___INT64
133# else
134# error "Your host said it wantted to use long long or __int64 but neither"
135# error "exist"
136# endif
137#else
138# define HOST_WIDEST_FAST_INT long
139# define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER_LONG
140#endif
141
2a281353 142#endif /* ! GCC_HWINT_H */