Commit 30d44f48 authored by Matthias Braun's avatar Matthias Braun
Browse files

Replace get_{struct|union|class}_XXX with get_compound_XXX where possible

parent 58423576
......@@ -462,8 +462,8 @@ static size_t get_free_methods(ir_entity ***free_methods)
/* insert all methods that are used in global variables initializers */
ir_type *global_tp = get_glob_type();
for (size_t j = 0, m = get_class_n_members(global_tp); j < m; ++j) {
ir_entity *const ent = get_class_member(global_tp, j);
for (size_t j = 0, m = get_compound_n_members(global_tp); j < m; ++j) {
ir_entity *const ent = get_compound_member(global_tp, j);
add_method_address(ent, free_set);
}
ir_type *tls_tp = get_tls_type();
......
......@@ -657,8 +657,8 @@ static void analyse_irg_entity_usage(ir_graph *irg)
/* set initial state to not_taken, as this is the "smallest" state */
ir_type *frame_type = get_irg_frame_type(irg);
for (size_t i = 0, n = get_class_n_members(frame_type); i < n; ++i) {
ir_entity *ent = get_class_member(frame_type, i);
for (size_t i = 0, n = get_compound_n_members(frame_type); i < n; ++i) {
ir_entity *ent = get_compound_member(frame_type, i);
/* methods can only be analyzed globally */
if (is_method_entity(ent))
continue;
......
......@@ -1464,13 +1464,12 @@ static void dump_type_info(ir_type *const tp, ir_entity *const ent, void *const
for (size_t i = get_class_n_supertypes(tp); i-- > 0;) {
print_type_type_edge(F, tp, get_class_supertype(tp, i), TYPE_SUPER_EDGE_ATTR);
}
for (size_t i = get_class_n_members(tp); i-- > 0;) {
print_type_ent_edge(F, tp, get_class_member(tp, i), TYPE_MEMBER_EDGE_ATTR);
}
break;
/* FALLTHROUGH */
case tpo_union:
case tpo_struct:
for (size_t i = get_struct_n_members(tp); i-- > 0;) {
print_type_ent_edge(F, tp, get_struct_member(tp, i), TYPE_MEMBER_EDGE_ATTR);
for (size_t i = get_compound_n_members(tp); i-- > 0;) {
ir_entity const *const entity = get_compound_member(tp, i);
print_type_ent_edge(F, tp, entity, TYPE_MEMBER_EDGE_ATTR);
}
break;
case tpo_method:
......@@ -1481,11 +1480,6 @@ static void dump_type_info(ir_type *const tp, ir_entity *const ent, void *const
print_type_type_edge(F, tp, get_method_res_type(tp, i), METH_RES_EDGE_ATTR,i);
}
break;
case tpo_union:
for (size_t i = get_union_n_members(tp); i-- > 0;) {
print_type_ent_edge(F, tp, get_union_member(tp, i), TYPE_MEMBER_EDGE_ATTR);
}
break;
case tpo_array:
print_type_type_edge(F, tp, get_array_element_type(tp), ARR_ELT_TYPE_EDGE_ATTR);
ir_node *size = get_array_size(tp);
......
......@@ -652,6 +652,24 @@ void dump_entity_to_file(FILE *const out, const ir_entity *const ent)
fprintf(out, "\n");
}
static void dump_compound_members(FILE *const F, ir_type const *const type)
{
if ((verbosity & (dump_verbosity_methods|dump_verbosity_fields)) == 0
|| !(verbosity & dump_verbosity_nostatic))
return;
fprintf(F, "\n members:\n");
for (size_t i = 0, n = get_compound_n_members(type); i < n; ++i) {
const ir_entity *mem = get_compound_member(type, i);
if (is_method_entity(mem)) {
if (!(verbosity & dump_verbosity_methods))
continue;
} else if (!(verbosity & dump_verbosity_fields))
continue;
dump_entity_to_file_prefix(F, mem, " ");
}
}
void dump_type_to_file(FILE *const F, const ir_type *const tp)
{
ir_fprintf(F, "%+F", tp);
......@@ -659,18 +677,7 @@ void dump_type_to_file(FILE *const F, const ir_type *const tp)
switch (get_type_tpop_code(tp)) {
case tpo_class:
if ((verbosity & dump_verbosity_methods) || (verbosity & dump_verbosity_fields)) {
fprintf(F, "\n members:\n");
}
for (size_t i = 0; i < get_class_n_members(tp); ++i) {
const ir_entity *mem = get_class_member(tp, i);
if (((verbosity & dump_verbosity_methods) && is_Method_type(get_entity_type(mem))) ||
((verbosity & dump_verbosity_fields) && !is_Method_type(get_entity_type(mem))) ) {
if (!(verbosity & dump_verbosity_nostatic)) {
dump_entity_to_file_prefix(F, mem, " ");
}
}
}
dump_compound_members(F, tp);
if (verbosity & dump_verbosity_typeattrs) {
fprintf(F, " supertypes: ");
for (size_t i = 0; i < get_class_n_supertypes(tp); ++i) {
......@@ -700,14 +707,7 @@ void dump_type_to_file(FILE *const F, const ir_type *const tp)
case tpo_union:
case tpo_struct:
if (verbosity & dump_verbosity_fields)
fprintf(F, "\n members: ");
for (size_t i = 0; i < get_compound_n_members(tp); ++i) {
const ir_entity *mem = get_compound_member(tp, i);
if (verbosity & dump_verbosity_fields) {
dump_entity_to_file_prefix(F, mem, " ");
}
}
dump_compound_members(F, tp);
break;
case tpo_array:
......@@ -795,9 +795,9 @@ void dump_types_as_text(FILE *const out)
void dump_globals_as_text(FILE *const out)
{
const ir_type *global_type = get_glob_type();
for (size_t i = 0, n_members = get_class_n_members(global_type);
for (size_t i = 0, n_members = get_compound_n_members(global_type);
i < n_members; ++i) {
const ir_entity *entity = get_class_member(global_type, i);
const ir_entity *entity = get_compound_member(global_type, i);
dump_entity_to_file(out, entity);
}
}
......@@ -24,7 +24,7 @@
void opt_frame_irg(ir_graph *irg)
{
ir_type *frame_tp = get_irg_frame_type(irg);
size_t n = get_class_n_members(frame_tp);
size_t n = get_compound_n_members(frame_tp);
if (n <= 0)
return;
......@@ -33,7 +33,7 @@ void opt_frame_irg(ir_graph *irg)
/* clear all entity links */
for (size_t i = n; i-- > 0;) {
ir_entity *entity = get_class_member(frame_tp, i);
ir_entity *entity = get_compound_member(frame_tp, i);
set_entity_link(entity, NULL);
}
......@@ -51,7 +51,7 @@ void opt_frame_irg(ir_graph *irg)
/* link unused ones */
ir_entity *list = NULL;
for (size_t i = n; i-- > 0;) {
ir_entity *entity = get_class_member(frame_tp, i);
ir_entity *entity = get_compound_member(frame_tp, i);
if (get_entity_link(entity) == NULL) {
set_entity_link(entity, list);
list = entity;
......
......@@ -243,9 +243,9 @@ static void copy_frame_entities(ir_graph *from, ir_graph *to)
ir_type *from_frame = get_irg_frame_type(from);
ir_type *to_frame = get_irg_frame_type(to);
assert(from_frame != to_frame);
for (size_t i = 0, n_members = get_class_n_members(from_frame);
for (size_t i = 0, n_members = get_compound_n_members(from_frame);
i < n_members; ++i) {
ir_entity *old_ent = get_class_member(from_frame, i);
ir_entity *old_ent = get_compound_member(from_frame, i);
// parameter entities are already copied and the link has been set
if (!is_parameter_entity(old_ent)) {
......@@ -267,9 +267,9 @@ static void copy_parameter_entities(ir_node *call, ir_graph *called_graph)
ir_node *call_mem = get_Call_mem(call);
ir_node **sync_mem = NULL;
for (size_t i = 0, n_entities = get_class_n_members(called_frame);
for (size_t i = 0, n_entities = get_compound_n_members(called_frame);
i < n_entities; ++i) {
ir_entity *old_entity = get_class_member(called_frame, i);
ir_entity *old_entity = get_compound_member(called_frame, i);
if (!is_parameter_entity(old_entity))
continue;
......
......@@ -284,8 +284,8 @@ static bool find_possible_replacements(ir_graph *irg)
{
/* First, clear the link field of all interesting entities. */
ir_type *frame_tp = get_irg_frame_type(irg);
for (size_t i = get_class_n_members(frame_tp); i-- > 0;) {
ir_entity *ent = get_class_member(frame_tp, i);
for (size_t i = get_compound_n_members(frame_tp); i-- > 0;) {
ir_entity *ent = get_compound_member(frame_tp, i);
set_entity_link(ent, NULL);
}
......
......@@ -160,8 +160,9 @@ static void compute_down_closure(ir_type *tp)
}
/* entities */
for (size_t i = 0, n_members = get_class_n_members(tp); i < n_members; ++i) {
ir_entity *mem = get_class_member(tp, i);
for (size_t i = 0, n_members = get_compound_n_members(tp); i < n_members;
++i) {
ir_entity *mem = get_compound_member(tp, i);
size_t j, n_overwrittenby = get_entity_n_overwrittenby(mem);
myset = get_entity_map(mem, d_down);
......@@ -209,8 +210,9 @@ static void compute_up_closure(ir_type *tp)
}
/* entities */
for (size_t i = 0, n_members = get_class_n_members(tp); i < n_members; ++i) {
ir_entity *mem = get_class_member(tp, i);
for (size_t i = 0, n_members = get_compound_n_members(tp); i < n_members;
++i) {
ir_entity *mem = get_compound_member(tp, i);
pset *myset = get_entity_map(mem, d_up);
for (size_t j = 0, n_overwrites = get_entity_n_overwrites(mem);
j < n_overwrites; ++j) {
......
......@@ -121,9 +121,9 @@ static void do_type_walk(ir_type *const tp, ir_entity *const ent,
i < n_types; ++i) {
do_type_walk(get_class_supertype(tp, i), NULL, pre, post, env);
}
for (size_t i = 0, n_mem = get_class_n_members(tp);
for (size_t i = 0, n_mem = get_compound_n_members(tp);
i < n_mem; ++i) {
do_type_walk(NULL, get_class_member(tp, i), pre, post, env);
do_type_walk(NULL, get_compound_member(tp, i), pre, post, env);
}
for (size_t i = 0, n_types = get_class_n_subtypes(tp);
i < n_types; ++i) {
......@@ -132,9 +132,10 @@ static void do_type_walk(ir_type *const tp, ir_entity *const ent,
break;
case tpo_struct:
for (size_t i = 0, n_mem = get_struct_n_members(tp);
case tpo_union:
for (size_t i = 0, n_mem = get_compound_n_members(tp);
i < n_mem; ++i) {
do_type_walk(NULL, get_struct_member(tp, i), pre, post, env);
do_type_walk(NULL, get_compound_member(tp, i), pre, post, env);
}
break;
......@@ -148,13 +149,6 @@ static void do_type_walk(ir_type *const tp, ir_entity *const ent,
}
break;
case tpo_union:
for (size_t i = 0, n_members = get_union_n_members(tp);
i < n_members; ++i) {
do_type_walk(NULL, get_union_member(tp, i), pre, post, env);
}
break;
case tpo_array:
do_type_walk(get_array_element_type(tp), NULL, pre, post, env);
break;
......@@ -392,16 +386,10 @@ void walk_types_entities(ir_type *tp, entity_walk_func *doit, void *env)
{
switch (get_type_tpop_code(tp)) {
case tpo_class:
for (size_t i = 0, n = get_class_n_members(tp); i < n; ++i)
doit(get_class_member(tp, i), env);
break;
case tpo_struct:
for (size_t i = 0, n = get_struct_n_members(tp); i < n; ++i)
doit(get_struct_member(tp, i), env);
break;
case tpo_union:
for (size_t i = 0, n = get_union_n_members(tp); i < n; ++i)
doit(get_union_member(tp, i), env);
for (size_t i = 0, n = get_compound_n_members(tp); i < n; ++i)
doit(get_compound_member(tp, i), env);
break;
case tpo_array:
case tpo_code:
......
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