Commit c7e266a6 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (CPTI_VTABLE_INDEX_TYPE): New macro.

	* cp-tree.h (CPTI_VTABLE_INDEX_TYPE): New macro.
	(CPTI_CLASS_STAR_TYPE): Remove.
	(vtable_index_type): Likewise.
	(class_star_type_node): Remove.
	(TYPE_PTRMEMFUNC_FN_TYPE): Adjust for the new ABI.
	(build_binary_op_nodefault): Remove.
	* call.c (build_new_op): Use build_binary_op instead of
	build_binary_op_nodefault.
	* decl.c (init_decl_processing): Remove class_star_type_node
	initialization.  Make delta_type_node ptrdiff_type_node under the
	new ABI.  Initialize vtable_index_type.
	(build_ptrmemfunc_type): Build different structures for the new
	ABI.
	(build_enumerator): Use build_binary_op instead of
	build_binary_op_nodefault.
	* method.c (build_overload_value): Mangle pointers-to-members
	appropriately under the new ABI.
	* typeck.c (build_array_ref): Use build_binary_op instead of
	build_binary_op_nodefault.
	(get_member_function_from_ptrfunc): Adjust for the new ABI.
	(build_binary_op_nodefault): Rename to ...
	(build_binary_op): ... this.  Remove old version.  Adjust for
	pointer-to-member comparisons under the new ABI.
	(build_ptrmemfunc1): Remove dead code.  Adjust for the new ABI.
	(build_ptrmemfunc): Adjust for the new ABI.
	(expand_ptrmemfunc_cst): Likewise.
	(delta2_from_ptrmemfunc): Assert that we're not using the new ABI.
	(pfn_from_ptrmemfunc): Adjust for the new ABI.

