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 3/3] genattr: New `enabled' insn attribute


Hello,

unfortunately we currently don't provide attribute accessor functions
returning a value for a certain alternative.

This patch extends the genattrtab tool to provide alternate accessor
functions which as an additional parameter take the number of the
alternative wherefor the value should be returned.  Each of the
alternate accessor functions gets _alt added to its function name.

The new `enabled' insn attribute is introduced as special attribute
whose value can be obtained using the alternative_enabled_p and
alternative_enabled_p_alt functions.

Bootstrapped together with the other patches on s390, s390x and i686.
No testsuite regressions.

OK for mainline?

Bye,

-Andreas-


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

	* genattrtab.c (struct attr_desc): New field alt_accessor;
	(enabled_str, alternative_str, which_alternative_str): New variables.
	(make_internal_attr, make_enabled_attr): Parameter added.
	(get_alternative_str): New function.
	(expand_delays, make_length_attrs, make_automaton_attrs):
	Invoke make_internal_attr with new parameter.
	(gen_attr): Sanity check for enabled attribute added.
	(write_test_expr): Pointer to the current attribute added as
	parameter.
	(write_attr_get, write_attr_set, write_attr_case,
	write_attr_value, find_attr): Deal with the alt_accessor flag.
	(main): Invoke make_enabled_attr and set the alt_accessor flag
	when emmitting the get_attr functions.
	
	* genattr.c (gen_attr): Emit prototypes for alternate accessor
	functions.


Index: gcc/genattrtab.c
===================================================================
*** gcc/genattrtab.c.orig	2007-08-27 16:06:24.000000000 +0200
--- gcc/genattrtab.c	2007-08-27 16:07:02.000000000 +0200
*************** struct attr_desc
*** 176,181 ****
--- 176,183 ----
    unsigned is_numeric	: 1;	/* Values of this attribute are numeric.  */
    unsigned is_const	: 1;	/* Attribute value constant for each run.  */
    unsigned is_special	: 1;	/* Don't call `write_attr_set'.  */
+   unsigned alt_accessor : 1;    /* Emit an alternate accessor function
+ 				   for this attribute.  */
  };
  
  /* Structure for each DEFINE_DELAY.  */
*************** static rtx true_rtx, false_rtx;
*** 235,244 ****
--- 237,250 ----
  
  static const char *alternative_name;
  static const char *length_str;
+ static const char *enabled_str;
  static const char *delay_type_str;
  static const char *delay_1_0_str;
  static const char *num_delay_slots_str;
  
+ static const char alternative_str[] = "alternative";
+ static const char which_alternative_str[] = "which_alternative";
+ 
  /* Simplify an expression.  Only call the routine if there is something to
     simplify.  */
  #define SIMPLIFY_TEST_EXP(EXP,INSN_CODE,INSN_INDEX)	\
*************** static char *next_comma_elt	   (const ch
*** 258,264 ****
  static rtx insert_right_side	   (enum rtx_code, rtx, rtx, int, int);
  static rtx copy_boolean		   (rtx);
  static int compares_alternatives_p (rtx);
! static void make_internal_attr     (const char *, rtx, int);
  static void insert_insn_ent        (struct attr_value *, struct insn_ent *);
  static void walk_attr_value	   (rtx);
  static int max_attr_value	   (rtx, int*);
--- 264,270 ----
  static rtx insert_right_side	   (enum rtx_code, rtx, rtx, int, int);
  static rtx copy_boolean		   (rtx);
  static int compares_alternatives_p (rtx);
! static void make_internal_attr     (const char *, rtx, int, int);
  static void insert_insn_ent        (struct attr_value *, struct insn_ent *);
  static void walk_attr_value	   (rtx);
  static int max_attr_value	   (rtx, int*);
*************** attr_hash_add_rtx (int hashcode, rtx rtl
*** 333,338 ****
--- 339,355 ----
    attr_hash_table[hashcode % RTL_HASH_SIZE] = h;
  }
  
+ /* Return the name of the variable where the number of the alternative
+    can be found for ATTR.  */
+ 
+ static const char *
+ get_alternative_str (struct attr_desc* attr)
+ {
+   if (attr->alt_accessor)
+     return alternative_str;
+   return which_alternative_str;
+ }
+ 
  /* Add an entry to the hash table for STRING with hash code HASHCODE.  */
  
  static void
*************** expand_delays (void)
*** 1344,1350 ****
  	= make_numeric_value (XVECLEN (delay->def, 1) / 3);
      }
  
