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]

Re: define_constraints patch, re-revised


On 10/3/06, Zack Weinberg <zackw@panix.com> wrote:
        * genpreds.c (add_constraint): Do not remove anything from the
        expression here.
        (write_tm_constrs_h): Determine whether op will be unused, and
        tag it with ARG_UNUSED if so.
        (write_insn_const_int_ok_for_constraint): Avoid writing out
        the redundant (andimpossible to evaluate in this context) test
        for a CONST_INT that will be in the predicate expression.


With the patch this time.


zw
==================================================================
--- genpreds.c	(revision 117474)
+++ genpreds.c	(local)
@@ -891,10 +891,6 @@ add_constraint (const char *name, const 
 	  have_error = 1;
 	  return;
 	}
-
-      /* Remove the redundant (and (match_code "const_(int|double)")
-	 from the expression.  */
-      exp = XEXP (exp, 1);
     }
 
   
@@ -1078,10 +1074,13 @@ write_tm_constrs_h (void)
 	bool needs_rval = needs_variable (c->exp, "rval");
 	bool needs_mode = (needs_variable (c->exp, "mode")
 			   || needs_hval || needs_lval || needs_rval);
+	bool needs_op = (needs_variable (c->exp, "op")
+			 || needs_ival || needs_mode);
 
 	printf ("static inline bool\n"
-		"satisfies_constraint_%s (rtx op)\n"
-		"{\n", c->c_name);
+		"satisfies_constraint_%s (rtx %s)\n"
+		"{\n", c->c_name,
+		needs_op ? "op" : "ARG_UNUSED (op)");
 	if (needs_mode)
 	  puts ("enum machine_mode mode = GET_MODE (op);");
 	if (needs_ival)
@@ -1157,7 +1156,10 @@ write_insn_const_int_ok_for_constraint (
     if (c->is_const_int)
       {
 	printf ("    case CONSTRAINT_%s:\n      return ", c->c_name);
-	write_predicate_expr (c->exp);
+	/* c->exp is guaranteed to be (and (match_code "const_int") (...));
+	   we know at this point that we have a const_int, so we need not
+	   bother with that part of the test.  */
+	write_predicate_expr (XEXP (c->exp, 1));
 	fputs (";\n\n", stdout);
       }
 

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