[PATCH]: cleanup for conversion exprs code patterns (16/16)

Tomas Bily tomby@atrey.karlin.mff.cuni.cz
Mon Mar 31 17:01:00 GMT 2008


 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 16

 Changelog:

2008-03-13  Tomas Bily  <tbily@suse.cz>

	* utils.c (rest_of_record_type_compilation): Use STRIP_NOPS_UNSAFE.



Index: gcc/ada/utils.c
===================================================================
--- gcc/ada/utils.c	(revision 132974)
+++ gcc/ada/utils.c	(working copy)
@@ -1021,10 +1021,7 @@ rest_of_record_type_compilation (tree re
 	      align = tree_low_cst (TREE_OPERAND (curpos, 1), 1);
 
 	      /* Strip off any conversions.  */
-	      while (TREE_CODE (offset) == NON_LVALUE_EXPR
-		     || TREE_CODE (offset) == NOP_EXPR
-		     || TREE_CODE (offset) == CONVERT_EXPR)
-		offset = TREE_OPERAND (offset, 0);
+	      STRIP_NOPS_UNSAFE (offset);
 
 	      /* An offset which is a bitwise AND with a negative power of 2
 		 means an alignment corresponding to this power of 2.  */



More information about the Gcc-patches mailing list