diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-18 14:51:45 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-18 14:51:45 +0000 |
commit | b633e10e4ec216b6c9e7c05800ae85829c4282a0 (patch) | |
tree | ea1865acfa2c48b11b47c74919bbc11f420abb9a /gcc | |
parent | 81b5246495335b32673d7b2dab3f699542365b7b (diff) | |
download | ppe42-gcc-b633e10e4ec216b6c9e7c05800ae85829c4282a0.tar.gz ppe42-gcc-b633e10e4ec216b6c9e7c05800ae85829c4282a0.zip |
gcc/
* tree.h (tree_to_shwi, tree_to_uhwi): Declare, with inline expansions.
* tree.c (tree_to_shwi, tree_to_uhwi): New functions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204958 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/tree.c | 22 | ||||
-rw-r--r-- | gcc/tree.h | 16 |
3 files changed, 43 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 20504ae3b56..276c1cbe66b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2013-11-18 Richard Sandiford <rdsandiford@googlemail.com> + * tree.h (tree_to_shwi, tree_to_uhwi): Declare, with inline expansions. + * tree.c (tree_to_shwi, tree_to_uhwi): New functions. + +2013-11-18 Richard Sandiford <rdsandiford@googlemail.com> + * expr.h: Update comments to refer to tree_fits_[su]hwi_p rather than host_integerp. diff --git a/gcc/tree.c b/gcc/tree.c index 4f290ba2f82..124e5312e31 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7027,6 +7027,28 @@ tree_low_cst (const_tree t, int pos) return TREE_INT_CST_LOW (t); } +/* T is an INTEGER_CST whose numerical value (extended according to + TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT. Return that + HOST_WIDE_INT. */ + +HOST_WIDE_INT +tree_to_shwi (const_tree t) +{ + gcc_assert (tree_fits_shwi_p (t)); + return TREE_INT_CST_LOW (t); +} + +/* T is an INTEGER_CST whose numerical value (extended according to + TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT. Return that + HOST_WIDE_INT. */ + +HOST_WIDE_INT +tree_to_uhwi (const_tree t) +{ + gcc_assert (tree_fits_uhwi_p (t)); + return TREE_INT_CST_LOW (t); +} + /* Return the most significant (sign) bit of T. */ int diff --git a/gcc/tree.h b/gcc/tree.h index 59da1619aa6..ae30deafbba 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3673,6 +3673,8 @@ extern bool tree_fits_uhwi_p (const_tree) #endif ; extern HOST_WIDE_INT tree_low_cst (const_tree, int); +extern HOST_WIDE_INT tree_to_shwi (const_tree); +extern HOST_WIDE_INT tree_to_uhwi (const_tree); #if !defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 4003) extern inline __attribute__ ((__gnu_inline__)) HOST_WIDE_INT tree_low_cst (const_tree t, int pos) @@ -3680,6 +3682,20 @@ tree_low_cst (const_tree t, int pos) gcc_assert (host_integerp (t, pos)); return TREE_INT_CST_LOW (t); } + +extern inline __attribute__ ((__gnu_inline__)) HOST_WIDE_INT +tree_to_shwi (const_tree t) +{ + gcc_assert (tree_fits_shwi_p (t)); + return TREE_INT_CST_LOW (t); +} + +extern inline __attribute__ ((__gnu_inline__)) HOST_WIDE_INT +tree_to_uhwi (const_tree t) +{ + gcc_assert (tree_fits_uhwi_p (t)); + return TREE_INT_CST_LOW (t); +} #endif extern int tree_int_cst_sgn (const_tree); extern int tree_int_cst_sign_bit (const_tree); |