!   make_internal_attr (num_delay_slots_str, condexp, ATTR_NONE);
  
    /* If more than one delay type, do the same for computing the delay type.  */
    if (num_delays > 1)
--- 1361,1367 ----
  	= make_numeric_value (XVECLEN (delay->def, 1) / 3);
      }
  
!   make_internal_attr (num_delay_slots_str, condexp, ATTR_NONE, 0);
  
    /* If more than one delay type, do the same for computing the delay type.  */
    if (num_delays > 1)
*************** expand_delays (void)
*** 1359,1365 ****
  	  XVECEXP (condexp, 0, i + 1) = make_numeric_value (delay->num);
  	}
  
!       make_internal_attr (delay_type_str, condexp, ATTR_SPECIAL);
      }
  
    /* For each delay possibility and delay slot, compute an eligibility
--- 1376,1382 ----
  	  XVECEXP (condexp, 0, i + 1) = make_numeric_value (delay->num);
  	}
  
!       make_internal_attr (delay_type_str, condexp, ATTR_SPECIAL, 0);
      }
  
    /* For each delay possibility and delay slot, compute an eligibility
*************** expand_delays (void)
*** 1377,1383 ****
  
  	  p = attr_printf (sizeof "*delay__" + MAX_DIGITS * 2,
  			   "*delay_%d_%d", delay->num, i / 3);
! 	  make_internal_attr (p, newexp, ATTR_SPECIAL);
  
  	  if (have_annul_true)
  	    {
--- 1394,1400 ----
  
  	  p = attr_printf (sizeof "*delay__" + MAX_DIGITS * 2,
  			   "*delay_%d_%d", delay->num, i / 3);
! 	  make_internal_attr (p, newexp, ATTR_SPECIAL, 0);
  
  	  if (have_annul_true)
  	    {
*************** expand_delays (void)
*** 1388,1394 ****
  				 make_numeric_value (0));
  	      p = attr_printf (sizeof "*annul_true__" + MAX_DIGITS * 2,
  			       "*annul_true_%d_%d", delay->num, i / 3);
! 	      make_internal_attr (p, newexp, ATTR_SPECIAL);
  	    }
  
  	  if (have_annul_false)
--- 1405,1411 ----
  				 make_numeric_value (0));
  	      p = attr_printf (sizeof "*annul_true__" + MAX_DIGITS * 2,
  			       "*annul_true_%d_%d", delay->num, i / 3);
! 	      make_internal_attr (p, newexp, ATTR_SPECIAL, 0);
  	    }
  
  	  if (have_annul_false)
*************** expand_delays (void)
*** 1400,1406 ****
  				 make_numeric_value (0));
  	      p = attr_printf (sizeof "*annul_false__" + MAX_DIGITS * 2,
  			       "*annul_false_%d_%d", delay->num, i / 3);
! 	      make_internal_attr (p, newexp, ATTR_SPECIAL);
  	    }
  	}
      }
--- 1417,1423 ----
  				 make_numeric_value (0));
  	      p = attr_printf (sizeof "*annul_false__" + MAX_DIGITS * 2,
  			       "*annul_false_%d_%d", delay->num, i / 3);
! 	      make_internal_attr (p, newexp, ATTR_SPECIAL, 0);
  	    }
  	}
      }
*************** make_length_attrs (void)
*** 1562,1568 ****
        make_internal_attr (new_names[i],
  			  substitute_address (length_attr->default_val->value,
  					      no_address_fn[i], address_fn[i]),
! 			  ATTR_NONE);
        new_attr = find_attr (&new_names[i], 0);
        for (av = length_attr->first_value; av; av = av->next)
  	for (ie = av->first_insn; ie; ie = ie->next)
--- 1579,1585 ----
        make_internal_attr (new_names[i],
  			  substitute_address (length_attr->default_val->value,
  					      no_address_fn[i], address_fn[i]),
! 			  ATTR_NONE, 1);
        new_attr = find_attr (&new_names[i], 0);
        for (av = length_attr->first_value; av; av = av->next)
  	for (ie = av->first_insn; ie; ie = ie->next)
*************** make_length_attrs (void)
*** 1578,1583 ****
--- 1595,1639 ----
      }
  }
  
+ /* Emit a special accessor function for the `enabled' attribute.  */
+ 
+ static void
+ make_enabled_attr (void)
+ {
+   static const char *new_name = "*alternative_enabled_p";
+   struct attr_desc *enabled_attr, *new_attr;
+   struct attr_value *av, *new_av;
+   struct insn_ent *ie, *new_ie;
+ 
+   /* See if attribute attribute is defined.  If so, it must be
+      numeric.  Make it special so we don't output anything for it.  */
+   enabled_attr = find_attr (&enabled_str, 0);
+   if (enabled_attr == 0)
+     return;
+ 
+   if (! enabled_attr->is_numeric)
+     fatal ("enabled attribute must be numeric");
+ 
+   enabled_attr->is_const = 0;
+   enabled_attr->is_special = 1;
+ 
+   make_internal_attr (new_name,
+ 		      substitute_address (enabled_attr->default_val->value,
+ 					  identity_fn, identity_fn),
+ 		      ATTR_NONE, 1);
+   new_attr = find_attr (&new_name, 0);
+   for (av = enabled_attr->first_value; av; av = av->next)
+     for (ie = av->first_insn; ie; ie = ie->next)
+       {
+ 	new_av = get_attr_value (substitute_address (av->value,
+ 						     identity_fn, identity_fn),
+ 					     new_attr, ie->def->insn_code);
+ 	new_ie = oballoc (sizeof (struct insn_ent));
+ 	new_ie->def = ie->def;
+ 	insert_insn_ent (new_av, new_ie);
+       }
+ }
+ 
  /* Utility functions called from above routine.  */
  
  static rtx
