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 const-ify tree_code_{type,name,length}


Currently, the arrays for tree_code_type, tree_code_name and
tree_code_length are mutable arrays of fixed size [256].  They are
first initialized in tree.c and any language specific tree codes are
set via memcpy separately in each frontend.

I noticed we could initialize these at compile time by moving the
array definition to each particular frontend.  In addition to living
in .rodata, the arrays would only be as large as they need, not
artificially taking up 256 elements.

In the process, I also noticed we could shrink tree_code_length by
changing its type to unsigned char instead of int.

Running a bootstrap on solaris2.7, I see significant code size
reductions.  It is most pronounced on cc1plus, and the bulk comes from
~14K of .text size getting eliminated.  I don't fully understand why
.text was impacted so much or why it was concentrated in the c++
frontend, but the diff was much less pronounced when tree checking was
disabled and cc1plus makes more use of the TREE_CODE_CLASS macros
through TYPE_P/DECL_P if those are clues.

Anyway, I'm not one to look a gift horse in the mouth for too long.
The code size reductions in bytes with tree checking *enabled* were:

cc1plus: 15773
jc1: 7104
cc1obj: 6429
cc1: 6053
f771: 4712

These are overall reductions, not just .data->.rodata migration of
which there was some too.  Specifically for size -f cc1plus, it was:

clean/build/gcc/cc1plus: 17(.interp) + 31948(.hash) + 63744(.dynsym) +
69846(.dynstr) + 32(.SUNW_version) + 36(.rela.got) + 36(.rela.bss) +
1176(.rela.plt) + 3484988(.text) + 28(.init) + 20(.fini) +
420456(.rodata) + 176(.rodata1) + 48(.got) + 1228(.plt) +
176(.dynamic) + 8508(.data) + 8(.ctors) + 8(.dtors) + 4(.eh_frame) +
4(.jcr) + 4(.data.rel.local) + 13(.data1) + 337404(.bss) = 4419908

patch/build/gcc/cc1plus: 17(.interp) + 31944(.hash) + 63728(.dynsym) +
69829(.dynstr) + 32(.SUNW_version) + 36(.rela.got) + 36(.rela.bss) +
1176(.rela.plt) + 3470948(.text) + 28(.init) + 20(.fini) +
421072(.rodata) + 176(.rodata1) + 48(.got) + 1228(.plt) +
176(.dynamic) + 6196(.data) + 8(.ctors) + 8(.dtors) + 4(.eh_frame) +
4(.jcr) + 4(.data.rel.local) + 13(.data1) + 337404(.bss) = 4404135

It appeared to be spread in small increments among many/all .o files.


Testing this was somewhat of a leap, because I don't have gnat for
building ada (no I rather not get it), and java barfs on solaris2.7
lately: http://gcc.gnu.org/ml/gcc-bugs/2001-12/msg00894.html

So I bootstrapped with c,c++,objc,f with tree checking enabled, and
there were no warning or testsuite regressions.  (I also made sure
that jc1 at least still compiles.)

BTW, I also made this change to the chill directory since its an
all-or-nothing kind of patch to tree_codes, but there's so much bitrot
there that I don't really see the value.  E.g. the "langhooks" stuff
doesn't seem to have been propagated to the ch directory and
tree_code_length stuff for IDENTIFIER_NODEs relies on it right now
before my patch.

Anyway, okay to install?

		Thanks,
		--Kaveh


2001-12-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* c-common.c (c_tree_code_type, c_tree_code_length,
	c_tree_code_name, add_c_tree_codes): Delete.
	* c-common.h (add_c_tree_codes): Delete.
	* c-lang.c (tree_code_type, tree_code_length, tree_code_name):
	Define.
	* c-objc-common.c (c_objc_common_init): Don't call
	add_c_tree_codes, instead set lang_unsafe_for_reeval.
	* objc/objc-act.c (objc_tree_code_type, objc_tree_code_length,
	objc_tree_code_name, add_objc_tree_codes): Delete.
	(objc_init): Don't call add_objc_tree_codes.
	* objc/objc-lang.c (tree_code_type, tree_code_length,
	tree_code_name): Define.
	* toplev.c (lang_independent_init): Don't set
	tree_code_length[IDENTIFIER_NODE].
	* tree.c (tree_code_type, tree_code_length, tree_code_name):
	Delete definitions, moved to language front-ends.
	* tree.def (IDENTIFIER_NODE): Hardwire the length.
	* tree.h (tree_code_type, tree_code_length, tree_code_name):
	Const-ify.
	(tree_code_length): Change type to unsigned char.
	
