diff options
author | Brooks Moses <brooks.moses@codesourcery.com> | 2007-04-30 19:14:04 +0000 |
---|---|---|
committer | Brooks Moses <brooks@gcc.gnu.org> | 2007-04-30 12:14:04 -0700 |
commit | e4fd22c6d5a014ae055d1ed7499c87f9dbb9a3cd (patch) | |
tree | 6479ca4b9aae9944979b25e103b6a70c19c8e7fe /gcc/tree.c | |
parent | 0a21c1d2bae57035c0f46cca64e85f228c6b4388 (diff) | |
download | gcc-e4fd22c6d5a014ae055d1ed7499c87f9dbb9a3cd.zip gcc-e4fd22c6d5a014ae055d1ed7499c87f9dbb9a3cd.tar.gz gcc-e4fd22c6d5a014ae055d1ed7499c87f9dbb9a3cd.tar.bz2 |
double-int.c (mpz_set_double_int): Moved from tree-ssa-loop-niter.c.
* double-int.c (mpz_set_double_int): Moved from
tree-ssa-loop-niter.c.
(mpz_get_double_int): Likewise; also, add option to wrap
out-of-range integers.
* double-int.h: New prototypes for above.
* tree.c (get_static_type_bounds): Moved from
tree-ssa-loop-niter.c; now returns TYPE_MIN_VALUE and
TYPE_MAX_VALUE if they exist..
* tree.h: New prototype for above.
* tree-ssa-loop-niter.c: Adjust mpz_to_double_int and
get_type_bounds calls.
(mpz_set_double_int): Move to double-int.c.
(get_type_bounds): Move to tree.c, rename to
get_static_type_bounds.
(mpz_to_double_int): Move to double-int.c, rename to
mpz_get_double_int.
From-SVN: r124304
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -6138,6 +6138,47 @@ int_fits_type_p (tree c, tree type) return !fit_double_type (low, high, &low, &high, type); } +/* Stores bounds of an integer TYPE in MIN and MAX. If TYPE has non-constant + bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be + represented (assuming two's-complement arithmetic) within the bit + precision of the type are returned instead. */ + +void +get_type_static_bounds (tree type, mpz_t min, mpz_t max) +{ + if (!POINTER_TYPE_P (type) && TYPE_MIN_VALUE (type) + && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST) + mpz_set_double_int (min, tree_to_double_int (TYPE_MIN_VALUE (type)), + TYPE_UNSIGNED (type)); + else + { + if (TYPE_UNSIGNED (type)) + mpz_set_ui (min, 0); + else + { + double_int mn; + mn = double_int_mask (TYPE_PRECISION (type) - 1); + mn = double_int_sext (double_int_add (mn, double_int_one), + TYPE_PRECISION (type)); + mpz_set_double_int (min, mn, false); + } + } + + if (!POINTER_TYPE_P (type) && TYPE_MAX_VALUE (type) + && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST) + mpz_set_double_int (max, tree_to_double_int (TYPE_MAX_VALUE (type)), + TYPE_UNSIGNED (type)); + else + { + if (TYPE_UNSIGNED (type)) + mpz_set_double_int (max, double_int_mask (TYPE_PRECISION (type)), + true); + else + mpz_set_double_int (max, double_int_mask (TYPE_PRECISION (type) - 1), + true); + } +} + /* Subprogram of following function. Called by walk_tree. Return *TP if it is an automatic variable or parameter of the |