aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2002-03-02 03:52:17 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2002-03-02 03:52:17 +0000
commit27b41650c178510367442f1a41b4c7a13915056d (patch)
tree75fe6685e297fa2a98efab337e910c5a2c995d5f /gcc/tree.c
parentca734b39f3a1dff4206545b43068998b2bf7821b (diff)
downloadgcc-27b41650c178510367442f1a41b4c7a13915056d.zip
gcc-27b41650c178510367442f1a41b4c7a13915056d.tar.gz
gcc-27b41650c178510367442f1a41b4c7a13915056d.tar.bz2
Makefile.in (CRTSTUFF_CFLAGS): Add -fno-zero-initialized-in-bss.
* Makefile.in (CRTSTUFF_CFLAGS): Add -fno-zero-initialized-in-bss. * doc/invoke.texi (-fno-zero-initialized-in-bss): Document. * flags.h (flag_zero_initialized_in_bss): Declare. * toplev.c (flag_zero_initialized_in_bss): New flag. (lang_independent_options): Add flag_zero_initialized_in_bss. * tree.c (initializer_zerop): New function. * tree.h (initializer_zerop): Declare. * varasm.c (assemble_variable): If we can emit bss, put zero initializers in the bss section. From-SVN: r50218
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 5e0210b..de65191 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -4975,3 +4975,45 @@ make_vector (mode, innertype, unsignedp)
return t;
}
+
+/* Given an initializer INIT, return TRUE if INIT is zero or some
+ aggregate of zeros. Otherwise return FALSE. */
+
+bool
+initializer_zerop (init)
+ tree init;
+{
+ STRIP_NOPS (init);
+
+ switch (TREE_CODE (init))
+ {
+ case INTEGER_CST:
+ return integer_zerop (init);
+ case REAL_CST:
+ return real_zerop (init)
+ && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (init));
+ case COMPLEX_CST:
+ return integer_zerop (init)
+ || (real_zerop (init)
+ && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_REALPART (init)))
+ && ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init))));
+ case CONSTRUCTOR:
+ {
+ if (AGGREGATE_TYPE_P (TREE_TYPE (init)))
+ {
+ tree aggr_init = TREE_OPERAND (init, 1);
+
+ while (aggr_init)
+ {
+ if (! initializer_zerop (TREE_VALUE (aggr_init)))
+ return false;
+ aggr_init = TREE_CHAIN (aggr_init);
+ }
+ return true;
+ }
+ return false;
+ }
+ default:
+ return false;
+ }
+}