From-SVN: r32099
parent 2323b28b
2000-02-21 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (CPTI_VTABLE_INDEX_TYPE): New macro.
(CPTI_CLASS_STAR_TYPE): Remove.
(vtable_index_type): Likewise.
(class_star_type_node): Remove.
(TYPE_PTRMEMFUNC_FN_TYPE): Adjust for the new ABI.
(build_binary_op_nodefault): Remove.
* call.c (build_new_op): Use build_binary_op instead of
build_binary_op_nodefault.
* decl.c (init_decl_processing): Remove class_star_type_node
initialization. Make delta_type_node ptrdiff_type_node under the
new ABI. Initialize vtable_index_type.
(build_ptrmemfunc_type): Build different structures for the new
ABI.
(build_enumerator): Use build_binary_op instead of
build_binary_op_nodefault.
* method.c (build_overload_value): Mangle pointers-to-members
appropriately under the new ABI.
* typeck.c (build_array_ref): Use build_binary_op instead of
build_binary_op_nodefault.
(get_member_function_from_ptrfunc): Adjust for the new ABI.
(build_binary_op_nodefault): Rename to ...
(build_binary_op): ... this. Remove old version. Adjust for
pointer-to-member comparisons under the new ABI.
(build_ptrmemfunc1): Remove dead code. Adjust for the new ABI.
(build_ptrmemfunc): Adjust for the new ABI.
(expand_ptrmemfunc_cst): Likewise.
(delta2_from_ptrmemfunc): Assert that we're not using the new ABI.
(pfn_from_ptrmemfunc): Adjust for the new ABI.
2000-02-21 Gabriel Dos Reis <gdr@codesourcery.com>
* call.c (build_object_call): Compress consecutive calls to
......
......@@ -3407,7 +3407,7 @@ builtin:
case BIT_XOR_EXPR:
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
return build_binary_op_nodefault (code, arg1, arg2, code);
return build_binary_op (code, arg1, arg2);
case CONVERT_EXPR:
case NEGATE_EXPR:
......
......@@ -517,6 +517,7 @@ enum cp_tree_index
CPTI_WCHAR_DECL,
CPTI_VTABLE_ENTRY_TYPE,
CPTI_DELTA_TYPE,
CPTI_VTABLE_INDEX_TYPE,
CPTI_CLEANUP_TYPE,
CPTI_TI_DESC_TYPE,
......@@ -532,7 +533,6 @@ enum cp_tree_index
CPTI_PTMD_DESC_TYPE,
CPTI_BASE_DESC_TYPE,
CPTI_CLASS_STAR_TYPE,
CPTI_CLASS_TYPE,
CPTI_RECORD_TYPE,
CPTI_UNION_TYPE,
......@@ -601,7 +601,12 @@ extern tree cp_global_trees[CPTI_MAX];
#define void_zero_node cp_global_trees[CPTI_VOID_ZERO]
#define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL]
#define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
/* The type used to represent an offset by which to adjust the `this'
pointer in pointer-to-member types and, when not using vtable
thunks, in vtables. */
#define delta_type_node cp_global_trees[CPTI_DELTA_TYPE]
/* The type used to represent an index into the vtable. */
#define vtable_index_type cp_global_trees[CPTI_VTABLE_INDEX_TYPE]
#define ti_desc_type_node cp_global_trees[CPTI_TI_DESC_TYPE]
#define bltn_desc_type_node cp_global_trees[CPTI_BLTN_DESC_TYPE]
......@@ -616,7 +621,6 @@ extern tree cp_global_trees[CPTI_MAX];
#define ptmd_desc_type_node cp_global_trees[CPTI_PTMD_DESC_TYPE]
#define base_desc_type_node cp_global_trees[CPTI_BASE_DESC_TYPE]
#define class_star_type_node cp_global_trees[CPTI_CLASS_STAR_TYPE]
#define class_type_node cp_global_trees[CPTI_CLASS_TYPE]
#define record_type_node cp_global_trees[CPTI_RECORD_TYPE]
#define union_type_node cp_global_trees[CPTI_UNION_TYPE]
......@@ -2498,12 +2502,27 @@ extern int flag_new_for_scope;
function.
(Of course, the exact values may differ depending on the mangling
scheme, sizes of types, and such.). */
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,
before using this macro. */
#define TYPE_PTRMEMFUNC_FN_TYPE(NODE) (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (NODE)))))))
#define TYPE_PTRMEMFUNC_FN_TYPE(NODE) \
(flag_new_abi \
? (TREE_TYPE (TYPE_FIELDS (NODE))) \
: (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (NODE))))))))
/* Returns `A' for a type like `int (A::*)(double)' */
#define TYPE_PTRMEMFUNC_OBJECT_TYPE(NODE) \
......@@ -4341,7 +4360,6 @@ extern tree build_function_call_maybe PARAMS ((tree, tree));
extern tree convert_arguments PARAMS ((tree, tree, tree, int));
extern tree build_x_binary_op PARAMS ((enum tree_code, tree, tree));
extern tree build_binary_op PARAMS ((enum tree_code, tree, tree));
extern tree build_binary_op_nodefault PARAMS ((enum tree_code, tree, tree, enum tree_code));
extern tree build_x_unary_op PARAMS ((enum tree_code, tree));
extern tree build_unary_op PARAMS ((enum tree_code, tree, int));
extern tree unary_complex_lvalue PARAMS ((enum tree_code, tree));
......
......@@ -222,7 +222,6 @@ tree error_mark_list;
tree __ptmf_desc_array_type, __ptmd_desc_array_type;
#endif
tree class_star_type_node;
tree class_type_node, record_type_node, union_type_node, enum_type_node;
tree unknown_type_node;
......@@ -6207,15 +6206,18 @@ init_decl_processing ()
int_array_type_node
= build_array_type (integer_type_node, array_domain_type);
/* This is just some anonymous class type. Nobody should ever
need to look inside this envelope. */
class_star_type_node = build_pointer_type (make_aggr_type (RECORD_TYPE));
if (flag_huge_objects)
if (flag_new_abi)
delta_type_node = ptrdiff_type_node;
else if (flag_huge_objects)
delta_type_node = long_integer_type_node;
else
delta_type_node = short_integer_type_node;
if (flag_new_abi)
vtable_index_type = ptrdiff_type_node;
else
vtable_index_type = delta_type_node;
default_function_type
= build_function_type (integer_type_node, NULL_TREE);
......@@ -8804,27 +8806,36 @@ build_ptrmemfunc_type (type)
unqualified_variant
= build_ptrmemfunc_type (TYPE_MAIN_VARIANT (type));
u = make_aggr_type (UNION_TYPE);
SET_IS_AGGR_TYPE (u, 0);
fields[0] = build_lang_decl (FIELD_DECL, pfn_identifier, type);
fields[1] = build_lang_decl (FIELD_DECL, delta2_identifier,
delta_type_node);
finish_builtin_type (u, "__ptrmemfunc_type", fields, 1, ptr_type_node);
TYPE_NAME (u) = NULL_TREE;
t = make_aggr_type (RECORD_TYPE);
/* Let the front-end know this is a pointer to member function... */
TYPE_PTRMEMFUNC_FLAG (t) = 1;
/* ... and not really an aggregate. */
SET_IS_AGGR_TYPE (t, 0);
fields[0] = build_lang_decl (FIELD_DECL, delta_identifier,
delta_type_node);
fields[1] = build_lang_decl (FIELD_DECL, index_identifier,
delta_type_node);
fields[2] = build_lang_decl (FIELD_DECL, pfn_or_delta2_identifier, u);
finish_builtin_type (t, "__ptrmemfunc_type", fields, 2, ptr_type_node);
if (!flag_new_abi)
{
u = make_aggr_type (UNION_TYPE);
SET_IS_AGGR_TYPE (u, 0);
fields[0] = build_lang_decl (FIELD_DECL, pfn_identifier, type);
fields[1] = build_lang_decl (FIELD_DECL, delta2_identifier,
delta_type_node);
finish_builtin_type (u, "__ptrmemfunc_type", fields, 1, ptr_type_node);
TYPE_NAME (u) = NULL_TREE;
fields[0] = build_lang_decl (FIELD_DECL, delta_identifier,
delta_type_node);
fields[1] = build_lang_decl (FIELD_DECL, index_identifier,
delta_type_node);
fields[2] = build_lang_decl (FIELD_DECL, pfn_or_delta2_identifier, u);
finish_builtin_type (t, "__ptrmemfunc_type", fields, 2, ptr_type_node);
}
else
{
fields[0] = build_lang_decl (FIELD_DECL, pfn_identifier, type);
fields[1] = build_lang_decl (FIELD_DECL, delta_identifier,
delta_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. */
......@@ -12777,10 +12788,9 @@ build_enumerator (name, value, enumtype)
/* The next value is the previous value ... */
prev_value = DECL_INITIAL (TREE_VALUE (TYPE_VALUES (enumtype)));
/* ... plus one. */
value = build_binary_op_nodefault (PLUS_EXPR,
prev_value,
integer_one_node,
PLUS_EXPR);
value = build_binary_op (PLUS_EXPR,
prev_value,
integer_one_node);
if (tree_int_cst_lt (value, prev_value))
cp_error ("overflow in enumeration values at `%D'", name);
......
......@@ -851,6 +851,7 @@ build_overload_value (type, value, flags)
tree idx;
tree pfn;
tree delta2;
tree fn;
my_friendly_assert (TYPE_PTRMEMFUNC_P (type), 0);
......@@ -872,17 +873,26 @@ build_overload_value (type, value, flags)
my_friendly_assert (TREE_CODE (value) == PTRMEM_CST, 0);
expand_ptrmemfunc_cst (value, &delta, &idx, &pfn, &delta2);
fn = PTRMEM_CST_MEMBER (value);
build_overload_int (delta, flags);
OB_PUTC ('_');
build_overload_int (idx, flags);
OB_PUTC ('_');
if (pfn)
if (!flag_new_abi)
{
build_overload_int (idx, flags);
OB_PUTC ('_');
}
else if (DECL_VIRTUAL_P (fn))
{
build_overload_int (DECL_VINDEX (fn), flags);
OB_PUTC ('_');
}
if (!DECL_VIRTUAL_P (fn))
{
numeric_output_need_bar = 0;
build_overload_identifier (DECL_ASSEMBLER_NAME
(PTRMEM_CST_MEMBER (value)));
build_overload_identifier (DECL_ASSEMBLER_NAME (fn));
}
else
else if (!flag_new_abi)
{
OB_PUTC ('i');
build_overload_int (delta2, flags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment