Commit 539ed333 by Nathan Sidwell Committed by Nathan Sidwell

cp-tree.h (SAME_BINFO_TYPE_P): New.

	* cp-tree.h (SAME_BINFO_TYPE_P): New.
	* class.c (build_base_path): Use SAME_BINFO_TYPE_P to compare
	binfo types.
	(convert_to_base_statically, determine_primary_bases,
	update_vtable_entry_for_fn, dfs_modify_vtables, build_vtt_inits,
	dfs_build_secondary_vptr_vtt_inits, build_ctor_vtbl_group,
	accumulate_vtbl_inits, dfs_accumulate_vtbl_inits,
	build_vtbl_initializer, add_vcall_offset_vtbl_entries_1): Likewise.
	* init.c (expand_member_init): Likewise.
	* search.c (lookup_base_r, dynamic_cast_base_recurse,
	binfo_via_virtual, copied_binfo, binfo_for_vbase,
	original_binfo): Likewise.
	* tree.c (copy_binfo): Likewise.

From-SVN: r88880
parent 19b63d8e
2004-10-11 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (SAME_BINFO_TYPE_P): New.
* class.c (build_base_path): Use SAME_BINFO_TYPE_P to compare
binfo types.
(convert_to_base_statically, determine_primary_bases,
update_vtable_entry_for_fn, dfs_modify_vtables, build_vtt_inits,
dfs_build_secondary_vptr_vtt_inits, build_ctor_vtbl_group,
accumulate_vtbl_inits, dfs_accumulate_vtbl_inits,
build_vtbl_initializer, add_vcall_offset_vtbl_entries_1): Likewise.
* init.c (expand_member_init): Likewise.
* search.c (lookup_base_r, dynamic_cast_base_recurse,
binfo_via_virtual, copied_binfo, binfo_for_vbase,
original_binfo): Likewise.
* tree.c (copy_binfo): Likewise.
2004-10-11 Kazu Hirata <kazu@cs.umass.edu> 2004-10-11 Kazu Hirata <kazu@cs.umass.edu>
* semantics.c: Fix comment typos. * semantics.c: Fix comment typos.
......
...@@ -259,11 +259,10 @@ build_base_path (enum tree_code code, ...@@ -259,11 +259,10 @@ build_base_path (enum tree_code code,
if (want_pointer) if (want_pointer)
probe = TYPE_MAIN_VARIANT (TREE_TYPE (probe)); probe = TYPE_MAIN_VARIANT (TREE_TYPE (probe));
gcc_assert (code == MINUS_EXPR gcc_assert ((code == MINUS_EXPR
? same_type_p (BINFO_TYPE (binfo), probe) && SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), probe))
: code == PLUS_EXPR || (code == PLUS_EXPR
? same_type_p (BINFO_TYPE (d_binfo), probe) && SAME_BINFO_TYPE_P (BINFO_TYPE (d_binfo), probe)));
: false);
if (binfo == d_binfo) if (binfo == d_binfo)
/* Nothing to do. */ /* Nothing to do. */
...@@ -445,8 +444,8 @@ convert_to_base (tree object, tree type, bool check_access) ...@@ -445,8 +444,8 @@ convert_to_base (tree object, tree type, bool check_access)
return build_base_path (PLUS_EXPR, object, binfo, /*nonnull=*/1); return build_base_path (PLUS_EXPR, object, binfo, /*nonnull=*/1);
} }
/* EXPR is an expression with class type. BASE is a base class (a /* EXPR is an expression with unqualified class type. BASE is a base
BINFO) of that class type. Returns EXPR, converted to the BASE binfo of that class type. Returns EXPR, converted to the BASE
type. This function assumes that EXPR is the most derived class; type. This function assumes that EXPR is the most derived class;
therefore virtual bases can be found at their static offsets. */ therefore virtual bases can be found at their static offsets. */
...@@ -456,7 +455,7 @@ convert_to_base_statically (tree expr, tree base) ...@@ -456,7 +455,7 @@ convert_to_base_statically (tree expr, tree base)
tree expr_type; tree expr_type;
expr_type = TREE_TYPE (expr); expr_type = TREE_TYPE (expr);
if (!same_type_p (expr_type, BINFO_TYPE (base))) if (!SAME_BINFO_TYPE_P (BINFO_TYPE (base), expr_type))
{ {
tree pointer_type; tree pointer_type;
...@@ -1276,7 +1275,8 @@ determine_primary_bases (tree t) ...@@ -1276,7 +1275,8 @@ determine_primary_bases (tree t)
tree parent_primary = CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (parent)); tree parent_primary = CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (parent));
if (parent_primary if (parent_primary
&& BINFO_TYPE (base_binfo) == BINFO_TYPE (parent_primary)) && SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo),
BINFO_TYPE (parent_primary)))
/* We are the primary binfo. */ /* We are the primary binfo. */
BINFO_PRIMARY_P (base_binfo) = 1; BINFO_PRIMARY_P (base_binfo) = 1;
} }
...@@ -2062,7 +2062,7 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, ...@@ -2062,7 +2062,7 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals,
{ {
/* If we find the final overrider, then we can stop /* If we find the final overrider, then we can stop
walking. */ walking. */
if (same_type_p (BINFO_TYPE (b), if (SAME_BINFO_TYPE_P (BINFO_TYPE (b),
BINFO_TYPE (TREE_VALUE (overrider)))) BINFO_TYPE (TREE_VALUE (overrider))))
break; break;
...@@ -2153,7 +2153,8 @@ dfs_modify_vtables (tree binfo, void* data) ...@@ -2153,7 +2153,8 @@ dfs_modify_vtables (tree binfo, void* data)
/* Similarly, a base without a vtable needs no modification. */ /* Similarly, a base without a vtable needs no modification. */
&& TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)) && TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo))
/* Don't do the primary vtable, if it's new. */ /* Don't do the primary vtable, if it's new. */
&& (BINFO_TYPE (binfo) != t || CLASSTYPE_HAS_PRIMARY_BASE_P (t))) && (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t)
|| CLASSTYPE_HAS_PRIMARY_BASE_P (t)))
{ {
tree virtuals; tree virtuals;
tree old_virtuals; tree old_virtuals;
...@@ -6697,7 +6698,7 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index) ...@@ -6697,7 +6698,7 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index)
tree init; tree init;
tree secondary_vptrs; tree secondary_vptrs;
secondary_vptr_vtt_init_data data; secondary_vptr_vtt_init_data data;
int top_level_p = same_type_p (TREE_TYPE (binfo), t); int top_level_p = SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t);
/* We only need VTTs for subobjects with virtual bases. */ /* We only need VTTs for subobjects with virtual bases. */
if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo))) if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)))
...@@ -6783,7 +6784,7 @@ dfs_build_secondary_vptr_vtt_inits (tree binfo, void *data_) ...@@ -6783,7 +6784,7 @@ dfs_build_secondary_vptr_vtt_inits (tree binfo, void *data_)
/* We're only interested in proper subobjects of the type being /* We're only interested in proper subobjects of the type being
constructed. */ constructed. */
if (same_type_p (BINFO_TYPE (binfo), data->type_being_constructed)) if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), data->type_being_constructed))
return NULL_TREE; return NULL_TREE;
/* We're only interested in bases with virtual bases or reachable /* We're only interested in bases with virtual bases or reachable
...@@ -6869,7 +6870,7 @@ build_ctor_vtbl_group (tree binfo, tree t) ...@@ -6869,7 +6870,7 @@ build_ctor_vtbl_group (tree binfo, tree t)
if (IDENTIFIER_GLOBAL_VALUE (id)) if (IDENTIFIER_GLOBAL_VALUE (id))
return; return;
gcc_assert (!same_type_p (BINFO_TYPE (binfo), t)); gcc_assert (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t));
/* Build a version of VTBL (with the wrong type) for use in /* Build a version of VTBL (with the wrong type) for use in
constructing the addresses of secondary vtables in the constructing the addresses of secondary vtables in the
construction vtable group. */ construction vtable group. */
...@@ -6925,9 +6926,9 @@ accumulate_vtbl_inits (tree binfo, ...@@ -6925,9 +6926,9 @@ accumulate_vtbl_inits (tree binfo,
{ {
int i; int i;
tree base_binfo; tree base_binfo;
int ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t); int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
gcc_assert (same_type_p (BINFO_TYPE (binfo), BINFO_TYPE (orig_binfo))); gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), BINFO_TYPE (orig_binfo)));
/* If it doesn't have a vptr, we don't do anything. */ /* If it doesn't have a vptr, we don't do anything. */
if (!TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo))) if (!TYPE_CONTAINS_VPTR_P (BINFO_TYPE (binfo)))
...@@ -6975,7 +6976,7 @@ dfs_accumulate_vtbl_inits (tree binfo, ...@@ -6975,7 +6976,7 @@ dfs_accumulate_vtbl_inits (tree binfo,
{ {
tree inits = NULL_TREE; tree inits = NULL_TREE;
tree vtbl = NULL_TREE; tree vtbl = NULL_TREE;
int ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t); int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
if (ctor_vtbl_p if (ctor_vtbl_p
&& BINFO_VIRTUAL_P (orig_binfo) && BINFO_PRIMARY_P (orig_binfo)) && BINFO_VIRTUAL_P (orig_binfo) && BINFO_PRIMARY_P (orig_binfo))
...@@ -7109,8 +7110,8 @@ build_vtbl_initializer (tree binfo, ...@@ -7109,8 +7110,8 @@ build_vtbl_initializer (tree binfo,
vid.derived = t; vid.derived = t;
vid.rtti_binfo = rtti_binfo; vid.rtti_binfo = rtti_binfo;
vid.last_init = &vid.inits; vid.last_init = &vid.inits;
vid.primary_vtbl_p = (binfo == TYPE_BINFO (t)); vid.primary_vtbl_p = SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t);
vid.ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t); vid.ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t);
vid.generate_vcall_entries = true; vid.generate_vcall_entries = true;
/* The first vbase or vcall offset is at index -3 in the vtable. */ /* The first vbase or vcall offset is at index -3 in the vtable. */
vid.index = ssize_int(-3 * TARGET_VTABLE_DATA_ENTRY_DISTANCE); vid.index = ssize_int(-3 * TARGET_VTABLE_DATA_ENTRY_DISTANCE);
...@@ -7523,7 +7524,7 @@ add_vcall_offset_vtbl_entries_1 (tree binfo, vtbl_init_data* vid) ...@@ -7523,7 +7524,7 @@ add_vcall_offset_vtbl_entries_1 (tree binfo, vtbl_init_data* vid)
/* When processing BINFO, we only want to generate vcall slots for /* When processing BINFO, we only want to generate vcall slots for
function slots introduced in BINFO. So don't try to generate function slots introduced in BINFO. So don't try to generate
one if the function isn't even defined in BINFO. */ one if the function isn't even defined in BINFO. */
if (!same_type_p (DECL_CONTEXT (orig_fn), BINFO_TYPE (binfo))) if (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), DECL_CONTEXT (orig_fn)))
continue; continue;
add_vcall_offset (orig_fn, binfo, vid); add_vcall_offset (orig_fn, binfo, vid);
......
...@@ -1370,6 +1370,14 @@ struct lang_type GTY(()) ...@@ -1370,6 +1370,14 @@ struct lang_type GTY(())
have this flag set. */ have this flag set. */
#define BINFO_NEW_VTABLE_MARKED(B) (BINFO_FLAG_2 (B)) #define BINFO_NEW_VTABLE_MARKED(B) (BINFO_FLAG_2 (B))
/* Compare a BINFO_TYPE with another type for equality. For a binfo,
this is functionally equivalent to using same_type_p, but
measurably faster. At least one of the arguments must be a
BINFO_TYPE. The other can be a BINFO_TYPE or a regular type. If
BINFO_TYPE(T) ever stops being the main variant of the class the
binfo is for, this macro must change. */
#define SAME_BINFO_TYPE_P(A, B) ((A) == (B))
/* Any subobject that needs a new vtable must have a vptr and must not /* Any subobject that needs a new vtable must have a vptr and must not
be a non-virtual primary base (since it would then use the vtable from a be a non-virtual primary base (since it would then use the vtable from a
derived class and never become non-primary.) */ derived class and never become non-primary.) */
......
...@@ -979,7 +979,7 @@ expand_member_init (tree name) ...@@ -979,7 +979,7 @@ expand_member_init (tree name)
/* Look for a direct base. */ /* Look for a direct base. */
for (i = 0; BINFO_BASE_ITERATE (class_binfo, i, direct_binfo); ++i) for (i = 0; BINFO_BASE_ITERATE (class_binfo, i, direct_binfo); ++i)
if (same_type_p (basetype, BINFO_TYPE (direct_binfo))) if (SAME_BINFO_TYPE_P (BINFO_TYPE (direct_binfo), basetype))
break; break;
/* Look for a virtual base -- unless the direct base is itself /* Look for a virtual base -- unless the direct base is itself
......
...@@ -90,7 +90,7 @@ lookup_base_r (tree binfo, tree base, base_access access, ...@@ -90,7 +90,7 @@ lookup_base_r (tree binfo, tree base, base_access access,
tree base_binfo; tree base_binfo;
base_kind found = bk_not_base; base_kind found = bk_not_base;
if (same_type_p (BINFO_TYPE (binfo), base)) if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), base))
{ {
/* We have found a base. Check against what we have found /* We have found a base. Check against what we have found
already. */ already. */
...@@ -279,7 +279,7 @@ dynamic_cast_base_recurse (tree subtype, tree binfo, bool is_via_virtual, ...@@ -279,7 +279,7 @@ dynamic_cast_base_recurse (tree subtype, tree binfo, bool is_via_virtual,
int i; int i;
int worst = -2; int worst = -2;
if (BINFO_TYPE (binfo) == subtype) if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), subtype))
{ {
if (is_via_virtual) if (is_via_virtual)
return -1; return -1;
...@@ -2346,7 +2346,7 @@ binfo_from_vbase (tree binfo) ...@@ -2346,7 +2346,7 @@ binfo_from_vbase (tree binfo)
tree tree
binfo_via_virtual (tree binfo, tree limit) binfo_via_virtual (tree binfo, tree limit)
{ {
for (; binfo && (!limit || !same_type_p (BINFO_TYPE (binfo), limit)); for (; binfo && !SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), limit);
binfo = BINFO_INHERITANCE_CHAIN (binfo)) binfo = BINFO_INHERITANCE_CHAIN (binfo))
{ {
if (BINFO_VIRTUAL_P (binfo)) if (BINFO_VIRTUAL_P (binfo))
...@@ -2382,7 +2382,7 @@ copied_binfo (tree binfo, tree here) ...@@ -2382,7 +2382,7 @@ copied_binfo (tree binfo, tree here)
cbinfo = copied_binfo (BINFO_INHERITANCE_CHAIN (binfo), here); cbinfo = copied_binfo (BINFO_INHERITANCE_CHAIN (binfo), here);
for (ix = 0; BINFO_BASE_ITERATE (cbinfo, ix, base_binfo); ix++) for (ix = 0; BINFO_BASE_ITERATE (cbinfo, ix, base_binfo); ix++)
if (BINFO_TYPE (base_binfo) == BINFO_TYPE (binfo)) if (SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo), BINFO_TYPE (binfo)))
{ {
result = base_binfo; result = base_binfo;
break; break;
...@@ -2390,7 +2390,7 @@ copied_binfo (tree binfo, tree here) ...@@ -2390,7 +2390,7 @@ copied_binfo (tree binfo, tree here)
} }
else else
{ {
gcc_assert (BINFO_TYPE (here) == BINFO_TYPE (binfo)); gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (here), BINFO_TYPE (binfo)));
result = here; result = here;
} }
...@@ -2407,7 +2407,7 @@ binfo_for_vbase (tree base, tree t) ...@@ -2407,7 +2407,7 @@ binfo_for_vbase (tree base, tree t)
for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0; for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0;
VEC_iterate (tree, vbases, ix, binfo); ix++) VEC_iterate (tree, vbases, ix, binfo); ix++)
if (BINFO_TYPE (binfo) == base) if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), base))
return binfo; return binfo;
return NULL; return NULL;
} }
...@@ -2422,7 +2422,7 @@ original_binfo (tree binfo, tree here) ...@@ -2422,7 +2422,7 @@ original_binfo (tree binfo, tree here)
{ {
tree result = NULL; tree result = NULL;
if (BINFO_TYPE (binfo) == BINFO_TYPE (here)) if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), BINFO_TYPE (here)))
result = here; result = here;
else if (BINFO_VIRTUAL_P (binfo)) else if (BINFO_VIRTUAL_P (binfo))
result = (CLASSTYPE_VBASECLASSES (BINFO_TYPE (here)) result = (CLASSTYPE_VBASECLASSES (BINFO_TYPE (here))
...@@ -2439,7 +2439,8 @@ original_binfo (tree binfo, tree here) ...@@ -2439,7 +2439,8 @@ original_binfo (tree binfo, tree here)
tree base_binfo; tree base_binfo;
for (ix = 0; (base_binfo = BINFO_BASE_BINFO (base_binfos, ix)); ix++) for (ix = 0; (base_binfo = BINFO_BASE_BINFO (base_binfos, ix)); ix++)
if (BINFO_TYPE (base_binfo) == BINFO_TYPE (binfo)) if (SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo),
BINFO_TYPE (binfo)))
{ {
result = base_binfo; result = base_binfo;
break; break;
......
...@@ -611,7 +611,7 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt) ...@@ -611,7 +611,7 @@ copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
tree base_binfo; tree base_binfo;
gcc_assert (!BINFO_DEPENDENT_BASE_P (binfo)); gcc_assert (!BINFO_DEPENDENT_BASE_P (binfo));
gcc_assert (type == BINFO_TYPE (binfo)); gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), type));
BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo); BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo);
BINFO_VIRTUALS (new_binfo) = BINFO_VIRTUALS (binfo); BINFO_VIRTUALS (new_binfo) = BINFO_VIRTUALS (binfo);
......
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