*************** gen_attr (rtx exp, int lineno)
*** 2980,2985 ****
--- 3036,3048 ----
        have_error = 1;
      }
  
+   if (! strcmp_check (attr->name, enabled_str) && ! attr->is_numeric)
+     {
+       message_with_line (lineno,
+ 			 "`enabled' attribute must take numeric values");
+       have_error = 1;
+     }
+ 
    /* Set up the default value.  */
    XEXP (exp, 2) = check_attr_value (XEXP (exp, 2), attr);
    attr->default_val = get_attr_value (XEXP (exp, 2), attr, -2);
*************** gen_delay (rtx def, int lineno)
*** 3136,3149 ****
  
  /* Given a piece of RTX, print a C expression to test its truth value.
     We use AND and IOR both for logical and bit-wise operations, so
!    interpret them as logical unless they are inside a comparison expression.
!    The first bit of FLAGS will be nonzero in that case.
  
     Set the second bit of FLAGS to make references to attribute values use
     a cached local variable instead of calling a function.  */
  
  static void
! write_test_expr (rtx exp, int flags)
  {
    int comparison_operator = 0;
    RTX_CODE code;
--- 3199,3214 ----
  
  /* Given a piece of RTX, print a C expression to test its truth value.
     We use AND and IOR both for logical and bit-wise operations, so
!    interpret them as logical unless they are inside a comparison
!    expression.  The first bit of FLAGS will be nonzero in that case.
!    ATTR_ACCESSOR points to the attribute which we are emitting an
!    accessor function for.
  
     Set the second bit of FLAGS to make references to attribute values use
     a cached local variable instead of calling a function.  */
  
  static void
! write_test_expr (rtx exp, int flags, struct attr_desc* attr_accessor)
  {
    int comparison_operator = 0;
    RTX_CODE code;
*************** write_test_expr (rtx exp, int flags)
*** 3170,3176 ****
      case PLUS:   case MINUS:  case MULT:     case DIV:      case MOD:
      case AND:    case IOR:    case XOR:
      case ASHIFT: case LSHIFTRT: case ASHIFTRT:
!       write_test_expr (XEXP (exp, 0), flags | comparison_operator);
        switch (code)
  	{
  	case EQ:
--- 3235,3242 ----
      case PLUS:   case MINUS:  case MULT:     case DIV:      case MOD:
      case AND:    case IOR:    case XOR:
      case ASHIFT: case LSHIFTRT: case ASHIFTRT:
!       write_test_expr (XEXP (exp, 0), flags | comparison_operator,
! 		       attr_accessor);
        switch (code)
  	{
  	case EQ:
*************** write_test_expr (rtx exp, int flags)
*** 3244,3250 ****
  	  gcc_unreachable ();
  	}
  
!       write_test_expr (XEXP (exp, 1), flags | comparison_operator);
        break;
  
      case NOT:
--- 3310,3317 ----
  	  gcc_unreachable ();
  	}
  
!       write_test_expr (XEXP (exp, 1), flags | comparison_operator,
! 		       attr_accessor);
        break;
  
      case NOT:
*************** write_test_expr (rtx exp, int flags)
*** 3252,3258 ****
        if (! (flags & 1) && GET_CODE (XEXP (exp, 0)) == EQ_ATTR
  	  && XSTR (XEXP (exp, 0), 0) == alternative_name)
  	{
! 	  printf ("which_alternative != %s", XSTR (XEXP (exp, 0), 1));
  	  break;
  	}
  
--- 3319,3326 ----
        if (! (flags & 1) && GET_CODE (XEXP (exp, 0)) == EQ_ATTR
  	  && XSTR (XEXP (exp, 0), 0) == alternative_name)
  	{
! 	  printf ("%s != %s", get_alternative_str (attr_accessor),
! 		  XSTR (XEXP (exp, 0), 1));
  	  break;
  	}
  
*************** write_test_expr (rtx exp, int flags)
*** 3278,3284 ****
  	  gcc_unreachable ();
  	}
  
!       write_test_expr (XEXP (exp, 0), flags);
        break;
  
      case EQ_ATTR_ALT:
--- 3346,3352 ----
  	  gcc_unreachable ();
  	}
  
