diff options
-rw-r--r-- | gcc/c-family/c-common.c | 6 | ||||
-rw-r--r-- | gcc/doc/generic.texi | 17 | ||||
-rw-r--r-- | gcc/tree.h | 44 |
3 files changed, 9 insertions, 58 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index f330fc5d92d..b8db750b60a 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -6056,8 +6056,10 @@ match_case_to_enum_1 (tree key, tree type, tree label) { char buf[WIDE_INT_PRINT_BUFFER_SIZE]; - if (tree_fits_hwi_p (key, TYPE_SIGN (type))) - print_dec (key, buf, TYPE_SIGN (type)); + if (tree_fits_uhwi_p (key)) + print_dec (key, buf, UNSIGNED); + else if (tree_fits_shwi_p (key)) + print_dec (key, buf, SIGNED); else print_hex (key, buf); diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi index ea5e81ad87f..642aee87d91 100644 --- a/gcc/doc/generic.texi +++ b/gcc/doc/generic.texi @@ -1024,10 +1024,8 @@ As this example indicates, the operands are zero-indexed. @tindex INTEGER_CST @tindex tree_fits_uhwi_p @tindex tree_fits_shwi_p -@tindex tree_fits_hwi_p @tindex tree_to_uhwi @tindex tree_to_shwi -@tindex tree_to_hwi @tindex REAL_CST @tindex FIXED_CST @tindex COMPLEX_CST @@ -1050,16 +1048,11 @@ represented in an array of HOST_WIDE_INT. There are enough elements in the array to represent the value without taking extra elements for redundant 0s or -1. -The functions @code{tree_fits_uhwi_p}, @code{tree_fits_shwi_p}, and -@code{tree_fits_hwi_p} can be used to tell if the value is small -enough to fit in a HOST_WIDE_INT, as either a signed value, an unsiged -value or a value whose sign is given as a parameter. The value can -then be extracted using the @code{tree_to_uhwi}, @code{tree_to_shwi}, -or @code{tree_to_hwi}. The @code{tree_to_hwi} comes in both checked -and unchecked flavors. However, when the value is used in a context -where it may represent a value that is larger than can be represented -in HOST_BITS_PER_WIDE_INT bits, the wide_int class should be used to -manipulate the constant. +The functions @code{tree_fits_shwi_p} and @code{tree_fits_uhwi_p} +can be used to tell if the value is small enough to fit in a +signed HOST_WIDE_INT or an unsigned HOST_WIDE_INT respectively. +The value can then be extracted using @code{tree_to_shwi} and +@code{tree_to_uhwi}. @item REAL_CST diff --git a/gcc/tree.h b/gcc/tree.h index f89bc271959..7045f10411c 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3754,50 +3754,6 @@ extern tree excess_precision_type (tree); extern bool valid_constant_size_p (const_tree); extern unsigned int element_precision (const_tree); -/* Return true if T is an INTEGER_CST that can be manipulated - efficiently on the host. If SIGN is SIGNED, the value can be - represented in a single HOST_WIDE_INT. If SIGN is UNSIGNED, the - value must be non-negative and can be represented in a single - unsigned HOST_WIDE_INT. */ - -static inline bool -tree_fits_hwi_p (const_tree cst, signop sign) -{ - return sign ? tree_fits_uhwi_p (cst) : tree_fits_shwi_p (cst); -} - -/* Return true if T is an INTEGER_CST that can be manipulated - efficiently on the host. If the sign of CST is SIGNED, the value - can be represented in a single HOST_WIDE_INT. If the sign of CST - is UNSIGNED, the value must be non-negative and can be represented - in a single unsigned HOST_WIDE_INT. */ - -static inline bool -tree_fits_hwi_p (const_tree cst) -{ - if (cst == NULL_TREE) - return false; - - if (TREE_CODE (cst) != INTEGER_CST) - return false; - - return TYPE_UNSIGNED (TREE_TYPE (cst)) - ? tree_fits_uhwi_p (cst) : tree_fits_shwi_p (cst); -} - -/* Return the HOST_WIDE_INT least significant bits of CST. The sign - of the checking is based on SIGNOP. */ - -static inline HOST_WIDE_INT -tree_to_hwi (const_tree cst, signop sgn) -{ - if (sgn == SIGNED) - return tree_to_shwi (cst); - else - return tree_to_uhwi (cst); -} - - /* Construct various nodes representing fract or accum data types. */ extern tree make_fract_type (int, int, int); |