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