1 /* Typedefs for polynomial integers used in GCC.
2 Copyright (C) 2016-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef HAVE_POLY_INT_TYPES_H
21 #define HAVE_POLY_INT_TYPES_H
23 typedef poly_int_pod
<NUM_POLY_INT_COEFFS
, unsigned short> poly_uint16_pod
;
24 typedef poly_int_pod
<NUM_POLY_INT_COEFFS
, HOST_WIDE_INT
> poly_int64_pod
;
25 typedef poly_int_pod
<NUM_POLY_INT_COEFFS
,
26 unsigned HOST_WIDE_INT
> poly_uint64_pod
;
27 typedef poly_int_pod
<NUM_POLY_INT_COEFFS
, offset_int
> poly_offset_int_pod
;
28 typedef poly_int_pod
<NUM_POLY_INT_COEFFS
, wide_int
> poly_wide_int_pod
;
29 typedef poly_int_pod
<NUM_POLY_INT_COEFFS
, widest_int
> poly_widest_int_pod
;
31 typedef poly_int
<NUM_POLY_INT_COEFFS
, unsigned short> poly_uint16
;
32 typedef poly_int
<NUM_POLY_INT_COEFFS
, HOST_WIDE_INT
> poly_int64
;
33 typedef poly_int
<NUM_POLY_INT_COEFFS
, unsigned HOST_WIDE_INT
> poly_uint64
;
34 typedef poly_int
<NUM_POLY_INT_COEFFS
, offset_int
> poly_offset_int
;
35 typedef poly_int
<NUM_POLY_INT_COEFFS
, wide_int
> poly_wide_int
;
36 typedef poly_int
<NUM_POLY_INT_COEFFS
, wide_int_ref
> poly_wide_int_ref
;
37 typedef poly_int
<NUM_POLY_INT_COEFFS
, widest_int
> poly_widest_int
;
39 /* Divide bit quantity X by BITS_PER_UNIT and round down (towards -Inf).
40 If X is a bit size, this gives the number of whole bytes spanned by X.
42 This is safe because non-constant mode sizes must be a whole number
44 #define bits_to_bytes_round_down(X) force_align_down_and_div (X, BITS_PER_UNIT)
46 /* Divide bit quantity X by BITS_PER_UNIT and round up (towards +Inf).
47 If X is a bit size, this gives the number of whole or partial bytes
50 This is safe because non-constant mode sizes must be a whole number
52 #define bits_to_bytes_round_up(X) force_align_up_and_div (X, BITS_PER_UNIT)
54 /* Return the number of bits in bit quantity X that do not belong to
55 whole bytes. This is equivalent to:
57 X - bits_to_bytes_round_down (X) * BITS_PER_UNIT
59 This is safe because non-constant mode sizes must be a whole number
61 #define num_trailing_bits(X) force_get_misalignment (X, BITS_PER_UNIT)
63 /* Return the size of an element in a vector of size SIZE, given that
64 the vector has NELTS elements. The return value is in the same units
65 as SIZE (either bits or bytes).
67 to_constant () is safe in this situation because vector elements are
68 always constant-sized scalars. */
69 #define vector_element_size(SIZE, NELTS) \
70 (exact_div (SIZE, NELTS).to_constant ())
72 /* Wrapper for poly_int arguments to target macros, so that if a target
73 doesn't need polynomial-sized modes, its header file can continue to
74 treat the argument as a normal constant. This should go away once
75 macros are moved to target hooks. It shouldn't be used in other
77 #if NUM_POLY_INT_COEFFS == 1
78 #define MACRO_INT(X) ((X).to_constant ())
80 #define MACRO_INT(X) (X)