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 to add `static' field for genattrtab attr_desc


Here's my attempt to correct the mistake I made with my previous patch
to remove spurious extern declarations in insn-attrtab.c.
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg00505.html

(Very sorry for the failures it caused.)
 
The previous patch failed because on some systems functions are output
into insn-attrtab.c without a corresponding declaration in
insn-attr.h.  These are functions created with `make_internal_attr',
and they are not called in any other file besides insn-attrtab.c so
they should IMO be declared `static' which removes the need for a
separate declaration as long as all callers follow the definition.

This patch therefore adds a new flag in the attr_desc field which
allows marking some of these internal functions as static.

I also noted that `internal_reset', whose function body was exactly
one call to memset, was just dying to be inlined. :-)

This patch relies on a previous one:
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg00575.html

I tested this patch in combination with the above by building cc1 in
cross-compiler configurations targetted to the following platforms and
ensuring that no prototype warnings arose in insn-attrtab.c:

alpha-dec-osf4.0 arc-unknown-elf arm-unknown-pe avr-unknown-elf
c4x-unknown-rtems cris-unknown-linux-gnu d30v-unknown-elf
dsp16xx-unknown-elf fr30-unknown-elf frv-unknown-elf
h8300-unknown-rtems hppa1.1-hp-hpux11 i370-unknown-linux-gnu
i686-pc-linux-gnu i960-unknown-rtems ia64-unknown-linux-gnu
ip2k-unknown-elf m32r-unknown-elf m68hc11-unknown-elf
m68k-unknown-linux-gnu mcore-unknown-elf mips-sgi-irix6.5
mmix-knuth-mmixware mn10300-unknown-elf ns32k-unknown-netbsd
pdp11-unknown-bsd powerpc-apple-darwin rs6000-ibm-aix4.3.3.0
s390-unknown-linux-gnu sh-unknown-rtems sparc-sun-solaris2.6
v850-unknown-elf vax-unknown-ultrix xstormy16-unknown-elf
xtensa-unknown-elf

Ok for mainline?

		Thanks,
		--Kaveh


2003-07-06  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* genattr.c (internal_dfa_insn_code): Don't prototype.
	* genattrtab.c (attr_desc): Add `static_p' field.
	(expand_units): Make blockage range and ready cost functions
	static.
	(write_attr_get): Don't add extern prototypes in C file.  Mark
	static functions as appropriate.
	(find_attr, make_internal_attr): Initialize static_p.
	* genattrtab.h (ATTR_STATIC): New macro.
	* genautomata.c (output_internal_reset_func): Mark output function
	as inline.
	(make_internal_dfa_insn_code_attr): Mark output function as static.
	
diff -rup orig/egcc-CVS20030705/gcc/genattr.c egcc-CVS20030705/gcc/genattr.c
--- orig/egcc-CVS20030705/gcc/genattr.c	2003-07-05 16:01:36.000000000 -0400
+++ egcc-CVS20030705/gcc/genattr.c	2003-07-06 09:49:54.695152000 -0400
@@ -379,7 +379,6 @@ main (int argc, char **argv)
       printf ("   insns scheduling heuristics. */\n");
       printf ("extern int insn_alts (rtx);\n\n");
       printf ("#endif\n\n");
-      printf ("extern int internal_dfa_insn_code (rtx);\n\n");
       printf ("/* Maximal possible number of insns waiting results being\n");
       printf ("   produced by insns whose execution is not finished. */\n");
       printf ("extern int max_insn_queue_index;\n\n");
diff -rup orig/egcc-CVS20030705/gcc/genattrtab.c egcc-CVS20030705/gcc/genattrtab.c
--- orig/egcc-CVS20030705/gcc/genattrtab.c	2003-07-06 10:57:52.728579000 -0400
+++ egcc-CVS20030705/gcc/genattrtab.c	2003-07-06 10:05:14.556534000 -0400
@@ -185,6 +185,7 @@ struct attr_desc
   unsigned is_special	: 1;	/* Don't call `write_attr_set'.  */
   unsigned func_units_p	: 1;	/* this is the function_units attribute */
   unsigned blockage_p	: 1;	/* this is the blockage range function */
+  unsigned static_p	: 1;	/* Make the output function static.  */
 };
 
 #define NULL_ATTR (struct attr_desc *) NULL
@@ -2078,18 +2079,20 @@ expand_units (void)
 	      str = attr_printf ((strlen (unit->name)
 				  + sizeof "*_unit_blockage_range"),
 				 "*%s_unit_blockage_range", unit->name);
-	      make_internal_attr (str, newexp, (ATTR_BLOCKAGE|ATTR_UNSIGNED));
+	      make_internal_attr (str, newexp, (ATTR_STATIC|ATTR_BLOCKAGE|ATTR_UNSIGNED));
 	    }
 
 	  str = attr_printf (strlen (unit->name) + sizeof "*_unit_ready_cost",
 			     "*%s_unit_ready_cost", unit->name);
