Commit 38b3627d by Nathan Sidwell Committed by Nathan Sidwell

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
parent 1763d000
2004-12-21 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): Reorder checks for better optimization.
(IS_EXPR_CODE_CLASS): Use IN_RANGE.
(INTEGRAL_TYPE_P, FLOAT_TYPE_P): Reorder checks for better
optimization.
2004-12-21 David O'Brien <obrien@FreeBSD.org> 2004-12-21 David O'Brien <obrien@FreeBSD.org>
* config/freebsd-spec.h: Use KSE pthread lib for -pthread. * config/freebsd-spec.h: Use KSE pthread lib for -pthread.
......
2004-12-21 Nathan Sidwell <nathan@codesourcery.com> 2004-12-21 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.def (TEMPLATE_TYPE_PARM,
BOUND_TEMPLATE_TEMPLATE_PARM, TYPE_OF_TYPE, TYPENAME_TYPE): Reorder
for better code efficiency.
* 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.
PR c++/18975 PR c++/18975
* method.c (do_build_copy_constructor): Refactor. Don't const * method.c (do_build_copy_constructor): Refactor. Don't const
qualify a mutable field. qualify a mutable field.
......
...@@ -159,10 +159,6 @@ DEFTREECODE (TEMPLATE_DECL, "template_decl", tcc_declaration, 0) ...@@ -159,10 +159,6 @@ DEFTREECODE (TEMPLATE_DECL, "template_decl", tcc_declaration, 0)
worrying about instantiating things. */ worrying about instantiating things. */
DEFTREECODE (TEMPLATE_PARM_INDEX, "template_parm_index", tcc_exceptional, 0) 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. /* Index into a template parameter list for template template parameters.
This parameter must be a type. The TYPE_FIELDS value will be a This parameter must be a type. The TYPE_FIELDS value will be a
TEMPLATE_PARM_INDEX. TEMPLATE_PARM_INDEX.
...@@ -172,12 +168,14 @@ DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", tcc_type, 0) ...@@ -172,12 +168,14 @@ DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", tcc_type, 0)
and TYPE_NAME is a TEMPLATE_DECL. */ and TYPE_NAME is a TEMPLATE_DECL. */
DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", tcc_type, 0) DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", tcc_type, 0)
/* Like TEMPLATE_TEMPLATE_PARM it is used with bound template arguments /* The ordering of the following codes is optimized for the checking
like TT<int>. macros in tree.h. Changing the order will degrade the speed of the
In this case, TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO contains the compiler. TEMPLATE_TYPE_PARM, TYPENAME_TYPE, TYPEOF_TYPE,
template name and its bound arguments. TYPE_NAME is a TYPE_DECL. */ BOUND_TEMPLATE_TEMPLATE_PARM. */
DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm",
tcc_type, 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)
/* A type designated by `typename T::t'. TYPE_CONTEXT is `T', /* 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 TYPE_NAME is an IDENTIFIER_NODE for `t'. If the type was named via
...@@ -185,15 +183,22 @@ DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm", ...@@ -185,15 +183,22 @@ DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm",
TREE_TYPE is always NULL. */ TREE_TYPE is always NULL. */
DEFTREECODE (TYPENAME_TYPE, "typename_type", tcc_type, 0) 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'. /* For template template argument of the form `T::template C'.
TYPE_CONTEXT is `T', the template parameter dependent object. TYPE_CONTEXT is `T', the template parameter dependent object.
TYPE_NAME is an IDENTIFIER_NODE for `C', the member class template. */ TYPE_NAME is an IDENTIFIER_NODE for `C', the member class template. */
DEFTREECODE (UNBOUND_CLASS_TEMPLATE, "unbound_class_template", tcc_type, 0) 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. /* A using declaration. DECL_INITIAL contains the specified scope.
This is not an alias, but is later expanded into multiple aliases. 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, The decl will have a NULL_TYPE iff the scope is a dependent scope,
......
...@@ -865,7 +865,8 @@ enum languages { lang_c, lang_cplusplus, lang_java }; ...@@ -865,7 +865,8 @@ enum languages { lang_c, lang_cplusplus, lang_java };
for template type parameters, typename types, and instantiated for template type parameters, typename types, and instantiated
template template parameters. Despite its name, template template parameters. Despite its name,
this macro has nothing to do with the definition of aggregate given this macro has nothing to do with the definition of aggregate given
in the standard. Think of this macro as MAYBE_CLASS_TYPE_P. */ in the standard. Think of this macro as MAYBE_CLASS_TYPE_P. Keep
these checks in ascending code order. */
#define IS_AGGR_TYPE(T) \ #define IS_AGGR_TYPE(T) \
(TREE_CODE (T) == TEMPLATE_TYPE_PARM \ (TREE_CODE (T) == TEMPLATE_TYPE_PARM \
|| TREE_CODE (T) == TYPENAME_TYPE \ || TREE_CODE (T) == TYPENAME_TYPE \
...@@ -881,9 +882,11 @@ enum languages { lang_c, lang_cplusplus, lang_java }; ...@@ -881,9 +882,11 @@ enum languages { lang_c, lang_cplusplus, lang_java };
/* Nonzero if T is a class type. Zero for template type parameters, /* Nonzero if T is a class type. Zero for template type parameters,
typename types, and so forth. */ typename types, and so forth. */
#define CLASS_TYPE_P(T) \ #define CLASS_TYPE_P(T) \
(IS_AGGR_TYPE_CODE (TREE_CODE (T)) && IS_AGGR_TYPE (T)) (IS_AGGR_TYPE_CODE (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))
#define IS_AGGR_TYPE_CODE(T) ((T) == RECORD_TYPE || (T) == UNION_TYPE) /* Keep these checks in ascending code order. */
#define IS_AGGR_TYPE_CODE(T) \
((T) == RECORD_TYPE || (T) == UNION_TYPE)
#define TAGGED_TYPE_P(T) \ #define TAGGED_TYPE_P(T) \
(CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE) (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
#define IS_OVERLOAD_TYPE(T) TAGGED_TYPE_P (T) #define IS_OVERLOAD_TYPE(T) TAGGED_TYPE_P (T)
...@@ -1485,11 +1488,12 @@ struct lang_type GTY(()) ...@@ -1485,11 +1488,12 @@ struct lang_type GTY(())
/* If a DECL has DECL_LANG_SPECIFIC, it is either a lang_decl_flags or /* If a DECL has DECL_LANG_SPECIFIC, it is either a lang_decl_flags or
a lang_decl (which has lang_decl_flags as its initial prefix). a lang_decl (which has lang_decl_flags as its initial prefix).
This macro is nonzero for tree nodes whose DECL_LANG_SPECIFIC is This macro is nonzero for tree nodes whose DECL_LANG_SPECIFIC is
the full lang_decl, and not just lang_decl_flags. */ the full lang_decl, and not just lang_decl_flags. Keep these
#define CAN_HAVE_FULL_LANG_DECL_P(NODE) \ checks in ascending code order. */
(!(TREE_CODE (NODE) == VAR_DECL \ #define CAN_HAVE_FULL_LANG_DECL_P(NODE) \
|| TREE_CODE (NODE) == CONST_DECL \ (!(TREE_CODE (NODE) == FIELD_DECL \
|| TREE_CODE (NODE) == FIELD_DECL \ || TREE_CODE (NODE) == VAR_DECL \
|| TREE_CODE (NODE) == CONST_DECL \
|| TREE_CODE (NODE) == USING_DECL)) || TREE_CODE (NODE) == USING_DECL))
struct lang_decl_flags GTY(()) struct lang_decl_flags GTY(())
...@@ -2315,8 +2319,12 @@ struct lang_decl GTY(()) ...@@ -2315,8 +2319,12 @@ struct lang_decl GTY(())
#define DECL_EXTERNAL_LINKAGE_P(DECL) \ #define DECL_EXTERNAL_LINKAGE_P(DECL) \
(decl_linkage (DECL) == lk_external) (decl_linkage (DECL) == lk_external)
#define INTEGRAL_CODE_P(CODE) \ /* Keep these codes in ascending code order. CHAR_TYPE is used here
((CODE) == INTEGER_TYPE || (CODE) == ENUMERAL_TYPE || (CODE) == BOOLEAN_TYPE) to completely fill the range. */
#define INTEGRAL_CODE_P(CODE) \
((CODE) == ENUMERAL_TYPE || (CODE) == BOOLEAN_TYPE \
|| (CODE) == CHAR_TYPE || (CODE) == INTEGER_TYPE)
/* [basic.fundamental] /* [basic.fundamental]
...@@ -2324,31 +2332,37 @@ struct lang_decl GTY(()) ...@@ -2324,31 +2332,37 @@ struct lang_decl GTY(())
are collectively called integral types. are collectively called integral types.
Note that INTEGRAL_TYPE_P, as defined in tree.h, allows enumeration Note that INTEGRAL_TYPE_P, as defined in tree.h, allows enumeration
types as well, which is incorrect in C++. */ types as well, which is incorrect in C++. Keep these checks in
ascending code order. CHAR_TYPE is added to complete the interval of
values. */
#define CP_INTEGRAL_TYPE_P(TYPE) \ #define CP_INTEGRAL_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == BOOLEAN_TYPE \ (TREE_CODE (TYPE) == BOOLEAN_TYPE \
|| TREE_CODE (TYPE) == CHAR_TYPE \
|| TREE_CODE (TYPE) == INTEGER_TYPE) || TREE_CODE (TYPE) == INTEGER_TYPE)
/* Returns true if TYPE is an integral or enumeration name. */ /* Returns true if TYPE is an integral or enumeration name. Keep
these checks in ascending code order. */
#define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \ #define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
(CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == ENUMERAL_TYPE) (TREE_CODE (TYPE) == ENUMERAL_TYPE || CP_INTEGRAL_TYPE_P (TYPE))
/* [basic.fundamental] /* [basic.fundamental]
Integral and floating types are collectively called arithmetic Integral and floating types are collectively called arithmetic
types. */ types. Keep these checks in ascending code order. */
#define ARITHMETIC_TYPE_P(TYPE) \ #define ARITHMETIC_TYPE_P(TYPE) \
(CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE) (CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE)
/* [basic.types] /* [basic.types]
Arithmetic types, enumeration types, pointer types, and Arithmetic types, enumeration types, pointer types, and
pointer-to-member types, are collectively called scalar types. */ pointer-to-member types, are collectively called scalar types.
Keep these checks in ascending code order. */
#define SCALAR_TYPE_P(TYPE) \ #define SCALAR_TYPE_P(TYPE) \
(ARITHMETIC_TYPE_P (TYPE) \ (TYPE_PTRMEM_P (TYPE) \
|| TREE_CODE (TYPE) == ENUMERAL_TYPE \ || TREE_CODE (TYPE) == ENUMERAL_TYPE \
|| ARITHMETIC_TYPE_P (TYPE) \
|| TYPE_PTR_P (TYPE) \ || TYPE_PTR_P (TYPE) \
|| TYPE_PTR_TO_MEMBER_P (TYPE)) || TYPE_PTRMEMFUNC_P (TYPE))
/* [dcl.init.aggr] /* [dcl.init.aggr]
...@@ -2356,12 +2370,12 @@ struct lang_decl GTY(()) ...@@ -2356,12 +2370,12 @@ struct lang_decl GTY(())
constructors, no private or protected non-static data members, no constructors, no private or protected non-static data members, no
base classes, and no virtual functions. base classes, and no virtual functions.
As an extension, we also treat vectors as aggregates. */ As an extension, we also treat vectors as aggregates. Keep these
#define CP_AGGREGATE_TYPE_P(TYPE) \ checks in ascending code order. */
(TREE_CODE (TYPE) == ARRAY_TYPE \ #define CP_AGGREGATE_TYPE_P(TYPE) \
|| TREE_CODE (TYPE) == VECTOR_TYPE \ (TREE_CODE (TYPE) == VECTOR_TYPE \
|| (CLASS_TYPE_P (TYPE) \ ||TREE_CODE (TYPE) == ARRAY_TYPE \
&& !CLASSTYPE_NON_AGGREGATE (TYPE))) || (CLASS_TYPE_P (TYPE) && !CLASSTYPE_NON_AGGREGATE (TYPE)))
/* Nonzero for a class type means that the class type has a /* Nonzero for a class type means that the class type has a
user-declared constructor. */ user-declared constructor. */
...@@ -2442,21 +2456,26 @@ struct lang_decl GTY(()) ...@@ -2442,21 +2456,26 @@ struct lang_decl GTY(())
/* Returns true if NODE is a pointer. */ /* Returns true if NODE is a pointer. */
#define TYPE_PTR_P(NODE) \ #define TYPE_PTR_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE) (TREE_CODE (NODE) == POINTER_TYPE)
/* Returns true if NODE is a pointer to an object. */ /* Returns true if NODE is a pointer to an object. Keep these checks
#define TYPE_PTROB_P(NODE) \ in ascending tree code order. */
(TYPE_PTR_P (NODE) \ #define TYPE_PTROB_P(NODE) \
&& TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE \ (TYPE_PTR_P (NODE) \
&& TREE_CODE (TREE_TYPE (NODE)) != METHOD_TYPE \ && !(TREE_CODE (TREE_TYPE (NODE)) == VOID_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) != VOID_TYPE) || TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE \
/* Returns true if NODE is a reference to an object. */ || TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE))
#define TYPE_REF_OBJ_P(NODE) \ /* Returns true if NODE is a reference to an object. Keep these checks
(TREE_CODE (NODE) == REFERENCE_TYPE \ in ascending tree code order. */
&& TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE \ #define TYPE_REF_OBJ_P(NODE) \
&& TREE_CODE (TREE_TYPE (NODE)) != METHOD_TYPE \ (TREE_CODE (NODE) == REFERENCE_TYPE \
&& TREE_CODE (TREE_TYPE (NODE)) != VOID_TYPE) && !(TREE_CODE (TREE_TYPE (NODE)) == VOID_TYPE \
/* Returns true if NODE is a pointer to an object, or a pointer to void. */ || TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE \
#define TYPE_PTROBV_P(NODE) \ || TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE))
(TYPE_PTR_P (NODE) && TREE_CODE (TREE_TYPE (NODE)) != FUNCTION_TYPE) /* Returns true if NODE is a pointer to an object, or a pointer to
void. Keep these checks in ascending tree code order. */
#define TYPE_PTROBV_P(NODE) \
(TYPE_PTR_P (NODE) \
&& !(TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE \
|| TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE))
/* Returns true if NODE is a pointer to function. */ /* Returns true if NODE is a pointer to function. */
#define TYPE_PTRFN_P(NODE) \ #define TYPE_PTRFN_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE \ (TREE_CODE (NODE) == POINTER_TYPE \
...@@ -2680,7 +2699,8 @@ struct lang_decl GTY(()) ...@@ -2680,7 +2699,8 @@ struct lang_decl GTY(())
This list is not used for static variable templates. */ This list is not used for static variable templates. */
#define DECL_TEMPLATE_SPECIALIZATIONS(NODE) DECL_SIZE (NODE) #define DECL_TEMPLATE_SPECIALIZATIONS(NODE) DECL_SIZE (NODE)
/* Nonzero for a DECL which is actually a template parameter. */ /* Nonzero for a DECL which is actually a template parameter. Keep
these checks in ascending tree code order. */
#define DECL_TEMPLATE_PARM_P(NODE) \ #define DECL_TEMPLATE_PARM_P(NODE) \
(DECL_LANG_FLAG_0 (NODE) \ (DECL_LANG_FLAG_0 (NODE) \
&& (TREE_CODE (NODE) == CONST_DECL \ && (TREE_CODE (NODE) == CONST_DECL \
......
...@@ -179,7 +179,7 @@ extern int errno; ...@@ -179,7 +179,7 @@ extern int errno;
UPPER. However the bounds themselves can be either positive or UPPER. However the bounds themselves can be either positive or
negative. */ negative. */
#define IN_RANGE(VALUE, LOWER, UPPER) \ #define IN_RANGE(VALUE, LOWER, UPPER) \
((unsigned HOST_WIDE_INT) ((VALUE) - (LOWER)) <= ((UPPER) - (LOWER))) ((unsigned)((VALUE) - (LOWER)) <= ((UPPER) - (LOWER)))
/* Infrastructure for defining missing _MAX and _MIN macros. Note that /* Infrastructure for defining missing _MAX and _MIN macros. Note that
macros defined with these cannot be used in #if. */ macros defined with these cannot be used in #if. */
......
...@@ -28,7 +28,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -28,7 +28,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
different structures, and the size is determined by the tree_union different structures, and the size is determined by the tree_union
member structure; the 4th element should be zero. Languages that member structure; the 4th element should be zero. Languages that
define language-specific tcc_exceptional or tcc_constant codes must 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. /* Any erroneous construct is parsed into a node of this type.
This type of node is accepted without complaint in all contexts This type of node is accepted without complaint in all contexts
...@@ -118,31 +123,16 @@ DEFTREECODE (BLOCK, "block", tcc_exceptional, 0) ...@@ -118,31 +123,16 @@ DEFTREECODE (BLOCK, "block", tcc_exceptional, 0)
ENUMERAL_TYPE, RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE nodes; ENUMERAL_TYPE, RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE nodes;
see below. */ see below. */
DEFTREECODE (VOID_TYPE, "void_type", tcc_type, 0) /* The ordering of the following codes is optimized for the checking
/* The void type in C */ macros in tree.h. Changing the order will degrade the speed of the
compiler. OFFSET_TYPE, ENUMERAL_TYPE, BOOLEAN_TYPE, CHAR_TYPE,
/* Integer types in all languages, including char in C. INTEGER_TYPE, REAL_TYPE, POINTER_TYPE. */
Also used for sub-ranges of other discrete types.
Has components TYPE_MIN_VALUE, TYPE_MAX_VALUE (expressions, inclusive) /* An offset is a pointer relative to an object.
and TYPE_PRECISION (number of bits used by this type). The TREE_TYPE field is the type of the object at the offset.
In the case of a subrange type in Pascal, the TREE_TYPE The TYPE_OFFSET_BASETYPE points to the node for the type of object
of this will point at the supertype (another INTEGER_TYPE, that the offset is relative to. */
or an ENUMERAL_TYPE, CHAR_TYPE, or BOOLEAN_TYPE). DEFTREECODE (OFFSET_TYPE, "offset_type", tcc_type, 0)
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. /* C enums. The type node looks just like an INTEGER_TYPE node.
The symbols for the values of the enum type are defined by The symbols for the values of the enum type are defined by
...@@ -157,38 +147,58 @@ DEFTREECODE (VECTOR_TYPE, "vector_type", tcc_type, 0) ...@@ -157,38 +147,58 @@ DEFTREECODE (VECTOR_TYPE, "vector_type", tcc_type, 0)
treated similarly. */ treated similarly. */
DEFTREECODE (ENUMERAL_TYPE, "enumeral_type", tcc_type, 0) DEFTREECODE (ENUMERAL_TYPE, "enumeral_type", tcc_type, 0)
/* Pascal's boolean type (true or false are the only values); /* Boolean type (true or false are the only values). Looks like an
no special fields needed. */ INTEGRAL_TYPE. */
DEFTREECODE (BOOLEAN_TYPE, "boolean_type", tcc_type, 0) DEFTREECODE (BOOLEAN_TYPE, "boolean_type", tcc_type, 0)
/* CHAR in Pascal; not used in C. /* CHAR in Java; not used in C. Looks like an INTEGRAL_TYPE. */
No special fields needed. */
DEFTREECODE (CHAR_TYPE, "char_type", tcc_type, 0) 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. /* All pointer-to-x types have code POINTER_TYPE.
The TREE_TYPE points to the node for the type pointed to. */ The TREE_TYPE points to the node for the type pointed to. */
DEFTREECODE (POINTER_TYPE, "pointer_type", tcc_type, 0) 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 /* A reference is like a pointer except that it is coerced
automatically to the value it points to. Used in C++. */ automatically to the value it points to. Used in C++. */
DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0) DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0)
/* METHOD_TYPE is the type of a function which takes an extra first /* The ordering of the following codes is optimized for the checking
argument for "self", which is not present in the declared argument list. macros in tree.h. Changing the order will degrade the speed of the
The TREE_TYPE is the return type of the method. The TYPE_METHOD_BASETYPE compiler. COMPLEX_TYPE, VECTOR_TYPE, ARRAY_TYPE. */
is the type of "self". TYPE_ARG_TYPES is the real argument list, which
includes the hidden argument for "self". */ /* Complex number types. The TREE_TYPE field is the data type
DEFTREECODE (METHOD_TYPE, "method_type", tcc_type, 0) of the real and imaginary parts. */
DEFTREECODE (COMPLEX_TYPE, "complex_type", tcc_type, 0)
/* Used for Pascal; details not determined right now. */ /* Vector types. The TREE_TYPE field is the data type of the vector
DEFTREECODE (FILE_TYPE, "file_type", tcc_type, 0) 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: /* Types of arrays. Special fields:
TREE_TYPE Type of an array element. TREE_TYPE Type of an array element.
TYPE_DOMAIN Type to index by. TYPE_DOMAIN Type to index by.
...@@ -222,6 +232,13 @@ DEFTREECODE (UNION_TYPE, "union_type", tcc_type, 0) /* C union type */ ...@@ -222,6 +232,13 @@ DEFTREECODE (UNION_TYPE, "union_type", tcc_type, 0) /* C union type */
the union. */ the union. */
DEFTREECODE (QUAL_UNION_TYPE, "qual_union_type", tcc_type, 0) 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: /* Type of functions. Special fields:
TREE_TYPE type of value returned. TREE_TYPE type of value returned.
TYPE_ARG_TYPES list of types of arguments expected. TYPE_ARG_TYPES list of types of arguments expected.
...@@ -230,6 +247,16 @@ DEFTREECODE (QUAL_UNION_TYPE, "qual_union_type", tcc_type, 0) ...@@ -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. */ have code FUNCTION_TYPE also, but then TREE_TYPE is zero or void type. */
DEFTREECODE (FUNCTION_TYPE, "function_type", tcc_type, 0) 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. /* This is a language-specific kind of type.
Its meaning is defined by the language front end. Its meaning is defined by the language front end.
layout_type does not know how to lay this out, layout_type does not know how to lay this out,
...@@ -323,12 +350,16 @@ DEFTREECODE (STRING_CST, "string_cst", tcc_constant, 0) ...@@ -323,12 +350,16 @@ DEFTREECODE (STRING_CST, "string_cst", tcc_constant, 0)
DEFTREECODE (FUNCTION_DECL, "function_decl", tcc_declaration, 0) DEFTREECODE (FUNCTION_DECL, "function_decl", tcc_declaration, 0)
DEFTREECODE (LABEL_DECL, "label_decl", tcc_declaration, 0) DEFTREECODE (LABEL_DECL, "label_decl", tcc_declaration, 0)
DEFTREECODE (CONST_DECL, "const_decl", tcc_declaration, 0) /* The ordering of the following codes is optimized for the checking
DEFTREECODE (TYPE_DECL, "type_decl", tcc_declaration, 0) 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 (VAR_DECL, "var_decl", tcc_declaration, 0)
DEFTREECODE (CONST_DECL, "const_decl", tcc_declaration, 0)
DEFTREECODE (PARM_DECL, "parm_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 (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 /* A namespace declaration. Namespaces appear in DECL_CONTEXT of other
_DECLs, providing a hierarchy of names. */ _DECLs, providing a hierarchy of names. */
...@@ -357,6 +388,10 @@ DEFTREECODE (COMPONENT_REF, "component_ref", tcc_reference, 3) ...@@ -357,6 +388,10 @@ DEFTREECODE (COMPONENT_REF, "component_ref", tcc_reference, 3)
BIT_FIELD_REF_UNSIGNED says which. */ BIT_FIELD_REF_UNSIGNED says which. */
DEFTREECODE (BIT_FIELD_REF, "bit_field_ref", tcc_reference, 3) 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. */ /* C unary `*' or Pascal `^'. One operand, an expression for a pointer. */
DEFTREECODE (INDIRECT_REF, "indirect_ref", tcc_reference, 1) DEFTREECODE (INDIRECT_REF, "indirect_ref", tcc_reference, 1)
......
...@@ -51,6 +51,7 @@ enum tree_code { ...@@ -51,6 +51,7 @@ enum tree_code {
enum tree_code_class { enum tree_code_class {
tcc_exceptional, /* An exceptional code (fits no category). */ tcc_exceptional, /* An exceptional code (fits no category). */
tcc_constant, /* A constant. */ tcc_constant, /* A constant. */
/* Order of tcc_type and tcc_declaration is important. */
tcc_type, /* A type object code. */ tcc_type, /* A type object code. */
tcc_declaration, /* A declaration (also serving as variable refs). */ tcc_declaration, /* A declaration (also serving as variable refs). */
tcc_reference, /* A reference to storage. */ tcc_reference, /* A reference to storage. */
...@@ -96,11 +97,12 @@ extern const enum tree_code_class tree_code_type[]; ...@@ -96,11 +97,12 @@ extern const enum tree_code_class tree_code_type[];
#define DECL_P(CODE)\ #define DECL_P(CODE)\
(TREE_CODE_CLASS (TREE_CODE (CODE)) == tcc_declaration) (TREE_CODE_CLASS (TREE_CODE (CODE)) == tcc_declaration)
/* Nonzero if CODE represents a INDIRECT_REF. */ /* Nonzero if CODE represents a INDIRECT_REF. Keep these checks in
ascending code order. */
#define INDIRECT_REF_P(CODE)\ #define INDIRECT_REF_P(CODE)\
(TREE_CODE (CODE) == INDIRECT_REF \ (TREE_CODE (CODE) == INDIRECT_REF \
|| TREE_CODE (CODE) == MISALIGNED_INDIRECT_REF \ || TREE_CODE (CODE) == ALIGN_INDIRECT_REF \
|| TREE_CODE (CODE) == ALIGN_INDIRECT_REF) || TREE_CODE (CODE) == MISALIGNED_INDIRECT_REF)
/* Nonzero if CODE represents a reference. */ /* Nonzero if CODE represents a reference. */
...@@ -145,7 +147,7 @@ extern const enum tree_code_class tree_code_type[]; ...@@ -145,7 +147,7 @@ extern const enum tree_code_class tree_code_type[];
expression. */ expression. */
#define IS_EXPR_CODE_CLASS(CLASS)\ #define IS_EXPR_CODE_CLASS(CLASS)\
(((CLASS) >= tcc_reference) && ((CLASS) <= tcc_expression)) (IN_RANGE (CLASS, tcc_reference, tcc_expression))
/* Returns nonzero iff NODE is an expression of some kind. */ /* Returns nonzero iff NODE is an expression of some kind. */
...@@ -737,11 +739,14 @@ extern void tree_operand_check_failed (int, enum tree_code, ...@@ -737,11 +739,14 @@ extern void tree_operand_check_failed (int, enum tree_code,
EXP = TREE_OPERAND (EXP, 0) EXP = TREE_OPERAND (EXP, 0)
/* Nonzero if TYPE represents an integral type. Note that we do not /* Nonzero if TYPE represents an integral type. Note that we do not
include COMPLEX types here. */ include COMPLEX types here. Keep these checks in ascending code
order. */
#define INTEGRAL_TYPE_P(TYPE) \ #define INTEGRAL_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == INTEGER_TYPE || TREE_CODE (TYPE) == ENUMERAL_TYPE \ (TREE_CODE (TYPE) == ENUMERAL_TYPE \
|| TREE_CODE (TYPE) == BOOLEAN_TYPE || TREE_CODE (TYPE) == CHAR_TYPE) || TREE_CODE (TYPE) == BOOLEAN_TYPE \
|| TREE_CODE (TYPE) == CHAR_TYPE \
|| TREE_CODE (TYPE) == INTEGER_TYPE)
/* Nonzero if TYPE represents a scalar floating-point type. */ /* Nonzero if TYPE represents a scalar floating-point type. */
...@@ -760,20 +765,25 @@ extern void tree_operand_check_failed (int, enum tree_code, ...@@ -760,20 +765,25 @@ extern void tree_operand_check_failed (int, enum tree_code,
&& TREE_CODE (TREE_TYPE (TYPE)) == REAL_TYPE) && TREE_CODE (TREE_TYPE (TYPE)) == REAL_TYPE)
/* Nonzero if TYPE represents a floating-point type, including complex /* Nonzero if TYPE represents a floating-point type, including complex
and vector floating-point types. */ and vector floating-point types. The vector and complex check does
not use the previous two macros to enable early folding. */
#define FLOAT_TYPE_P(TYPE) \ #define FLOAT_TYPE_P(TYPE) \
(SCALAR_FLOAT_TYPE_P (TYPE) || COMPLEX_FLOAT_TYPE_P (TYPE) \ (SCALAR_FLOAT_TYPE_P (TYPE) \
|| VECTOR_FLOAT_TYPE_P (TYPE)) || ((TREE_CODE (TYPE) == COMPLEX_TYPE \
|| TREE_CODE (TYPE) == VECTOR_TYPE) \
&& SCALAR_FLOAT_TYPE_P (TREE_TYPE (TYPE))))
/* Nonzero if TYPE represents an aggregate (multi-component) type. */ /* Nonzero if TYPE represents an aggregate (multi-component) type.
Keep these checks in ascending code order. */
#define AGGREGATE_TYPE_P(TYPE) \ #define AGGREGATE_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == ARRAY_TYPE || TREE_CODE (TYPE) == RECORD_TYPE \ (TREE_CODE (TYPE) == ARRAY_TYPE || TREE_CODE (TYPE) == RECORD_TYPE \
|| TREE_CODE (TYPE) == UNION_TYPE || TREE_CODE (TYPE) == QUAL_UNION_TYPE) || TREE_CODE (TYPE) == UNION_TYPE || TREE_CODE (TYPE) == QUAL_UNION_TYPE)
/* Nonzero if TYPE represents a pointer or reference type. /* Nonzero if TYPE represents a pointer or reference type.
(It should be renamed to INDIRECT_TYPE_P.) */ (It should be renamed to INDIRECT_TYPE_P.) Keep these checks in
ascending code order. */
#define POINTER_TYPE_P(TYPE) \ #define POINTER_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == POINTER_TYPE || TREE_CODE (TYPE) == REFERENCE_TYPE) (TREE_CODE (TYPE) == POINTER_TYPE || TREE_CODE (TYPE) == REFERENCE_TYPE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment