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]

Reorder some tree codes


This patch reorders the _TYPE codes and a few others to allow
range comparison to determine certain kinds of types.  This showed
a 0.25% speed improvement on darwin, and a 2% text size reduction in cc1plus.

booted & tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-12-20  Nathan Sidwell  <nathan@codesourcery.com>

	* system.c (IN_RANGE): Use plain unsigned, not unsigned
	HOST_WIDE_INT.
	* tree.def (VOID_TYPE, INTEGER_TYPE, REAL_TYPE, COMPLEX_TYPE,
	VECTOR_TYPE, OFFSET_TYPE, ENUMERAL_TYPE, BOOLEAN_TYPE, CHAR_TYPE,
	POINTER_TYPE, REFERENCE_TYPE, METHOD_TYPE, FUNCTION_TYPE,
	FILE_TYPE, ARRAY_TYPE, RECORD_TYPE, UNION_TYPE,
	QUAL_UNION_TYPE): Reorder for better code efficiency.
	(CONST_DECL, TYPE_DECL, VAR_DECL, FIELD_DECL, PARM_DECL): Likewise.
	(INDIRECT_REF, ALIGN_INDIRECT_REF, MISALIGNED_INDIRECT_REF): Likewise.
	* tree.h (INDIRECT_REF_P): Use IN_RANGE.
	(IS_TYPE_OR_DECL_P, IS_EXPR_CODE_CLASS, INTEGRAL_TYPE_P,
	FLOAT_TYPE_P, AGGREGATE_TYPE_P, POINTER_TYPE_P): Likewise.

	* cp/cp-tree.def (TEMPLATE_TYPE_PARM,
	BOUND_TEMPLATE_TEMPLATE_PARM, TYPE_OF_TYPE, TYPENAME_TYPE): Reorder 
	for better code efficiency.
	* cp/cp-tree.h (IS_AGGR_TYPE): Use IN_RANGE.
	(CLASS_TYPE_P, IS_AGGR_TYPE_CODE, CAN_HAVE_FULL_LANG_DECL_P,
	INTEGRAL_CODE_P, CP_INTEGRAL_TYPE_P,
	INTEGRAL_OR_ENUMERATION_TYPE_P, ARITHMETIC_TYPE_P, SCALAR_TYPE_P,
	CP_AGGREGATE_TYPE_P, TYPE_PTROB_P, TYPE_REF_OBJ_P, TYPE_PTROBV_P,
	DECL_TEMPLATE_PARM_P): Likewise.

Index: system.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/system.h,v
retrieving revision 1.238
diff -c -3 -p -r1.238 system.h
*** system.h	29 Nov 2004 20:46:11 -0000	1.238
--- system.h	17 Dec 2004 09:32:06 -0000
*************** extern int errno;
*** 179,185 ****
     UPPER.  However the bounds themselves can be either positive or
     negative.  */
  #define IN_RANGE(VALUE, LOWER, UPPER) \
!   ((unsigned HOST_WIDE_INT) ((VALUE) - (LOWER)) <= ((UPPER) - (LOWER)))
  
  /* Infrastructure for defining missing _MAX and _MIN macros.  Note that
     macros defined with these cannot be used in #if.  */
--- 179,185 ----
     UPPER.  However the bounds themselves can be either positive or
     negative.  */
  #define IN_RANGE(VALUE, LOWER, UPPER) \
!   ((unsigned)((VALUE) - (LOWER)) <= ((UPPER) - (LOWER)))
  
  /* Infrastructure for defining missing _MAX and _MIN macros.  Note that
     macros defined with these cannot be used in #if.  */
