PATH: add integer_types array

Mark Mitchell mark@codesourcery.com
Sat Mar 18 16:41:00 GMT 2000


This patch breaks out the C integer types int a separate array in the
front-end, and gives each a corresonding enumeral, so that it's easy
to walk through the various integer types supported by the compiler.
One use of this will show up in my next C++ patch.

Bootstrapped and tested on i686-pc-linux-gnu.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-03-18  Mark Mitchell  <mark@codesourcery.com>

	* tree.h (tree_index): Remove enumerals for integer types.
	(integer_type_kind): New type.
	(integer_types): New variable.
	(char_type_node): Adjust.
	(signed_char_type_node): Likewise.
	(unsigned_char_type_node): Likewise.
	(short_integer_type_node): Likewise.
	(short_unsigned_type_node): Likewise.
	(integer_type_node): Likewise.
	(unsigned_type_node): Likewise.
	(long_integer_type_node): Likewise.
	(long_unsigned_type_node): Likewise.
	(long_long_integer_type_node): Likewise.
	(long_long_unsigned_type_node): Likewise.
	* tree.c (integer_types): New variable.
	(init_obstacks): Register it as a root.

Index: tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.c,v
retrieving revision 1.125
diff -c -p -r1.125 tree.c
*** tree.c	2000/03/17 22:40:45	1.125
--- tree.c	2000/03/19 00:31:59
*************** static char *built_in_filename;
*** 296,301 ****
--- 296,302 ----
  #define BUILT_IN_FILENAME ("<built-in>")
  
  tree global_trees[TI_MAX];
+ tree integer_types[itk_none];
  
  /* Init the principal obstacks.  */
  
*************** init_obstacks ()
*** 333,338 ****
--- 334,340 ----
  		sizeof type_hash_table / sizeof type_hash_table [0],
  		sizeof type_hash_table[0], mark_type_hash);
    ggc_add_tree_root (global_trees, TI_MAX);
+   ggc_add_tree_root (integer_types, itk_none);
  }
  
  void
Index: tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.h,v
retrieving revision 1.144
diff -c -p -r1.144 tree.h
*** tree.h	2000/03/17 22:40:45	1.144
--- tree.h	2000/03/19 00:32:02
*************** enum tree_index
*** 1515,1532 ****
    TI_UINTDI_TYPE,
    TI_UINTTI_TYPE,
      
-   TI_CHAR_TYPE,
-   TI_SIGNED_CHAR_TYPE,
-   TI_UNSIGNED_CHAR_TYPE,
-   TI_INTEGER_TYPE,
-   TI_UNSIGNED_TYPE,
-   TI_SHORT_INTEGER_TYPE,
-   TI_SHORT_UNSIGNED_TYPE,
-   TI_LONG_INTEGER_TYPE,
-   TI_LONG_UNSIGNED_TYPE,
-   TI_LONG_LONG_INTEGER_TYPE,
-   TI_LONG_LONG_UNSIGNED_TYPE,
- 
    TI_INTEGER_ZERO,
    TI_INTEGER_ONE,
    TI_NULL_POINTER,
--- 1515,1520 ----
*************** extern tree global_trees[TI_MAX];
*** 1568,1585 ****
  #define unsigned_intDI_type_node	global_trees[TI_UINTDI_TYPE]
  #define unsigned_intTI_type_node	global_trees[TI_UINTTI_TYPE]
  
- #define char_type_node			global_trees[TI_CHAR_TYPE]
- #define signed_char_type_node		global_trees[TI_SIGNED_CHAR_TYPE]
- #define unsigned_char_type_node		global_trees[TI_UNSIGNED_CHAR_TYPE]
- #define short_integer_type_node		global_trees[TI_SHORT_INTEGER_TYPE]
- #define short_unsigned_type_node	global_trees[TI_SHORT_UNSIGNED_TYPE]
- #define integer_type_node		global_trees[TI_INTEGER_TYPE]
- #define unsigned_type_node		global_trees[TI_UNSIGNED_TYPE]
- #define long_integer_type_node		global_trees[TI_LONG_INTEGER_TYPE]
- #define long_unsigned_type_node		global_trees[TI_LONG_UNSIGNED_TYPE]
- #define long_long_integer_type_node	global_trees[TI_LONG_LONG_INTEGER_TYPE]
- #define long_long_unsigned_type_node	global_trees[TI_LONG_LONG_UNSIGNED_TYPE]
- 
  #define integer_zero_node		global_trees[TI_INTEGER_ZERO]
  #define integer_one_node		global_trees[TI_INTEGER_ONE]
  #define size_zero_node			global_trees[TI_SIZE_ZERO]
--- 1556,1561 ----
*************** extern tree global_trees[TI_MAX];
*** 1602,1607 ****
--- 1578,1620 ----
  #define const_ptr_type_node		global_trees[TI_CONST_PTR_TYPE]
  #define ptrdiff_type_node		global_trees[TI_PTRDIFF_TYPE]
  #define va_list_type_node		global_trees[TI_VA_LIST_TYPE]
+ 
+ /* An enumeration of the standard C integer types.  These must be
+    ordered so that shorter types appear before longer ones.  */
+ enum integer_type_kind 
+ {
+   itk_char,
+   itk_signed_char,
+   itk_unsigned_char,
+   itk_short,
+   itk_unsigned_short,
+   itk_int,
+   itk_unsigned_int,
+   itk_long,
+   itk_unsigned_long,
+   itk_long_long,
+   itk_unsigned_long_long,
+   itk_none
+ };
+ 
+ typedef enum integer_type_kind integer_type_kind;
+ 
+ /* The standard C integer types.  Use integer_type_kind to index into
+    this array.  */
+ extern tree integer_types[itk_none];
+ 
+ #define char_type_node			integer_types[itk_char]
+ #define signed_char_type_node		integer_types[itk_signed_char]
+ #define unsigned_char_type_node		integer_types[itk_unsigned_char]
+ #define short_integer_type_node		integer_types[itk_short]
+ #define short_unsigned_type_node	integer_types[itk_unsigned_short]
+ #define integer_type_node		integer_types[itk_int]
+ #define unsigned_type_node		integer_types[itk_unsigned_int]
+ #define long_integer_type_node		integer_types[itk_long]
+ #define long_unsigned_type_node		integer_types[itk_unsigned_long]
+ #define long_long_integer_type_node	integer_types[itk_long_long]
+ #define long_long_unsigned_type_node	integer_types[itk_unsigned_long_long]
+ 
  
  #define NULL_TREE (tree) NULL
  


More information about the Gcc-patches mailing list