diff options
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/fold-const.c | 10 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 3 | ||||
-rw-r--r-- | gcc/langhooks.c | 7 | ||||
-rw-r--r-- | gcc/langhooks.h | 4 |
5 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 708334d3096..d9de0a2da47 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 033dbfcfc62..b8da1a74b26 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 d8628513559..0b05d14609f 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 e2feb067360..54332b82e2b 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 7ddd32c88f7..34c300d82c1 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; |