+	  make_internal_attr (str, readycost, ATTR_STATIC);
 	}
       else
-	str = "*result_ready_cost";
-
-      /* Make an attribute for the ready_cost function.  Simplifying
-	 further with simplify_by_exploding doesn't win.  */
-      make_internal_attr (str, readycost, ATTR_NONE);
+        {
+	  /* Make an attribute for the ready_cost function.  Simplifying
+	     further with simplify_by_exploding doesn't win.  */
+	  str = "*result_ready_cost";
+	  make_internal_attr (str, readycost, ATTR_NONE);
+	}
     }
 
   /* For each unit that requires a conflict cost function, make an attribute
@@ -4766,23 +4769,10 @@ write_attr_get (struct attr_desc *attr)
      switch we will generate.  */
   common_av = find_most_used (attr);
 
-  /* Write out prototype of function.  */
-  if (!attr->is_numeric)
-    printf ("extern enum attr_%s ", attr->name);
-  else if (attr->unsigned_p)
-    printf ("extern unsigned int ");
-  else
-    printf ("extern int ");
-  /* 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);\n", &attr->name[1]);
-  else
-    printf ("get_attr_%s (%s);\n", attr->name,
-	    (attr->is_const ? "void" : "rtx"));
-
   /* Write out start of function, then all values with explicit `case' lines,
      then a `default', then the value with the most uses.  */
+  if (attr->static_p)
+    printf ("static ");
   if (!attr->is_numeric)
     printf ("enum attr_%s\n", attr->name);
   else if (attr->unsigned_p)
@@ -5593,7 +5583,7 @@ find_attr (const char *name, int create)
   attr->name = attr_string (name, strlen (name));
   attr->first_value = attr->default_val = NULL;
   attr->is_numeric = attr->negative_ok = attr->is_const = attr->is_special = 0;
-  attr->unsigned_p = attr->func_units_p = attr->blockage_p = 0;
+  attr->unsigned_p = attr->func_units_p = attr->blockage_p = attr->static_p = 0;
   attr->next = attrs[index];
   attrs[index] = attr;
 
@@ -5618,6 +5608,7 @@ make_internal_attr (const char *name, rt
   attr->unsigned_p = (special & ATTR_UNSIGNED) != 0;
   attr->func_units_p = (special & ATTR_FUNC_UNITS) != 0;
   attr->blockage_p = (special & ATTR_BLOCKAGE) != 0;
+  attr->static_p = (special & ATTR_STATIC) != 0;
   attr->default_val = get_attr_value (value, attr, -2);
 }
 
diff -rup orig/egcc-CVS20030705/gcc/genattrtab.h egcc-CVS20030705/gcc/genattrtab.h
--- orig/egcc-CVS20030705/gcc/genattrtab.h	2003-07-06 10:57:52.668576000 -0400
+++ egcc-CVS20030705/gcc/genattrtab.h	2003-07-06 10:10:41.608727000 -0400
@@ -55,3 +55,4 @@ extern void write_automata              
 #define ATTR_UNSIGNED		(1 << 2)
 #define ATTR_FUNC_UNITS		(1 << 3)
 #define ATTR_BLOCKAGE		(1 << 4)
+#define ATTR_STATIC		(1 << 5)
diff -rup orig/egcc-CVS20030705/gcc/genautomata.c egcc-CVS20030705/gcc/genautomata.c
--- orig/egcc-CVS20030705/gcc/genautomata.c	2003-07-06 10:57:52.768634000 -0400
+++ egcc-CVS20030705/gcc/genautomata.c	2003-07-06 10:14:09.691249000 -0400
@@ -8572,7 +8572,7 @@ output_dead_lock_func (void)
 static void
 output_internal_reset_func (void)
 {
-  fprintf (output_file, "static void\n%s (struct %s *%s)\n",
+  fprintf (output_file, "static inline void\n%s (struct %s *%s)\n",
 	   INTERNAL_RESET_FUNC_NAME, CHIP_NAME, CHIP_PARAMETER_NAME);
   fprintf (output_file, "{\n  memset (%s, 0, sizeof (struct %s));\n}\n\n",
 	   CHIP_PARAMETER_NAME, CHIP_NAME);
@@ -9474,7 +9474,7 @@ make_internal_dfa_insn_code_attr (void)
     (attr_printf (sizeof ("*")
 		  + strlen (INTERNAL_DFA_INSN_CODE_FUNC_NAME) + 1,
 		  "*%s", INTERNAL_DFA_INSN_CODE_FUNC_NAME),
-     condexp, ATTR_NONE);
+     condexp, ATTR_STATIC);
 }
 
 


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