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 (13/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:13 +0200 (CEST)
- Subject: [PATCH]: cleanup for conversion exprs code patterns (13/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 13
Changelog:
2008-03-13 Tomas Bily <tbily@suse.cz>
* utils2.c (known_alignment, gnat_mark_addressable): Use CASE_NOPS.
* decl.c (annotate_value): Likewise.
* utils.c (remove_conversions): Likewise.
Index: gcc/ada/utils.c
===================================================================
--- gcc/ada/utils.c (revision 132974)
+++ gcc/ada/utils.c (working copy)
@@ -3733,8 +3730,8 @@ remove_conversions (tree exp, bool true_
return remove_conversions (TREE_OPERAND (exp, 0), true_address);
break;
- case VIEW_CONVERT_EXPR: case NON_LVALUE_EXPR:
- case NOP_EXPR: case CONVERT_EXPR:
+ case VIEW_CONVERT_EXPR:
+ CASE_NOPS:
return remove_conversions (TREE_OPERAND (exp, 0), true_address);
default:
Index: gcc/ada/decl.c
===================================================================
--- gcc/ada/decl.c (revision 132974)
+++ gcc/ada/decl.c (working copy)
@@ -6324,7 +6324,7 @@ annotate_value (tree gnu_size)
else
return No_Uint;
- case NOP_EXPR: case CONVERT_EXPR: case NON_LVALUE_EXPR:
+ CASE_NOPS:
return annotate_value (TREE_OPERAND (gnu_size, 0));
/* Now just list the operations we handle. */
Index: gcc/ada/utils2.c
===================================================================
--- gcc/ada/utils2.c (revision 132974)
+++ gcc/ada/utils2.c (working copy)
@@ -156,10 +156,8 @@ known_alignment (tree exp)
switch (TREE_CODE (exp))
{
- case CONVERT_EXPR:
case VIEW_CONVERT_EXPR:
- case NOP_EXPR:
- case NON_LVALUE_EXPR:
+ CASE_NOPS:
/* Conversions between pointers and integers don't change the alignment
of the underlying object. */
this_alignment = known_alignment (TREE_OPERAND (exp, 0));
@@ -2150,9 +2147,7 @@ gnat_mark_addressable (tree expr_node)
case REALPART_EXPR:
case IMAGPART_EXPR:
case VIEW_CONVERT_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
- case NOP_EXPR:
+ CASE_NOPS:
expr_node = TREE_OPERAND (expr_node, 0);
break;