From 38b3627d6fcedf4e1b99e988440c1c366f6dba10 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan@codesourcery.com>
Date: Tue, 21 Dec 2004 17:43:27 +0000
Subject: system.c (IN_RANGE): Use plain unsigned, not unsigned HOST_WIDE_INT.

	* 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): Reorder checks for better optimization.
	(IS_EXPR_CODE_CLASS): Use IN_RANGE.
	(INTEGRAL_TYPE_P, FLOAT_TYPE_P): Reorder checks for better
	optimization.

	* 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 (CLASS_TYPE_P): Short circuit IS_AGGR_TYPE check.
	(CAN_HAVE_FULL_LANG_DECL_P): Reorder for better optimization.
	(INTEGRAL_CODE_P, CP_INTEGRAL_TYPE_P,
	INTEGRAL_OR_ENUMERATION_TYPE_P, SCALAR_TYPE_P,
	CP_AGGREGATE_TYPE_P, TYPE_PTROB_P, TYPE_REF_OBJ_P,
	TYPE_PTROBV_P): Likewise.

From-SVN: r92463
---
 gcc/tree.def | 129 +++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 82 insertions(+), 47 deletions(-)

(limited to 'gcc/tree.def')

diff --git a/gcc/tree.def b/gcc/tree.def
index 3fc39e5..b69dfcc 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -28,7 +28,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    different structures, and the size is determined by the tree_union
    member structure; the 4th element should be zero.  Languages that
    define language-specific tcc_exceptional or tcc_constant codes must
-   define the tree_size langhook to say how big they are.  */
+   define the tree_size langhook to say how big they are.
+
+   These tree codes have been sorted so that the macros in tree.h that
+   check for various tree codes are optimized into range checks.  This
+   gives a measureable performance improvement.  When adding a new
+   code, consider its placement in relation to the other codes.  */
 
 /* Any erroneous construct is parsed into a node of this type.
    This type of node is accepted without complaint in all contexts
@@ -118,31 +123,16 @@ DEFTREECODE (BLOCK, "block", tcc_exceptional, 0)
     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)
+/* The ordering of the following codes is optimized for the checking
+   macros in tree.h.  Changing the order will degrade the speed of the
+   compiler.  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
@@ -157,38 +147,58 @@ DEFTREECODE (VECTOR_TYPE, "vector_type", tcc_type, 0)
    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.  */
+/* Boolean type (true or false are the only values).  Looks like an
+   INTEGRAL_TYPE. */
 DEFTREECODE (BOOLEAN_TYPE, "boolean_type", tcc_type, 0)
 
-/* CHAR in Pascal; not used in C.
-   No special fields needed.  */
+/* 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 optimized for the checking
+   macros in tree.h.  Changing the order will degrade the speed of the
+   compiler.  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)
 
-/* 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)
+/* The ordering of the following codes is optimized for the checking
+   macros in tree.h.  Changing the order will degrade the speed of the
+   compiler.  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)
 
-/* Used for Pascal; details not determined right now.  */
-DEFTREECODE (FILE_TYPE, "file_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 codes is optimized for the checking
+   macros in tree.h.  Changing the order will degrade the speed of the
+   compiler.  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.
@@ -222,6 +232,13 @@ DEFTREECODE (UNION_TYPE, "union_type", tcc_type, 0)	/* C union type */
    the union.  */
 DEFTREECODE (QUAL_UNION_TYPE, "qual_union_type", tcc_type, 0)
 
+/* The ordering of the following codes is optimized for the checking
+   macros in tree.h.  Changing the order will degrade the speed of the
+   compiler.  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.
@@ -230,6 +247,16 @@ DEFTREECODE (QUAL_UNION_TYPE, "qual_union_type", tcc_type, 0)
    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,
@@ -323,12 +350,16 @@ DEFTREECODE (STRING_CST, "string_cst", tcc_constant, 0)
 
 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)
+/* The ordering of the following codes is optimized for the checking
+   macros in tree.h.  Changing the order will degrade the speed of the
+   compiler.  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)
-DEFTREECODE (FIELD_DECL, "field_decl", tcc_declaration, 0)
 
 /* A namespace declaration.  Namespaces appear in DECL_CONTEXT of other
    _DECLs, providing a hierarchy of names.  */
@@ -357,6 +388,10 @@ DEFTREECODE (COMPONENT_REF, "component_ref", tcc_reference, 3)
    BIT_FIELD_REF_UNSIGNED says which.  */
 DEFTREECODE (BIT_FIELD_REF, "bit_field_ref", tcc_reference, 3)
 
+/* The ordering of the following codes is optimized for the checking
+   macros in tree.h.  Changing the order will degrade the speed of the
+   compiler.  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)
 
-- 
cgit v1.1

