public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 2/3] reload,recog: New `enabled' insn attribute - refreshed
@ 2008-04-15 13:59 Andreas Krebbel
  2008-04-25 13:43 ` Andreas Krebbel
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Krebbel @ 2008-04-15 13:59 UTC (permalink / raw)
  To: gcc-patches

Hello,

the last version of this patch lacked the modifications to regclass.c.
This is necessary to draw the attribute into account when calculating
the operand costs for different register classes.

Bootstrapped and regression tested on x86_64, s390 and s390x.

Ok for mainline?

Bye,

-Andreas-


2008-04-15  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.
	* regclass.c: Include insn-attr.h.
	(record_operand_costs): Care about the 'enabled' attribute.
	(record_reg_classes): Skip alternative according to the
	'enabled' attribute.


Index: gcc/reload.c
===================================================================
*** gcc/reload.c.orig	2008-04-14 09:58:14.000000000 +0200
--- gcc/reload.c	2008-04-14 09:58:44.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)			\
*************** push_secondary_reload (int in_p, rtx x, 
*** 440,445 ****
--- 441,448 ----
  	&& MERGABLE_RELOADS (secondary_type, rld[s_reload].when_needed,
  			     opnum, rld[s_reload].opnum))
        {
+ 
+ 	fprintf (stderr, "MERGE SECONDARY RELOAD\n");
  	if (in_p)
  	  rld[s_reload].inmode = mode;
  	if (! in_p)
*************** find_reloads (rtx insn, int replace, int
*** 2914,2919 ****
--- 2917,2940 ----
  	 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	2008-04-14 09:58:14.000000000 +0200
--- gcc/recog.c	2008-04-14 09:58:44.000000000 +0200
*************** extract_insn (rtx insn)
*** 1968,1973 ****
--- 1968,1977 ----
  	      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)
*** 1986,1991 ****
--- 1990,2001 ----
        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)
*** 2033,2038 ****
--- 2043,2061 ----
  	  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)
*** 2202,2207 ****
--- 2225,2249 ----
        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	2008-04-14 09:58:14.000000000 +0200
--- gcc/recog.h	2008-04-14 09:58:44.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;
  };
Index: gcc/regclass.c
===================================================================
*** gcc/regclass.c.orig	2008-04-14 09:58:14.000000000 +0200
--- gcc/regclass.c	2008-04-14 09:58:44.000000000 +0200
*************** along with GCC; see the file COPYING3.  
*** 49,54 ****
--- 49,55 ----
  #include "target.h"
  #include "tree-pass.h"
  #include "df.h"
+ #include "insn-attr.h"
  
  /* Maximum register number used in this function, plus one.  */
  
*************** record_operand_costs (rtx insn, struct c
*** 1145,1152 ****
  			     0, MEM, SCRATCH, frequency * 2);
        else if (constraints[i][0] == 'p'
  	       || EXTRA_ADDRESS_CONSTRAINT (constraints[i][0], constraints[i]))
! 	record_address_regs (VOIDmode, recog_data.operand[i], 0, ADDRESS,
! 			     SCRATCH, frequency * 2);
      }
  
    /* Check for commutative in a separate loop so everything will
--- 1146,1156 ----
  			     0, MEM, SCRATCH, frequency * 2);
        else if (constraints[i][0] == 'p'
  	       || EXTRA_ADDRESS_CONSTRAINT (constraints[i][0], constraints[i]))
! #ifdef HAVE_ATTR_enabled
! 	if (recog_data.alternative_enabled_p[0])
! #endif
! 	  record_address_regs (VOIDmode, recog_data.operand[i], 0, ADDRESS,
! 			       SCRATCH, frequency * 2);
      }
  
    /* Check for commutative in a separate loop so everything will
*************** record_reg_classes (int n_alts, int n_op
*** 1932,1937 ****
--- 1936,1946 ----
        if (alt_fail)
  	continue;
  
+ #ifdef HAVE_ATTR_enabled
+       if (!recog_data.alternative_enabled_p[alt])
+ 	continue;
+ #endif
+ 
        /* Finally, update the costs with the information we've calculated
  	 about this alternative.  */
  

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/3] reload,recog: New `enabled' insn attribute - refreshed
  2008-04-15 13:59 [PATCH 2/3] reload,recog: New `enabled' insn attribute - refreshed Andreas Krebbel
@ 2008-04-25 13:43 ` Andreas Krebbel
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Krebbel @ 2008-04-25 13:43 UTC (permalink / raw)
  To: gcc-patches

> *** 440,445 ****
> --- 441,448 ----
>   	&& MERGABLE_RELOADS (secondary_type, rld[s_reload].when_needed,
>   			     opnum, rld[s_reload].opnum))
>         {
> + 
> + 	fprintf (stderr, "MERGE SECONDARY RELOAD\n");
>   	if (in_p)
>   	  rld[s_reload].inmode = mode;
>   	if (! in_p)

I'll of course remove that debug printf.

Bye,

-Andreas-

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-25 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-15 13:59 [PATCH 2/3] reload,recog: New `enabled' insn attribute - refreshed Andreas Krebbel
2008-04-25 13:43 ` Andreas Krebbel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).