Commit e20463aa by Nathan Froyd Committed by Nathan Froyd

rtti.c (tinfo_base_init): Use build_constructor instead of build_constructor_from_list.

	* rtti.c (tinfo_base_init): Use build_constructor instead of
	build_constructor_from_list.  Don't cons a tree node for
	returning.
	(generic_initializer): Use build_constructor_single instead of
	build_constructor_from_list.
	(ptr_initializer): Use build_constructor instead of
	build_constructor_from_list
	(ptm_initializer): Likewise.
	(class_initializer): Likewise.  Take varargs instead of TRAIL.
	(get_pseudo_ti_init): Adjust calls to class_initializer.  Use
	build_constructor instead of build_constructor_from_list.

From-SVN: r159788
parent 42f40af4
2010-05-24 Nathan Froyd <froydnj@codesourcery.com>
* rtti.c (tinfo_base_init): Use build_constructor instead of
build_constructor_from_list. Don't cons a tree node for
returning.
(generic_initializer): Use build_constructor_single instead of
build_constructor_from_list.
(ptr_initializer): Use build_constructor instead of
build_constructor_from_list
(ptm_initializer): Likewise.
(class_initializer): Likewise. Take varargs instead of TRAIL.
(get_pseudo_ti_init): Adjust calls to class_initializer. Use
build_constructor instead of build_constructor_from_list.
2010-05-22 Steven Bosscher <steven@gcc.gnu.org> 2010-05-22 Steven Bosscher <steven@gcc.gnu.org>
* semantics.c: Include bitmap.h. * semantics.c: Include bitmap.h.
......
...@@ -116,7 +116,7 @@ static tree tinfo_base_init (tinfo_s *, tree); ...@@ -116,7 +116,7 @@ static tree tinfo_base_init (tinfo_s *, tree);
static tree generic_initializer (tinfo_s *, tree); static tree generic_initializer (tinfo_s *, tree);
static tree ptr_initializer (tinfo_s *, tree); static tree ptr_initializer (tinfo_s *, tree);
static tree ptm_initializer (tinfo_s *, tree); static tree ptm_initializer (tinfo_s *, tree);
static tree class_initializer (tinfo_s *, tree, tree); static tree class_initializer (tinfo_s *, tree, unsigned, ...);
static void create_pseudo_type_info (int, const char *, ...); static void create_pseudo_type_info (int, const char *, ...);
static tree get_pseudo_ti_init (tree, unsigned); static tree get_pseudo_ti_init (tree, unsigned);
static unsigned get_pseudo_ti_index (tree); static unsigned get_pseudo_ti_index (tree);
...@@ -862,9 +862,10 @@ involves_incomplete_p (tree type) ...@@ -862,9 +862,10 @@ involves_incomplete_p (tree type)
static tree static tree
tinfo_base_init (tinfo_s *ti, tree target) tinfo_base_init (tinfo_s *ti, tree target)
{ {
tree init = NULL_TREE; tree init;
tree name_decl; tree name_decl;
tree vtable_ptr; tree vtable_ptr;
VEC(constructor_elt,gc) *v;
{ {
tree name_name, name_string; tree name_name, name_string;
...@@ -927,14 +928,13 @@ tinfo_base_init (tinfo_s *ti, tree target) ...@@ -927,14 +928,13 @@ tinfo_base_init (tinfo_s *ti, tree target)
ti->vtable = vtable_ptr; ti->vtable = vtable_ptr;
} }
init = tree_cons (NULL_TREE, vtable_ptr, init); v = VEC_alloc (constructor_elt, gc, 2);
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, vtable_ptr);
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, decay_conversion (name_decl));
init = tree_cons (NULL_TREE, decay_conversion (name_decl), init); init = build_constructor (init_list_type_node, v);
init = build_constructor_from_list (init_list_type_node, nreverse (init));
TREE_CONSTANT (init) = 1; TREE_CONSTANT (init) = 1;
TREE_STATIC (init) = 1; TREE_STATIC (init) = 1;
init = tree_cons (NULL_TREE, init, NULL_TREE);
return init; return init;
} }
...@@ -948,7 +948,7 @@ generic_initializer (tinfo_s *ti, tree target) ...@@ -948,7 +948,7 @@ generic_initializer (tinfo_s *ti, tree target)
{ {
tree init = tinfo_base_init (ti, target); tree init = tinfo_base_init (ti, target);
init = build_constructor_from_list (init_list_type_node, init); init = build_constructor_single (init_list_type_node, NULL_TREE, init);
TREE_CONSTANT (init) = 1; TREE_CONSTANT (init) = 1;
TREE_STATIC (init) = 1; TREE_STATIC (init) = 1;
return init; return init;
...@@ -965,15 +965,16 @@ ptr_initializer (tinfo_s *ti, tree target) ...@@ -965,15 +965,16 @@ ptr_initializer (tinfo_s *ti, tree target)
tree to = TREE_TYPE (target); tree to = TREE_TYPE (target);
int flags = qualifier_flags (to); int flags = qualifier_flags (to);
bool incomplete = target_incomplete_p (to); bool incomplete = target_incomplete_p (to);
VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 3);
if (incomplete) if (incomplete)
flags |= 8; flags |= 8;
init = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, flags), init); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init);
init = tree_cons (NULL_TREE, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, flags));
get_tinfo_ptr (TYPE_MAIN_VARIANT (to)), CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
init); get_tinfo_ptr (TYPE_MAIN_VARIANT (to)));
init = build_constructor_from_list (init_list_type_node, nreverse (init)); init = build_constructor (init_list_type_node, v);
TREE_CONSTANT (init) = 1; TREE_CONSTANT (init) = 1;
TREE_STATIC (init) = 1; TREE_STATIC (init) = 1;
return init; return init;
...@@ -992,20 +993,19 @@ ptm_initializer (tinfo_s *ti, tree target) ...@@ -992,20 +993,19 @@ ptm_initializer (tinfo_s *ti, tree target)
tree klass = TYPE_PTRMEM_CLASS_TYPE (target); tree klass = TYPE_PTRMEM_CLASS_TYPE (target);
int flags = qualifier_flags (to); int flags = qualifier_flags (to);
bool incomplete = target_incomplete_p (to); bool incomplete = target_incomplete_p (to);
VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 4);
if (incomplete) if (incomplete)
flags |= 0x8; flags |= 0x8;
if (!COMPLETE_TYPE_P (klass)) if (!COMPLETE_TYPE_P (klass))
flags |= 0x10; flags |= 0x10;
init = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, flags), init); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init);
init = tree_cons (NULL_TREE, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (NULL_TREE, flags));
get_tinfo_ptr (TYPE_MAIN_VARIANT (to)), CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
init); get_tinfo_ptr (TYPE_MAIN_VARIANT (to)));
init = tree_cons (NULL_TREE, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, get_tinfo_ptr (klass));
get_tinfo_ptr (klass),
init); init = build_constructor (init_list_type_node, v);
init = build_constructor_from_list (init_list_type_node, nreverse (init));
TREE_CONSTANT (init) = 1; TREE_CONSTANT (init) = 1;
TREE_STATIC (init) = 1; TREE_STATIC (init) = 1;
return init; return init;
...@@ -1013,15 +1013,23 @@ ptm_initializer (tinfo_s *ti, tree target) ...@@ -1013,15 +1013,23 @@ ptm_initializer (tinfo_s *ti, tree target)
/* Return the CONSTRUCTOR expr for a type_info of class TYPE. /* Return the CONSTRUCTOR expr for a type_info of class TYPE.
TI provides information about the particular __class_type_info derivation, TI provides information about the particular __class_type_info derivation,
which adds hint flags and TRAIL initializers to the type_info base. */ which adds hint flags and N extra initializers to the type_info base. */
static tree static tree
class_initializer (tinfo_s *ti, tree target, tree trail) class_initializer (tinfo_s *ti, tree target, unsigned n, ...)
{ {
tree init = tinfo_base_init (ti, target); tree init = tinfo_base_init (ti, target);
va_list extra_inits;
unsigned i;
VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, n+1);
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init);
va_start (extra_inits, n);
for (i = 0; i < n; i++)
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, va_arg (extra_inits, tree));
va_end (extra_inits);
TREE_CHAIN (init) = trail; init = build_constructor (init_list_type_node, v);
init = build_constructor_from_list (init_list_type_node, init);
TREE_CONSTANT (init) = 1; TREE_CONSTANT (init) = 1;
TREE_STATIC (init) = 1; TREE_STATIC (init) = 1;
return init; return init;
...@@ -1082,17 +1090,16 @@ get_pseudo_ti_init (tree type, unsigned tk_index) ...@@ -1082,17 +1090,16 @@ get_pseudo_ti_init (tree type, unsigned tk_index)
return generic_initializer (ti, type); return generic_initializer (ti, type);
case TK_CLASS_TYPE: case TK_CLASS_TYPE:
return class_initializer (ti, type, NULL_TREE); return class_initializer (ti, type, 0);
case TK_SI_CLASS_TYPE: case TK_SI_CLASS_TYPE:
{ {
tree base_binfo = BINFO_BASE_BINFO (TYPE_BINFO (type), 0); tree base_binfo = BINFO_BASE_BINFO (TYPE_BINFO (type), 0);
tree tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo)); tree tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo));
tree base_inits = tree_cons (NULL_TREE, tinfo, NULL_TREE);
/* get_tinfo_ptr might have reallocated the tinfo_descs vector. */ /* get_tinfo_ptr might have reallocated the tinfo_descs vector. */
ti = VEC_index (tinfo_s, tinfo_descs, tk_index); ti = VEC_index (tinfo_s, tinfo_descs, tk_index);
return class_initializer (ti, type, base_inits); return class_initializer (ti, type, 1, tinfo);
} }
default: default:
...@@ -1105,17 +1112,21 @@ get_pseudo_ti_init (tree type, unsigned tk_index) ...@@ -1105,17 +1112,21 @@ get_pseudo_ti_init (tree type, unsigned tk_index)
tree offset_type = integer_types[itk_long]; tree offset_type = integer_types[itk_long];
tree base_inits = NULL_TREE; tree base_inits = NULL_TREE;
int ix; int ix;
VEC(constructor_elt,gc) *init_vec = NULL;
constructor_elt *e;
gcc_assert (tk_index >= TK_FIXED); gcc_assert (tk_index >= TK_FIXED);
VEC_safe_grow (constructor_elt, gc, init_vec, nbases);
/* Generate the base information initializer. */ /* Generate the base information initializer. */
for (ix = nbases; ix--;) for (ix = nbases; ix--;)
{ {
tree base_binfo = BINFO_BASE_BINFO (binfo, ix); tree base_binfo = BINFO_BASE_BINFO (binfo, ix);
tree base_init = NULL_TREE; tree base_init;
int flags = 0; int flags = 0;
tree tinfo; tree tinfo;
tree offset; tree offset;
VEC(constructor_elt,gc) *v;
if (VEC_index (tree, base_accesses, ix) == access_public_node) if (VEC_index (tree, base_accesses, ix) == access_public_node)
flags |= 2; flags |= 2;
...@@ -1138,25 +1149,22 @@ get_pseudo_ti_init (tree type, unsigned tk_index) ...@@ -1138,25 +1149,22 @@ get_pseudo_ti_init (tree type, unsigned tk_index)
offset = fold_build2_loc (input_location, offset = fold_build2_loc (input_location,
BIT_IOR_EXPR, offset_type, offset, BIT_IOR_EXPR, offset_type, offset,
build_int_cst (offset_type, flags)); build_int_cst (offset_type, flags));
base_init = tree_cons (NULL_TREE, offset, base_init); v = VEC_alloc (constructor_elt, gc, 2);
base_init = tree_cons (NULL_TREE, tinfo, base_init); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, tinfo);
base_init = build_constructor_from_list (init_list_type_node, base_init); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, offset);
base_inits = tree_cons (NULL_TREE, base_init, base_inits); base_init = build_constructor (init_list_type_node, v);
e = VEC_index (constructor_elt, init_vec, ix);
e->index = NULL_TREE;
e->value = base_init;
} }
base_inits = build_constructor_from_list (init_list_type_node, base_inits); base_inits = build_constructor (init_list_type_node, init_vec);
base_inits = tree_cons (NULL_TREE, base_inits, NULL_TREE);
/* Prepend the number of bases. */
base_inits = tree_cons (NULL_TREE,
build_int_cst (NULL_TREE, nbases),
base_inits);
/* Prepend the hint flags. */
base_inits = tree_cons (NULL_TREE,
build_int_cst (NULL_TREE, hint),
base_inits);
/* get_tinfo_ptr might have reallocated the tinfo_descs vector. */ /* get_tinfo_ptr might have reallocated the tinfo_descs vector. */
ti = VEC_index (tinfo_s, tinfo_descs, tk_index); ti = VEC_index (tinfo_s, tinfo_descs, tk_index);
return class_initializer (ti, type, base_inits); return class_initializer (ti, type, 3,
build_int_cst (NULL_TREE, hint),
build_int_cst (NULL_TREE, nbases),
base_inits);
} }
} }
} }
......
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