* 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
+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.
/* 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.
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. */
}
/* 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
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));
#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
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, \
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
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;