This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: cleanup for conversion exprs code patterns (12/16)
- From: tomby at atrey dot karlin dot mff dot cuni dot cz (Tomas Bily)
- To: gcc-patches at gcc dot gnu dot org
- Cc: tomby at ucw dot cz,tbily at suse dot cz
- Date: Mon, 31 Mar 2008 16:50:08 +0200 (CEST)
- Subject: [PATCH]: cleanup for conversion exprs code patterns (12/16)
Hi,
this series of patches is doing small cleanup in using conversion
expressions code patterns. There is a lot of duplicate code patterns
for conversion expressions (CONVERT_EXPR, NOP_EXPR, NON_LVALUE_EXPR)
that can be substituted by macro. Patterns are:
(TREE_CODE (EXP) == NOP_EXPR || TREE_CODE (EXP) == CONVERT_EXPR)
-> TEST_CONVERT_NOPS_P(EXP)
(TREE_CODE (EXP) == NOP_EXPR || TREE_CODE (EXP) == CONVERT_EXPR
|| TREE_CODE (EXP) == NON_LVALUE_EXPR)
-> TEST_NOPS_P(EXP)
case NOP_EXPR: case CONVERT_EXPR
-> CASE_CONVERT_NOPS
case NOP_EXPR: case CONVERT_EXPR: case NON_LVALUE_EXPR
-> CASE_NOPS
while (TREE_CODE (EXP) == NOP_EXPR
|| TREE_CODE (EXP) == CONVERT_EXPR
|| TREE_CODE (EXP) == NON_LVALUE_EXPR)
(EXP) = TREE_OPERAND (EXP, 0)
-> STRIP_NOPS_UNSAFE(EXP)
-> means replaced by
Patch 1: Add new macros (TEST_CONVERT_NOPS_P(EXP), TEST_NOPS_P(EXP),
CASE_CONVERT_NOPS, CASE_NOPS, STRIP_NOPS_UNSAFE(EXP)).
Patch 2-4: Add support of TEST_CONVERT_NOPS_P.
Patch 5-8: Add support of TEST_NOPS_P.
Patch 9-11: Add support of CASE_CONVERT_NOPS.
Patch 12-13: Add support of CASE_NOPS.
Patch 14-16: Add support of STRIP_NOPS_UNSAFE.
Bootstraped and tested on x86_64 x86_64 GNU/Linux.
Ok?
Greetings
Tomas
Patch 12
Changelog:
2008-03-13 Tomas Bily <tbily@suse.cz>
* config/pa/pa.c (reloc_needed): Use CASE_NOPS.
* tree-cfg.c (verify_expr): Likewise.
* tree-ssa-structalias.c (get_constraint_for): Likewise.
* tree-object-size.c (compute_object_offset): Likewise.
* tree-inline.c (estimate_num_insns_1): Likewise.
* varasm.c (const_hash_1, compare_constant, copy_constant)
(compute_reloc_for_constant, output_addressed_constants): Likewise.
* c-typeck.c (c_finish_return): Likewise.
* expr.c (highest_pow2_factor, expand_expr_real_1): Likewise.
* dwarf2out.c (loc_descriptor_from_tree_1, add_bound_info): Likewise.
* tree-ssa-loop-ivopts.c (may_be_nonaddressable_p): Likewise.
* fold-const.c (make_range, extract_muldiv_1): Likewise.
* builtins.c (get_pointer_alignment): Likewise.
* tree-scalar-evolution.c (instantiate_parameters_1): Likewise.
* tree.c (expr_align): Likewise.
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 132974)
+++ gcc/tree.c (working copy)
@@ -1925,7 +1922,7 @@ expr_align (const_tree t)
switch (TREE_CODE (t))
{
- case NOP_EXPR: case CONVERT_EXPR: case NON_LVALUE_EXPR:
+ CASE_NOPS:
/* If we have conversions, we know that the alignment of the
object must meet each of the alignments of the types. */
align0 = expr_align (TREE_OPERAND (t, 0));
Index: gcc/tree-scalar-evolution.c
===================================================================
--- gcc/tree-scalar-evolution.c (revision 132974)
+++ gcc/tree-scalar-evolution.c (working copy)
@@ -2115,9 +2114,7 @@ instantiate_parameters_1 (struct loop *l
}
return chrec;
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
flags, cache, size_expr);
if (op0 == chrec_dont_know)
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 132974)
+++ gcc/builtins.c (working copy)
@@ -279,9 +279,7 @@ get_pointer_alignment (tree exp, unsigne
{
switch (TREE_CODE (exp))
{
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
exp = TREE_OPERAND (exp, 0);
if (! POINTER_TYPE_P (TREE_TYPE (exp)))
return align;
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c (revision 132974)
+++ gcc/fold-const.c (working copy)
@@ -4308,7 +4305,7 @@ make_range (tree exp, int *pin_p, tree *
exp = arg0;
continue;
- case NOP_EXPR: case NON_LVALUE_EXPR: case CONVERT_EXPR:
+ CASE_NOPS:
if (TYPE_PRECISION (arg0_type) > TYPE_PRECISION (exp_type))
break;
@@ -5717,7 +5714,7 @@ extract_muldiv_1 (tree t, tree c, enum t
fold_convert (ctype, c), 0);
break;
- case CONVERT_EXPR: case NON_LVALUE_EXPR: case NOP_EXPR:
+ CASE_NOPS:
/* If op0 is an expression ... */
if ((COMPARISON_CLASS_P (op0)
|| UNARY_CLASS_P (op0)
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c (revision 132974)
+++ gcc/tree-ssa-loop-ivopts.c (working copy)
@@ -1535,9 +1534,7 @@ may_be_nonaddressable_p (tree expr)
case ARRAY_RANGE_REF:
return may_be_nonaddressable_p (TREE_OPERAND (expr, 0));
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
- case NOP_EXPR:
+ CASE_NOPS:
return true;
default:
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 132974)
+++ gcc/dwarf2out.c (working copy)
@@ -9549,9 +9549,7 @@ loc_descriptor_from_tree_1 (tree loc, in
case COMPOUND_EXPR:
return loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 1), want_address);
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
case VIEW_CONVERT_EXPR:
case SAVE_EXPR:
case GIMPLE_MODIFY_STMT:
@@ -11034,9 +11032,7 @@ add_bound_info (dw_die_ref subrange_die,
add_AT_unsigned (subrange_die, bound_attr, tree_low_cst (bound, 0));
break;
- case CONVERT_EXPR:
- case NOP_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
case VIEW_CONVERT_EXPR:
add_bound_info (subrange_die, bound_attr, TREE_OPERAND (bound, 0));
break;
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 132974)
+++ gcc/expr.c (working copy)
@@ -6599,7 +6599,7 @@ highest_pow2_factor (const_tree exp)
}
break;
- case NON_LVALUE_EXPR: case NOP_EXPR: case CONVERT_EXPR:
+ CASE_NOPS:
case SAVE_EXPR:
return highest_pow2_factor (TREE_OPERAND (exp, 0));
@@ -8051,9 +8051,7 @@ expand_expr_real_1 (tree exp, rtx target
return expand_call (exp, target, ignore);
case PAREN_EXPR:
- case NON_LVALUE_EXPR:
- case NOP_EXPR:
- case CONVERT_EXPR:
+ CASE_NOPS:
if (TREE_OPERAND (exp, 0) == error_mark_node)
return const0_rtx;
Index: gcc/c-typeck.c
===================================================================
--- gcc/c-typeck.c (revision 132974)
+++ gcc/c-typeck.c (working copy)
@@ -7120,7 +7114,7 @@ c_finish_return (tree retval)
{
switch (TREE_CODE (inner))
{
- case NOP_EXPR: case NON_LVALUE_EXPR: case CONVERT_EXPR:
+ CASE_NOPS:
case PLUS_EXPR:
inner = TREE_OPERAND (inner, 0);
continue;
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 132974)
+++ gcc/varasm.c (working copy)
@@ -2823,9 +2823,7 @@ const_hash_1 (const tree exp)
return (const_hash_1 (TREE_OPERAND (exp, 0)) * 9
+ const_hash_1 (TREE_OPERAND (exp, 1)));
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
return const_hash_1 (TREE_OPERAND (exp, 0)) * 7 + 2;
default:
@@ -2978,9 +2976,7 @@ compare_constant (const tree t1, const t
return (compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0))
&& compare_constant(TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)));
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
case VIEW_CONVERT_EXPR:
return compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
@@ -3026,9 +3022,7 @@ copy_constant (tree exp)
copy_constant (TREE_OPERAND (exp, 0)),
copy_constant (TREE_OPERAND (exp, 1)));
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
case VIEW_CONVERT_EXPR:
return build1 (TREE_CODE (exp), TREE_TYPE (exp),
copy_constant (TREE_OPERAND (exp, 0)));
@@ -3930,9 +3924,7 @@ compute_reloc_for_constant (tree exp)
reloc |= reloc2;
break;
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
case VIEW_CONVERT_EXPR:
reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
break;
@@ -3986,9 +3978,7 @@ output_addressed_constants (tree exp)
output_addressed_constants (TREE_OPERAND (exp, 1));
/* Fall through. */
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
case VIEW_CONVERT_EXPR:
output_addressed_constants (TREE_OPERAND (exp, 0));
break;
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c (revision 132974)
+++ gcc/tree-inline.c (working copy)
@@ -2222,8 +2222,7 @@ estimate_num_insns_1 (tree *tp, int *wal
case BIND_EXPR:
case WITH_CLEANUP_EXPR:
case PAREN_EXPR:
- case NOP_EXPR:
- case CONVERT_EXPR:
+ CASE_NOPS:
case VIEW_CONVERT_EXPR:
case SAVE_EXPR:
case ADDR_EXPR:
@@ -2235,7 +2234,6 @@ estimate_num_insns_1 (tree *tp, int *wal
case EH_FILTER_EXPR:
case STATEMENT_LIST:
case ERROR_MARK:
- case NON_LVALUE_EXPR:
case FDESC_EXPR:
case VA_ARG_EXPR:
case TRY_CATCH_EXPR:
Index: gcc/tree-object-size.c
===================================================================
--- gcc/tree-object-size.c (revision 132974)
+++ gcc/tree-object-size.c (working copy)
@@ -110,10 +110,8 @@ compute_object_offset (const_tree expr,
break;
case REALPART_EXPR:
- case NOP_EXPR:
- case CONVERT_EXPR:
+ CASE_NOPS:
case VIEW_CONVERT_EXPR:
- case NON_LVALUE_EXPR:
return compute_object_offset (TREE_OPERAND (expr, 0), var);
case IMAGPART_EXPR:
Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c (revision 132974)
+++ gcc/tree-ssa-structalias.c (working copy)
@@ -2911,9 +2911,7 @@ get_constraint_for (tree t, VEC (ce_s, h
{
switch (TREE_CODE (t))
{
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
{
tree op = TREE_OPERAND (t, 0);
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 132974)
+++ gcc/tree-cfg.c (working copy)
@@ -3233,14 +3233,12 @@ verify_expr (tree *tp, int *walk_subtree
}
break;
- case NOP_EXPR:
- case CONVERT_EXPR:
+ CASE_NOPS:
case FIX_TRUNC_EXPR:
case FLOAT_EXPR:
case NEGATE_EXPR:
case ABS_EXPR:
case BIT_NOT_EXPR:
- case NON_LVALUE_EXPR:
case TRUTH_NOT_EXPR:
CHECK_OP (0, "invalid operand to unary operator");
break;
Index: gcc/config/pa/pa.c
===================================================================
--- gcc/config/pa/pa.c (revision 132974)
+++ gcc/config/pa/pa.c (working copy)
@@ -2103,9 +2103,7 @@ reloc_needed (tree exp)
reloc |= reloc_needed (TREE_OPERAND (exp, 1));
break;
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
reloc = reloc_needed (TREE_OPERAND (exp, 0));
break;