explow.c (int_expr_size): New fn.
authorJason Merrill <jason@redhat.com>
Sat, 3 Aug 2002 20:20:35 +0000 (16:20 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 3 Aug 2002 20:20:35 +0000 (16:20 -0400)
        * explow.c (int_expr_size): New fn.
        * expr.c (expand_expr) [CONSTRUCTOR]: Use it.
        * expr.h: Declare it.

From-SVN: r56009

gcc/ChangeLog
gcc/explow.c
gcc/expr.c
gcc/expr.h

index 54fac85304a2cdfddbd65ce30e94ec653e80162b..96046ec70c4568fe15486e70689f28f4456e34bc 100644 (file)
@@ -1,3 +1,9 @@
+2002-08-03  Jason Merrill  <jason@redhat.com>
+
+       * explow.c (int_expr_size): New fn.
+       * expr.c (expand_expr) [CONSTRUCTOR]: Use it.
+       * expr.h: Declare it.
+
 2002-08-02  Krister Walfridsson  <cato@df.lth.se>
 
        * Makefile.in (gengtype-lex.o, gengtype-yacc.o): Add path to
index 5bc34517e8e303ddecfc3a7dad2aa5972231e7e4..1d2764064e1ee33641b4f4eaa92c95a4dae3242b 100644 (file)
@@ -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);
+}
 \f
 /* Return a copy of X in which all memory references
    and all constants that involve symbol refs
index dddd26877709b88b1081679c6d0fbce2bd8e9ada..4591af434e63b2fed947885298bf3fbd77dbf2b7 100644 (file)
@@ -6812,7 +6812,7 @@ expand_expr (exp, target, tmode, modifier)
                                                       * TYPE_QUAL_CONST))),
                             0, TREE_ADDRESSABLE (exp), 1);
 
-         store_constructor (exp, target, 0, INTVAL (expr_size (exp)));
+         store_constructor (exp, target, 0, int_expr_size (exp));
          return target;
        }
 
index 64340a2f409247d0b349ebaf914cf33a13d44a48..76b5c809e8e93499f726506c52f596a5e3ba4983 100644 (file)
@@ -544,6 +544,10 @@ extern unsigned int case_values_threshold PARAMS ((void));
 /* Return an rtx for the size in bytes of the value of an expr.  */
 extern rtx expr_size PARAMS ((tree));
 
+/* 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.  */
+extern HOST_WIDE_INT int_expr_size PARAMS ((tree));
+
 extern rtx lookup_static_chain PARAMS ((tree));
 
 /* Convert a stack slot address ADDR valid in function FNDECL