Index: tree.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.def,v
retrieving revision 1.107
diff -c -3 -p -r1.107 tree.def
*** tree.def	14 Dec 2004 17:24:44 -0000	1.107
--- tree.def	17 Dec 2004 09:32:12 -0000
*************** DEFTREECODE (BLOCK, "block", tcc_excepti
*** 118,148 ****
      ENUMERAL_TYPE, RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE nodes;
      see below.  */
  
! DEFTREECODE (VOID_TYPE, "void_type", tcc_type, 0)
! 	/* The void type in C */
! 
! /* Integer types in all languages, including char in C.
!    Also used for sub-ranges of other discrete types.
!    Has components TYPE_MIN_VALUE, TYPE_MAX_VALUE (expressions, inclusive)
!    and TYPE_PRECISION (number of bits used by this type).
!    In the case of a subrange type in Pascal, the TREE_TYPE
!    of this will point at the supertype (another INTEGER_TYPE,
!    or an ENUMERAL_TYPE, CHAR_TYPE, or BOOLEAN_TYPE).
!    Otherwise, the TREE_TYPE is zero.  */
! DEFTREECODE (INTEGER_TYPE, "integer_type", tcc_type, 0)
! 
! /* C's float and double.  Different floating types are distinguished
!    by machine mode and by the TYPE_SIZE and the TYPE_PRECISION.  */
! DEFTREECODE (REAL_TYPE, "real_type", tcc_type, 0)
! 
! /* Complex number types.  The TREE_TYPE field is the data type
!    of the real and imaginary parts.  */
! DEFTREECODE (COMPLEX_TYPE, "complex_type", tcc_type, 0)
! 
! /* Vector types.  The TREE_TYPE field is the data type of the vector
!    elements.  The TYPE_PRECISION field is the number of subparts of
!    the vector.  */
! DEFTREECODE (VECTOR_TYPE, "vector_type", tcc_type, 0)
  
  /* C enums.  The type node looks just like an INTEGER_TYPE node.
     The symbols for the values of the enum type are defined by
--- 118,133 ----
      ENUMERAL_TYPE, RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE nodes;
      see below.  */
  
! /* The ordering of the following codes is important.  Do
!    not change without updating the macros in tree.h and elsewhere.
!    OFFSET_TYPE, ENUMERAL_TYPE, BOOLEAN_TYPE, CHAR_TYPE, INTEGER_TYPE,
!    REAL_TYPE, POINTER_TYPE.   */
!      
! /* An offset is a pointer relative to an object.
!    The TREE_TYPE field is the type of the object at the offset.
!    The TYPE_OFFSET_BASETYPE points to the node for the type of object
!    that the offset is relative to.  */
! DEFTREECODE (OFFSET_TYPE, "offset_type", tcc_type, 0)
  
  /* C enums.  The type node looks just like an INTEGER_TYPE node.
     The symbols for the values of the enum type are defined by
*************** DEFTREECODE (VECTOR_TYPE, "vector_type",
*** 157,194 ****
     treated similarly.  */
  DEFTREECODE (ENUMERAL_TYPE, "enumeral_type", tcc_type, 0)
  
! /* Pascal's boolean type (true or false are the only values);
!    no special fields needed.  */
  DEFTREECODE (BOOLEAN_TYPE, "boolean_type", tcc_type, 0)
  
! /* CHAR in Pascal; not used in C.
!    No special fields needed.  */
  DEFTREECODE (CHAR_TYPE, "char_type", tcc_type, 0)
  
  /* All pointer-to-x types have code POINTER_TYPE.
     The TREE_TYPE points to the node for the type pointed to.  */
  DEFTREECODE (POINTER_TYPE, "pointer_type", tcc_type, 0)
  
- /* An offset is a pointer relative to an object.
-    The TREE_TYPE field is the type of the object at the offset.
-    The TYPE_OFFSET_BASETYPE points to the node for the type of object
-    that the offset is relative to.  */
- DEFTREECODE (OFFSET_TYPE, "offset_type", tcc_type, 0)
- 
  /* A reference is like a pointer except that it is coerced
     automatically to the value it points to.  Used in C++.  */
  DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0)
  
! /* METHOD_TYPE is the type of a function which takes an extra first
!    argument for "self", which is not present in the declared argument list.
!    The TREE_TYPE is the return type of the method.  The TYPE_METHOD_BASETYPE
!    is the type of "self".  TYPE_ARG_TYPES is the real argument list, which
!    includes the hidden argument for "self".  */
! DEFTREECODE (METHOD_TYPE, "method_type", tcc_type, 0)
  
! /* Used for Pascal; details not determined right now.  */
! DEFTREECODE (FILE_TYPE, "file_type", tcc_type, 0)
  
  /* Types of arrays.  Special fields:
     TREE_TYPE		  Type of an array element.
     TYPE_DOMAIN		  Type to index by.
--- 142,199 ----
     treated similarly.  */
  DEFTREECODE (ENUMERAL_TYPE, "enumeral_type", tcc_type, 0)
  
! /* Boolean type (true or false are the only values).  Looks like an
!    INTEGRAL_TYPE. */
  DEFTREECODE (BOOLEAN_TYPE, "boolean_type", tcc_type, 0)
  
! /* CHAR in Java; not used in C.  Looks like an INTEGRAL_TYPE.  */
  DEFTREECODE (CHAR_TYPE, "char_type", tcc_type, 0)
  
