This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: cleanup for conversion exprs code patterns (4/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 4

 Changelog:

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

	* trans.c (Attribute_to_gnu): Use TEST_CONVERT_NOPS_P.
	
	* utils2.c (build_binary_op): Likewise.


Index: gcc/ada/trans.c
===================================================================
--- gcc/ada/trans.c	(revision 132974)
+++ gcc/ada/trans.c	(working copy)
@@ -868,8 +868,7 @@ Attribute_to_gnu (Node_Id gnat_node, tre
       if (attribute == Attr_Code_Address)
 	{
 	  for (gnu_expr = gnu_result;
-	       TREE_CODE (gnu_expr) == NOP_EXPR
-	       || TREE_CODE (gnu_expr) == CONVERT_EXPR;
+	       TEST_CONVERT_NOPS_P (gnu_expr);
 	       gnu_expr = TREE_OPERAND (gnu_expr, 0))
 	    TREE_CONSTANT (gnu_expr) = 1;
 
@@ -883,8 +882,7 @@ Attribute_to_gnu (Node_Id gnat_node, tre
       else if (TREE_CODE (TREE_TYPE (gnu_prefix)) == FUNCTION_TYPE)
 	{
 	  for (gnu_expr = gnu_result;
-	       TREE_CODE (gnu_expr) == NOP_EXPR
-	       || TREE_CODE (gnu_expr) == CONVERT_EXPR;
+	       TEST_CONVERT_NOPS_P (gnu_expr);
 	       gnu_expr = TREE_OPERAND (gnu_expr, 0))
 	    ;
 
Index: gcc/ada/utils2.c
===================================================================
--- gcc/ada/utils2.c	(revision 132974)
+++ gcc/ada/utils2.c	(working copy)
@@ -643,8 +643,7 @@ build_binary_op (enum tree_code op_code,
 	 conversions between array and record types.  But don't do this if
 	 the right operand is not BLKmode (for packed arrays)
 	 unless we are not changing the mode.  */
-      while ((TREE_CODE (left_operand) == CONVERT_EXPR
-	      || TREE_CODE (left_operand) == NOP_EXPR
+      while ((TEST_CONVERT_NOPS_P (left_operand)
 	      || TREE_CODE (left_operand) == VIEW_CONVERT_EXPR)
 	     && (((INTEGRAL_TYPE_P (left_type)
 		   || POINTER_TYPE_P (left_type))
@@ -708,8 +707,7 @@ build_binary_op (enum tree_code op_code,
 	      result = TREE_OPERAND (result, 0);
 	  else if (TREE_CODE (result) == REALPART_EXPR
 		   || TREE_CODE (result) == IMAGPART_EXPR
-		   || ((TREE_CODE (result) == NOP_EXPR
-			|| TREE_CODE (result) == CONVERT_EXPR)
+		   || (TEST_CONVERT_NOPS_P (result)
 		       && (((TREE_CODE (restype)
 			     == TREE_CODE (TREE_TYPE
 					   (TREE_OPERAND (result, 0))))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]