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]

[ast-optimizer-branch] PATCH for more SIMPLE cleanup


More cleanup of our SIMPLE representation to match the spec; condexprs are
also binary_exprs, so there's no need for the additional rule.  I needed to
fix the binary_expr test, though.  The extra rule in compref seems
pointless.

Booted i686-pc-linux-gnu.

2002-06-08  Jason Merrill  <jason@redhat.com>

	* tree-simple.c (is_simple_rhs): Remove condexpr rule.
	(is_simple_compref_lhs): Remove &ID.idlist rule.
	(is_simple_relop): New fn.
	(is_simple_binary_expr, is_simple_condexpr): Use it.
	* tree-simple.h: Declare it.

*** tree-simple.c.~1~	Sat Jun  8 07:15:13 2002
--- tree-simple.c	Sat Jun  8 07:17:36 2002
*************** Boston, MA 02111-1307, USA.  */
*** 117,128 ****
        rhs
  	      : binary_expr
  	      | unary_expr
- 	      | condexpr		=> Original grammar does not allow
- 					   conditional expressions.
- 					   Allowing them here, leads to
- 					   less code being generated when
- 					   simplifying IF/WHILE/DO
- 					   conditionals.
  
        unary_expr
  	      : simp_expr
--- 117,122 ----
*************** Boston, MA 02111-1307, USA.  */
*** 156,172 ****
        unop
  	      : '+'
  	      | '-'
  
        binop
  	      : relop
  	      | '-'
  	      | '+'
! 	      ....
  
        relop
  	      : '<'
  	      | '<='
! 	      ...
  
        condexpr
  	      : val
--- 150,178 ----
        unop
  	      : '+'
  	      | '-'
+ 	      | '!'
+ 	      | '~'
  
        binop
  	      : relop
  	      | '-'
  	      | '+'
! 	      | '/'
! 	      | '*'
! 	      | '%'
! 	      | '&'
! 	      | '|'
! 	      | '<<'
! 	      | '>>'
! 	      | '^'
  
        relop
  	      : '<'
  	      | '<='
! 	      | '>'
! 	      | '>='
! 	      | '=='
! 	      | '!='
  
        condexpr
  	      : val
*************** Boston, MA 02111-1307, USA.  */
*** 200,207 ****
  
        compref
  	      : '(' '*' ID ')' '.' idlist
- 	      : '&' ID '.' idlist	=> Original grammar does not allow
- 					   this.
  	      | idlist
  
       ----------------------------------------------------------------------  */
--- 206,211 ----
*************** is_simple_expr (t)
*** 393,404 ****
  
        rhs
  	      : binary_expr
! 	      | unary_expr
! 	      | condexpr	=> Original grammar does not allow
! 				   conditional expressions on RHS.
! 				   However, allowing them lets us generate
! 				   fewer code when simplifying IF/WHILE/DO
! 				   structures.  */
  
  int
  is_simple_rhs (t)
--- 397,403 ----
  
        rhs
  	      : binary_expr
! 	      | unary_expr  */
  
  int
  is_simple_rhs (t)
*************** is_simple_rhs (t)
*** 408,415 ****
      return 1;
  
    return (is_simple_binary_expr (t)
!           || is_simple_unary_expr (t)
! 	  || is_simple_condexpr (t));
  }
  
  /* }}} */
--- 407,413 ----
      return 1;
  
    return (is_simple_binary_expr (t)
!           || is_simple_unary_expr (t));
  }
  
  /* }}} */
*************** is_simple_modify_expr_lhs (t)
*** 460,465 ****
--- 458,484 ----
  
  /* }}} */
  
+ /** {{{ is_simple_relop ()
+ 
+     Return true if CODE is designates a SIMPLE relop:
+ 
+       relop
+ 	      : '<'
+ 	      | '<='
+ 	      ...  */
+     
+ bool
+ is_simple_relop (code)
+      enum tree_code code;
+ {
+   return (TREE_CODE_CLASS (code) == '<'
+ 	  || code == TRUTH_AND_EXPR
+ 	  || code == TRUTH_OR_EXPR
+ 	  || code == TRUTH_XOR_EXPR);
+ }
+ 
+ /* }}} */
+ 
  /** {{{ is_simple_binary_expr ()
  
      Return nonzero if T is a SIMPLE binary expression:
*************** is_simple_binary_expr (t)
*** 480,486 ****
        || TREE_CODE (t) == NON_LVALUE_EXPR)
      return is_simple_binary_expr (TREE_OPERAND (t, 0));
  
!   return (TREE_CODE_CLASS (TREE_CODE (t)) == '2'
  	  && is_simple_val (TREE_OPERAND (t, 0))
  	  && is_simple_val (TREE_OPERAND (t, 1)));
  }
--- 499,506 ----
        || TREE_CODE (t) == NON_LVALUE_EXPR)
      return is_simple_binary_expr (TREE_OPERAND (t, 0));
  
!   return ((TREE_CODE_CLASS (TREE_CODE (t)) == '2'
! 	   || is_simple_relop (TREE_CODE (t)))
  	  && is_simple_val (TREE_OPERAND (t, 0))
  	  && is_simple_val (TREE_OPERAND (t, 1)));
  }
*************** is_simple_condexpr (t)
*** 509,518 ****
      return is_simple_condexpr (TREE_OPERAND (t, 0));
  
    return (is_simple_val (t)
! 	  || ((TREE_CODE_CLASS (TREE_CODE (t)) == '<'
! 	       || TREE_CODE (t) == TRUTH_AND_EXPR
! 	       || TREE_CODE (t) == TRUTH_OR_EXPR
! 	       || TREE_CODE (t) == TRUTH_XOR_EXPR)
  	      && is_simple_val (TREE_OPERAND (t, 0))
  	      && is_simple_val (TREE_OPERAND (t, 1))));
  }
--- 529,535 ----
      return is_simple_condexpr (TREE_OPERAND (t, 0));
  
    return (is_simple_val (t)
! 	  || (is_simple_relop (TREE_CODE (t))
  	      && is_simple_val (TREE_OPERAND (t, 0))
  	      && is_simple_val (TREE_OPERAND (t, 1))));
  }
*************** is_simple_arrayref (t)
*** 828,834 ****
  
        compref
  	      : '(' '*' ID ')' '.' idlist
- 	      : '&' ID '.' idlist
  	      | idlist
  
        idlist
--- 845,850 ----
*************** is_simple_compref_lhs (t)
*** 865,872 ****
    return (is_simple_id (t)
  	  || (TREE_CODE (t) == INDIRECT_REF
  	      && is_simple_id (TREE_OPERAND (t, 0)))
- 	  || (TREE_CODE (t) == ADDR_EXPR
- 	      && is_simple_id (TREE_OPERAND (t, 0)))
  	  || is_simple_compref (t));
  }
  
--- 881,886 ----
*** tree-simple.h.~1~	Sat Jun  8 07:15:13 2002
--- tree-simple.h	Sat Jun  8 07:18:26 2002
*************** int is_simple_expr                     P
*** 40,45 ****
--- 41,47 ----
  int is_simple_rhs                      PARAMS ((tree));
  int is_simple_modify_expr              PARAMS ((tree));
  int is_simple_modify_expr_lhs          PARAMS ((tree));
+ bool is_simple_relop		       PARAMS ((enum tree_code));
  int is_simple_binary_expr              PARAMS ((tree));
  int is_simple_condexpr                 PARAMS ((tree));
  int is_simple_unary_expr               PARAMS ((tree));

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