diff options
Diffstat (limited to 'gcc/double-int.c')
-rw-r--r-- | gcc/double-int.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/double-int.c b/gcc/double-int.c index 3be0abf4f3a..f1824da8ff4 100644 --- a/gcc/double-int.c +++ b/gcc/double-int.c @@ -290,7 +290,8 @@ double_int_umod (double_int a, double_int b, unsigned code) return double_int_mod (a, b, true, code); } -/* Constructs tree in type TYPE from with value given by CST. */ +/* Constructs tree in type TYPE from with value given by CST. Signedness of CST + is assumed to be the same as the signedness of TYPE. */ tree double_int_to_tree (tree type, double_int cst) @@ -300,6 +301,19 @@ double_int_to_tree (tree type, double_int cst) return build_int_cst_wide (type, cst.low, cst.high); } +/* Returns true if CST fits into range of TYPE. Signedness of CST is assumed + to be the same as the signedness of TYPE. */ + +bool +double_int_fits_to_tree_p (tree type, double_int cst) +{ + double_int ext = double_int_ext (cst, + TYPE_PRECISION (type), + TYPE_UNSIGNED (type)); + + return double_int_equal_p (cst, ext); +} + /* Returns true if CST is negative. Of course, CST is considered to be signed. */ |