diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-03-28 19:27:15 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-03-28 19:27:15 +0000 |
commit | da3d4dfa91a591ace5286a262e7cc817a60b5827 (patch) | |
tree | 3d2b3ff39b53629e00a55e4fccb013b1edbff512 /gcc/cp/rtti.c | |
parent | 65a0aad55d6e7d02cc09f8d869ff9cb7555544b4 (diff) | |
download | gcc-da3d4dfa91a591ace5286a262e7cc817a60b5827.zip gcc-da3d4dfa91a591ace5286a262e7cc817a60b5827.tar.gz gcc-da3d4dfa91a591ace5286a262e7cc817a60b5827.tar.bz2 |
Put RTTI entries at negative offsets in new ABI.
* class.c (dfs_build_vbase_offset_vtbl_entries): Put the first
vbase offset at index -3, not -1.
(build_vtabe_offset_vtbl_entries): Use unmarked_vtable_pathp, not
dfs_vtable_path_unmarked_real_bases_queue_p to walk bases.
(dfs_build_vcall_offset_vtbl_entries): Don't use skip_rtti_stuff.
(build_rtti_vtbl_entries): New function.
(set_rtti_entry): Remove.
(build_primary_vtable): Don't use it.
(build_secondary_vtable): Likewise.
(start_vtable): Remove.
(first_vfun_index): New function.
(set_vindex): Likewise.
(add_virtual_function): Don't call start_vtable. Do call
set_vindex.
(set_primary_base): Rename parameter.
(determine_primary_base): Likewise.
(num_vfun_entries): Don't use skip_rtti_stuff.
(num_extra_vtbl_entries): Include RTTI information.
(build_vtbl_initializer): Use build_rtti_vtbl_entries.
(skip_rtti_stuff): Remove.
(dfs_modify_vtables): Don't use it.
(modify_all_vtables): Don't use start_vtable. Do use set_vindex.
(layout_nonempty_base_or_field): Update size handling.
(create_vtable_ptr): Tweak.
(layout_class_type): Adjust parameter names.
(finish_struct_1): Simplify.
* cp-tree.h (CLASSTYPE_VSIZE): Tweak documentation.
(skip_rtti_stuff): Remove.
(first_vfun_index): New function.
(dfs_vtable_path_unmarked_real_bases_queue_p): Remove.
(dfs_vtable_path_marked_real_bases_queue_p): Remove.
(marked_vtable_pathp): Declare.
(unmarked_vtable_pathp): Likewise.
* error.c (dump_expr): Use first_vfun_index to calculate vtable
offsets.
* rtti.c (build_headof): Look for RTTI at negative offsets.
(get_tinfo_decl_dynamic): Likewise.
(tinfo_base_init): Don't take the address of the TINFO_VTABLE_DECL
here.
(create_pseudo_type_info): Do it here instead. Adjust so that
vptr points at first virtual function.
* search.c (marked_vtable_pathp): Make it global.
(unmarked_vtable_pathp): Likewise.
(dfs_vtable_path_unmarked_real_bases_queue_p): Remove.
(dfs_vtable_path_marked_real_bases_queue_p): Likewise.
(dfs_get_pure_virtuals): Don't use skip_rtti_stuff.
(get_pure_virtuals): Likewise.
(expand_upcast_fixups): Likewise.
* tree.c (debug_binfo): Likewise.
* tinfo.cc (__dynamic_cast): Look for vtable_prefix at appropriate
negative offset.
From-SVN: r32787
Diffstat (limited to 'gcc/cp/rtti.c')
-rw-r--r-- | gcc/cp/rtti.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 30a972c..ea21756 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -132,6 +132,7 @@ build_headof (exp) tree type = TREE_TYPE (exp); tree aref; tree offset; + tree index; my_friendly_assert (TREE_CODE (type) == POINTER_TYPE, 20000112); type = TREE_TYPE (type); @@ -151,7 +152,15 @@ build_headof (exp) /* We use this a couple of times below, protect it. */ exp = save_expr (exp); - aref = build_vtbl_ref (build_indirect_ref (exp, NULL_PTR), integer_zero_node); + /* Under the new ABI, the offset-to-top field is at index -2 from + the vptr. */ + if (new_abi_rtti_p ()) + index = build_int_2 (-2, -1); + /* But under the old ABI, it is at offset zero. */ + else + index = integer_zero_node; + + aref = build_vtbl_ref (build_indirect_ref (exp, NULL_PTR), index); if (flag_vtable_thunks) offset = aref; @@ -230,6 +239,7 @@ get_tinfo_decl_dynamic (exp) { /* build reference to type_info from vtable. */ tree t; + tree index; if (! flag_rtti) error ("taking dynamic typeid of object with -fno-rtti"); @@ -247,10 +257,15 @@ get_tinfo_decl_dynamic (exp) exp = build_indirect_ref (exp, NULL_PTR); } - if (flag_vtable_thunks) - t = build_vfn_ref ((tree *) 0, exp, integer_one_node); + /* The RTTI information is always in the vtable, but it's at + different indices depending on the ABI. */ + if (new_abi_rtti_p ()) + index = minus_one_node; + else if (flag_vtable_thunks) + index = integer_one_node; else - t = build_vfn_ref ((tree *) 0, exp, integer_zero_node); + index = integer_zero_node; + t = build_vfn_ref ((tree *) 0, exp, index); TREE_TYPE (t) = build_pointer_type (tinfo_decl_type); return t; } @@ -1284,8 +1299,7 @@ tinfo_base_init (desc, target) if (TINFO_VTABLE_DECL (desc)) { - tree vtbl_ptr = build_unary_op (ADDR_EXPR, TINFO_VTABLE_DECL (desc), 0); - + tree vtbl_ptr = TINFO_VTABLE_DECL (desc); init = tree_cons (NULL_TREE, vtbl_ptr, init); } @@ -1616,7 +1630,18 @@ create_pseudo_type_info VPARAMS((const char *real_name, int ident, ...)) /* Get the vtable decl. */ real_type = xref_tag (class_type_node, get_identifier (real_name), 1); vtable_decl = get_vtable_decl (real_type, /*complete=*/1); - + vtable_decl = build_unary_op (ADDR_EXPR, vtable_decl, 0); + + /* Under the new ABI, we need to point into the middle of the + vtable. */ + if (vbase_offsets_in_vtable_p ()) + { + vtable_decl = build (PLUS_EXPR, TREE_TYPE (vtable_decl), + vtable_decl, + size_extra_vtbl_entries (TYPE_BINFO (real_type))); + TREE_CONSTANT (vtable_decl) = 1; + } + /* First field is the pseudo type_info base class. */ fields[0] = build_lang_decl (FIELD_DECL, NULL_TREE, ti_desc_type_node); |