The enum op_pin_state is defined in irop.h. */
FIRM_API op_pin_state get_irg_pinned(const ir_graph *irg);
-/** state: outs_state
- * Outs are the back edges or def-use edges of ir nodes.
- * Values: outs_none, outs_consistent, outs_inconsistent */
-typedef enum {
- outs_none, /**< Outs are not computed, no memory is allocated. */
- outs_consistent, /**< Outs are computed and correct. */
- outs_inconsistent /**< Outs have been computed, memory is still allocated,
- but the graph has been changed since. */
-} irg_outs_state;
-
/** state: callee_information_state
* Call nodes contain a list of possible callees. This list must be
* computed by an analysis.
FIRM_API irg_phase_state get_irp_phase_state(void);
FIRM_API void set_irp_phase_state(irg_phase_state s);
-FIRM_API irg_outs_state get_irp_ip_outs_state(void);
-FIRM_API void set_irp_ip_outs_inconsistent(void);
-
/**
* Creates an ir_prog pass for set_irp_phase_state().
*
/* Building and Removing the trout datastructure */
/*------------------------------------------------------------------*/
-/** The state of the tr_out datastructure.
- *
- * We reuse the enum of irouts.
- * @see irouts.h. */
-FIRM_API irg_outs_state get_trouts_state(void);
-/** Set the tr out state to inconsistent if it is consistent. */
-FIRM_API void set_trouts_inconsistent(void);
-
/** Compute the outs of types and entities.
*
* Collects all reference from irnodes to types or entities in the
}
}
-irg_outs_state get_trouts_state(void)
-{
- return irp->trouts_state;
-}
-
-void set_trouts_inconsistent(void)
-{
- if (irp->trouts_state == outs_consistent)
- irp->trouts_state = outs_inconsistent;
-}
-
/* compute the trouts data structures. */
void compute_trouts(void)
{
ir_type *type = get_irp_type(--i);
chain_types(type);
}
-
- irp->trouts_state = outs_consistent;
}
void free_trouts(void)
pmap_destroy(type_arraytype_map);
type_arraytype_map = NULL;
}
-
- irp->trouts_state = outs_none;
}
fprintf(out, "graph %s\n", get_irg_dump_name(irg));
}
-/** dumps something like:
- *
- * "prefix" "Name" (x): node1, ... node7,\n
- * "prefix" node8, ... node15,\n
- * "prefix" node16, node17\n
- */
-static void dump_node_list(FILE *F, firm_kind *k, const char *prefix,
- size_t (*get_entity_n_nodes)(firm_kind *ent),
- ir_node *(*get_entity_node)(firm_kind *ent, size_t pos),
- const char *name)
-{
- size_t i, n_nodes = get_entity_n_nodes(k);
- const char *comma = "";
-
- ir_fprintf(F, "%s %s (%zu):", prefix, name, n_nodes);
- for (i = 0; i < n_nodes; ++i) {
- if (i > 7 && !(i & 7)) { /* line break every eight node. */
- fprintf(F, ",\n%s ", prefix);
- comma = "";
- }
- fprintf(F, "%s ", comma);
- dump_node_label(F, get_entity_node(k, i));
- comma = ",";
- }
- fprintf(F, "\n");
-}
-
-/** dumps something like:
- *
- * "prefix" "Name" (x): node1, ... node7,\n
- * "prefix" node8, ... node15,\n
- * "prefix" node16, node17\n
- */
-static void dump_type_list(FILE *F, ir_type *tp, const char *prefix,
- size_t (*get_n_types)(const ir_type *tp),
- ir_type *(*get_type)(const ir_type *tp, size_t pos),
- const char *name)
-{
- size_t i, n_nodes = get_n_types(tp);
- const char *comma = "";
-
- ir_fprintf(F, "%s %s (%zu):", prefix, name, n_nodes);
- for (i = 0; i < n_nodes; ++i) {
- if (i > 7 && !(i & 7)) { /* line break every eight node. */
- fprintf(F, ",\n%s ", prefix);
- comma = "";
- }
- ir_fprintf(F, "%s %+F", comma, get_type(tp, i));
- comma = ",";
- }
- fprintf(F, "\n");
-}
-
static int need_nl = 1;
/**
}
fputc('\n', F);
}
-
- if (get_trouts_state()) {
- fprintf(F, "%s Entity outs:\n", prefix);
- dump_node_list(F, (firm_kind *)ent, prefix, (size_t(*)(firm_kind *))get_entity_n_accesses,
- (ir_node *(*)(firm_kind *, size_t))get_entity_access, "Accesses");
- dump_node_list(F, (firm_kind *)ent, prefix, (size_t(*)(firm_kind *))get_entity_n_references,
- (ir_node *(*)(firm_kind *, size_t))get_entity_reference, "References");
- }
}
void dump_entity_to_file(FILE *out, ir_entity *ent)
if (is_atomic_type(tp) || is_Method_type(tp))
fprintf(F, " mode: %s,\n", get_mode_name(get_type_mode(tp)));
- if (get_trouts_state()) {
- fprintf(F, "\n Type outs:\n");
- dump_node_list(F, (firm_kind *)tp, " ", (size_t(*)(firm_kind *))get_type_n_allocs,
- (ir_node *(*)(firm_kind *, size_t))get_type_alloc, "Allocations");
- dump_node_list(F, (firm_kind *)tp, " ", (size_t(*)(firm_kind *))get_type_n_casts,
- (ir_node *(*)(firm_kind *, size_t))get_type_cast, "Casts");
- dump_type_list(F, tp, " ", get_type_n_pointertypes_to, get_type_pointertype_to, "PointerTpsTo");
- }
-
fprintf(F, "\n\n");
}
irp->const_code_irg = new_const_code_irg();
irp->phase_state = phase_building;
- irp->outs_state = outs_none;
- irp->ip_outedges = NULL;
- irp->trouts_state = outs_none;
irp->class_cast_state = ir_class_casts_transitive;
irp->globals_entity_usage_state = ir_entity_usage_not_computed;
return &pass->pass;
}
-irg_outs_state get_irp_ip_outs_state(void)
-{
- return irp->outs_state;
-}
-
-void set_irp_ip_outs_inconsistent(void)
-{
- irp->outs_state = outs_inconsistent;
-}
-
void set_irp_ip_outedges(ir_node ** ip_outedges)
{
irp->ip_outedges = ip_outedges;
/* -- states of and access to generated information -- */
irg_phase_state phase_state; /**< The state of construction. */
- irg_outs_state outs_state; /**< The state of out edges of type information. */
ir_node **ip_outedges; /**< A huge Array that contains all out edges
in interprocedural view. */
- irg_outs_state trouts_state; /**< The state of out edges of type information. */
irg_callee_info_state callee_info_state; /**< Validity of callee information.
Contains the lowest value or all irgs. */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
| IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
- /* Calls might be removed/added. */
- set_trouts_inconsistent();
-
/* verify here */
irg_verify(irg, VERIFY_NORMAL);
/* control flow changed */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
| IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
-
- /* Calls might be removed. */
- set_trouts_inconsistent();
}
for (bl = env.all_blocks; bl != NULL; bl = bl->all_next) {
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
| IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
- /* calls are removed */
- set_trouts_inconsistent();
-
/* we must build some new nodes WITHOUT CSE */
set_optimize(0);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
| IR_GRAPH_STATE_CONSISTENT_LOOPINFO
| IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
- set_trouts_inconsistent();
set_irg_callee_info_state(irg, irg_callee_info_inconsistent);
set_optimize(rem);
*/
static ir_type *default_gen_pointer_type_to(ir_type *tp)
{
- ir_type *res = NULL;
- if (get_trouts_state() == outs_consistent) {
- if (get_type_n_pointertypes_to(tp) > 0) {
- res = get_type_pointertype_to(tp, 0);
- } else {
- res = new_type_pointer(tp);
- /* Update trout for pointer types, so we can use it in next call. */
- add_type_pointertype_to(tp, res);
- }
- } else {
- res = find_pointer_type_to_type(tp);
- if (res == firm_unknown_type)
- res = new_type_pointer(tp);
- }
+ ir_type *res = find_pointer_type_to_type(tp);
+ if (res == firm_unknown_type)
+ res = new_type_pointer(tp);
return res;
}
pred = new_cast;
++n_casts_normalized;
set_irn_typeinfo_type(new_cast, new_type); /* keep type information up to date. */
- if (get_trouts_state() != outs_none) add_type_cast(new_type, new_cast);
}
} else {
assert(is_SuperClass_of(totype, fromtype));
pred = new_cast;
++n_casts_normalized;
set_irn_typeinfo_type(new_cast, new_type); /* keep type information up to date. */
- if (get_trouts_state() != outs_none) add_type_cast(new_type, new_cast);
}
}
return new_cast;
changed = 0;
all_irg_walk(NULL, irn_optimize_class_cast, &changed);
- if (changed) {
- set_trouts_inconsistent();
- }
-
DB((dbg, SET_LEVEL_1, " Cast optimization: %zu Casts removed, %zu Sels concretized.\n",
n_casts_removed, n_sels_concretized));
}