This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ patch] Hookize output_vtable_inherit
> On Sat, 2003-06-21 at 12:06, Jan Hubicka wrote:
> >
> > Hi,
> > this patch adds hooks to assemble_variable to deal with output_vtable_inherit
> > as discussed earlier. I didn't find pleasant way to discover virtual tables
> > and vtts, so I simply look for them in the list.
>
> That's no good; let's not turn what used to be a constant-time operation
> into a linear-time operation. Add a mark bit if you need one.
OK, here is updated patch. There does not appear to be language
specific decl flag but I can use generic tree flag.
Does this look better?
(regtested/bootstrapped x86-64)
Mon Jun 23 20:11:36 CEST 2003 Jan Hubicka <jh@suse.cz>
* class.c (build_vtable): Make vtables.
* cp-tree.h (DECL_VTABLE_OR_VTT_P): New macro.
* decl2.c (output_vtable_inherit): Rename to ...
(prepare_assemble_variable): ... this one; change interface.
(maybe_emit_vtables): Do not call output_vtable_inherit.
* cp-lang.c (LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE): Define.
* cp-tree.h (prepare_assemble_variable): New.
* langhooks-def.h (LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE): New macro.
* langhooks.h (lang_hooks_for_decls): Add prepare_assemble_variable.
* varasm.c (assemble_variable): Call prepare_assemble_variable.
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.543
diff -c -3 -p -r1.543 class.c
*** class.c 17 Jun 2003 22:24:57 -0000 1.543
--- class.c 23 Jun 2003 18:11:05 -0000
*************** build_vtable (tree class_type, tree name
*** 530,535 ****
--- 530,536 ----
TREE_READONLY (decl) = 1;
DECL_VIRTUAL_P (decl) = 1;
DECL_ALIGN (decl) = TARGET_VTABLE_ENTRY_ALIGN;
+ DECL_VTABLE_OR_VTT_P (decl) = 1;
/* At one time the vtable info was grabbed 2 words at a time. This
fails on sparc unless you have 8-byte alignment. (tiemann) */
Index: cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.50
diff -c -3 -p -r1.50 cp-lang.c
*** cp-lang.c 7 Jun 2003 11:10:43 -0000 1.50
--- cp-lang.c 23 Jun 2003 18:11:05 -0000
*************** static bool cp_var_mod_type_p (tree);
*** 145,150 ****
--- 145,153 ----
#undef LANG_HOOKS_EXPR_SIZE
#define LANG_HOOKS_EXPR_SIZE cp_expr_size
+ #undef LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE
+ #define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE prepare_assemble_variable
+
#undef LANG_HOOKS_MAKE_TYPE
#define LANG_HOOKS_MAKE_TYPE cxx_make_type
#undef LANG_HOOKS_TYPE_FOR_MODE
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.858
diff -c -3 -p -r1.858 cp-tree.h
*** cp-tree.h 20 Jun 2003 02:40:33 -0000 1.858
--- cp-tree.h 23 Jun 2003 18:11:05 -0000
*************** struct diagnostic_context;
*** 73,78 ****
--- 73,79 ----
NEED_TEMPORARY_P (in REF_BIND, BASE_CONV)
IDENTIFIER_TYPENAME_P (in IDENTIFIER_NODE)
5: C_IS_RESERVED_WORD (in IDENTIFIER_NODE)
+ DECL_VTABLE_OR_VTT_P (in VAR_DECL)
6: For future expansion
Usage of TYPE_LANG_FLAG_?:
*************** struct lang_decl GTY(())
*** 2056,2061 ****
--- 2057,2065 ----
(DECL_CONTEXT (NODE) \
&& TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
+ /* 1 iff VAR_DECL node NODE is virtual table or VTT. */
+ #define DECL_VTABLE_OR_VTT_P(NODE) TREE_LANG_FLAG_5 (VAR_DECL_CHECK (NODE))
+
/* 1 iff NODE is function-local, but for types. */
#define LOCAL_CLASS_P(NODE) \
(decl_function_context (TYPE_MAIN_DECL (NODE)) != NULL_TREE)
*************** extern tree build_artificial_parm (tree,
*** 3794,3799 ****
--- 3798,3804 ----
extern tree get_guard (tree);
extern tree get_guard_cond (tree);
extern tree set_guard (tree);
+ extern void prepare_assemble_variable (tree);
extern void cp_error_at (const char *msgid, ...);
extern void cp_warning_at (const char *msgid, ...);
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.631
diff -c -3 -p -r1.631 decl2.c
*** decl2.c 23 Jun 2003 17:46:26 -0000 1.631
--- decl2.c 23 Jun 2003 18:11:05 -0000
*************** static void add_using_namespace (tree, t
*** 66,72 ****
static cxx_binding *ambiguous_decl (tree, cxx_binding *, cxx_binding *, int);
static tree build_anon_union_vars (tree);
static bool acceptable_java_type (tree);
- static void output_vtable_inherit (tree);
static tree start_objects (int, int);
static void finish_objects (int, int, tree);
static tree merge_functions (tree, tree);
--- 66,71 ----
*************** import_export_class (tree ctype)
*** 1606,1617 ****
/* We need to describe to the assembler the relationship between
a vtable and the vtable of the parent class. */
! static void
! output_vtable_inherit (tree vars)
{
tree parent;
rtx child_rtx, parent_rtx;
child_rtx = XEXP (DECL_RTL (vars), 0); /* strip the mem ref */
parent = binfo_for_vtable (vars);
--- 1606,1621 ----
/* We need to describe to the assembler the relationship between
a vtable and the vtable of the parent class. */
! void
! prepare_assemble_variable (tree vars)
{
tree parent;
rtx child_rtx, parent_rtx;
+ if (!flag_vtable_gc || TREE_CODE (vars) != VAR_DECL
+ || !DECL_VTABLE_OR_VTT_P (vars))
+ return;
+
child_rtx = XEXP (DECL_RTL (vars), 0); /* strip the mem ref */
parent = binfo_for_vtable (vars);
*************** maybe_emit_vtables (tree ctype)
*** 1708,1716 ****
rest_of_decl_compilation (vtbl, NULL, 1, 1);
- if (flag_vtable_gc)
- output_vtable_inherit (vtbl);
-
/* Because we're only doing syntax-checking, we'll never end up
actually marking the variable as written. */
if (flag_syntax_only)
--- 1711,1716 ----