aboutsummaryrefslogtreecommitdiff
path: root/gcc/explow.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2002-08-03 16:20:35 -0400
committerJason Merrill <jason@gcc.gnu.org>2002-08-03 16:20:35 -0400
commitde8920be70e85d22a890bc99e0c3a20df4089af0 (patch)
tree0f3eddb683599b1fa6da741865277a804942c1f7 /gcc/explow.c
parent7a9ffd82b6227ee0ebe3f7a4f767e470b847d77a (diff)
downloadgcc-de8920be70e85d22a890bc99e0c3a20df4089af0.zip
gcc-de8920be70e85d22a890bc99e0c3a20df4089af0.tar.gz
gcc-de8920be70e85d22a890bc99e0c3a20df4089af0.tar.bz2
explow.c (int_expr_size): New fn.
* explow.c (int_expr_size): New fn. * expr.c (expand_expr) [CONSTRUCTOR]: Use it. * expr.h: Declare it. From-SVN: r56009
Diffstat (limited to 'gcc/explow.c')
-rw-r--r--gcc/explow.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/explow.c b/gcc/explow.c
index 5bc3451..1d27640 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -294,6 +294,26 @@ expr_size (exp)
return expand_expr (size, NULL_RTX, TYPE_MODE (sizetype), 0);
}
+
+/* Return a wide integer for the size in bytes of the value of EXP, or -1
+ if the size can vary or is larger than an integer. */
+
+HOST_WIDE_INT
+int_expr_size (exp)
+ tree exp;
+{
+ tree t = (*lang_hooks.expr_size) (exp);
+
+ if (t == 0
+ || TREE_CODE (t) != INTEGER_CST
+ || TREE_OVERFLOW (t)
+ || TREE_INT_CST_HIGH (t) != 0
+ /* If the result would appear negative, it's too big to represent. */
+ || (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0)
+ return -1;
+
+ return TREE_INT_CST_LOW (t);
+}
/* Return a copy of X in which all memory references
and all constants that involve symbol refs