fold-const.c (all_ones_mask_p, [...]): Constify.

* fold-const.c (all_ones_mask_p, sign_bit_p, simple_operand_p,
	fold_real_zero_addition_p, reorder_operands_p,
	div_if_zero_remainder, fold_undefer_overflow_warnings,
	int_binop_types_match_p, fold_convert_const_int_from_int,
	fold_convert_const_int_from_real,
	fold_convert_const_int_from_fixed,
	fold_convert_const_real_from_real,
	fold_convert_const_real_from_fixed,
	fold_convert_const_fixed_from_fixed,
	fold_convert_const_fixed_from_int,
	fold_convert_const_fixed_from_real, maybe_lvalue_p,
	fold_checksum_tree, fold_check_failed, print_fold_checksum,
	debug_fold_checksum, multiple_of_p): Constify.
	* tree-flow-inline.h (get_lineno): Likewise.
	* tree-flow.h (get_lineno): Likewise.
	* tree-object-size.c (compute_object_offset, addr_object_size,
	alloc_object_size, pass_through_call): Likewise.
	* tree-pretty-print.c (op_symbol, print_call_name,
	print_struct_decl, do_niy): Likewise.
	* tree.h (fold_undefer_overflow_warnings, multiple_of_p,
	debug_fold_checksum): Likewise.

From-SVN: r128120
This commit is contained in:
Kaveh R. Ghazi 2007-09-05 06:59:36 +00:00 committed by Kaveh Ghazi
parent bda9fc3983
commit ac545c6462
7 changed files with 86 additions and 62 deletions

View File

@ -1,3 +1,27 @@
2007-09-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* fold-const.c (all_ones_mask_p, sign_bit_p, simple_operand_p,
fold_real_zero_addition_p, reorder_operands_p,
div_if_zero_remainder, fold_undefer_overflow_warnings,
int_binop_types_match_p, fold_convert_const_int_from_int,
fold_convert_const_int_from_real,
fold_convert_const_int_from_fixed,
fold_convert_const_real_from_real,
fold_convert_const_real_from_fixed,
fold_convert_const_fixed_from_fixed,
fold_convert_const_fixed_from_int,
fold_convert_const_fixed_from_real, maybe_lvalue_p,
fold_checksum_tree, fold_check_failed, print_fold_checksum,
debug_fold_checksum, multiple_of_p): Constify.
* tree-flow-inline.h (get_lineno): Likewise.
* tree-flow.h (get_lineno): Likewise.
* tree-object-size.c (compute_object_offset, addr_object_size,
alloc_object_size, pass_through_call): Likewise.
* tree-pretty-print.c (op_symbol, print_call_name,
print_struct_decl, do_niy): Likewise.
* tree.h (fold_undefer_overflow_warnings, multiple_of_p,
debug_fold_checksum): Likewise.
2007-09-04 Steven Bosscher <steven@gcc.gnu.org>
PR middle-end/33029

View File

