aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2002-08-22 00:42:40 +0000
committerTom Tromey <tromey@gcc.gnu.org>2002-08-22 00:42:40 +0000
commit57ce46bb22f5d56069e3648022a1d43dc858a790 (patch)
treeab953fd73d6634557761e02e3e308f4b315d6dc6 /gcc
parent0d811e1a74221354e24d7d1d4f74df1c39c35994 (diff)
downloadgcc-57ce46bb22f5d56069e3648022a1d43dc858a790.zip
gcc-57ce46bb22f5d56069e3648022a1d43dc858a790.tar.gz
gcc-57ce46bb22f5d56069e3648022a1d43dc858a790.tar.bz2
For PR java/6005 and PR java/7611:
* fold-const.c (fold_truthop): Use can_use_bit_fields_p. (fold): Likewise. * langhooks.c (lhd_can_use_bit_fields_p): New function. * langhooks-def.h (lhd_can_use_bit_fields_p): Declare. (LANG_HOOKS_CAN_USE_BIT_FIELDS_P): New define. (LANG_HOOKS_INITIALIZER): Use it. * langhooks.h (struct lang_hooks) [can_use_bit_fields_p]: New field. From-SVN: r56498
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/fold-const.c10
-rw-r--r--gcc/langhooks-def.h3
-rw-r--r--gcc/langhooks.c7
-rw-r--r--gcc/langhooks.h4
5 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 708334d..d9de0a2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2002-08-21 Tom Tromey <tromey@redhat.com>
+
+ For PR java/6005 and PR java/7611:
+ * fold-const.c (fold_truthop): Use can_use_bit_fields_p.
+ (fold): Likewise.
+ * langhooks.c (lhd_can_use_bit_fields_p): New function.
+ * langhooks-def.h (lhd_can_use_bit_fields_p): Declare.
+ (LANG_HOOKS_CAN_USE_BIT_FIELDS_P): New define.
+ (LANG_HOOKS_INITIALIZER): Use it.
+ * langhooks.h (struct lang_hooks) [can_use_bit_fields_p]: New
+ field.
+
2002-08-21 Stan Shebs <shebs@apple.com>
* tree.c (finish_vector_type): Fix a typo in a comment.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 033dbfcf..b8da1a7 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -1,5 +1,5 @@
/* Fold a constant sub-tree into a single node for C-compiler
- Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2002,
1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GCC.
@@ -3711,6 +3711,11 @@ fold_truthop (code, truth_type, lhs, rhs)
return 0;
}
+ /* After this point all optimizations will generate bit-field
+ references, which we might not want. */
+ if (! (*lang_hooks.can_use_bit_fields_p) ())
+ return 0;
+
/* See if we can find a mode that contains both fields being compared on
the left. If we can't, fail. Otherwise, update all constants and masks
to be relative to a field of that size. */
@@ -6590,7 +6595,8 @@ fold (expr)
}
/* If this is a comparison of a field, we may be able to simplify it. */
- if ((TREE_CODE (arg0) == COMPONENT_REF
+ if (((TREE_CODE (arg0) == COMPONENT_REF
+ && (*lang_hooks.can_use_bit_fields_p) ())
|| TREE_CODE (arg0) == BIT_FIELD_REF)
&& (code == EQ_EXPR || code == NE_EXPR)
/* Handle the constant case even without -O
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index d862851..0b05d14 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -59,6 +59,7 @@ extern rtx lhd_expand_expr PARAMS ((tree, rtx, enum machine_mode, int));
extern void lhd_print_error_function PARAMS ((struct diagnostic_context *,
const char *));
extern void lhd_set_decl_assembler_name PARAMS ((tree));
+extern bool lhd_can_use_bit_fields_p PARAMS ((void));
extern bool lhd_warn_unused_global_decl PARAMS ((tree));
extern void lhd_incomplete_type_error PARAMS ((tree, tree));
extern tree lhd_type_promotes_to PARAMS ((tree));
@@ -102,6 +103,7 @@ tree lhd_tree_inlining_convert_parm_for_inlining PARAMS ((tree, tree, tree));
#define LANG_HOOKS_UNSAVE_EXPR_NOW lhd_unsave_expr_now
#define LANG_HOOKS_MAYBE_BUILD_CLEANUP lhd_return_null_tree
#define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lhd_set_decl_assembler_name
+#define LANG_HOOKS_CAN_USE_BIT_FIELDS_P lhd_can_use_bit_fields_p
#define LANG_HOOKS_HONOR_READONLY false
#define LANG_HOOKS_PRINT_STATISTICS lhd_do_nothing
#define LANG_HOOKS_PRINT_XNODE lhd_print_tree_nothing
@@ -241,6 +243,7 @@ int lhd_tree_dump_type_quals PARAMS ((tree));
LANG_HOOKS_UNSAVE_EXPR_NOW, \
LANG_HOOKS_MAYBE_BUILD_CLEANUP, \
LANG_HOOKS_SET_DECL_ASSEMBLER_NAME, \
+ LANG_HOOKS_CAN_USE_BIT_FIELDS_P, \
LANG_HOOKS_HONOR_READONLY, \
LANG_HOOKS_PRINT_STATISTICS, \
LANG_HOOKS_PRINT_XNODE, \
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index e2feb06..54332b8 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -175,6 +175,13 @@ lhd_set_decl_assembler_name (decl)
abort ();
}
+/* By default we always allow bit-field based optimizations. */
+bool
+lhd_can_use_bit_fields_p ()
+{
+ return true;
+}
+
/* Provide a default routine to clear the binding stack. This is used
by languages that don't need to do anything special. */
void
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index 7ddd32c..34c300d 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -299,6 +299,10 @@ struct lang_hooks
assembler does not talk about it. */
void (*set_decl_assembler_name) PARAMS ((tree));
+ /* Return nonzero if fold-const is free to use bit-field
+ optimizations, for instance in fold_truthop(). */
+ bool (*can_use_bit_fields_p) PARAMS ((void));
+
/* Nonzero if TYPE_READONLY and TREE_READONLY should always be honored. */
bool honor_readonly;