ada:
	* misc.c (gnat_tree_code_type, gnat_tree_code_length,
	gnat_tree_code_name): Delete.
	(tree_code_type, tree_code_length, tree_code_name): Define.
	(gnat_init): Don't try to copy into the various tree_code
	arrays.

ch:
	* decl.c (chill_tree_code_type, chill_tree_code_length,
	chill_tree_code_name): Delete.
	(tree_code_type, tree_code_length, tree_code_name): Define.
	(init_decl_processing): Don't try to copy into the various
	tree_code arrays.
	
cp:
	* cp-lang.c (tree_code_type, tree_code_length, tree_code_name):
	Define.
	* decl.c (duplicate_decls): Use TREE_CODE_LENGTH, not
	tree_code_length.
	* lex.c (cplus_tree_code_type, cplus_tree_code_length,
	cplus_tree_code_name): Delete.
	(cxx_init): Don't call add_c_tree_codes, instead set
	lang_unsafe_for_reeval.  Don't try to copy into the various
	tree_code arrays.
	
f:
	* com.c (tree_code_type, tree_code_length, tree_code_name):
	Define.

java:
	* lang.c (java_tree_code_type, java_tree_code_length,
	tree_code_name): Delete.
	(tree_code_type, tree_code_length, tree_code_name): Define.
	(java_init): Don't try to copy into the various tree_code
	arrays.
	
diff -rup orig/egcc-CVS20011224/gcc/c-common.c egcc-CVS20011224/gcc/c-common.c
--- orig/egcc-CVS20011224/gcc/c-common.c	Thu Dec 20 21:31:52 2001
+++ egcc-CVS20011224/gcc/c-common.c	Mon Dec 24 13:21:13 2001
@@ -3511,56 +3511,6 @@ c_staticp (exp)
   return 0;
 }
 