@ -114,9 +114,9 @@ static tree optimize_bit_field_compare (enum tree_code, tree, tree, tree);
static tree decode_field_reference (tree, HOST_WIDE_INT *, HOST_WIDE_INT *,
enum machine_mode *, int *, int *,
tree *, tree *);
static int all_ones_mask_p (tree, int);
static tree sign_bit_p (tree, tree);
static int simple_operand_p (tree);
static int all_ones_mask_p (const_tree, int);
static tree sign_bit_p (tree, const_tree);
static int simple_operand_p (const_tree);
static tree range_binop (enum tree_code, tree, tree, int, tree, int);
static tree range_predecessor (tree);
static tree range_successor (tree);
@ -134,12 +134,12 @@ static tree extract_muldiv_1 (tree, tree, enum tree_code, tree, bool *);
static tree fold_binary_op_with_conditional_arg (enum tree_code, tree,
tree, tree,
tree, tree, int);
static bool fold_real_zero_addition_p (tree, tree, int);
static bool fold_real_zero_addition_p (const_tree, const_tree, int);
static tree fold_mathfn_compare (enum built_in_function, enum tree_code,
tree, tree, tree);
static tree fold_inf_compare (enum tree_code, tree, tree, tree);
static tree fold_div_compare (enum tree_code, tree, tree, tree);
static bool reorder_operands_p (tree, tree);
static bool reorder_operands_p (const_tree, const_tree);
static tree fold_negate_const (tree, tree);
static tree fold_not_const (tree, tree);
static tree fold_relational_const (enum tree_code, tree, tree, tree);
@ -877,7 +877,7 @@ div_and_round_double (enum tree_code code, int uns,
Otherwise returns NULL_TREE. */
static tree
div_if_zero_remainder (enum tree_code code, tree arg1, tree arg2)
div_if_zero_remainder (enum tree_code code, const_tree arg1, const_tree arg2)
{
unsigned HOST_WIDE_INT int1l, int2l;
HOST_WIDE_INT int1h, int2h;
@ -952,7 +952,7 @@ fold_defer_overflow_warnings (void)
deferred code. */
void
fold_undefer_overflow_warnings (bool issue, tree stmt, int code)
fold_undefer_overflow_warnings (bool issue, const_tree stmt, int code)
{
const char *warnmsg;
location_t locus;
@ -1598,7 +1598,7 @@ associate_trees (tree t1, tree t2, enum tree_code code, tree type)
for use in int_const_binop, size_binop and size_diffop. */
static bool
int_binop_types_match_p (enum tree_code code, tree type1, tree type2)
int_binop_types_match_p (enum tree_code code, const_tree type1, const_tree type2)
{
if (TREE_CODE (type1) != INTEGER_TYPE && !POINTER_TYPE_P (type1))
return false;
@ -2110,7 +2110,7 @@ size_diffop (tree arg0, tree arg1)
INTEGER_CST to another integer type. */
static tree
fold_convert_const_int_from_int (tree type, tree arg1)
fold_convert_const_int_from_int (tree type, const_tree arg1)
{
tree t;
@ -2133,7 +2133,7 @@ fold_convert_const_int_from_int (tree type, tree arg1)
to an integer type. */
static tree
fold_convert_const_int_from_real (enum tree_code code, tree type, tree arg1)
fold_convert_const_int_from_real (enum tree_code code, tree type, const_tree arg1)
{
int overflow = 0;
tree t;
@ -2211,7 +2211,7 @@ fold_convert_const_int_from_real (enum tree_code code, tree type, tree arg1)
FIXED_CST to an integer type. */
static tree
fold_convert_const_int_from_fixed (tree type, tree arg1)
fold_convert_const_int_from_fixed (tree type, const_tree arg1)
{
tree t;
double_int temp, temp_trunc;
@ -2266,7 +2266,7 @@ fold_convert_const_int_from_fixed (tree type, tree arg1)
to another floating point type. */
static tree
fold_convert_const_real_from_real (tree type, tree arg1)
fold_convert_const_real_from_real (tree type, const_tree arg1)
{
REAL_VALUE_TYPE value;
tree t;
@ -2282,7 +2282,7 @@ fold_convert_const_real_from_real (tree type, tree arg1)
to a floating point type. */
static tree
fold_convert_const_real_from_fixed (tree type, tree arg1)
fold_convert_const_real_from_fixed (tree type, const_tree arg1)
{
REAL_VALUE_TYPE value;
tree t;
@ -2300,7 +2300,7 @@ fold_convert_const_real_from_fixed (tree type, tree arg1)
to another fixed-point type. */
static tree
fold_convert_const_fixed_from_fixed (tree type, tree arg1)
fold_convert_const_fixed_from_fixed (tree type, const_tree arg1)
{
FIXED_VALUE_TYPE value;
tree t;
@ -2325,7 +2325,7 @@ fold_convert_const_fixed_from_fixed (tree type, tree arg1)
to a fixed-point type. */
static tree
fold_convert_const_fixed_from_int (tree type, tree arg1)
fold_convert_const_fixed_from_int (tree type, const_tree arg1)
{
FIXED_VALUE_TYPE value;
tree t;
@ -2352,7 +2352,7 @@ fold_convert_const_fixed_from_int (tree type, tree arg1)
to a fixed-point type. */
static tree
fold_convert_const_fixed_from_real (tree type, tree arg1)
fold_convert_const_fixed_from_real (tree type, const_tree arg1)
{
FIXED_VALUE_TYPE value;
tree t;
@ -2631,7 +2631,7 @@ fold_convert (tree type, tree arg)
otherwise. */
static bool
maybe_lvalue_p (tree x)
maybe_lvalue_p (const_tree x)
{
/* We only need to wrap lvalue tree codes. */
switch (TREE_CODE (x))
@ -4123,7 +4123,7 @@ decode_field_reference (tree exp, HOST_WIDE_INT *pbitsize,
bit positions. */
static int
all_ones_mask_p (tree mask, int size)
all_ones_mask_p (const_tree mask, int size)
{
tree type = TREE_TYPE (mask);
unsigned int precision = TYPE_PRECISION (type);
@ -4147,7 +4147,7 @@ all_ones_mask_p (tree mask, int size)
or NULL_TREE otherwise. */
static tree
sign_bit_p (tree exp, tree val)
sign_bit_p (tree exp, const_tree val)
{
unsigned HOST_WIDE_INT mask_lo, lo;
HOST_WIDE_INT mask_hi, hi;
@ -4202,7 +4202,7 @@ sign_bit_p (tree exp, tree val)
to be evaluated unconditionally. */
static int
simple_operand_p (tree exp)
simple_operand_p (const_tree exp)
{
/* Strip any conversions that don't change the machine mode. */
STRIP_NOPS (exp);
@ -6471,7 +6471,7 @@ fold_binary_op_with_conditional_arg (enum tree_code code,
modes, X + 0 is not the same as X because -0 + 0 is 0. */
static bool
fold_real_zero_addition_p (tree type, tree addend, int negate)
fold_real_zero_addition_p (const_tree type, const_tree addend, int negate)
{
if (!real_zerop (addend))
return false;
@ -6984,7 +6984,7 @@ fold_single_bit_test (enum tree_code code, tree arg0, tree arg1,
such that the evaluation of arg1 occurs before arg0. */
static bool
reorder_operands_p (tree arg0, tree arg1)
reorder_operands_p (const_tree arg0, const_tree arg1)
{
if (! flag_evaluation_order)
return true;
@ -13148,9 +13148,9 @@ fold (tree expr)
#ifdef ENABLE_FOLD_CHECKING
#undef fold
static void fold_checksum_tree (tree, struct md5_ctx *, htab_t);
static void fold_check_failed (tree, tree);
void print_fold_checksum (tree);
static void fold_checksum_tree (const_tree, struct md5_ctx *, htab_t);
static void fold_check_failed (const_tree, const_tree);
void print_fold_checksum (const_tree);
/* When --enable-checking=fold, compute a digest of expr before
and after actual fold call to see if fold did not accidentally
@ -13184,7 +13184,7 @@ fold (tree expr)
}
void
print_fold_checksum (tree expr)
print_fold_checksum (const_tree expr)
{
struct md5_ctx ctx;
unsigned char checksum[16], cnt;
@ -13201,15 +13201,15 @@ print_fold_checksum (tree expr)
}
static void
fold_check_failed (tree expr ATTRIBUTE_UNUSED, tree ret ATTRIBUTE_UNUSED)
fold_check_failed (const_tree expr ATTRIBUTE_UNUSED, const_tree ret ATTRIBUTE_UNUSED)
{
internal_error ("fold check: original tree changed by fold");
}
static void
fold_checksum_tree (tree expr, struct md5_ctx *ctx, htab_t ht)
fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, htab_t ht)
{
void **slot;
const void **slot;
enum tree_code code;
struct tree_function_decl buf;
int i, len;
@ -13221,7 +13221,7 @@ recursive_label:
&& sizeof (struct tree_type) <= sizeof (struct tree_function_decl));
if (expr == NULL)
return;
slot = htab_find_slot (ht, expr, INSERT);
slot = (const void **) htab_find_slot (ht, expr, INSERT);
if (*slot != NULL)
return;
*slot = expr;
@ -13231,8 +13231,8 @@ recursive_label:
{
/* Allow DECL_ASSEMBLER_NAME to be modified. */
memcpy ((char *) &buf, expr, tree_size (expr));
SET_DECL_ASSEMBLER_NAME ((tree)&buf, NULL);
expr = (tree) &buf;
SET_DECL_ASSEMBLER_NAME (expr, NULL);
}
else if (TREE_CODE_CLASS (code) == tcc_type
&& (TYPE_POINTER_TO (expr) || TYPE_REFERENCE_TO (expr)
@ -13240,15 +13240,16 @@ recursive_label:
|| TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr)))
{
/* Allow these fields to be modified. */
tree tmp;
memcpy ((char *) &buf, expr, tree_size (expr));
expr = (tree) &buf;
TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr) = 0;
TYPE_POINTER_TO (expr) = NULL;
TYPE_REFERENCE_TO (expr) = NULL;
if (TYPE_CACHED_VALUES_P (expr))
expr = tmp = (tree) &buf;
TYPE_CONTAINS_PLACEHOLDER_INTERNAL (tmp) = 0;
TYPE_POINTER_TO (tmp) = NULL;
TYPE_REFERENCE_TO (tmp) = NULL;
if (TYPE_CACHED_VALUES_P (tmp))
{
TYPE_CACHED_VALUES_P (expr) = 0;
TYPE_CACHED_VALUES (expr) = NULL;
TYPE_CACHED_VALUES_P (tmp) = 0;
TYPE_CACHED_VALUES (tmp) = NULL;
}
}
md5_process_bytes (expr, tree_size (expr), ctx);
@ -13358,7 +13359,7 @@ recursive_label:
outputs differ. */
void
debug_fold_checksum (tree t)
debug_fold_checksum (const_tree t)
{
int i;
unsigned char checksum[16];
@ -13710,7 +13711,7 @@ fold_build_call_array_initializer (tree type, tree fn,
transformed version). */
int
multiple_of_p (tree type, tree top, tree bottom)
multiple_of_p (tree type, const_tree top, const_tree bottom)
{
if (operand_equal_p (top, bottom, 0))
return 1;

View File

@ -313,7 +313,7 @@ may_aliases (const_tree var)
/* Return the line number for EXPR, or return -1 if we have no line
number information for it. */
static inline int
get_lineno (tree expr)
get_lineno (const_tree expr)
{
if (expr == NULL_TREE)
return -1;

View File

@ -530,7 +530,7 @@ static inline bool noreturn_call_p (tree);
static inline void update_stmt (tree);
static inline bool stmt_modified_p (tree);
static inline bitmap may_aliases (const_tree);
static inline int get_lineno (tree);
static inline int get_lineno (const_tree);
static inline bitmap addresses_taken (tree);
/*---------------------------------------------------------------------------

View File

@ -41,10 +41,10 @@ struct object_size_info
static unsigned HOST_WIDE_INT unknown[4] = { -1, -1, 0, 0 };
static tree compute_object_offset (tree, tree);
static unsigned HOST_WIDE_INT addr_object_size (tree, int);
static unsigned HOST_WIDE_INT alloc_object_size (tree, int);
static tree pass_through_call (tree);
static tree compute_object_offset (const_tree, const_tree);
static unsigned HOST_WIDE_INT addr_object_size (const_tree, int);
static unsigned HOST_WIDE_INT alloc_object_size (const_tree, int);
static tree pass_through_call (const_tree);
static void collect_object_sizes_for (struct object_size_info *, tree);
static void expr_object_size (struct object_size_info *, tree, tree);
static bool merge_object_sizes (struct object_size_info *, tree, tree,
@ -88,7 +88,7 @@ init_offset_limit (void)
if unknown. */
static tree
compute_object_offset (tree expr, tree var)
compute_object_offset (const_tree expr, const_tree var)
{
enum tree_code code = PLUS_EXPR;
tree base, off, t;
@ -152,7 +152,7 @@ compute_object_offset (tree expr, tree var)
If unknown, return unknown[object_size_type]. */
static unsigned HOST_WIDE_INT
addr_object_size (tree ptr, int object_size_type)
addr_object_size (const_tree ptr, int object_size_type)
{
tree pt_var;
@ -226,7 +226,7 @@ addr_object_size (tree ptr, int object_size_type)
unknown[object_size_type]. */
static unsigned HOST_WIDE_INT
alloc_object_size (tree call, int object_size_type)
alloc_object_size (const_tree call, int object_size_type)
{
tree callee, bytes = NULL_TREE;
tree alloc_size;
@ -287,7 +287,7 @@ alloc_object_size (tree call, int object_size_type)
Otherwise return NULL. */
static tree
pass_through_call (tree call)
pass_through_call (const_tree call)
{
tree callee = get_callee_fndecl (call);

View File

@ -38,14 +38,14 @@ along with GCC; see the file COPYING3. If not see
/* Local functions, macros and variables. */
static int op_prio (const_tree);
static const char *op_symbol (tree);
static const char *op_symbol (const_tree);
static void pretty_print_string (pretty_printer *, const char*);
static void print_call_name (pretty_printer *, tree);
static void print_call_name (pretty_printer *, const_tree);
static void newline_and_indent (pretty_printer *, int);
static void maybe_init_pretty_print (FILE *);
static void print_declaration (pretty_printer *, tree, int, int);
static void print_struct_decl (pretty_printer *, tree, int, int);
static void do_niy (pretty_printer *, tree);
static void print_struct_decl (pretty_printer *, const_tree, int, int);
static void do_niy (pretty_printer *, const_tree);
static void dump_vops (pretty_printer *, tree, int, int);
static void dump_generic_bb_buff (pretty_printer *, basic_block, int, int);
@ -65,7 +65,7 @@ static int initialized = 0;
/* Try to print something for an unknown tree code. */
static void
do_niy (pretty_printer *buffer, tree node)
do_niy (pretty_printer *buffer, const_tree node)
{
int i, len;
@ -2243,7 +2243,7 @@ print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
FIXME: Still incomplete. */
static void
print_struct_decl (pretty_printer *buffer, tree node, int spc, int flags)
print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
{
/* Print the name of the structure. */
if (TYPE_NAME (node))
@ -2627,7 +2627,7 @@ op_symbol_code (enum tree_code code)
/* Return the symbol associated with operator OP. */
static const char *
op_symbol (tree op)
op_symbol (const_tree op)
{
return op_symbol_code (TREE_CODE (op));
}
@ -2635,7 +2635,7 @@ op_symbol (tree op)
/* Prints the name of a CALL_EXPR. */
static void
print_call_name (pretty_printer *buffer, tree node)
print_call_name (pretty_printer *buffer, const_tree node)
{
tree op0;

View File

@ -4675,7 +4675,7 @@ extern tree fold_ignored_result (tree);
extern tree fold_abs_const (tree, tree);
extern tree fold_indirect_ref_1 (tree, tree);
extern void fold_defer_overflow_warnings (void);
extern void fold_undefer_overflow_warnings (bool, tree, int);
extern void fold_undefer_overflow_warnings (bool, const_tree, int);
extern void fold_undefer_and_ignore_overflow_warnings (void);
extern bool fold_deferring_overflow_warnings_p (void);
extern tree maybe_fold_offset_to_reference (tree, tree, tree);
@ -4725,7 +4725,7 @@ enum operand_equal_flag
};
extern int operand_equal_p (const_tree, const_tree, unsigned int);
extern int multiple_of_p (tree, tree, tree);
extern int multiple_of_p (tree, const_tree, const_tree);
extern tree omit_one_operand (tree, tree, tree);
extern tree omit_two_operands (tree, tree, tree, tree);
extern tree invert_truthvalue (tree);
@ -4752,7 +4752,6 @@ extern enum tree_code invert_tree_comparison (enum tree_code, bool);
extern bool tree_expr_nonzero_p (tree);
extern bool tree_expr_nonzero_warnv_p (tree, bool *);
extern int multiple_of_p (tree, tree, tree);
/* In builtins.c */
extern tree fold_call_expr (tree, bool);
@ -4770,7 +4769,7 @@ extern enum built_in_function builtin_mathfn_code (const_tree);
extern tree build_function_call_expr (tree, tree);
extern tree fold_build_call_expr (tree, tree, tree, tree);
extern tree fold_builtin_call_array (tree, tree, int, tree *);
extern void debug_fold_checksum (tree);
extern void debug_fold_checksum (const_tree);
extern tree build_call_expr (tree, int, ...);
extern tree mathfn_built_in (tree, enum built_in_function fn);
extern tree strip_float_extensions (tree);