+2001-05-11 Alexandre Oliva <aoliva@redhat.com>
+
+ Reverted Geoff Keating's 2001-05-03's patch.
+
2001-05-11 Ira Ruben <ira@apple.com>
* cp/cp-tree.h (C_EXP_ORIGINAL_CODE): Delete; declared in c-common.h.
CPTI_NELTS_IDENTIFIER,
CPTI_THIS_IDENTIFIER,
CPTI_PFN_IDENTIFIER,
- CPTI_PFN_VFLAG_IDENTIFIER,
CPTI_PFN_OR_DELTA2_IDENTIFIER,
CPTI_VPTR_IDENTIFIER,
CPTI_STD_IDENTIFIER,
#define nelts_identifier cp_global_trees[CPTI_NELTS_IDENTIFIER]
#define this_identifier cp_global_trees[CPTI_THIS_IDENTIFIER]
#define pfn_identifier cp_global_trees[CPTI_PFN_IDENTIFIER]
-#define pfn_vflag_identifier cp_global_trees[CPTI_PFN_VFLAG_IDENTIFIER]
#define pfn_or_delta2_identifier cp_global_trees[CPTI_PFN_OR_DELTA2_IDENTIFIER]
#define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER]
/* The name of the std namespace. */
/* A pointer-to-function member type looks like:
struct {
- __P __pfn;
- ptrdiff_t __delta;
+ short __delta;
+ short __index;
+ union {
+ P __pfn;
+ short __delta2;
+ } __pfn_or_delta2;
};
- where P is either a POINTER_TYPE to a METHOD_TYPE appropriate for
- the pointer to member, or one plus twice the index into the vtable;
- the two cases are distinguished by looking at the least significant
- bit of P. When FUNCTION_BOUNDARY is less than 16 (and so it might
- happen that the function pointer might naturally have the low bit
- set), the type is instead
+ where P is a POINTER_TYPE to a METHOD_TYPE appropriate for the
+ pointer to member. The fields are used as follows:
- struct {
- __P __pfn;
- ptrdiff_t __delta;
- char __vflag;
- };
+ If __INDEX is -1, then the function to call is non-virtual, and
+ is located at the address given by __PFN.
- and __pfn is a pointer to a method when __vflag is zero.
+ If __INDEX is zero, then this a NULL pointer-to-member.
- In all cases, the value to use for the THIS parameter is the
- address of the object plus __DELTA / 2 .
+ Otherwise, the function to call is virtual. Then, __DELTA2 gives
+ the offset from an instance of the object to the virtual function
+ table, and __INDEX - 1 is the index into the vtable to use to
+ find the function.
+
+ The value to use for the THIS parameter is the address of the
+ object plus __DELTA.
For example, given:
the pointer-to-member for `&S::f' looks like:
- { &f__2B2, 4, 0 };
+ { 4, -1, { &f__2B2 } };
+
+ The `4' means that given an `S*' you have to add 4 bytes to get to
+ the address of the `B2*'. Then, the -1 indicates that this is a
+ non-virtual function. Of course, `&f__2B2' is the name of that
+ function.
+
+ (Of course, the exact values may differ depending on the mangling
+ scheme, sizes of types, and such.).
+
+ Under the new ABI, we do:
+
+ struct {
+ __P __pfn;
+ ptrdiff_t __delta;
+ };
-*/
+ (We don't need DELTA2, because the vtable is always the first thing
+ in the object.) If the function is virtual, then PFN is one plus
+ twice the index into the vtable; otherwise, it is just a pointer to
+ the function. */
/* Get the POINTER_TYPE to the METHOD_TYPE associated with this
pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true,
extern int cp_has_mutable_p PARAMS ((tree));
extern int at_least_as_qualified_p PARAMS ((tree, tree));
extern int more_qualified_p PARAMS ((tree, tree));
-extern tree build_ptrmemfunc1 PARAMS ((tree, tree, tree,
- tree));
-extern void expand_ptrmemfunc_cst PARAMS ((tree, tree *,
- tree *, tree *));
+extern tree build_ptrmemfunc1 PARAMS ((tree, tree, tree));
+extern void expand_ptrmemfunc_cst PARAMS ((tree, tree *, tree *));
extern tree pfn_from_ptrmemfunc PARAMS ((tree));
extern tree type_after_usual_arithmetic_conversions PARAMS ((tree, tree));
extern tree composite_pointer_type PARAMS ((tree, tree, tree, tree,
{ "nelts", &nelts_identifier, 0 },
{ THIS_NAME, &this_identifier, 0 },
{ VTABLE_PFN_NAME, &pfn_identifier, 0 },
- { "__vflag", &pfn_vflag_identifier, 0 },
{ "__pfn_or_delta2", &pfn_or_delta2_identifier, 0 },
{ "_vptr", &vptr_identifier, 0 },
{ "__vtt_parm", &vtt_parm_identifier, 0 },
fields[0] = build_decl (FIELD_DECL, pfn_identifier, type);
fields[1] = build_decl (FIELD_DECL, delta_identifier,
delta_type_node);
- if (FUNCTION_BOUNDARY < 16)
- {
- fields[2] = build_decl (FIELD_DECL, pfn_vflag_identifier,
- char_type_node);
- finish_builtin_type (t, "__ptrmemfunc_type", fields, 2, ptr_type_node);
- } else {
- finish_builtin_type (t, "__ptrmemfunc_type", fields, 1, ptr_type_node);
- }
+ finish_builtin_type (t, "__ptrmemfunc_type", fields, 1, ptr_type_node);
/* Zap out the name so that the back-end will give us the debugging
information for this anonymous RECORD_TYPE. */
{
tree delta;
tree pfn;
- tree flag;
- expand_ptrmemfunc_cst (cst, &delta, &pfn, &flag);
- cst = build_ptrmemfunc1 (type, delta, pfn, flag);
+ expand_ptrmemfunc_cst (cst, &delta, &pfn);
+ cst = build_ptrmemfunc1 (type, delta, pfn);
}
}
break;
idx = cp_build_binary_op (TRUNC_DIV_EXPR,
build1 (NOP_EXPR, vtable_index_type, e3),
TYPE_SIZE_UNIT (vtable_entry_type));
- if (FUNCTION_BOUNDARY < 16)
- {
- tree delta;
- tree pfn;
- if (TREE_CODE (function) == PTRMEM_CST)
- expand_ptrmemfunc_cst (function, &delta, &pfn, &e1);
- else
- e1 = build_component_ref (function, pfn_vflag_identifier,
- NULL_TREE, 0);
- }
- else
- {
- e1 = cp_build_binary_op (BIT_AND_EXPR,
- build1 (NOP_EXPR, vtable_index_type, e3),
- integer_one_node);
- }
+ e1 = cp_build_binary_op (BIT_AND_EXPR,
+ build1 (NOP_EXPR, vtable_index_type, e3),
+ integer_one_node);
vtbl = convert_pointer_to (ptr_type_node, instance);
delta = cp_convert (ptrdiff_type_node,
the other components as specified. */
tree
-build_ptrmemfunc1 (type, delta, pfn, flag)
- tree type, delta, pfn, flag;
+build_ptrmemfunc1 (type, delta, pfn)
+ tree type, delta, pfn;
{
tree u = NULL_TREE;
tree delta_field;
tree pfn_field;
- tree vflag_field;
/* Pull the FIELD_DECLs out of the type. */
pfn_field = TYPE_FIELDS (type);
delta_field = TREE_CHAIN (pfn_field);
- vflag_field = TREE_CHAIN (delta_field); /* NULL if no such field. */
/* Make sure DELTA has the type we want. */
delta = convert_and_check (delta_type_node, delta);
/* Finish creating the initializer. */
- if (FUNCTION_BOUNDARY < 16)
- {
- u = tree_cons (pfn_field, pfn,
- tree_cons (delta_field, delta,
- build_tree_list (vflag_field, flag)));
- }
- else
- {
- u = tree_cons (pfn_field, pfn,
- build_tree_list (delta_field, delta));
- }
+ u = tree_cons (pfn_field, pfn,
+ build_tree_list (delta_field, delta));
u = build (CONSTRUCTOR, type, NULL_TREE, u);
TREE_CONSTANT (u) = TREE_CONSTANT (pfn) && TREE_CONSTANT (delta);
TREE_STATIC (u) = (TREE_CONSTANT (u)
{
tree delta = NULL_TREE;
tree npfn = NULL_TREE;
- tree flag = NULL_TREE;
tree n;
if (!force
/* Obtain the function pointer and the current DELTA. */
if (TREE_CODE (pfn) == PTRMEM_CST)
- expand_ptrmemfunc_cst (pfn, &delta, &npfn, &flag);
+ expand_ptrmemfunc_cst (pfn, &delta, &npfn);
else
{
npfn = build_component_ref (pfn, pfn_identifier, NULL_TREE, 0);
delta = build_component_ref (pfn, delta_identifier, NULL_TREE, 0);
- if (FUNCTION_BOUNDARY < 16)
- flag = build_component_ref (pfn, pfn_vflag_identifier,
- NULL_TREE, 0);
}
/* Under the new ABI, the conversion is easy. Just adjust
the DELTA field. */
delta = cp_convert (ptrdiff_type_node, delta);
delta = cp_build_binary_op (PLUS_EXPR, delta, n);
- return build_ptrmemfunc1 (to_type, delta, npfn, flag);
+ return build_ptrmemfunc1 (to_type, delta, npfn);
}
/* Handle null pointer to member function conversions. */
pfn = build_c_cast (type, integer_zero_node);
return build_ptrmemfunc1 (to_type,
integer_zero_node,
- pfn,
- integer_zero_node);
+ pfn);
}
if (type_unknown_p (pfn))
return make_ptrmem_cst (to_type, fn);
}
-/* Return the DELTA, PFN, and FLAG values for the PTRMEM_CST
+/* Return the DELTA, IDX, PFN, and DELTA2 values for the PTRMEM_CST
given by CST.
??? There is no consistency as to the types returned for the above
integer_type_node. */
void
-expand_ptrmemfunc_cst (cst, delta, pfn, flag)
+expand_ptrmemfunc_cst (cst, delta, pfn)
tree cst;
tree *delta;
tree *pfn;
- tree *flag;
{
tree type = TREE_TYPE (cst);
tree fn = PTRMEM_CST_MEMBER (cst);
*delta = get_delta_difference (fn_class, ptr_class, /*force=*/0);
if (!DECL_VIRTUAL_P (fn))
- {
- *pfn = convert (TYPE_PTRMEMFUNC_FN_TYPE (type), build_addr_func (fn));
- *flag = integer_zero_node;
- }
+ *pfn = convert (TYPE_PTRMEMFUNC_FN_TYPE (type), build_addr_func (fn));
else
{
/* If we're dealing with a virtual function, we have to adjust 'this'
integer_one_node));
*pfn = fold (build1 (NOP_EXPR, TYPE_PTRMEMFUNC_FN_TYPE (type),
*pfn));
- *flag = integer_one_node;
}
}
{
tree delta;
tree pfn;
- tree flag;
- expand_ptrmemfunc_cst (t, &delta, &pfn, &flag);
+ expand_ptrmemfunc_cst (t, &delta, &pfn);
if (pfn)
return pfn;
}