-/* Tree code classes.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-static const char c_tree_code_type[] = {
-  'x',
-#include "c-common.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
-   operands beyond the fixed part of the node structure.
-   Not used for types or decls.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-static const int c_tree_code_length[] = {
-  0,
-#include "c-common.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
-   Used for printing out the tree and error messages.  */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-static const char *const c_tree_code_name[] = {
-  "@@dummy",
-#include "c-common.def"
-};
-#undef DEFTREECODE
-
-/* Adds the tree codes specific to the C front end to the list of all
-   tree codes.  */
-
-void
-add_c_tree_codes ()
-{
-  memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
-	  c_tree_code_type,
-	  (int)LAST_C_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
-  memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
-	  c_tree_code_length,
-	  (LAST_C_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
-  memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
-	  c_tree_code_name,
-	  (LAST_C_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
-  lang_unsafe_for_reeval = c_unsafe_for_reeval;
-}
-
 #define CALLED_AS_BUILT_IN(NODE) \
    (!strncmp (IDENTIFIER_POINTER (DECL_NAME (NODE)), "__builtin_", 10))
 
diff -rup orig/egcc-CVS20011224/gcc/c-common.h egcc-CVS20011224/gcc/c-common.h
--- orig/egcc-CVS20011224/gcc/c-common.h	Mon Dec 17 07:30:20 2001
+++ egcc-CVS20011224/gcc/c-common.h	Mon Dec 24 13:21:13 2001
@@ -713,7 +713,6 @@ enum c_tree_code {
 
 #undef DEFTREECODE
 
-extern void add_c_tree_codes		        PARAMS ((void));
 extern void genrtl_do_pushlevel                 PARAMS ((void));
 extern void genrtl_goto_stmt                    PARAMS ((tree));
 extern void genrtl_expr_stmt                    PARAMS ((tree));
diff -rup orig/egcc-CVS20011224/gcc/c-lang.c egcc-CVS20011224/gcc/c-lang.c
--- orig/egcc-CVS20011224/gcc/c-lang.c	Mon Dec 17 21:26:47 2001
+++ egcc-CVS20011224/gcc/c-lang.c	Mon Dec 24 13:21:13 2001
@@ -71,6 +71,41 @@ static void c_post_options PARAMS ((void
 /* Each front end provides its own.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
+/* Tree code classes.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+  'x',
+#include "c-common.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+   operands beyond the fixed part of the node structure.
+   Not used for types or decls.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+  0,
+#include "c-common.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+   Used for printing out the tree and error messages.  */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char *const tree_code_name[] = {
+#include "tree.def"
+  "@@dummy",
+#include "c-common.def"
+};
+#undef DEFTREECODE
+
 /* Post-switch processing.  */
 static void
 c_post_options ()
diff -rup orig/egcc-CVS20011224/gcc/c-objc-common.c egcc-CVS20011224/gcc/c-objc-common.c
--- orig/egcc-CVS20011224/gcc/c-objc-common.c	Mon Dec 17 21:26:47 2001
+++ egcc-CVS20011224/gcc/c-objc-common.c	Mon Dec 24 13:21:13 2001
@@ -210,7 +210,7 @@ c_objc_common_init (filename)
 
   filename = c_common_init (filename);
 
-  add_c_tree_codes ();
+  lang_unsafe_for_reeval = c_unsafe_for_reeval;
 
   save_lang_status = &push_c_function_context;
   restore_lang_status = &pop_c_function_context;
diff -rup orig/egcc-CVS20011224/gcc/ada/misc.c egcc-CVS20011224/gcc/ada/misc.c
--- orig/egcc-CVS20011224/gcc/ada/misc.c	Tue Dec 18 21:35:38 2001
+++ egcc-CVS20011224/gcc/ada/misc.c	Mon Dec 24 13:21:47 2001
@@ -75,42 +75,6 @@ extern FILE *asm_out_file;
 extern int save_argc;
 extern char **save_argv;
 
-/* Tables describing GCC tree codes used only by GNAT.  
-
-   Table indexed by tree code giving a string containing a character
-   classifying the tree code.  Possibilities are
-   t, d, s, c, r, <, 1 and 2.  See cp-tree.def for details.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-static char const gnat_tree_code_type[] = {
-  'x',
-#include "ada-tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
-   operands beyond the fixed part of the node structure.
-   Not used for types or decls.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-static int const gnat_tree_code_length[] = {
-  0,
-#include "ada-tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
-   Used for printing out the tree and error messages.  */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-static const char *gnat_tree_code_name[] = {
-  "@@dummy",
-#include "ada-tree.def"
-};
-#undef DEFTREECODE
-
 static const char *gnat_init		PARAMS ((const char *));
 static void gnat_init_options		PARAMS ((void));
 static int gnat_decode_option		PARAMS ((int, char **));
@@ -145,6 +109,45 @@ static tree gnat_expand_constant	PARAMS 
 
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
+/* Tables describing GCC tree codes used only by GNAT.  
+
+   Table indexed by tree code giving a string containing a character
+   classifying the tree code.  Possibilities are
+   t, d, s, c, r, <, 1 and 2.  See cp-tree.def for details.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+  'x',
+#include "ada-tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+   operands beyond the fixed part of the node structure.
+   Not used for types or decls.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+  0,
+#include "ada-tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+   Used for printing out the tree and error messages.  */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char *const tree_code_name[] = {
+#include "tree.def"
+  "@@dummy",
+#include "ada-tree.def"
+};
+#undef DEFTREECODE
+
 /* gnat standard argc argv */
 
 extern int gnat_argc;
@@ -353,21 +356,6 @@ gnat_init (filename)
    it, but it's where g++ does it.  */
 
   lang_expand_expr = gnat_expand_expr;
-
-  memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
-	  (char *) gnat_tree_code_type,
-	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (char *)));
-
-  memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
-	  (char *) gnat_tree_code_length,
-	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (int)));
-
-  memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
-	  (char *) gnat_tree_code_name,
-	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (char *)));
 
   gnat_init_decl_processing ();
 
