[PATCH 2/3] reload,recog: New `enabled' insn attribute

Andreas Krebbel andreas@de.ibm.com
Tue Aug 28 07:34:00 GMT 2007


Hello,

the second patch makes recog and reload aware of the new insn
attribute.

The values of the attribute for the insn alternatives are cached
inside the recog_data data structure by extract_insn.  These values
are then used in reload and recog to simply skip the alternatives
which aren't enabled.

Bootstrapped on s390, s390x and i686.
No testsuite regressions.

OK for mainline?

Bye,

-Andreas-

2007-08-28  Andreas Krebbel  <krebbel1@de.ibm.com>

	* reload.c: Include insn-attr.h.
	(find_reloads): Respect the enabled attribute.
	* recog.c (extract_insn): Set the alternative_enabled_p array
	in the recog_data struct.
	(preprocess_constraints, constrain_operands): Respect the
	enabled attribute.
	* recog.h (struct recog_data): New field alternative_enabled_p.

Index: gcc/reload.c
===================================================================
*** gcc/reload.c.orig	2007-08-27 16:06:24.000000000 +0200
--- gcc/reload.c	2007-08-27 16:07:02.000000000 +0200
*************** a register with any other reload.  */
*** 112,117 ****
--- 112,118 ----
  #include "params.h"
  #include "target.h"
  #include "df.h"
+ #include "insn-attr.h"
  
  /* True if X is a constant that can be forced into the constant pool.  */
  #define CONST_POOL_OK_P(X)			\
*************** find_reloads (rtx insn, int replace, int
*** 2900,2905 ****
--- 2901,2924 ----
  	 a bad register class to only count 1/3 as much.  */
        int reject = 0;
  
+ #ifdef HAVE_ATTR_enabled
+       {
+ 	if (!recog_data.alternative_enabled_p[this_alternative_number])
+ 	  {
+ 	    int i;
+ 
+ 	    for (i = 0; i < recog_data.n_operands; i++)
+ 	      {
+ 		while (*constraints[i] != '\0' && *constraints[i] != ',')
+ 		  constraints[i]++;
+ 		if (*constraints[i] == ',')
+ 		  constraints[i]++;
+ 	      }
+ 	    continue;
+ 	  }
+       }
+ #endif
+ 
        this_earlyclobber = 0;
  
        for (i = 0; i < noperands; i++)
Index: gcc/recog.c
===================================================================
*** gcc/recog.c.orig	2007-08-27 16:06:24.000000000 +0200
--- gcc/recog.c	2007-08-27 16:46:03.000000000 +0200
*************** extract_insn (rtx insn)
*** 1975,1980 ****
--- 1975,1984 ----
  	      recog_data.n_alternatives = 1;
  	      while (*p)
  		recog_data.n_alternatives += (*p++ == ',');
+ #ifdef HAVE_ATTR_enabled
+ 	      for (i = 0; i < recog_data.n_alternatives; i++)
+ 		recog_data.alternative_enabled_p[i] = 1;
+ #endif
  	    }
  	  break;
  	}
*************** extract_insn (rtx insn)
*** 1993,1998 ****
--- 1997,2008 ----
        recog_data.n_alternatives = insn_data[icode].n_alternatives;
        recog_data.n_dups = insn_data[icode].n_dups;
  
+ #ifdef HAVE_ATTR_enabled
+       for (i = 0; i < recog_data.n_alternatives; i++)
+ 	recog_data.alternative_enabled_p[i] =
+ 	  alternative_enabled_p_alt (insn, i);
+ #endif
+ 
        insn_extract (insn);
  
        for (i = 0; i < noperands; i++)
*************** preprocess_constraints (void)
*** 2040,2045 ****
--- 2050,2068 ----
  	  op_alt[j].matches = -1;
  	  op_alt[j].matched = -1;
  
+ #ifdef HAVE_ATTR_enabled
+ 	  {
+ 	    if (!recog_data.alternative_enabled_p[j])
+ 	      {
+ 		while (*p != '\0' && *p != ',')
+ 		  p++;
+ 		if (*p == ',')
+ 		  p++;
+ 		continue;
+ 	      }
+ 	  }
+ #endif
+ 
  	  if (*p == '\0' || *p == ',')
  	    {
  	      op_alt[j].anything_ok = 1;
*************** constrain_operands (int strict)
*** 2209,2214 ****
--- 2232,2256 ----
        int lose = 0;
        funny_match_index = 0;
  
+ #ifdef HAVE_ATTR_enabled
+       {
+ 	if (!recog_data.alternative_enabled_p[which_alternative])
+ 	  {
+ 	    int i;
+ 
+ 	    for (i = 0; i < recog_data.n_operands; i++)
+ 	      {
+ 		while (*constraints[i] != '\0' && *constraints[i] != ',')
+ 		  constraints[i]++;
+ 		if (*constraints[i] == ',')
+ 		  constraints[i]++;
+ 	      }
+ 	    which_alternative++;
+ 	    continue;
+ 	  }
+ 	}
+ #endif
+ 
        for (opno = 0; opno < recog_data.n_operands; opno++)
  	{
  	  rtx op = recog_data.operand[opno];
Index: gcc/recog.h
===================================================================
*** gcc/recog.h.orig	2007-08-27 16:06:24.000000000 +0200
--- gcc/recog.h	2007-08-27 16:07:02.000000000 +0200
*************** struct recog_data
*** 201,206 ****
--- 201,212 ----
    /* The number of alternatives in the constraints for the insn.  */
    char n_alternatives;
  
+   /* Specifies whether an insn alternative is enabled using the
+      `enabled' attribute in the insn pattern definition.  For back
+      ends not using the `enabled' attribute the content of this array
+      is undefined.  */
+   bool alternative_enabled_p [MAX_RECOG_ALTERNATIVES];
+ 
    /* In case we are caching, hold insn data was generated for.  */
    rtx insn;
  };



More information about the Gcc-patches mailing list