diff options
| author | Richard Henderson <rth@redhat.com> | 2001-09-21 09:58:22 -0700 |
|---|---|---|
| committer | Richard Henderson <rth@gcc.gnu.org> | 2001-09-21 09:58:22 -0700 |
| commit | 6723181663a87a735bdfdf2e16a6bd41dbc30be1 (patch) | |
| tree | 746cb9ad4b9e1b8562a39be3d23d3c85abfdac19 /gcc/cp/class.c | |
| parent | 2e3b2d2c0791d979571fd33155b62e66ea7fe27c (diff) | |
| download | gcc-6723181663a87a735bdfdf2e16a6bd41dbc30be1.zip gcc-6723181663a87a735bdfdf2e16a6bd41dbc30be1.tar.gz gcc-6723181663a87a735bdfdf2e16a6bd41dbc30be1.tar.bz2 | |
tree.def (FDESC_EXPR): New.
gcc/
* tree.def (FDESC_EXPR): New.
* expr.c (expand_expr): Handle it.
* varasm.c (initializer_constant_valid_p): Likewise.
(output_constant): Likewise.
* defaults.h (TARGET_VTABLE_USES_DESCRIPTORS): New.
* config/ia64/ia64.h (TARGET_VTABLE_USES_DESCRIPTORS): New.
(ASM_OUTPUT_FDESC): New.
* doc/tm.texi: Document the new macros.
gcc/cp/
* class.c (set_vindex): Mind TARGET_VTABLE_USES_DESCRIPTORS.
(build_vtbl_initializer): Likewise.
(build_vfn_ref): New.
* cp-tree.h: Declare it.
* call.c (build_over_call): Use it.
* decl2.c (mark_vtable_entries): Mark FDESC_EXPR.
* typeck.c (get_member_function_from_ptrfunc): Mind descriptors.
gcc/java/
* class.c (get_dispatch_table): Handle function descriptors.
(build_dtable_decl): Likewise.
* expr.c (build_invokevirtual): Likewise.
gcc/testsuite/
* g++.old-deja/g++.abi/ptrmem.C: Update for ia64 c++ abi.
* g++.old-deja/g++.abi/vtable2.C: Likewise.
From-SVN: r45733
Diffstat (limited to 'gcc/cp/class.c')
| -rw-r--r-- | gcc/cp/class.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0c106c3..ac71fc5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -459,9 +459,9 @@ build_vtable_entry_ref (basetype, idx) } /* Given an object INSTANCE, return an expression which yields the - virtual function vtable element corresponding to INDEX. There are - many special cases for INSTANCE which we take care of here, mainly - to avoid creating extra tree nodes when we don't have to. */ + vtable element corresponding to INDEX. There are many special + cases for INSTANCE which we take care of here, mainly to avoid + creating extra tree nodes when we don't have to. */ tree build_vtbl_ref (instance, idx) @@ -543,6 +543,24 @@ build_vtbl_ref (instance, idx) return aref; } +/* Given an object INSTANCE, return an expression which yields a + function pointer corresponding to vtable element INDEX. */ + +tree +build_vfn_ref (instance, idx) + tree instance, idx; +{ + tree aref = build_vtbl_ref (instance, idx); + + /* When using function descriptors, the address of the + vtable entry is treated as a function pointer. */ + if (TARGET_VTABLE_USES_DESCRIPTORS) + return build1 (NOP_EXPR, TREE_TYPE (aref), + build_unary_op (ADDR_EXPR, aref, /*noconvert=*/1)); + + return aref; +} + /* Return the name of the virtual function table (as an IDENTIFIER_NODE) for the given TYPE. */ @@ -823,7 +841,9 @@ set_vindex (decl, vfuns_p) { int vindex; - vindex = (*vfuns_p)++; + vindex = *vfuns_p; + *vfuns_p += (TARGET_VTABLE_USES_DESCRIPTORS + ? TARGET_VTABLE_USES_DESCRIPTORS : 1); DECL_VINDEX (decl) = build_shared_int_cst (vindex); } @@ -7587,7 +7607,25 @@ build_vtbl_initializer (binfo, orig_binfo, t, rtti_binfo, non_fn_entries_p) } /* And add it to the chain of initializers. */ - vfun_inits = tree_cons (NULL_TREE, init, vfun_inits); + if (TARGET_VTABLE_USES_DESCRIPTORS) + { + int i; + if (init == size_zero_node) + for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i) + vfun_inits = tree_cons (NULL_TREE, init, vfun_inits); + else + for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i) + { + tree fdesc = build (FDESC_EXPR, vfunc_ptr_type_node, + TREE_OPERAND (init, 0), + build_int_2 (i, 0)); + TREE_CONSTANT (fdesc) = 1; + + vfun_inits = tree_cons (NULL_TREE, fdesc, vfun_inits); + } + } + else + vfun_inits = tree_cons (NULL_TREE, init, vfun_inits); } /* The initializers for virtual functions were built up in reverse |
