aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-12-21 17:43:27 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-12-21 17:43:27 +0000
commit38b3627d6fcedf4e1b99e988440c1c366f6dba10 (patch)
tree4b5adf425ed835f3fe30098c1efdec407152dc19 /gcc/cp
parent1763d00076ac7e7da7a781a74932bb8aef649b8b (diff)
downloadgcc-38b3627d6fcedf4e1b99e988440c1c366f6dba10.zip
gcc-38b3627d6fcedf4e1b99e988440c1c366f6dba10.tar.gz
gcc-38b3627d6fcedf4e1b99e988440c1c366f6dba10.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/cp-tree.def33
-rw-r--r--gcc/cp/cp-tree.h98
3 files changed, 88 insertions, 53 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cb5d4ae..c90f5af 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,15 @@
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
* method.c (do_build_copy_constructor): Refactor. Don't const
qualify a mutable field.
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index a01ed76..74f0d37 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -159,10 +159,6 @@ DEFTREECODE (TEMPLATE_DECL, "template_decl", tcc_declaration, 0)
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.
@@ -172,12 +168,14 @@ DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", tcc_type, 0)
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)
+/* 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. 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
@@ -185,15 +183,22 @@ DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm",
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 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,
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index fdc828d..82cd13f 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -865,7 +865,8 @@ enum languages { lang_c, lang_cplusplus, lang_java };
for template type parameters, typename types, and instantiated
template template parameters. Despite its name,
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) \
(TREE_CODE (T) == TEMPLATE_TYPE_PARM \
|| TREE_CODE (T) == TYPENAME_TYPE \
@@ -881,9 +882,11 @@ enum languages { lang_c, lang_cplusplus, lang_java };
/* 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))
+ (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) \
(CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
#define IS_OVERLOAD_TYPE(T) TAGGED_TYPE_P (T)
@@ -1485,11 +1488,12 @@ struct lang_type GTY(())
/* 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).
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 \
+ the full lang_decl, and not just lang_decl_flags. Keep these
+ checks in ascending code order. */
+#define CAN_HAVE_FULL_LANG_DECL_P(NODE) \
+ (!(TREE_CODE (NODE) == FIELD_DECL \
+ || TREE_CODE (NODE) == VAR_DECL \
+ || TREE_CODE (NODE) == CONST_DECL \
|| TREE_CODE (NODE) == USING_DECL))
struct lang_decl_flags GTY(())
@@ -2315,8 +2319,12 @@ struct lang_decl GTY(())
#define DECL_EXTERNAL_LINKAGE_P(DECL) \
(decl_linkage (DECL) == lk_external)
-#define INTEGRAL_CODE_P(CODE) \
- ((CODE) == INTEGER_TYPE || (CODE) == ENUMERAL_TYPE || (CODE) == BOOLEAN_TYPE)
+/* Keep these codes in ascending code order. CHAR_TYPE is used here
+ to completely fill the range. */
+
+#define INTEGRAL_CODE_P(CODE) \
+ ((CODE) == ENUMERAL_TYPE || (CODE) == BOOLEAN_TYPE \
+ || (CODE) == CHAR_TYPE || (CODE) == INTEGER_TYPE)
/* [basic.fundamental]
@@ -2324,31 +2332,37 @@ struct lang_decl GTY(())
are collectively called integral types.
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) \
(TREE_CODE (TYPE) == BOOLEAN_TYPE \
+ || TREE_CODE (TYPE) == CHAR_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) \
- (CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == ENUMERAL_TYPE)
+ (TREE_CODE (TYPE) == ENUMERAL_TYPE || CP_INTEGRAL_TYPE_P (TYPE))
/* [basic.fundamental]
Integral and floating types are collectively called arithmetic
- types. */
+ types. Keep these checks in ascending code order. */
#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. */
+ pointer-to-member types, are collectively called scalar types.
+ Keep these checks in ascending code order. */
#define SCALAR_TYPE_P(TYPE) \
- (ARITHMETIC_TYPE_P (TYPE) \
+ (TYPE_PTRMEM_P (TYPE) \
|| TREE_CODE (TYPE) == ENUMERAL_TYPE \
+ || ARITHMETIC_TYPE_P (TYPE) \
|| TYPE_PTR_P (TYPE) \
- || TYPE_PTR_TO_MEMBER_P (TYPE))
+ || TYPE_PTRMEMFUNC_P (TYPE))
/* [dcl.init.aggr]
@@ -2356,12 +2370,12 @@ struct lang_decl GTY(())
constructors, no private or protected non-static data members, no
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)))
+ As an extension, we also treat vectors as aggregates. Keep these
+ checks in ascending code order. */
+#define CP_AGGREGATE_TYPE_P(TYPE) \
+ (TREE_CODE (TYPE) == VECTOR_TYPE \
+ ||TREE_CODE (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. */
@@ -2442,21 +2456,26 @@ struct lang_decl GTY(())
/* Returns true if NODE is a pointer. */
#define TYPE_PTR_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE)
-/* 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 an object. Keep these checks
+ in ascending tree code order. */
+#define TYPE_PTROB_P(NODE) \
+ (TYPE_PTR_P (NODE) \
+ && !(TREE_CODE (TREE_TYPE (NODE)) == VOID_TYPE \
+ || TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE \
+ || TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE))
+/* Returns true if NODE is a reference to an object. Keep these checks
+ in ascending tree code order. */
+#define TYPE_REF_OBJ_P(NODE) \
+ (TREE_CODE (NODE) == REFERENCE_TYPE \
+ && !(TREE_CODE (TREE_TYPE (NODE)) == VOID_TYPE \
+ || TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE \
+ || TREE_CODE (TREE_TYPE (NODE)) == METHOD_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. */
#define TYPE_PTRFN_P(NODE) \
(TREE_CODE (NODE) == POINTER_TYPE \
@@ -2680,7 +2699,8 @@ struct lang_decl GTY(())
This list is not used for static variable templates. */
#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) \
(DECL_LANG_FLAG_0 (NODE) \
&& (TREE_CODE (NODE) == CONST_DECL \