diff -rup orig/egcc-CVS20011224/gcc/ch/decl.c egcc-CVS20011224/gcc/ch/decl.c
--- orig/egcc-CVS20011224/gcc/ch/decl.c	Sat Dec 15 16:30:19 2001
+++ egcc-CVS20011224/gcc/ch/decl.c	Mon Dec 24 13:21:13 2001
@@ -542,7 +542,8 @@ int warn_missing_braces;
 
 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
   
-  const char chill_tree_code_type[] = {
+const char tree_code_type[] = {
+#include "tree.def"
     'x',
 #include "ch-tree.def"
   };
@@ -554,7 +555,8 @@ int warn_missing_braces;
 
 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
   
-int chill_tree_code_length[] = {
+const unsigned char tree_code_length[] = {
+#include "tree.def"
     0,
 #include "ch-tree.def"
   };
@@ -565,7 +567,8 @@ int chill_tree_code_length[] = {
    Used for printing out the tree and error messages.  */
 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
   
-const char *chill_tree_code_name[] = {
+const char *const tree_code_name[] = {
+#include "tree.def"
     "@@dummy",
 #include "ch-tree.def"
   };
@@ -3503,18 +3506,6 @@ init_decl_processing ()
   DECL_SOURCE_LINE (temp) = 0;
   initializer_type = TREE_TYPE (temp);
 
-  memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
-	  chill_tree_code_type,
-	  (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (char)));
-  memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
-	  chill_tree_code_length,
-	  (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (int)));
-  memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
-	  chill_tree_code_name,
-	  (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (char *)));
   boolean_code_name = (const char **) xcalloc (sizeof (char *),
 					       (int) LAST_CHILL_TREE_CODE);
 
diff -rup orig/egcc-CVS20011224/gcc/cp/cp-lang.c egcc-CVS20011224/gcc/cp/cp-lang.c
--- orig/egcc-CVS20011224/gcc/cp/cp-lang.c	Wed Dec  5 22:09:41 2001
+++ egcc-CVS20011224/gcc/cp/cp-lang.c	Mon Dec 24 13:21:13 2001
@@ -95,6 +95,47 @@ static HOST_WIDE_INT cxx_get_alias_set P
 /* Each front end provides its own hooks, for toplev.c.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
+/* Tree code classes. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+  'x',
+#include "c-common.def"
+  'x',
+#include "cp-tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+   operands beyond the fixed part of the node structure.
+   Not used for types or decls.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+  0,
+#include "c-common.def"
+  0,
+#include "cp-tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+   Used for printing out the tree and error messages.  */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char *const tree_code_name[] = {
+#include "tree.def"
+  "@@dummy",
+#include "c-common.def"
+  "@@dummy",
+#include "cp-tree.def"
+};
+#undef DEFTREECODE
+
 /* Special routine to get the alias set for C++.  */
 
 static HOST_WIDE_INT
diff -rup orig/egcc-CVS20011224/gcc/cp/decl.c egcc-CVS20011224/gcc/cp/decl.c
--- orig/egcc-CVS20011224/gcc/cp/decl.c	Tue Dec 18 16:30:31 2001
+++ egcc-CVS20011224/gcc/cp/decl.c	Mon Dec 24 13:21:13 2001
@@ -3777,7 +3777,7 @@ duplicate_decls (newdecl, olddecl)
       memcpy ((char *) olddecl + sizeof (struct tree_common),
 	      (char *) newdecl + sizeof (struct tree_common),
 	      sizeof (struct tree_decl) - sizeof (struct tree_common)
-	      + tree_code_length [(int)TREE_CODE (newdecl)] * sizeof (char *));
+	      + TREE_CODE_LENGTH (TREE_CODE (newdecl)) * sizeof (char *));
     }
 
   DECL_UID (olddecl) = olddecl_uid;
diff -rup orig/egcc-CVS20011224/gcc/cp/lex.c egcc-CVS20011224/gcc/cp/lex.c
--- orig/egcc-CVS20011224/gcc/cp/lex.c	Mon Dec 17 23:47:47 2001
+++ egcc-CVS20011224/gcc/cp/lex.c	Mon Dec 24 13:21:13 2001
@@ -205,37 +205,6 @@ int interface_only;		/* whether or not c
 int interface_unknown;		/* whether or not we know this class
 				   to behave according to #pragma interface.  */
 
