diff options
Diffstat (limited to 'gcc/doc/generic.texi')
-rw-r--r-- | gcc/doc/generic.texi | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi index cacab01f9a4..78fa45f7d79 100644 --- a/gcc/doc/generic.texi +++ b/gcc/doc/generic.texi @@ -1017,10 +1017,12 @@ As this example indicates, the operands are zero-indexed. @node Constant expressions @subsection Constant expressions @tindex INTEGER_CST -@findex TREE_INT_CST_HIGH -@findex TREE_INT_CST_LOW -@findex tree_int_cst_lt -@findex tree_int_cst_equal +@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 @@ -1039,36 +1041,20 @@ These nodes represent integer constants. Note that the type of these constants is obtained with @code{TREE_TYPE}; they are not always of type @code{int}. In particular, @code{char} constants are represented with @code{INTEGER_CST} nodes. The value of the integer constant @code{e} is -given by -@smallexample -((TREE_INT_CST_HIGH (e) << HOST_BITS_PER_WIDE_INT) -+ TREE_INST_CST_LOW (e)) -@end smallexample -@noindent -HOST_BITS_PER_WIDE_INT is at least thirty-two on all platforms. Both -@code{TREE_INT_CST_HIGH} and @code{TREE_INT_CST_LOW} return a -@code{HOST_WIDE_INT}. The value of an @code{INTEGER_CST} is interpreted -as a signed or unsigned quantity depending on the type of the constant. -In general, the expression given above will overflow, so it should not -be used to calculate the value of the constant. - -The variable @code{integer_zero_node} is an integer constant with value -zero. Similarly, @code{integer_one_node} is an integer constant with -value one. The @code{size_zero_node} and @code{size_one_node} variables -are analogous, but have type @code{size_t} rather than @code{int}. - -The function @code{tree_int_cst_lt} is a predicate which holds if its -first argument is less than its second. Both constants are assumed to -have the same signedness (i.e., either both should be signed or both -should be unsigned.) The full width of the constant is used when doing -the comparison; the usual rules about promotions and conversions are -ignored. Similarly, @code{tree_int_cst_equal} holds if the two -constants are equal. The @code{tree_int_cst_sgn} function returns the -sign of a constant. The value is @code{1}, @code{0}, or @code{-1} -according on whether the constant is greater than, equal to, or less -than zero. Again, the signedness of the constant's type is taken into -account; an unsigned constant is never less than zero, no matter what -its bit-pattern. +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. @item REAL_CST |