1 /* Typedefs for polynomial integers used in GCC.
2 Copyright (C) 2016-2023 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 /* Round bit quantity X down to the nearest byte boundary.
65 This is safe because non-constant mode sizes must be a whole number
67 #define round_down_to_byte_boundary(X) force_align_down (X, BITS_PER_UNIT)
69 /* Round bit quantity X up the nearest byte boundary.
71 This is safe because non-constant mode sizes must be a whole number
73 #define round_up_to_byte_boundary(X) force_align_up (X, BITS_PER_UNIT)
75 /* Return the size of an element in a vector of size SIZE, given that
76 the vector has NELTS elements. The return value is in the same units
77 as SIZE (either bits or bytes).
79 to_constant () is safe in this situation because vector elements are
80 always constant-sized scalars. */
81 #define vector_element_size(SIZE, NELTS) \
82 (exact_div (SIZE, NELTS).to_constant ())
84 /* Return the number of unroll times when a vector that has NELTS1 elements
85 is unrolled to vectors that have NELTS2 elements.
87 to_constant () is safe in this situation because the multiples of the
88 NELTS of two vectors are always constant-size scalars. */
89 #define vector_unroll_factor(NELTS1, NELTS2) \
90 (exact_div (NELTS1, NELTS2).to_constant ())
92 /* Wrapper for poly_int arguments to target macros, so that if a target
93 doesn't need polynomial-sized modes, its header file can continue to
94 treat the argument as a normal constant. This should go away once
95 macros are moved to target hooks. It shouldn't be used in other
97 #if NUM_POLY_INT_COEFFS == 1
98 #define MACRO_INT(X) ((X).to_constant ())
100 #define MACRO_INT(X) (X)