!       write_test_expr (XEXP (exp, 0), flags, attr_accessor);
        break;
  
      case EQ_ATTR_ALT:
*************** write_test_expr (rtx exp, int flags)
*** 3316,3328 ****
  	      if (!(set & 1))
  		bit++;
  
! 	      printf ("which_alternative %s= %d",
  		      XINT (exp, 1) ? "!" : "=", bit);
  	    }
  	  else
  	    {
! 	      printf ("%s((1 << which_alternative) & 0x%x)",
! 		      XINT (exp, 1) ? "!" : "", set);
  	    }
  	}
        break;
--- 3384,3397 ----
  	      if (!(set & 1))
  		bit++;
  
! 	      printf ("%s %s= %d", get_alternative_str (attr_accessor),
  		      XINT (exp, 1) ? "!" : "=", bit);
  	    }
  	  else
  	    {
! 	      printf ("%s((1 << %s) & 0x%x)",
! 		      XINT (exp, 1) ? "!" : "",
! 		      get_alternative_str (attr_accessor), set);
  	    }
  	}
        break;
*************** write_test_expr (rtx exp, int flags)
*** 3336,3342 ****
  
        if (XSTR (exp, 0) == alternative_name)
  	{
! 	  printf ("which_alternative == %s", XSTR (exp, 1));
  	  break;
  	}
  
--- 3405,3412 ----
  
        if (XSTR (exp, 0) == alternative_name)
  	{
! 	  printf ("%s == %s", get_alternative_str (attr_accessor),
! 		  XSTR (exp, 1));
  	  break;
  	}
  
*************** write_test_expr (rtx exp, int flags)
*** 3348,3361 ****
  	{
  	  write_test_expr (evaluate_eq_attr (exp, attr->default_val->value,
  					     -2, -2),
! 			   flags);
  	}
        else
  	{
  	  if (flags & 2)
  	    printf ("attr_%s", attr->name);
  	  else
! 	    printf ("get_attr_%s (insn)", attr->name);
  	  printf (" == ");
  	  write_attr_valueq (attr, XSTR (exp, 1));
  	}