+ /* Integer types in all languages, including char in C.
+    Also used for sub-ranges of other discrete types.
+    Has components TYPE_MIN_VALUE, TYPE_MAX_VALUE (expressions, inclusive)
+    and TYPE_PRECISION (number of bits used by this type).
+    In the case of a subrange type in Pascal, the TREE_TYPE
+    of this will point at the supertype (another INTEGER_TYPE,
+    or an ENUMERAL_TYPE, CHAR_TYPE, or BOOLEAN_TYPE).
+    Otherwise, the TREE_TYPE is zero.  */
+ DEFTREECODE (INTEGER_TYPE, "integer_type", tcc_type, 0)
+ 
+ /* C's float and double.  Different floating types are distinguished
+    by machine mode and by the TYPE_SIZE and the TYPE_PRECISION.  */
+ DEFTREECODE (REAL_TYPE, "real_type", tcc_type, 0)
+ 
+ /* The ordering of the following codes is important.  Do not
+    change without updating the macros in tree.h and elsewhere.
+    POINTER_TYPE, REFERENCE_TYPE.  Note that this range overlaps the
+    previous range of ordered types. */
+      
  /* All pointer-to-x types have code POINTER_TYPE.
     The TREE_TYPE points to the node for the type pointed to.  */
  DEFTREECODE (POINTER_TYPE, "pointer_type", tcc_type, 0)
  
  /* A reference is like a pointer except that it is coerced
     automatically to the value it points to.  Used in C++.  */
  DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0)
  
! /* The ordering of the following codes is important.  Do not
!    change without updating the macros in tree.h and elsewhere.
!    COMPLEX_TYPE, VECTOR_TYPE, ARRAY_TYPE.  */
!      
! /* Complex number types.  The TREE_TYPE field is the data type
!    of the real and imaginary parts.  */
! DEFTREECODE (COMPLEX_TYPE, "complex_type", tcc_type, 0)
  
! /* Vector types.  The TREE_TYPE field is the data type of the vector
!    elements.  The TYPE_PRECISION field is the number of subparts of
!    the vector.  */
! DEFTREECODE (VECTOR_TYPE, "vector_type", tcc_type, 0)
  
+ /* The ordering of the following aggregate types is important.  Do not
+    change without updating the macros in tree.h and elsewhere.
+    ARRAY_TYPE, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE.  Note that
+    this range overlaps the previous range.  */
+      
  /* Types of arrays.  Special fields:
     TREE_TYPE		  Type of an array element.
     TYPE_DOMAIN		  Type to index by.
*************** DEFTREECODE (UNION_TYPE, "union_type", t
*** 222,227 ****
--- 227,239 ----
     the union.  */
  DEFTREECODE (QUAL_UNION_TYPE, "qual_union_type", tcc_type, 0)
  
+ /* The ordering of the following codes is important.  Do not
+    change without updating the macros in tree.h and elsewhere.
+    VOID_TYPE, FUNCTION_TYPE, METHOD_TYPE.  */
+      
+ /* The void type in C */
+ DEFTREECODE (VOID_TYPE, "void_type", tcc_type, 0)
+ 
  /* Type of functions.  Special fields:
     TREE_TYPE		    type of value returned.
     TYPE_ARG_TYPES      list of types of arguments expected.
*************** DEFTREECODE (QUAL_UNION_TYPE, "qual_unio
*** 230,235 ****
--- 242,257 ----
     have code FUNCTION_TYPE also, but then TREE_TYPE is zero or void type.  */
  DEFTREECODE (FUNCTION_TYPE, "function_type", tcc_type, 0)
  
+ /* METHOD_TYPE is the type of a function which takes an extra first
+    argument for "self", which is not present in the declared argument list.
+    The TREE_TYPE is the return type of the method.  The TYPE_METHOD_BASETYPE
+    is the type of "self".  TYPE_ARG_TYPES is the real argument list, which
+    includes the hidden argument for "self".  */
+ DEFTREECODE (METHOD_TYPE, "method_type", tcc_type, 0)
+ 
+ /* Used for Pascal; details not determined right now.  */
+ DEFTREECODE (FILE_TYPE, "file_type", tcc_type, 0)
+ 
  /* This is a language-specific kind of type.
     Its meaning is defined by the language front end.
     layout_type does not know how to lay this out,
*************** DEFTREECODE (STRING_CST, "string_cst", t
*** 323,334 ****
  
  DEFTREECODE (FUNCTION_DECL, "function_decl", tcc_declaration, 0)
  DEFTREECODE (LABEL_DECL, "label_decl", tcc_declaration, 0)
! DEFTREECODE (CONST_DECL, "const_decl", tcc_declaration, 0)
! DEFTREECODE (TYPE_DECL, "type_decl", tcc_declaration, 0)
  DEFTREECODE (VAR_DECL, "var_decl", tcc_declaration, 0)
  DEFTREECODE (PARM_DECL, "parm_decl", tcc_declaration, 0)
  DEFTREECODE (RESULT_DECL, "result_decl", tcc_declaration, 0)
- DEFTREECODE (FIELD_DECL, "field_decl", tcc_declaration, 0)
  
  /* A namespace declaration.  Namespaces appear in DECL_CONTEXT of other
     _DECLs, providing a hierarchy of names.  */
--- 345,359 ----
  
  DEFTREECODE (FUNCTION_DECL, "function_decl", tcc_declaration, 0)
  DEFTREECODE (LABEL_DECL, "label_decl", tcc_declaration, 0)
