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]

[Patch] C specific tree nodes


This is the second patch that will move us towards using the C++ tree
representation in C as well as C++.  Eventually, the C front-end will work
like the C++ front-end, using function-at-a-time processing.  We want to
share as much code as possible between the two front-ends. These changes
were tested on i686-pc-linux-gnu. They cause the the C front end to define
the tree nodes relevent to C as was previously done only in C++. These
nodes are not yet used, only defined in c-lex.c.

This patch has been approved by Mark Mitchell.

Benjamin Chelf
chelf@codesourcery.com
CodeSourcery, LLC

2000-06-16  Benjamin Chelf  <chelf@codesourcery.com>

	* c-common.c (c_tree_code_type): New array.
	(c_tree_code_length): Likewise.
	(c_tree_code_name): Likewise.
	(add_c_tree_codes): New function.

	* c-common.h (add_c_tree_codes): Declare.
	(enum c_tree_code): New enum.

	* c-lex.c (init_parse): Added call to add_c_tree_codes.

	* cp/cp-tree.h (enum cplus_tree_code): Changed __DUMMY to
	CP_DUMMY_TREE_CODE. Remove #include "c-common.def".

	* cp/lex.c (cplus_tree_code_type[]): Removed #include "c-common.def".
	(cplus_tree_code_length[]): Likewise.
	(cplus_tree_code_name[]): Likewise.
	(init_parse): Added call to add_c_tree_codes. Changed 
	LAST_AND_UNUSED_TREE_CODE to LAST_C_TREE_CODE.

Index: gcc/c-common.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.c,v
retrieving revision 1.118
diff -c -p -r1.118 c-common.c
*** c-common.c	2000/06/14 05:30:08	1.118
--- c-common.c	2000/06/17 02:33:12
*************** expand_tree_builtin (function, params, c
*** 3962,3964 ****
--- 3962,4013 ----
  
    return NULL_TREE;
  }
+ 
+ /* Tree code classes. */
+ 
+ #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+ 
+ static 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 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 *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 (void)
+ {
+   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 *));
+ }
Index: gcc/c-common.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.h,v
retrieving revision 1.16
diff -c -p -r1.16 c-common.h
*** c-common.h	2000/06/14 17:26:17	1.16
--- c-common.h	2000/06/17 02:33:12
*************** extern tree simple_type_promotes_to		PAR
*** 246,248 ****
--- 246,261 ----
     function ended.  */
  #define STMT_LINENO_FOR_FN_P(NODE) 		\
    (TREE_LANG_FLAG_2 ((NODE)))
+ 
+ 
+ #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
+ 
+ enum c_tree_code {
+   C_DUMMY_TREE_CODE = LAST_AND_UNUSED_TREE_CODE,
+ #include "c-common.def"
+   LAST_C_TREE_CODE
+ };
+ 
+ #undef DEFTREECODE
+ 
+ extern void add_c_tree_codes		        PARAMS ((void));
Index: gcc/c-lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lex.c,v
retrieving revision 1.82
diff -c -p -r1.82 c-lex.c
*** c-lex.c	2000/06/06 21:54:52	1.82
--- c-lex.c	2000/06/17 02:33:12
*************** init_parse (filename)
*** 252,257 ****
--- 252,259 ----
    cpp_token = CPP_DIRECTIVE;
  #endif
  
+   add_c_tree_codes ();
+   
    init_lex ();
    init_pragma ();

Index: gcc/cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.484
diff -c -p -r1.484 cp-tree.h
*** cp-tree.h	2000/06/16 15:35:07	1.484
--- cp-tree.h	2000/06/17 02:33:14
*************** extern void (*back_end_hook) PARAMS ((tr
*** 1250,1257 ****
  /* C++ language-specific tree codes.  */
  #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
  enum cplus_tree_code {
!   __DUMMY = LAST_AND_UNUSED_TREE_CODE,
! #include "c-common.def"
  #include "cp-tree.def"
    LAST_CPLUS_TREE_CODE
  };
--- 1250,1256 ----
  /* C++ language-specific tree codes.  */
  #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
  enum cplus_tree_code {
!   CP_DUMMY_TREE_CODE = LAST_C_TREE_CODE,
  #include "cp-tree.def"
    LAST_CPLUS_TREE_CODE
  };
Index: gcc/cp/lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lex.c,v
retrieving revision 1.207
diff -c -p -r1.207 lex.c
*** lex.c	2000/06/16 07:34:42	1.207
--- lex.c	2000/06/17 02:33:14
*************** get_time_identifier (name)
*** 341,355 ****
    return time_identifier;
  }
  
- /* 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/cp-tree.def for details.  */
  
  #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
  
  static char cplus_tree_code_type[] = {
    'x',
- #include "c-common.def"
  #include "cp-tree.def"
  };
  #undef DEFTREECODE
--- 341,353 ----
    return time_identifier;
  }
  
  
+ /* Tree code classes. */
+ 
  #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
  
  static char cplus_tree_code_type[] = {
    'x',
  #include "cp-tree.def"
  };
  #undef DEFTREECODE
*************** static char cplus_tree_code_type[] = {
*** 362,368 ****
  
  static int cplus_tree_code_length[] = {
    0,
- #include "c-common.def"
  #include "cp-tree.def"
  };
  #undef DEFTREECODE
--- 360,365 ----
*************** static int cplus_tree_code_length[] = {
*** 373,379 ****
  
  static const char *cplus_tree_code_name[] = {
    "@@dummy",
- #include "c-common.def"
  #include "cp-tree.def"
  };
  #undef DEFTREECODE
--- 370,375 ----
*************** init_parse (filename)
*** 583,598 ****
  
    init_tree ();
    init_cplus_expand ();
  
!   memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
  	  cplus_tree_code_type,
! 	  (int)LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
!   memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
  	  cplus_tree_code_length,
! 	  (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof
(int));
!   memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
  	  cplus_tree_code_name,
! 	  (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof
(char *));
  
    init_operators ();
    init_method ();
--- 579,596 ----
  
    init_tree ();
    init_cplus_expand ();
+ 
+   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
*));
  
    init_operators ();
    init_method ();



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