This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Remove more old abi
- To: mark at codesourcery dot com
- Subject: [C++ PATCH] Remove more old abi
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Tue, 31 Jul 2001 13:59:33 +0100
- CC: gcc-patches at gcc dot gnu dot org, jason at redhat dot com
- Organization: Codesourcery LLC
Mark,
This removes some more old ABI code.
1) We no longer have virtual base pointer fields, so that can go.
2) Every polymophic class has a vtable pointer, so looking
for the vtable in easy.
3) Added a comment answering Jason's query as to why
create_real_tinfo_var has to have a hidden name.
booted & tested on i686-pc-linux-gnu, ok for mainline?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-07-31 Nathan Sidwell <nathan@codesourcery.com>
The 3.0 ABI no longer has vbase pointer fields.
* cp-tree.h (VBASE_NAME, VBASE_NAME_FORMAT, VBASE_NAME_P,
FORMAT_VBASE_NAME): Remove.
* method.c (do_build_copy_constructor): Adjust.
(do_build_assign_ref): Adjust.
* search.c (lookup_field_r): Adjust.
* typeck.c (build_component_ref): Adjust.
The 3.0 ABI always has a vtable pointer at the start of every
polymorphic class.
* rtti.c (build_headof_sub): Remove.
(build_headof): Adjust.
(get_tinfo_decl_dynamic): No need to check flag_rtti
here. Adjust.
(create_real_tinfo_var): Explain why we need a hidden name.
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.632
diff -c -3 -p -r1.632 cp-tree.h
*** cp-tree.h 2001/07/25 15:04:30 1.632
--- cp-tree.h 2001/07/31 12:37:52
*************** extern varray_type local_classes;
*** 3140,3147 ****
#define VFIELD_BASE "$vf"
#define VFIELD_NAME "_vptr$"
#define VFIELD_NAME_FORMAT "_vptr$%s"
- #define VBASE_NAME "_vb$"
- #define VBASE_NAME_FORMAT "_vb$%s"
#define STATIC_NAME_FORMAT "_%s$%s"
#define ANON_AGGRNAME_FORMAT "$_%d"
--- 3140,3145 ----
*************** extern varray_type local_classes;
*** 3162,3169 ****
#define VFIELD_BASE ".vf"
#define VFIELD_NAME "_vptr."
#define VFIELD_NAME_FORMAT "_vptr.%s"
- #define VBASE_NAME "_vb."
- #define VBASE_NAME_FORMAT "_vb.%s"
#define STATIC_NAME_FORMAT "_%s.%s"
#define ANON_AGGRNAME_FORMAT "._%d"
--- 3160,3165 ----
*************** extern varray_type local_classes;
*** 3197,3207 ****
(!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, \
sizeof (VFIELD_NAME) - 1))
#define VFIELD_NAME_FORMAT "_vptr_%s"
- #define VBASE_NAME "__vb_"
- #define VBASE_NAME_P(ID_NODE) \
- (!strncmp (IDENTIFIER_POINTER (ID_NODE), VBASE_NAME, \
- sizeof (VBASE_NAME) - 1))
- #define VBASE_NAME_FORMAT "__vb_%s"
#define STATIC_NAME_FORMAT "__static_%s_%s"
#define ANON_AGGRNAME_PREFIX "__anon_"
--- 3193,3198 ----
*************** extern varray_type local_classes;
*** 3244,3253 ****
&& IDENTIFIER_POINTER (ID_NODE)[2] == 't' \
&& IDENTIFIER_POINTER (ID_NODE)[3] == JOINER)
- #define VBASE_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == 'v' \
- && IDENTIFIER_POINTER (ID_NODE)[2] == 'b' \
- && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER)
-
#define TEMP_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), AUTO_TEMP_NAME, sizeof (AUTO_TEMP_NAME)-1))
#define VFIELD_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, sizeof(VFIELD_NAME)-1))
--- 3235,3240 ----
*************** extern varray_type local_classes;
*** 3260,3273 ****
#define ANON_PARMNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == '_' \
&& IDENTIFIER_POINTER (ID_NODE)[1] <= '9')
#endif /* !defined(NO_DOLLAR_IN_LABEL) || !defined(NO_DOT_IN_LABEL) */
-
- /* Store the vbase pointer field name for type TYPE into pointer BUF. */
- #define FORMAT_VBASE_NAME(BUF,TYPE) do { \
- char *wbuf = (char *) alloca (TYPE_ASSEMBLER_NAME_LENGTH (TYPE) \
- + sizeof (VBASE_NAME) + 1); \
- sprintf (wbuf, VBASE_NAME_FORMAT, TYPE_ASSEMBLER_NAME_STRING (TYPE)); \
- (BUF) = wbuf; \
- } while (0)
/* Returns non-zero iff NODE is a declaration for the global function
`main'. */
--- 3247,3252 ----
Index: method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.206
diff -c -3 -p -r1.206 method.c
*** method.c 2001/07/29 01:39:17 1.206
--- method.c 2001/07/31 12:37:52
*************** do_build_copy_constructor (fndecl)
*** 588,595 ****
{
if (VFIELD_NAME_P (DECL_NAME (field)))
continue;
- if (VBASE_NAME_P (DECL_NAME (field)))
- continue;
/* True for duplicate members. */
if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field)
--- 588,593 ----
*************** do_build_assign_ref (fndecl)
*** 677,684 ****
if (DECL_NAME (field))
{
if (VFIELD_NAME_P (DECL_NAME (field)))
- continue;
- if (VBASE_NAME_P (DECL_NAME (field)))
continue;
/* True for duplicate members. */
--- 675,680 ----
Index: rtti.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/rtti.c,v
retrieving revision 1.118
diff -c -3 -p -r1.118 rtti.c
*** rtti.c 2001/07/24 08:56:12 1.118
--- rtti.c 2001/07/31 12:37:52
*************** Boston, MA 02111-1307, USA. */
*** 41,47 ****
extern struct obstack permanent_obstack;
- static tree build_headof_sub PARAMS((tree));
static tree build_headof PARAMS((tree));
static tree ifnonnull PARAMS((tree, tree));
static tree tinfo_name PARAMS((tree));
--- 41,46 ----
*************** init_rtti_processing ()
*** 82,104 ****
build_qualified_type (type_info_type_node, TYPE_QUAL_CONST);
}
- /* Given a pointer to an object with at least one virtual table
- pointer somewhere, return a pointer to a possible sub-object that
- has a virtual table pointer in it that is the vtable parent for
- that sub-object. */
-
- static tree
- build_headof_sub (exp)
- tree exp;
- {
- tree type = TREE_TYPE (TREE_TYPE (exp));
- tree basetype = CLASSTYPE_RTTI (type);
- tree binfo = get_binfo (basetype, type, 0);
-
- exp = convert_pointer_to_real (binfo, exp);
- return exp;
- }
-
/* Given the expression EXP of type `class *', return the head of the
object pointed to by EXP with type cv void*, if the class has any
virtual functions (TYPE_POLYMORPHIC_P), else just return the
--- 81,86 ----
*************** build_headof (exp)
*** 118,127 ****
if (!TYPE_POLYMORPHIC_P (type))
return exp;
- /* If we don't have rtti stuff, get to a sub-object that does. */
- if (!CLASSTYPE_VFIELDS (TREE_TYPE (TREE_TYPE (exp))))
- exp = build_headof_sub (exp);
-
/* We use this a couple of times below, protect it. */
exp = save_expr (exp);
--- 100,105 ----
*************** get_tinfo_decl_dynamic (exp)
*** 204,220 ****
tree t;
tree index;
- if (! flag_rtti)
- error ("taking dynamic typeid of object with -fno-rtti");
-
- /* If we don't have rtti stuff, get to a sub-object that does. */
- if (! CLASSTYPE_VFIELDS (type))
- {
- exp = build_unary_op (ADDR_EXPR, exp, 0);
- exp = build_headof_sub (exp);
- exp = build_indirect_ref (exp, NULL);
- }
-
/* The RTTI information is at index -1. */
index = integer_minus_one_node;
t = build_vfn_ref (exp, index);
--- 182,187 ----
*************** create_real_tinfo_var (target_type, name
*** 1146,1152 ****
tree decl;
tree hidden_name;
char hidden[30];
!
sprintf (hidden, "__ti_%d", count++);
hidden_name = get_identifier (hidden);
--- 1113,1122 ----
tree decl;
tree hidden_name;
char hidden[30];
!
! /* We cannot give this the name NAME, as that already is globally
! bound to the tinfo_decl we originally created for this type in
! get_tinfo_decl. */
sprintf (hidden, "__ti_%d", count++);
hidden_name = get_identifier (hidden);
Index: search.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/search.c,v
retrieving revision 1.212
diff -c -3 -p -r1.212 search.c
*** search.c 2001/07/21 09:42:18 1.212
--- search.c 2001/07/31 12:37:53
*************** lookup_field_r (binfo, data)
*** 1451,1465 ****
}
else
{
- /* If the thing we're looking for is a virtual base class, then
- we know we've got what we want at this point; there's no way
- to get an ambiguity. */
- if (VBASE_NAME_P (lfi->name))
- {
- lfi->rval = nval;
- return nval;
- }
-
if (from_dep_base_p && TREE_CODE (nval) != TYPE_DECL
/* We need to return a member template class so we can
define partial specializations. Is there a better
--- 1451,1456 ----
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.361
diff -c -3 -p -r1.361 typeck.c
*** typeck.c 2001/07/25 09:38:25 1.361
--- typeck.c 2001/07/31 12:37:55
*************** build_component_ref (datum, component, b
*** 2237,2252 ****
error ("invalid reference to NULL ptr, use ptr-to-member instead");
return error_mark_node;
}
! if (VBASE_NAME_P (DECL_NAME (field)))
! {
! /* It doesn't matter which vbase pointer we grab, just
! find one of them. */
! tree binfo = get_binfo (base,
! TREE_TYPE (TREE_TYPE (addr)), 0);
! addr = convert_pointer_to_real (binfo, addr);
! }
! else
! addr = convert_pointer_to (base, addr);
datum = build_indirect_ref (addr, NULL);
if (datum == error_mark_node)
return error_mark_node;
--- 2237,2243 ----
error ("invalid reference to NULL ptr, use ptr-to-member instead");
return error_mark_node;
}
! addr = convert_pointer_to (base, addr);
datum = build_indirect_ref (addr, NULL);
if (datum == error_mark_node)
return error_mark_node;