--- 3418,3433 ----
  	{
  	  write_test_expr (evaluate_eq_attr (exp, attr->default_val->value,
  					     -2, -2),
! 			   flags, attr_accessor);
  	}
        else
  	{
  	  if (flags & 2)
  	    printf ("attr_%s", attr->name);
  	  else
! 	    printf ("get_attr_%s%s (%s)", attr->name,
! 		    attr_accessor->alt_accessor ? "_alt" : "",
! 		    attr_accessor->alt_accessor ? "insn, alternative" : "insn");
  	  printf (" == ");
  	  write_attr_valueq (attr, XSTR (exp, 1));
  	}
*************** write_test_expr (rtx exp, int flags)
*** 3415,3425 ****
        break;
  
      case IF_THEN_ELSE:
!       write_test_expr (XEXP (exp, 0), flags & 2);
        printf (" ? ");
!       write_test_expr (XEXP (exp, 1), flags | 1);
        printf (" : ");
!       write_test_expr (XEXP (exp, 2), flags | 1);
        break;
  
      default:
--- 3487,3497 ----
        break;
  
      case IF_THEN_ELSE:
!       write_test_expr (XEXP (exp, 0), flags & 2, attr_accessor);
        printf (" ? ");
!       write_test_expr (XEXP (exp, 1), flags | 1, attr_accessor);
        printf (" : ");
!       write_test_expr (XEXP (exp, 2), flags | 1, attr_accessor);
        break;
  
      default:
*************** write_attr_get (struct attr_desc *attr)
*** 3647,3657 ****
    /* If the attribute name starts with a star, the remainder is the name of
       the subroutine to use, instead of `get_attr_...'.  */
    if (attr->name[0] == '*')
!     printf ("%s (rtx insn ATTRIBUTE_UNUSED)\n", &attr->name[1]);
    else if (attr->is_const == 0)