-/* Tree code classes. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-static const char cplus_tree_code_type[] = {
-  'x',
-#include "cp-tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
-   operands beyond the fixed part of the node structure.
-   Not used for types or decls.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-static const int cplus_tree_code_length[] = {
-  0,
-#include "cp-tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
-   Used for printing out the tree and error messages.  */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-static const char *const cplus_tree_code_name[] = {
-  "@@dummy",
-#include "cp-tree.def"
-};
-#undef DEFTREECODE
 
 /* Post-switch processing.  */
 void
@@ -685,17 +654,7 @@ cxx_init (filename)
   init_cplus_expand ();
   init_cp_semantics ();
 
-  add_c_tree_codes ();
-
-  memcpy (tree_code_type + (int) LAST_C_TREE_CODE,
-	  cplus_tree_code_type,
-	  (int)LAST_CPLUS_TREE_CODE - (int)LAST_C_TREE_CODE);
-  memcpy (tree_code_length + (int) LAST_C_TREE_CODE,
-	  cplus_tree_code_length,
-	  (LAST_CPLUS_TREE_CODE - (int)LAST_C_TREE_CODE) * sizeof (int));
-  memcpy (tree_code_name + (int) LAST_C_TREE_CODE,
-	  cplus_tree_code_name,
-	  (LAST_CPLUS_TREE_CODE - (int)LAST_C_TREE_CODE) * sizeof (char *));
+  lang_unsafe_for_reeval = c_unsafe_for_reeval;
 
   init_operators ();
   init_method ();
