1 | /* Typedefs for polynomial integers used in GCC. |
2 | Copyright (C) 2016-2023 Free Software Foundation, Inc. |
3 | |
4 | This file is part of GCC. |
5 | |
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 |
9 | version. |
10 | |
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 |
14 | for more details. |
15 | |
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/>. */ |
19 | |
20 | #ifndef HAVE_POLY_INT_TYPES_H |
21 | #define HAVE_POLY_INT_TYPES_H |
22 | |
23 | typedef poly_int<NUM_POLY_INT_COEFFS, unsigned short> poly_uint16; |
24 | typedef poly_int<NUM_POLY_INT_COEFFS, HOST_WIDE_INT> poly_int64; |
25 | typedef poly_int<NUM_POLY_INT_COEFFS, unsigned HOST_WIDE_INT> poly_uint64; |
26 | typedef poly_int<NUM_POLY_INT_COEFFS, offset_int> poly_offset_int; |
27 | typedef poly_int<NUM_POLY_INT_COEFFS, wide_int> poly_wide_int; |
28 | typedef poly_int<NUM_POLY_INT_COEFFS, wide_int_ref> poly_wide_int_ref; |
29 | typedef poly_int<NUM_POLY_INT_COEFFS, widest_int> poly_widest_int; |
30 | |
31 | /* Divide bit quantity X by BITS_PER_UNIT and round down (towards -Inf). |
32 | If X is a bit size, this gives the number of whole bytes spanned by X. |
33 | |
34 | This is safe because non-constant mode sizes must be a whole number |
35 | of bytes in size. */ |
36 | #define bits_to_bytes_round_down(X) force_align_down_and_div (X, BITS_PER_UNIT) |
37 | |
38 | /* Divide bit quantity X by BITS_PER_UNIT and round up (towards +Inf). |
39 | If X is a bit size, this gives the number of whole or partial bytes |
40 | spanned by X. |
41 | |
42 | This is safe because non-constant mode sizes must be a whole number |
43 | of bytes in size. */ |
44 | #define bits_to_bytes_round_up(X) force_align_up_and_div (X, BITS_PER_UNIT) |
45 | |
46 | /* Return the number of bits in bit quantity X that do not belong to |
47 | whole bytes. This is equivalent to: |
48 | |
49 | X - bits_to_bytes_round_down (X) * BITS_PER_UNIT |
50 | |
51 | This is safe because non-constant mode sizes must be a whole number |
52 | of bytes in size. */ |
53 | #define num_trailing_bits(X) force_get_misalignment (X, BITS_PER_UNIT) |
54 | |
55 | /* Round bit quantity X down to the nearest byte boundary. |
56 | |
57 | This is safe because non-constant mode sizes must be a whole number |
58 | of bytes in size. */ |
59 | #define round_down_to_byte_boundary(X) force_align_down (X, BITS_PER_UNIT) |
60 | |
61 | /* Round bit quantity X up the nearest byte boundary. |
62 | |
63 | This is safe because non-constant mode sizes must be a whole number |
64 | of bytes in size. */ |
65 | #define round_up_to_byte_boundary(X) force_align_up (X, BITS_PER_UNIT) |
66 | |
67 | /* Return the size of an element in a vector of size SIZE, given that |
68 | the vector has NELTS elements. The return value is in the same units |
69 | as SIZE (either bits or bytes). |
70 | |
71 | to_constant () is safe in this situation because vector elements are |
72 | always constant-sized scalars. */ |
73 | #define vector_element_size(SIZE, NELTS) \ |
74 | (exact_div (SIZE, NELTS).to_constant ()) |
75 | |
76 | /* Return the number of unroll times when a vector that has NELTS1 elements |
77 | is unrolled to vectors that have NELTS2 elements. |
78 | |
79 | to_constant () is safe in this situation because the multiples of the |
80 | NELTS of two vectors are always constant-size scalars. */ |
81 | #define vector_unroll_factor(NELTS1, NELTS2) \ |
82 | (exact_div (NELTS1, NELTS2).to_constant ()) |
83 | |
84 | /* Wrapper for poly_int arguments to target macros, so that if a target |
85 | doesn't need polynomial-sized modes, its header file can continue to |
86 | treat the argument as a normal constant. This should go away once |
87 | macros are moved to target hooks. It shouldn't be used in other |
88 | contexts. */ |
89 | #if NUM_POLY_INT_COEFFS == 1 |
90 | #define MACRO_INT(X) ((X).to_constant ()) |
91 | #else |
92 | #define MACRO_INT(X) (X) |
93 | #endif |
94 | |
95 | #endif |
96 | |