!     printf ("get_attr_%s (rtx insn ATTRIBUTE_UNUSED)\n", attr->name);
    else
      {
        printf ("get_attr_%s (void)\n", attr->name);
        printf ("{\n");
  
--- 3719,3739 ----
    /* If the attribute name starts with a star, the remainder is the name of
       the subroutine to use, instead of `get_attr_...'.  */
    if (attr->name[0] == '*')
!     printf ("%s%s (%s)\n", &attr->name[1],
! 	    attr->alt_accessor ? "_alt" : "",
! 	    attr->alt_accessor ? ("rtx insn ATTRIBUTE_UNUSED, "
! 				 "int alternative ATTRIBUTE_UNUSED")
! 	    : "rtx insn ATTRIBUTE_UNUSED");
    else if (attr->is_const == 0)
!     printf ("get_attr_%s%s (%s)\n", attr->name,
! 	    attr->alt_accessor ? "_alt" : "",
! 	    attr->alt_accessor ? ("rtx insn ATTRIBUTE_UNUSED, "
! 				    "int alternative ATTRIBUTE_UNUSED")
! 	    : "rtx insn ATTRIBUTE_UNUSED");
    else
      {
+       if (attr->alt_accessor)
+ 	return;
        printf ("get_attr_%s (void)\n", attr->name);
        printf ("{\n");
  
*************** write_attr_set (struct attr_desc *attr, 
*** 3761,3767 ****
  	  write_indent (indent);
  	  printf ("%sif ", first_if ? "" : "else ");
  	  first_if = 0;
! 	  write_test_expr (testexp, 0);
  	  printf ("\n");
  	  write_indent (indent + 2);
  	  printf ("{\n");
--- 3843,3849 ----
  	  write_indent (indent);
  	  printf ("%sif ", first_if ? "" : "else ");
  	  first_if = 0;
! 	  write_test_expr (testexp, 0, attr);
  	  printf ("\n");
  	  write_indent (indent + 2);
  	  printf ("{\n");
*************** write_attr_case (struct attr_desc *attr,
*** 3829,3835 ****
    if (av->num_insns == 0)
      return;
  
!   if (av->has_asm_insn)
      {
        write_indent (indent);
        printf ("case -1:\n");
--- 3911,3917 ----
    if (av->num_insns == 0)
      return;
  
!   if (av->has_asm_insn && !attr->alt_accessor)
      {
        write_indent (indent);
        printf ("case -1:\n");
*************** write_attr_case (struct attr_desc *attr,
*** 3853,3867 ****
    must_extract = must_constrain = address_used = 0;
    walk_attr_value (av->value);
  
!   if (must_constrain)
      {
!       write_indent (indent + 2);
!       printf ("extract_constrain_insn_cached (insn);\n");
!     }
!   else if (must_extract)
!     {
!       write_indent (indent + 2);
!       printf ("extract_insn_cached (insn);\n");
      }
  
    if (av->num_insns == 1)
--- 3935,3952 ----
    must_extract = must_constrain = address_used = 0;
    walk_attr_value (av->value);
  
!   if (!attr->alt_accessor)
      {
!       if (must_constrain)
! 	{
! 	  write_indent (indent + 2);
! 	  printf ("extract_constrain_insn_cached (insn);\n");
! 	}
!       else if (must_extract)
! 	{
! 	  write_indent (indent + 2);
! 	  printf ("extract_insn_cached (insn);\n");
! 	}
      }
  
    if (av->num_insns == 1)
*************** write_attr_value (struct attr_desc *attr
*** 3924,3931 ****
      case ATTR:
        {
  	struct attr_desc *attr2 = find_attr (&XSTR (value, 0), 0);
! 	printf ("get_attr_%s (%s)", attr2->name,
! 		(attr2->is_const ? "" : "insn"));
        }
        break;
  
--- 4009,4018 ----
      case ATTR:
        {
  	struct attr_desc *attr2 = find_attr (&XSTR (value, 0), 0);
! 	printf ("get_attr_%s%s (%s)", attr2->name,
! 		attr->alt_accessor ? "_alt" : "",
! 		(attr2->is_const ? ""
! 		 : (attr->alt_accessor ? "insn, alternative" : "insn")));
        }
        break;
  
*************** find_attr (const char **name_p, int crea
*** 4164,4169 ****
--- 4251,4257 ----
    attr->is_numeric = attr->is_const = attr->is_special = 0;
    attr->next = attrs[index];
    attrs[index] = attr;
+   attr->alt_accessor = 1;
  
    *name_p = attr->name;
  
*************** find_attr (const char **name_p, int crea
*** 4173,4179 ****
  /* Create internal attribute with the given default value.  */
  
  static void
! make_internal_attr (const char *name, rtx value, int special)
  {
    struct attr_desc *attr;
  
--- 4261,4267 ----
  /* Create internal attribute with the given default value.  */
  
  static void
! make_internal_attr (const char *name, rtx value, int special, int alt_accessor)
  {
    struct attr_desc *attr;
  
*************** make_internal_attr (const char *name, rt
*** 4184,4189 ****
--- 4272,4278 ----
    attr->is_const = 0;
    attr->is_special = (special & ATTR_SPECIAL) != 0;
    attr->default_val = get_attr_value (value, attr, -2);
+   attr->alt_accessor = alt_accessor;
  }
  
  /* Find the most used value of an attribute.  */
*************** make_automaton_attrs (void)
*** 4428,4436 ****
  	  }
      }
  
!   make_internal_attr ("*internal_dfa_insn_code", code_exp, ATTR_NONE);
!   make_internal_attr ("*insn_default_latency",   lats_exp, ATTR_NONE);
!   make_internal_attr ("*bypass_p",               byps_exp, ATTR_NONE);
  }
  
  int
--- 4517,4525 ----
  	  }
      }
  
!   make_internal_attr ("*internal_dfa_insn_code", code_exp, ATTR_NONE, 0);
!   make_internal_attr ("*insn_default_latency",   lats_exp, ATTR_NONE, 0);
!   make_internal_attr ("*bypass_p",               byps_exp, ATTR_NONE, 0);
  }
  
  int
*************** main (int argc, char **argv)
*** 4460,4465 ****
--- 4549,4555 ----
  
    alternative_name = DEF_ATTR_STRING ("alternative");
    length_str = DEF_ATTR_STRING ("length");
+   enabled_str = DEF_ATTR_STRING ("enabled");
    delay_type_str = DEF_ATTR_STRING ("*delay_type");
    delay_1_0_str = DEF_ATTR_STRING ("*delay_1_0");
    num_delay_slots_str = DEF_ATTR_STRING ("*num_delay_slots");
*************** from the machine description file `md'. 
*** 4578,4583 ****
--- 4668,4676 ----
    /* Construct extra attributes for `length'.  */
    make_length_attrs ();
  
+   /* Construct the special `enabled' attribute.  */
+   make_enabled_attr ();
+ 
    /* Perform any possible optimizations to speed up compilation.  */
    optimize_attrs ();
  
*************** from the machine description file `md'. 
*** 4588,4594 ****
      for (attr = attrs[i]; attr; attr = attr->next)
        {
  	if (! attr->is_special && ! attr->is_const)
! 	  write_attr_get (attr);
        }
  
    /* Write out delay eligibility information, if DEFINE_DELAY present.
--- 4681,4697 ----
      for (attr = attrs[i]; attr; attr = attr->next)
        {
  	if (! attr->is_special && ! attr->is_const)
! 	  {
! 	    if (attr->alt_accessor)
! 	      {
! 		attr->alt_accessor = 0;
! 		write_attr_get (attr);
! 		attr->alt_accessor = 1;
! 		write_attr_get (attr);
! 	      }
! 	    else
! 	      write_attr_get (attr);
! 	  }
        }
  
    /* Write out delay eligibility information, if DEFINE_DELAY present.
Index: gcc/genattr.c
===================================================================
*** gcc/genattr.c.orig	2007-08-27 16:06:24.000000000 +0200
--- gcc/genattr.c	2007-08-27 16:07:02.000000000 +0200
*************** gen_attr (rtx attr)
*** 47,57 ****
  
    printf ("#define HAVE_ATTR_%s\n", XSTR (attr, 0));
  
    /* If numeric attribute, don't need to write an enum.  */
    p = XSTR (attr, 1);
    if (*p == '\0')
!     printf ("extern int get_attr_%s (%s);\n", XSTR (attr, 0),
! 	    (is_const ? "void" : "rtx"));
    else
      {
        printf ("enum attr_%s {", XSTR (attr, 0));
--- 47,68 ----
  
    printf ("#define HAVE_ATTR_%s\n", XSTR (attr, 0));
  
+   if (! strcmp (XSTR (attr, 0), "enabled"))
+     {
+       puts ("extern int alternative_enabled_p (rtx);\n\
+ extern int alternative_enabled_p_alt (rtx, int);\n");
+       return;
+     }
+ 
    /* If numeric attribute, don't need to write an enum.  */
    p = XSTR (attr, 1);
    if (*p == '\0')
!     {
!       printf ("extern int get_attr_%s (%s);\n", XSTR (attr, 0),
! 	      (is_const ? "void" : "rtx"));
!       if (!is_const)
! 	printf ("extern int get_attr_%s_alt (rtx, int);\n", XSTR (attr, 0));
!     }
    else
      {
        printf ("enum attr_%s {", XSTR (attr, 0));
*************** gen_attr (rtx attr)
*** 69,74 ****
--- 80,88 ----
        fputs ("};\n", stdout);
        printf ("extern enum attr_%s get_attr_%s (%s);\n\n",
  	      XSTR (attr, 0), XSTR (attr, 0), (is_const ? "void" : "rtx"));
+       if (!is_const)
+ 	printf ("extern enum attr_%s get_attr_%s_alt (rtx, int);\n\n",
+ 		XSTR (attr, 0), XSTR (attr, 0));
      }
  
    /* If `length' attribute, write additional function definitions and define
*************** extern int insn_default_length (rtx);\n\
*** 81,86 ****
--- 95,104 ----
  extern int insn_min_length (rtx);\n\
  extern int insn_variable_length_p (rtx);\n\
  extern int insn_current_length (rtx);\n\n\
+ extern int insn_default_length_alt (rtx, int);\n\
+ extern int insn_min_length_alt (rtx, int);\n\
+ extern int insn_variable_length_p_alt (rtx, int);\n\
+ extern int insn_current_length_alt (rtx, int);\n\n\
  #include \"insn-addr.h\"\n");
      }
  }


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