! /* The ordering of the following codes is important.  Do not change
!    without altering the macros in tree.h and elsewhere.  FIELD_DECL,
!    VAR_DECL, CONST_DECL, PARM_DECL, TYPE_DECL.  */
! DEFTREECODE (FIELD_DECL, "field_decl", tcc_declaration, 0)
  DEFTREECODE (VAR_DECL, "var_decl", tcc_declaration, 0)
+ DEFTREECODE (CONST_DECL, "const_decl", tcc_declaration, 0)
  DEFTREECODE (PARM_DECL, "parm_decl", tcc_declaration, 0)
+ DEFTREECODE (TYPE_DECL, "type_decl", tcc_declaration, 0)
  DEFTREECODE (RESULT_DECL, "result_decl", tcc_declaration, 0)
  
  /* A namespace declaration.  Namespaces appear in DECL_CONTEXT of other
     _DECLs, providing a hierarchy of names.  */
*************** DEFTREECODE (COMPONENT_REF, "component_r
*** 357,362 ****
--- 382,391 ----
     BIT_FIELD_REF_UNSIGNED says which.  */
  DEFTREECODE (BIT_FIELD_REF, "bit_field_ref", tcc_reference, 3)
  
+ /* The ordering of the following codes is important.  Do
+    not change without updating the macros in tree.h and elsewhere.
+    INDIRECT_REF, ALIGN_INDIRECT_REF, MISALIGNED_INDIRECT_REF.  */
+ 
  /* C unary `*' or Pascal `^'.  One operand, an expression for a pointer.  */
  DEFTREECODE (INDIRECT_REF, "indirect_ref", tcc_reference, 1)
  
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.666
diff -c -3 -p -r1.666 tree.h
*** tree.h	9 Dec 2004 10:54:38 -0000	1.666
--- tree.h	17 Dec 2004 09:32:19 -0000
*************** enum tree_code {
*** 51,56 ****
--- 51,57 ----
  enum tree_code_class {
    tcc_exceptional, /* An exceptional code (fits no category).  */
    tcc_constant,    /* A constant.  */
+   /* Order of tcc_type and tcc_declaration is important.  */
    tcc_type,        /* A type object code.  */
    tcc_declaration, /* A declaration (also serving as variable refs).  */
    tcc_reference,   /* A reference to storage.  */
*************** extern const enum tree_code_class tree_c
*** 98,106 ****
  
  /* Nonzero if CODE represents a INDIRECT_REF.  */
  #define INDIRECT_REF_P(CODE)\
!   (TREE_CODE (CODE) == INDIRECT_REF \
!    || TREE_CODE (CODE) == MISALIGNED_INDIRECT_REF \
!    || TREE_CODE (CODE) == ALIGN_INDIRECT_REF)
  
  /* Nonzero if CODE represents a reference.  */
  
--- 99,105 ----
  
  /* Nonzero if CODE represents a INDIRECT_REF.  */
  #define INDIRECT_REF_P(CODE)\
!   (IN_RANGE (TREE_CODE (CODE), INDIRECT_REF, MISALIGNED_INDIRECT_REF))
  
  /* Nonzero if CODE represents a reference.  */
  
*************** extern const enum tree_code_class tree_c
*** 139,151 ****
  /* Returns nonzero iff CODE represents a type or declaration.  */
  
  #define IS_TYPE_OR_DECL_P(CODE)\
! 	(TYPE_P (CODE) || DECL_P (CODE))
  
  /* Returns nonzero iff CLASS is the tree-code class of an
     expression.  */
  
  #define IS_EXPR_CODE_CLASS(CLASS)\
! 	(((CLASS) >= tcc_reference) && ((CLASS) <= tcc_expression))
  
  /* Returns nonzero iff NODE is an expression of some kind.  */
  
--- 138,151 ----
  /* Returns nonzero iff CODE represents a type or declaration.  */
  
  #define IS_TYPE_OR_DECL_P(CODE)\
! 	(IN_RANGE (TREE_CODE_CLASS (TREE_CODE (CODE)), \
! 	 tcc_type, tcc_declaration))
  
  /* Returns nonzero iff CLASS is the tree-code class of an
     expression.  */
  
  #define IS_EXPR_CODE_CLASS(CLASS)\
! 	(IN_RANGE (CLASS, tcc_reference, tcc_expression))
  
  /* Returns nonzero iff NODE is an expression of some kind.  */
  
*************** extern void tree_operand_check_failed (i
*** 740,747 ****
     include COMPLEX types here.  */
  
  #define INTEGRAL_TYPE_P(TYPE)  \
!   (TREE_CODE (TYPE) == INTEGER_TYPE || TREE_CODE (TYPE) == ENUMERAL_TYPE  \
!    || TREE_CODE (TYPE) == BOOLEAN_TYPE || TREE_CODE (TYPE) == CHAR_TYPE)
  
  /* Nonzero if TYPE represents a scalar floating-point type.  */
  
--- 740,746 ----
     include COMPLEX types here.  */
  
  #define INTEGRAL_TYPE_P(TYPE)  \
!   (IN_RANGE (TREE_CODE (TYPE), ENUMERAL_TYPE, INTEGER_TYPE))
  
  /* Nonzero if TYPE represents a scalar floating-point type.  */
  
*************** extern void tree_operand_check_failed (i
*** 763,782 ****
     and vector floating-point types.  */
  
  #define FLOAT_TYPE_P(TYPE)		\
!   (SCALAR_FLOAT_TYPE_P (TYPE) || COMPLEX_FLOAT_TYPE_P (TYPE)	\
!    || VECTOR_FLOAT_TYPE_P (TYPE))
  
  /* Nonzero if TYPE represents an aggregate (multi-component) type.  */
  
  #define AGGREGATE_TYPE_P(TYPE) \
!   (TREE_CODE (TYPE) == ARRAY_TYPE || TREE_CODE (TYPE) == RECORD_TYPE \
!    || TREE_CODE (TYPE) == UNION_TYPE || TREE_CODE (TYPE) == QUAL_UNION_TYPE)
  
  /* Nonzero if TYPE represents a pointer or reference type.
     (It should be renamed to INDIRECT_TYPE_P.)  */
  
  #define POINTER_TYPE_P(TYPE) \
!   (TREE_CODE (TYPE) == POINTER_TYPE || TREE_CODE (TYPE) == REFERENCE_TYPE)
  
  /* Nonzero if this type is a complete type.  */
  #define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE)
--- 762,781 ----
     and vector floating-point types.  */
  
  #define FLOAT_TYPE_P(TYPE)		\
!   (SCALAR_FLOAT_TYPE_P (TYPE)		\
!    || (IN_RANGE (TREE_CODE (TYPE), COMPLEX_TYPE, VECTOR_TYPE)	\
!        && SCALAR_FLOAT_TYPE_P (TREE_TYPE (TYPE))))
  
  /* Nonzero if TYPE represents an aggregate (multi-component) type.  */
  
  #define AGGREGATE_TYPE_P(TYPE) \
!   (IN_RANGE (TREE_CODE (TYPE), ARRAY_TYPE, QUAL_UNION_TYPE))
  
  /* Nonzero if TYPE represents a pointer or reference type.
     (It should be renamed to INDIRECT_TYPE_P.)  */
  
  #define POINTER_TYPE_P(TYPE) \
!   (IN_RANGE (TREE_CODE (TYPE), POINTER_TYPE, REFERENCE_TYPE))
  
  /* Nonzero if this type is a complete type.  */
  #define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE)
Index: cp/cp-tree.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.def,v
retrieving revision 1.91
diff -c -3 -p -r1.91 cp-tree.def
*** cp/cp-tree.def	29 Nov 2004 20:10:07 -0000	1.91
--- cp/cp-tree.def	17 Dec 2004 09:32:28 -0000
*************** DEFTREECODE (TEMPLATE_DECL, "template_de
*** 159,168 ****
     worrying about instantiating things.  */
  DEFTREECODE (TEMPLATE_PARM_INDEX, "template_parm_index", tcc_exceptional, 0)
  
- /* Index into a template parameter list.  This parameter must be a type.
-    The type.value field will be a TEMPLATE_PARM_INDEX.  */
- DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", tcc_type, 0)
- 
  /* Index into a template parameter list for template template parameters.
     This parameter must be a type.  The TYPE_FIELDS value will be a 
     TEMPLATE_PARM_INDEX.
--- 159,164 ----
*************** DEFTREECODE (TEMPLATE_TYPE_PARM, "templa
*** 172,183 ****
     and TYPE_NAME is a TEMPLATE_DECL.  */
  DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", tcc_type, 0)
  
! /* Like TEMPLATE_TEMPLATE_PARM it is used with bound template arguments 
!    like TT<int>.
!    In this case, TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO contains the
!    template name and its bound arguments.  TYPE_NAME is a TYPE_DECL.  */
! DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm",
! 	     tcc_type, 0)
  
  /* A type designated by `typename T::t'.  TYPE_CONTEXT is `T',
     TYPE_NAME is an IDENTIFIER_NODE for `t'.  If the type was named via
--- 168,180 ----
     and TYPE_NAME is a TEMPLATE_DECL.  */
  DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", tcc_type, 0)
  
! /* The ordering of the following codes is important.  Do not change
!    without updating the macros in cp-tree.h.  TEMPLATE_TYPE_PARM,
!    TYPENAME_TYPE, TYPEOF_TYPE, BOUND_TEMPLATE_TEMPLATE_PARM.  */
!      
! /* Index into a template parameter list.  This parameter must be a type.
!    The type.value field will be a TEMPLATE_PARM_INDEX.  */
! DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", tcc_type, 0)
  
  /* A type designated by `typename T::t'.  TYPE_CONTEXT is `T',
     TYPE_NAME is an IDENTIFIER_NODE for `t'.  If the type was named via
*************** DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PAR
*** 185,199 ****
     TREE_TYPE is always NULL.  */
  DEFTREECODE (TYPENAME_TYPE, "typename_type", tcc_type, 0)
  
  /* For template template argument of the form `T::template C'.
     TYPE_CONTEXT is `T', the template parameter dependent object.
     TYPE_NAME is an IDENTIFIER_NODE for `C', the member class template.  */
  DEFTREECODE (UNBOUND_CLASS_TEMPLATE, "unbound_class_template", tcc_type, 0)
  
- /* A type designated by `__typeof (expr)'.  TYPEOF_TYPE_EXPR is the
-    expression in question.  */
- DEFTREECODE (TYPEOF_TYPE, "typeof_type", tcc_type, 0)
- 
  /* A using declaration.  DECL_INITIAL contains the specified scope.  
     This is not an alias, but is later expanded into multiple aliases.
     The decl will have a NULL_TYPE iff the scope is a dependent scope,
--- 182,203 ----
     TREE_TYPE is always NULL.  */
  DEFTREECODE (TYPENAME_TYPE, "typename_type", tcc_type, 0)
  
+ /* A type designated by `__typeof (expr)'.  TYPEOF_TYPE_EXPR is the
+    expression in question.  */
+ DEFTREECODE (TYPEOF_TYPE, "typeof_type", tcc_type, 0)
+ 
+ /* Like TEMPLATE_TEMPLATE_PARM it is used with bound template arguments 
+    like TT<int>.
+    In this case, TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO contains the
+    template name and its bound arguments.  TYPE_NAME is a TYPE_DECL.  */
+ DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm",
+ 	     tcc_type, 0)
+ 
  /* For template template argument of the form `T::template C'.
     TYPE_CONTEXT is `T', the template parameter dependent object.
     TYPE_NAME is an IDENTIFIER_NODE for `C', the member class template.  */
  DEFTREECODE (UNBOUND_CLASS_TEMPLATE, "unbound_class_template", tcc_type, 0)
  
  /* A using declaration.  DECL_INITIAL contains the specified scope.  
     This is not an alias, but is later expanded into multiple aliases.
     The decl will have a NULL_TYPE iff the scope is a dependent scope,
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.1081
diff -c -3 -p -r1.1081 cp-tree.h
*** cp/cp-tree.h	16 Dec 2004 11:03:17 -0000	1.1081
--- cp/cp-tree.h	17 Dec 2004 09:32:41 -0000
*************** enum languages { lang_c, lang_cplusplus,
*** 867,876 ****
     this macro has nothing to do with the definition of aggregate given
     in the standard.  Think of this macro as MAYBE_CLASS_TYPE_P.  */
  #define IS_AGGR_TYPE(T)					\
!   (TREE_CODE (T) == TEMPLATE_TYPE_PARM			\
!    || TREE_CODE (T) == TYPENAME_TYPE			\
!    || TREE_CODE (T) == TYPEOF_TYPE			\
!    || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM	\
     || TYPE_LANG_FLAG_5 (T))
  
  /* Set IS_AGGR_TYPE for T to VAL.  T must be a class, struct, or
--- 867,873 ----
     this macro has nothing to do with the definition of aggregate given
     in the standard.  Think of this macro as MAYBE_CLASS_TYPE_P.  */
  #define IS_AGGR_TYPE(T)					\
!   (IN_RANGE (TREE_CODE (T), TEMPLATE_TYPE_PARM, BOUND_TEMPLATE_TEMPLATE_PARM) \
     || TYPE_LANG_FLAG_5 (T))
  
  /* Set IS_AGGR_TYPE for T to VAL.  T must be a class, struct, or
*************** enum languages { lang_c, lang_cplusplus,
*** 881,889 ****
  /* Nonzero if T is a class type.  Zero for template type parameters,
     typename types, and so forth.  */
  #define CLASS_TYPE_P(T) \
!   (IS_AGGR_TYPE_CODE (TREE_CODE (T)) && IS_AGGR_TYPE (T))
  
! #define IS_AGGR_TYPE_CODE(T)	((T) == RECORD_TYPE || (T) == UNION_TYPE)
  #define TAGGED_TYPE_P(T) \
    (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
  #define IS_OVERLOAD_TYPE(T) TAGGED_TYPE_P (T)
--- 878,887 ----
  /* Nonzero if T is a class type.  Zero for template type parameters,
     typename types, and so forth.  */
  #define CLASS_TYPE_P(T) \
!   (IS_AGGR_TYPE_CODE (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))
  
! #define IS_AGGR_TYPE_CODE(T)	\
!   (IN_RANGE (T, RECORD_TYPE, UNION_TYPE))
  #define TAGGED_TYPE_P(T) \
    (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
  #define IS_OVERLOAD_TYPE(T) TAGGED_TYPE_P (T)
*************** struct lang_type GTY(())
*** 1486,1495 ****
     a lang_decl (which has lang_decl_flags as its initial prefix).
     This macro is nonzero for tree nodes whose DECL_LANG_SPECIFIC is
     the full lang_decl, and not just lang_decl_flags.  */
! #define CAN_HAVE_FULL_LANG_DECL_P(NODE)		\
!   (!(TREE_CODE (NODE) == VAR_DECL		\
!      || TREE_CODE (NODE) == CONST_DECL		\
!      || TREE_CODE (NODE) == FIELD_DECL		\
       || TREE_CODE (NODE) == USING_DECL))
  
  struct lang_decl_flags GTY(())
--- 1484,1491 ----
     a lang_decl (which has lang_decl_flags as its initial prefix).
     This macro is nonzero for tree nodes whose DECL_LANG_SPECIFIC is
     the full lang_decl, and not just lang_decl_flags.  */
! #define CAN_HAVE_FULL_LANG_DECL_P(NODE)				\
!   (!(IN_RANGE (TREE_CODE (NODE), FIELD_DECL, CONST_DECL)	\
       || TREE_CODE (NODE) == USING_DECL))
  
  struct lang_decl_flags GTY(())
*************** struct lang_decl GTY(())
*** 2315,2321 ****
    (decl_linkage (DECL) == lk_external)
  
  #define INTEGRAL_CODE_P(CODE) \
!   ((CODE) == INTEGER_TYPE || (CODE) == ENUMERAL_TYPE || (CODE) == BOOLEAN_TYPE)
  
  /* [basic.fundamental]
  
--- 2311,2317 ----
    (decl_linkage (DECL) == lk_external)
  
  #define INTEGRAL_CODE_P(CODE) \
!   (IN_RANGE (CODE, ENUMERAL_TYPE, INTEGER_TYPE))
  
  /* [basic.fundamental]
  
*************** struct lang_decl GTY(())
*** 2325,2353 ****
     Note that INTEGRAL_TYPE_P, as defined in tree.h, allows enumeration
     types as well, which is incorrect in C++.  */
  #define CP_INTEGRAL_TYPE_P(TYPE)		\
!   (TREE_CODE (TYPE) == BOOLEAN_TYPE		\
!    || TREE_CODE (TYPE) == INTEGER_TYPE)
  
  /* Returns true if TYPE is an integral or enumeration name.  */
  #define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
!   (CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == ENUMERAL_TYPE)
  
  /* [basic.fundamental]
  
     Integral and floating types are collectively called arithmetic
     types.  */
  #define ARITHMETIC_TYPE_P(TYPE) \
!   (CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE)
  
  /* [basic.types]
  
     Arithmetic types, enumeration types, pointer types, and
!    pointer-to-member types, are collectively called scalar types.  */
! #define SCALAR_TYPE_P(TYPE)			\
!   (ARITHMETIC_TYPE_P (TYPE)			\
!    || TREE_CODE (TYPE) == ENUMERAL_TYPE		\
!    || TYPE_PTR_P (TYPE)				\
!    || TYPE_PTR_TO_MEMBER_P (TYPE))
  
  /* [dcl.init.aggr]
  
--- 2321,2347 ----
     Note that INTEGRAL_TYPE_P, as defined in tree.h, allows enumeration
     types as well, which is incorrect in C++.  */
  #define CP_INTEGRAL_TYPE_P(TYPE)		\
!   (IN_RANGE (TREE_CODE (TYPE), BOOLEAN_TYPE, INTEGER_TYPE))
  
  /* Returns true if TYPE is an integral or enumeration name.  */
  #define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
!   (IN_RANGE (TREE_CODE (TYPE), ENUMERAL_TYPE, INTEGER_TYPE))
  
  /* [basic.fundamental]
  
     Integral and floating types are collectively called arithmetic
     types.  */
  #define ARITHMETIC_TYPE_P(TYPE) \
!   (IN_RANGE (TREE_CODE (TYPE), BOOLEAN_TYPE, REAL_TYPE))
  
  /* [basic.types]
  
     Arithmetic types, enumeration types, pointer types, and
!    pointer-to-member types, are collectively called scalar types.
!    The scalar type codes are between OFFSET_TYPE and POINTER_TYPE.  */
! #define SCALAR_TYPE_P(TYPE)					\
!   (IN_RANGE (TREE_CODE (TYPE), OFFSET_TYPE, POINTER_TYPE)	\
!    || TYPE_PTRMEMFUNC_P (TYPE))
  
  /* [dcl.init.aggr]
  
*************** struct lang_decl GTY(())
*** 2356,2366 ****
     base classes, and no virtual functions.
  
     As an extension, we also treat vectors as aggregates.  */
! #define CP_AGGREGATE_TYPE_P(TYPE)		\
!   (TREE_CODE (TYPE) == ARRAY_TYPE		\
!    || TREE_CODE (TYPE) == VECTOR_TYPE		\
!    || (CLASS_TYPE_P (TYPE)			\
!        && !CLASSTYPE_NON_AGGREGATE (TYPE)))
  
  /* Nonzero for a class type means that the class type has a
     user-declared constructor.  */
--- 2350,2358 ----
     base classes, and no virtual functions.
  
     As an extension, we also treat vectors as aggregates.  */
! #define CP_AGGREGATE_TYPE_P(TYPE)				\
!   (IN_RANGE (TREE_CODE (TYPE), VECTOR_TYPE, ARRAY_TYPE)		\
!    || (CLASS_TYPE_P (TYPE) && !CLASSTYPE_NON_AGGREGATE (TYPE)))
  
  /* Nonzero for a class type means that the class type has a
     user-declared constructor.  */
*************** struct lang_decl GTY(())
*** 2444,2461 ****
  /* Returns true if NODE is a pointer to an object.  */
  #define TYPE_PTROB_P(NODE)				\
    (TYPE_PTR_P (NODE) 					\
!    && TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE	\
!    && TREE_CODE (TREE_TYPE (NODE)) != METHOD_TYPE	\
!    && TREE_CODE (TREE_TYPE (NODE)) != VOID_TYPE)
  /* Returns true if NODE is a reference to an object.  */
  #define TYPE_REF_OBJ_P(NODE)				\
    (TREE_CODE (NODE) == REFERENCE_TYPE			\
!    && TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE	\
!    && TREE_CODE (TREE_TYPE (NODE)) != METHOD_TYPE	\
!    && TREE_CODE (TREE_TYPE (NODE)) != VOID_TYPE)
  /* Returns true if NODE is a pointer to an object, or a pointer to void.  */
  #define TYPE_PTROBV_P(NODE)						\
!   (TYPE_PTR_P (NODE) && TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE)
  /* Returns true if NODE is a pointer to function.  */
  #define TYPE_PTRFN_P(NODE)				\
    (TREE_CODE (NODE) == POINTER_TYPE			\
--- 2436,2450 ----
  /* Returns true if NODE is a pointer to an object.  */
  #define TYPE_PTROB_P(NODE)				\
    (TYPE_PTR_P (NODE) 					\
!    && !IN_RANGE (TREE_CODE (TREE_TYPE (NODE)), VOID_TYPE, METHOD_TYPE))
  /* Returns true if NODE is a reference to an object.  */
  #define TYPE_REF_OBJ_P(NODE)				\
    (TREE_CODE (NODE) == REFERENCE_TYPE			\
!    && !IN_RANGE (TREE_CODE (TREE_TYPE (NODE)), VOID_TYPE, METHOD_TYPE))
  /* Returns true if NODE is a pointer to an object, or a pointer to void.  */
  #define TYPE_PTROBV_P(NODE)						\
!   (TYPE_PTR_P (NODE) 					\
!    && !IN_RANGE (TREE_CODE (TREE_TYPE (NODE)), FUNCTION_TYPE, METHOD_TYPE))
  /* Returns true if NODE is a pointer to function.  */
  #define TYPE_PTRFN_P(NODE)				\
    (TREE_CODE (NODE) == POINTER_TYPE			\
*************** struct lang_decl GTY(())
*** 2680,2690 ****
  #define DECL_TEMPLATE_SPECIALIZATIONS(NODE)     DECL_SIZE (NODE)
  
  /* Nonzero for a DECL which is actually a template parameter.  */
! #define DECL_TEMPLATE_PARM_P(NODE)		\
!   (DECL_LANG_FLAG_0 (NODE)			\
!    && (TREE_CODE (NODE) == CONST_DECL		\
!        || TREE_CODE (NODE) == PARM_DECL		\
!        || TREE_CODE (NODE) == TYPE_DECL		\
         || TREE_CODE (NODE) == TEMPLATE_DECL))
  
  /* Mark NODE as a template parameter.  */
--- 2669,2677 ----
  #define DECL_TEMPLATE_SPECIALIZATIONS(NODE)     DECL_SIZE (NODE)
  
  /* Nonzero for a DECL which is actually a template parameter.  */
! #define DECL_TEMPLATE_PARM_P(NODE)				\
!   (DECL_LANG_FLAG_0 (NODE)					\
!    && (IN_RANGE (TREE_CODE (NODE), CONST_DECL, TYPE_DECL)	\
         || TREE_CODE (NODE) == TEMPLATE_DECL))
  
  /* Mark NODE as a template parameter.  */

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