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#define HOST_BITS_PER_PTR (CHAR_BIT * SIZEOF_VOID_P)
18#define HOST_BITS_PER_LONGLONG (CHAR_BIT * SIZEOF_LONG_LONG)
22#ifndef HOST_LONG_FORMAT
23#define HOST_LONG_FORMAT "l"
28#ifndef HOST_LONG_LONG_FORMAT
29#define HOST_LONG_LONG_FORMAT "ll"
36#define HOST_BITS_PER_WIDE_INT 64
38# define HOST_WIDE_INT long
39# define HOST_WIDE_INT_C(X) X ## L
41# if HOST_BITS_PER_LONGLONG == 64
42# define HOST_WIDE_INT long long
43# define HOST_WIDE_INT_C(X) X ## LL
45 #error "Unable to find a suitable type for HOST_WIDE_INT"
49#define HOST_WIDE_INT_UC(X) HOST_WIDE_INT_C (X ## U)
50#define HOST_WIDE_INT_0 HOST_WIDE_INT_C (0)
51#define HOST_WIDE_INT_0U HOST_WIDE_INT_UC (0)
52#define HOST_WIDE_INT_1 HOST_WIDE_INT_C (1)
53#define HOST_WIDE_INT_1U HOST_WIDE_INT_UC (1)
54#define HOST_WIDE_INT_M1 HOST_WIDE_INT_C (-1)
55#define HOST_WIDE_INT_M1U HOST_WIDE_INT_UC (-1)
63#ifndef HAVE_INTTYPES_H
65# define GCC_PRI64 HOST_LONG_FORMAT
67# define GCC_PRI64 HOST_LONG_LONG_FORMAT
70#define PRId64 GCC_PRI64 "d"
72#define PRIi64 GCC_PRI64 "i"
74#define PRIo64 GCC_PRI64 "o"
76#define PRIu64 GCC_PRI64 "u"
78#define PRIx64 GCC_PRI64 "x"
80#define PRIX64 GCC_PRI64 "X"
86# define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT
87# define HOST_WIDE_INT_PRINT_C "L"
89# define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT
90# define HOST_WIDE_INT_PRINT_C "LL"
93#define HOST_WIDE_INT_PRINT_DEC "%" PRId64
94#define HOST_WIDE_INT_PRINT_DEC_C "%" PRId64 HOST_WIDE_INT_PRINT_C
95#define HOST_WIDE_INT_PRINT_UNSIGNED "%" PRIu64
96#define HOST_WIDE_INT_PRINT_HEX "%#" PRIx64
97#define HOST_WIDE_INT_PRINT_HEX_PURE "%" PRIx64
98#define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%" PRIx64 "%016" PRIx64
99#define HOST_WIDE_INT_PRINT_PADDED_HEX "%016" PRIx64
106#if SIZE_MAX <= UINT_MAX
108# define fmt_size_t unsigned int
109#elif SIZE_MAX <= ULONG_MAX
110# define GCC_PRISZ HOST_LONG_FORMAT
111# define fmt_size_t unsigned long int
113# define GCC_PRISZ HOST_LONG_LONG_FORMAT
114# define fmt_size_t unsigned long long int
117#define HOST_SIZE_T_PRINT_DEC "%" GCC_PRISZ "d"
118#define HOST_SIZE_T_PRINT_UNSIGNED "%" GCC_PRISZ "u"
119#define HOST_SIZE_T_PRINT_HEX "%#" GCC_PRISZ "x"
120#define HOST_SIZE_T_PRINT_HEX_PURE "%" GCC_PRISZ "x"
129#ifdef USE_LONG_LONG_FOR_WIDEST_FAST_INT
130# define HOST_WIDEST_FAST_INT long long
131# define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER_LONGLONG
133# define HOST_WIDEST_FAST_INT long
134# define HOST_BITS_PER_WIDEST_FAST_INT HOST_BITS_PER_LONG
141inline unsigned HOST_WIDE_INT
163#if GCC_VERSION < 3004
165extern int clz_hwi (
unsigned HOST_WIDE_INT x);
166extern int ctz_hwi (
unsigned HOST_WIDE_INT x);
167extern int ffs_hwi (
unsigned HOST_WIDE_INT x);
173extern int exact_log2 (
unsigned HOST_WIDE_INT);
176extern int floor_log2 (
unsigned HOST_WIDE_INT);
179extern int ceil_log2 (
unsigned HOST_WIDE_INT);
185clz_hwi (
unsigned HOST_WIDE_INT x)
189# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
190 return __builtin_clzl (x);
191# elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
192 return __builtin_clzll (x);
194 return __builtin_clz (x);
199ctz_hwi (
unsigned HOST_WIDE_INT x)
203# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
204 return __builtin_ctzl (x);
205# elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
206 return __builtin_ctzll (x);
208 return __builtin_ctz (x);
213ffs_hwi (
unsigned HOST_WIDE_INT x)
215# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
216 return __builtin_ffsl (x);
217# elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
218 return __builtin_ffsll (x);
220 return __builtin_ffs (x);
227# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
228 return __builtin_popcountl (x);
229# elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
230 return __builtin_popcountll (x);
232 return __builtin_popcount (x);
256#define HOST_WIDE_INT_MIN (HOST_WIDE_INT) \
257 (HOST_WIDE_INT_1U << (HOST_BITS_PER_WIDE_INT - 1))
258#define HOST_WIDE_INT_MAX (~(HOST_WIDE_INT_MIN))
260extern HOST_WIDE_INT
abs_hwi (HOST_WIDE_INT);
261extern unsigned HOST_WIDE_INT
absu_hwi (HOST_WIDE_INT);
262extern HOST_WIDE_INT
gcd (HOST_WIDE_INT, HOST_WIDE_INT);
263extern HOST_WIDE_INT
pos_mul_hwi (HOST_WIDE_INT, HOST_WIDE_INT);
264extern HOST_WIDE_INT
mul_hwi (HOST_WIDE_INT, HOST_WIDE_INT);
266extern unsigned HOST_WIDE_INT
reflect_hwi (
unsigned HOST_WIDE_INT,
unsigned);
270extern unsigned HOST_WIDE_INT
271calculate_crc (
unsigned HOST_WIDE_INT,
unsigned HOST_WIDE_INT,
272 unsigned HOST_WIDE_INT,
unsigned short,
unsigned short);
276extern unsigned HOST_WIDE_INT
278 unsigned HOST_WIDE_INT,
unsigned short,
299#if defined (__GNUC__)
307 return ((HOST_WIDE_INT) ((
unsigned HOST_WIDE_INT) src << shift)) >> shift;
312 return (((src & value_mask) ^ sign_mask) - sign_mask);
318inline unsigned HOST_WIDE_INT
319zext_hwi (
unsigned HOST_WIDE_INT src,
unsigned int prec)
336 return x >= 0 ? x : -x;
341inline unsigned HOST_WIDE_INT
344 return x >= 0 ? (
unsigned HOST_WIDE_INT)x : -(
unsigned HOST_WIDE_INT)x;
351add_hwi (HOST_WIDE_INT
a, HOST_WIDE_INT
b,
bool *overflow)
353#if GCC_VERSION < 11000
354 unsigned HOST_WIDE_INT result =
a + (
unsigned HOST_WIDE_INT)
b;
355 if ((((result ^
a) & (result ^
b))
361 HOST_WIDE_INT result;
362 *overflow = __builtin_add_overflow (
a,
b, &result);
371mul_hwi (HOST_WIDE_INT
a, HOST_WIDE_INT
b,
bool *overflow)
373#if GCC_VERSION < 11000
374 unsigned HOST_WIDE_INT result =
a * (
unsigned HOST_WIDE_INT)
b;
376 || (
a != 0 && (HOST_WIDE_INT)result /
a !=
b))
381 HOST_WIDE_INT result;
382 *overflow = __builtin_mul_overflow (
a,
b, &result);
394 HOST_WIDE_INT result =
add_hwi (
a,
b, &overflow);
407 HOST_WIDE_INT result =
mul_hwi (
a,
b, &overflow);
unsigned HOST_WIDE_INT calculate_crc(unsigned HOST_WIDE_INT crc, unsigned HOST_WIDE_INT data, unsigned HOST_WIDE_INT polynomial, unsigned short crc_bits, unsigned short data_bits)
Definition hwint.cc:232
int ffs_hwi(unsigned HOST_WIDE_INT x)
Definition hwint.cc:110
HOST_WIDE_INT gcd(HOST_WIDE_INT a, HOST_WIDE_INT b)
Definition hwint.cc:139
HOST_WIDE_INT mul_hwi(HOST_WIDE_INT x, HOST_WIDE_INT y)
Definition hwint.cc:172
HOST_WIDE_INT pos_mul_hwi(HOST_WIDE_INT x, HOST_WIDE_INT y)
Definition hwint.cc:160
unsigned HOST_WIDE_INT calculate_reversed_crc(unsigned HOST_WIDE_INT crc, unsigned HOST_WIDE_INT data, unsigned HOST_WIDE_INT polynomial, unsigned short crc_bits, unsigned short data_bits)
Definition hwint.cc:264
int exact_log2(unsigned HOST_WIDE_INT x)
Definition hwint.cc:82
int floor_log2(unsigned HOST_WIDE_INT x)
Definition hwint.cc:43
unsigned HOST_WIDE_INT reflect_hwi(unsigned HOST_WIDE_INT value, unsigned bitwidth)
Definition hwint.cc:202
int ceil_log2(unsigned HOST_WIDE_INT x)
Definition hwint.cc:73
int ctz_hwi(unsigned HOST_WIDE_INT x)
Definition hwint.cc:93
HOST_WIDE_INT least_common_multiple(HOST_WIDE_INT a, HOST_WIDE_INT b)
Definition hwint.cc:194
int clz_hwi(unsigned HOST_WIDE_INT x)
Definition hwint.cc:101
int popcount_hwi(unsigned HOST_WIDE_INT x)
Definition hwint.cc:118
HOST_WIDE_INT abs_hwi(HOST_WIDE_INT)
Definition hwint.h:333
bool pow2p_hwi(unsigned HOST_WIDE_INT x)
Definition hwint.h:158
HOST_WIDE_INT add_sat_hwi(HOST_WIDE_INT a, HOST_WIDE_INT b)
Definition hwint.h:391
#define HOST_WIDE_INT_1U
Definition hwint.h:53
int ctz_or_zero(unsigned HOST_WIDE_INT x)
Definition hwint.h:284
bool pow2_or_zerop(unsigned HOST_WIDE_INT x)
Definition hwint.h:150
unsigned HOST_WIDE_INT absu_hwi(HOST_WIDE_INT)
Definition hwint.h:342
HOST_WIDE_INT sext_hwi(HOST_WIDE_INT src, unsigned int prec)
Definition hwint.h:292
unsigned HOST_WIDE_INT least_bit_hwi(unsigned HOST_WIDE_INT x)
Definition hwint.h:142
#define HOST_WIDE_INT_MIN
Definition hwint.h:256
#define HOST_WIDE_INT_1
Definition hwint.h:52
#define HOST_WIDE_INT_MAX
Definition hwint.h:258
HOST_WIDE_INT __gcc_host_wide_int__
Definition hwint.h:60
#define HOST_BITS_PER_WIDE_INT
Definition hwint.h:36
HOST_WIDE_INT mul_sat_hwi(HOST_WIDE_INT a, HOST_WIDE_INT b)
Definition hwint.h:404
unsigned HOST_WIDE_INT zext_hwi(unsigned HOST_WIDE_INT src, unsigned int prec)
Definition hwint.h:319
HOST_WIDE_INT add_hwi(HOST_WIDE_INT a, HOST_WIDE_INT b, bool *overflow)
Definition hwint.h:351
Ca const poly_int< N, Cb > & b
Definition poly-int.h:771
Ca & a
Definition poly-int.h:770
#define gcc_checking_assert(EXPR)
Definition system.h:779