diff -rup orig/egcc-CVS20011224/gcc/f/com.c egcc-CVS20011224/gcc/f/com.c
--- orig/egcc-CVS20011224/gcc/f/com.c	Sun Dec 23 10:44:32 2001
+++ egcc-CVS20011224/gcc/f/com.c	Mon Dec 24 13:21:13 2001
@@ -14253,6 +14253,37 @@ static void ffe_print_identifier PARAMS 
 
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
+/* Table indexed by tree code giving a string containing a character
+   classifying the tree code.  Possibilities are
+   t, d, s, c, r, <, 1, 2 and e.  See tree.def for details.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+   operands beyond the fixed part of the node structure.
+   Not used for types or decls.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+   Used for printing out the tree and error messages.  */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char *const tree_code_name[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
 static const char *
 ffe_init (filename)
      const char *filename;
diff -rup orig/egcc-CVS20011224/gcc/java/lang.c egcc-CVS20011224/gcc/java/lang.c
--- orig/egcc-CVS20011224/gcc/java/lang.c	Sun Dec 23 10:44:33 2001
+++ egcc-CVS20011224/gcc/java/lang.c	Mon Dec 24 13:21:13 2001
@@ -70,7 +70,8 @@ static int process_option_with_no PARAMS
 
 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
 
-static const char java_tree_code_type[] = {
+const char tree_code_type[] = {
+#include "tree.def"
   'x',
 #include "java-tree.def"
 };
@@ -82,7 +83,8 @@ static const char java_tree_code_type[] 
 
 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
 
-static const int java_tree_code_length[] = {
+const unsigned char tree_code_length[] = {
+#include "tree.def"
   0,
 #include "java-tree.def"
 };
@@ -92,7 +94,8 @@ static const int java_tree_code_length[]
    Used for printing out the tree and error messages.  */
 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
 
-static const char *const java_tree_code_name[] = {
+const char *const tree_code_name[] = {
+#include "tree.def"
   "@@dummy",
 #include "java-tree.def"
 };
@@ -488,19 +491,6 @@ java_init (filename)
   print_error_function = lang_print_error;
   lang_expand_expr = java_lang_expand_expr;
 
-  /* Append to Gcc tree node definition arrays */
-
-  memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
-	  java_tree_code_type,
-	  (int)LAST_JAVA_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
-  memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
-	  java_tree_code_length,
-	  (LAST_JAVA_TREE_CODE - 
-	   (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
-  memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
-	  java_tree_code_name,
-	  (LAST_JAVA_TREE_CODE - 
-	   (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
   java_init_decl_processing ();
 
   using_eh_for_cleanups ();
diff -rup orig/egcc-CVS20011224/gcc/objc/objc-act.c egcc-CVS20011224/gcc/objc/objc-act.c
--- orig/egcc-CVS20011224/gcc/objc/objc-act.c	Mon Dec 17 21:26:53 2001
+++ egcc-CVS20011224/gcc/objc/objc-act.c	Mon Dec 24 13:21:13 2001
@@ -86,40 +86,6 @@ Boston, MA 02111-1307, USA.  */
 #define OBJC_FORWARDING_MIN_OFFSET 0
 #endif
 
-/* Define the special tree codes that we use.  */
-
-/* Table indexed by tree code giving a string containing a character
-   classifying the tree code.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-static const char objc_tree_code_type[] = {
-  'x',
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
-   operands beyond the fixed part of the node structure.
-   Not used for types or decls.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-static const int objc_tree_code_length[] = {
-  0,
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
-   Used for printing out the tree and error messages.  */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-static const char * const objc_tree_code_name[] = {
-  "@@dummy",
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
 
 /* Set up for use of obstacks.  */
 
@@ -270,7 +236,6 @@ static void dump_interface			PARAMS ((FI
 
 /* Everything else.  */
 
-static void add_objc_tree_codes			PARAMS ((void));
 static tree define_decl				PARAMS ((tree, tree));
 static tree lookup_method_in_protocol_list	PARAMS ((tree, tree, int));
 static tree lookup_protocol_in_reflist		PARAMS ((tree, tree));
@@ -516,7 +481,6 @@ objc_init (filename)
      const char *filename;
 {
   filename = c_objc_common_init (filename);
-  add_objc_tree_codes ();
 
   decl_printable_name = objc_printable_name;
 
@@ -8067,22 +8031,6 @@ objc_printable_name (decl, kind)
      int kind ATTRIBUTE_UNUSED;
 {
   return objc_demangle (IDENTIFIER_POINTER (DECL_NAME (decl)));
-}
-
-/* Adds the tree codes specific to the ObjC/ObjC++ front end to the
-   list of all tree codes.  */
-
-static void
-add_objc_tree_codes ()
-{
-  int add = (int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE;
-
-  memcpy (tree_code_type + (int) LAST_BASE_TREE_CODE,
-	  objc_tree_code_type, add);
-  memcpy (tree_code_length + (int) LAST_BASE_TREE_CODE,
-	  objc_tree_code_length, add * sizeof (int));
-  memcpy (tree_code_name + (int) LAST_BASE_TREE_CODE,
-	  objc_tree_code_name, add * sizeof (char *));
 }
 
 static void
diff -rup orig/egcc-CVS20011224/gcc/objc/objc-lang.c egcc-CVS20011224/gcc/objc/objc-lang.c
--- orig/egcc-CVS20011224/gcc/objc/objc-lang.c	Wed Dec  5 07:30:50 2001
+++ egcc-CVS20011224/gcc/objc/objc-lang.c	Mon Dec 24 13:21:14 2001
@@ -64,6 +64,50 @@ static void objc_post_options           
 /* Each front end provides its own hooks, for toplev.c.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
+/* Define the special tree codes that we use.  */
+
+/* Table indexed by tree code giving a string containing a character
+   classifying the tree code.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+const char tree_code_type[] = {
+#include "tree.def"
+  'x',
+#include "c-common.def"
+  'x',
+#include "objc-tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+   operands beyond the fixed part of the node structure.
+   Not used for types or decls.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+  0,
+#include "c-common.def"
+  0,
+#include "objc-tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+   Used for printing out the tree and error messages.  */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+const char * const tree_code_name[] = {
+#include "tree.def"
+  "@@dummy",
+#include "c-common.def"
+  "@@dummy",
+#include "objc-tree.def"
+};
+#undef DEFTREECODE
+
 static void 
 objc_init_options ()
 {
diff -rup orig/egcc-CVS20011224/gcc/toplev.c egcc-CVS20011224/gcc/toplev.c
--- orig/egcc-CVS20011224/gcc/toplev.c	Mon Dec 17 16:30:35 2001
+++ egcc-CVS20011224/gcc/toplev.c	Mon Dec 24 13:21:14 2001
@@ -4956,11 +4956,6 @@ lang_independent_init ()
   decl_printable_name = decl_name;
   lang_expand_expr = (lang_expand_expr_t) do_abort;
 
-  /* Set the language-dependent identifier size.  */
-  tree_code_length[(int) IDENTIFIER_NODE]
-    = ((lang_hooks.identifier_size - sizeof (struct tree_common))
-       / sizeof (tree));
-
   /* Initialize the garbage-collector, and string pools.  */
   init_ggc ();
   ggc_add_rtx_root (&stack_limit_rtx, 1);
diff -rup orig/egcc-CVS20011224/gcc/tree.c egcc-CVS20011224/gcc/tree.c
--- orig/egcc-CVS20011224/gcc/tree.c	Tue Dec 11 16:30:30 2001
+++ egcc-CVS20011224/gcc/tree.c	Mon Dec 24 13:21:14 2001
@@ -58,37 +58,6 @@ static void unsave_expr_now_r PARAMS ((t
 
 struct obstack permanent_obstack;
 
-/* Table indexed by tree code giving a string containing a character
-   classifying the tree code.  Possibilities are
-   t, d, s, c, r, <, 1, 2 and e.  See tree.def for details.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-char tree_code_type[MAX_TREE_CODES] = {
-#include "tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
-   operands beyond the fixed part of the node structure.
-   Not used for types or decls.  */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-int tree_code_length[MAX_TREE_CODES] = {
-#include "tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
-   Used for printing out the tree and error messages.  */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-const char *tree_code_name[MAX_TREE_CODES] = {
-#include "tree.def"
-};
-#undef DEFTREECODE
-
 /* Statistics-gathering stuff.  */
 typedef enum
 {
diff -rup orig/egcc-CVS20011224/gcc/tree.def egcc-CVS20011224/gcc/tree.def
--- orig/egcc-CVS20011224/gcc/tree.def	Wed Nov 21 19:11:36 2001
+++ egcc-CVS20011224/gcc/tree.def	Mon Dec 24 13:21:14 2001
@@ -49,7 +49,7 @@ DEFTREECODE (ERROR_MARK, "error_mark", '
    Internally it looks like a STRING_CST node.
    There is only one IDENTIFIER_NODE ever made for any particular name.
    Use `get_identifier' to get it (or create it, the first time).  */
-DEFTREECODE (IDENTIFIER_NODE, "identifier_node", 'x', -1)
+DEFTREECODE (IDENTIFIER_NODE, "identifier_node", 'x', ((LANG_HOOKS_IDENTIFIER_SIZE - sizeof (struct tree_common)) / sizeof (tree)))
 
 /* Has the TREE_VALUE and TREE_PURPOSE fields.  */
 /* These nodes are made into lists by chaining through the
diff -rup orig/egcc-CVS20011224/gcc/tree.h egcc-CVS20011224/gcc/tree.h
--- orig/egcc-CVS20011224/gcc/tree.h	Tue Dec 11 16:30:31 2001
+++ egcc-CVS20011224/gcc/tree.h	Mon Dec 24 13:21:14 2001
@@ -46,7 +46,7 @@ enum tree_code {
    and `x' for anything else (TREE_LIST, IDENTIFIER, etc).  */
 
 #define MAX_TREE_CODES 256
-extern char tree_code_type[MAX_TREE_CODES];
+extern const char tree_code_type[];
 #define TREE_CODE_CLASS(CODE)	tree_code_type[(int) (CODE)]
 
 /* Returns non-zero iff CLASS is the tree-code class of an
@@ -57,12 +57,12 @@ extern char tree_code_type[MAX_TREE_CODE
 
 /* Number of argument-words in each kind of tree-node.  */
 
-extern int tree_code_length[MAX_TREE_CODES];
+extern const unsigned char tree_code_length[];
 #define TREE_CODE_LENGTH(CODE)	tree_code_length[(int) (CODE)]
 
 /* Names of tree components.  */
 
-extern const char *tree_code_name[MAX_TREE_CODES];
+extern const char *const tree_code_name[];
 
 /* Classify which part of the compiler has defined a given builtin function.
    Note that we assume below that this is no more than two bits.  */


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