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 | |
| 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')
| -rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
| -rw-r--r-- | gcc/cp/call.c | 2 | ||||
| -rw-r--r-- | gcc/cp/class.c | 48 | ||||
| -rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
| -rw-r--r-- | gcc/cp/decl2.c | 3 | ||||
| -rw-r--r-- | gcc/cp/typeck.c | 6 |
6 files changed, 63 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f5e7d63..25efd97 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2001-09-21 Richard Henderson <rth@redhat.com> + + * 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. + Fri Sep 21 08:16:19 2001 J"orn Rennecke <amylaar@redhat.com> * decl.c (grokdeclarator): Use C syntax for attr_flags declaration. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 9caae4b..4273148 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4321,7 +4321,7 @@ build_over_call (cand, args, flags) if (DECL_CONTEXT (fn) && TYPE_JAVA_INTERFACE (DECL_CONTEXT (fn))) fn = build_java_interface_fn_ref (fn, *p); else - fn = build_vtbl_ref (build_indirect_ref (*p, 0), DECL_VINDEX (fn)); + fn = build_vfn_ref (build_indirect_ref (*p, 0), DECL_VINDEX (fn)); TREE_TYPE (fn) = t; } else if (DECL_INLINE (fn)) 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 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 2662356..525750d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3527,6 +3527,7 @@ extern tree perform_implicit_conversion PARAMS ((tree, tree)); /* in class.c */ extern tree build_vbase_path PARAMS ((enum tree_code, tree, tree, tree, int)); extern tree build_vtbl_ref PARAMS ((tree, tree)); +extern tree build_vfn_ref PARAMS ((tree, tree)); extern tree get_vtable_decl PARAMS ((tree, int)); extern void add_method PARAMS ((tree, tree, int)); extern int currently_open_class PARAMS ((tree)); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 28236ef..372b8ee 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2168,7 +2168,8 @@ mark_vtable_entries (decl) tree fnaddr = TREE_VALUE (entries); tree fn; - if (TREE_CODE (fnaddr) != ADDR_EXPR) + if (TREE_CODE (fnaddr) != ADDR_EXPR + && TREE_CODE (fnaddr) != FDESC_EXPR) /* This entry is an offset: a virtual base class offset, a virtual call offset, an RTTI offset, etc. */ continue; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8a84565..54dc0ed 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2910,6 +2910,12 @@ get_member_function_from_ptrfunc (instance_ptrptr, function) vtbl = build_indirect_ref (vtbl, NULL); e2 = build_array_ref (vtbl, idx); + /* When using function descriptors, the address of the + vtable entry is treated as a function pointer. */ + if (TARGET_VTABLE_USES_DESCRIPTORS) + e2 = build1 (NOP_EXPR, TREE_TYPE (e2), + build_unary_op (ADDR_EXPR, e2, /*noconvert=*/1)); + TREE_TYPE (e2) = TREE_TYPE (e3); e1 = build_conditional_expr (e1, e2, e3); |
