X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeinfo.c;h=652d7cacf82175bb64c3b9dc381e2a432cc65c88;hb=1209ae49db1b42e9d39269eb3a86b187f0c263d9;hp=c1a04fa23b4fbec2f266281b40b58f24f842f036;hpb=342720ec49991f59ea0d32d0751cb66624f4f0cc;p=libfirm diff --git a/ir/be/beinfo.c b/ir/be/beinfo.c index c1a04fa23..652d7cacf 100644 --- a/ir/be/beinfo.c +++ b/ir/be/beinfo.c @@ -20,33 +20,36 @@ /** * @file * @author Matthias Braun - * @version $Id$ */ #include "config.h" #include #include "beinfo.h" +#include "beirg.h" #include "bearch.h" #include "benode.h" #include "besched.h" +#include "bedump.h" +#include "belive_t.h" #include "irgwalk.h" #include "irnode_t.h" #include "irdump_t.h" +#include "irhooks.h" #include "error.h" static copy_attr_func old_phi_copy_attr; -void be_info_new_node(ir_node *node) +void be_info_new_node(ir_graph *irg, ir_node *node) { struct obstack *obst; backend_info_t *info; - /* Projs need no be info, their tuple holds all information */ + /* Projs need no be info, all info is fetched from their predecessor */ if (is_Proj(node)) return; - obst = be_get_be_obst(current_ir_graph); + obst = be_get_be_obst(irg); info = OALLOCZ(obst, backend_info_t); assert(node->backend_info == NULL); @@ -57,25 +60,19 @@ void be_info_new_node(ir_node *node) * backend graphs */ switch (get_irn_opcode(node)) { - case iro_Bad: case iro_Block: case iro_Dummy: - case iro_End: case iro_NoMem: - case iro_Unknown: - info->flags |= arch_irn_flags_not_scheduled; - break; case iro_Anchor: case iro_Pin: case iro_Sync: + case iro_Bad: + case iro_End: + case iro_Unknown: info->flags |= arch_irn_flags_not_scheduled; - info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1); - memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0])); - info->out_infos[0].req = arch_no_register_req; - break; + /* FALLTHROUGH */ case iro_Phi: - info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1); - memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0])); + info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, 1); info->out_infos[0].req = arch_no_register_req; break; default: @@ -127,11 +124,31 @@ int be_nodes_equal(const ir_node *node1, const ir_node *node2) static void init_walker(ir_node *node, void *data) { + ir_graph *irg = get_irn_irg(node); (void) data; - be_info_new_node(node); + be_info_new_node(irg, node); } -static bool initialized = false; +static bool initialized = false; +static hook_entry_t hook_liveness_info; + +static void dump_liveness_info_hook(void *context, FILE *F, const ir_node *node) +{ + (void)context; + if (!is_Block(node)) + return; + ir_graph *irg = get_irn_irg(node); + if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_BACKEND)) + return; + + be_lv_t *lv = be_get_irg_liveness(irg); + if (lv == NULL) + return; + if (!lv->sets_valid) + return; + + be_dump_liveness_block(lv, F, node); +} void be_info_init(void) { @@ -145,30 +162,36 @@ void be_info_init(void) /* phis have register and register requirements now which we want to dump */ assert(op_Phi->ops.dump_node == NULL); op_Phi->ops.dump_node = be_dump_phi_reg_reqs; + + hook_liveness_info.hook._hook_node_info = dump_liveness_info_hook; + register_hook(hook_node_info, &hook_liveness_info); } /** * Edge hook to dump the schedule edges. */ -static void sched_edge_hook(FILE *F, ir_node *irn) +static void sched_edge_hook(FILE *F, const ir_node *irn) { - if (is_Proj(irn)) + ir_graph *irg = get_irn_irg(irn); + if (!irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_BACKEND)) return; - if (get_irn_irg(irn)->be_data == NULL) + + if (is_Proj(irn) || is_Block(irn) || !sched_is_scheduled(irn)) return; - if (sched_is_scheduled(irn) && sched_has_prev(irn)) { - ir_node *prev = sched_prev(irn); - fprintf(F, "edge:{sourcename:\""); - PRINT_NODEID(irn); - fprintf(F, "\" targetname:\""); - PRINT_NODEID(prev); - fprintf(F, "\" color:magenta}\n"); + ir_node *const prev = sched_prev(irn); + if (!sched_is_begin(prev)) { + fprintf(F, "edge:{sourcename: "); + print_nodeid(F, irn); + fprintf(F, " targetname: "); + print_nodeid(F, prev); + fprintf(F, " color:magenta}\n"); } } void be_info_init_irg(ir_graph *irg) { + add_irg_constraints(irg, IR_GRAPH_CONSTRAINT_BACKEND); irg_walk_anchors(irg, init_walker, NULL, NULL); set_dump_node_edge_hook(sched_edge_hook); @@ -177,7 +200,7 @@ void be_info_init_irg(ir_graph *irg) void be_info_free(void) { if (!initialized) - panic("be_info_free called without prior init"); + panic("called without prior init"); assert(op_Phi->ops.copy_attr == new_phi_copy_attr); op_Phi->ops.copy_attr = old_phi_copy_attr; @@ -185,10 +208,6 @@ void be_info_free(void) assert(op_Phi->ops.dump_node == be_dump_phi_reg_reqs); op_Phi->ops.dump_node = NULL; -} -int be_info_initialized(const ir_graph *irg) -{ - (void) irg; - return initialized; + unregister_hook(hook_node_info, &hook_liveness_info); }