X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeinfo.c;h=b6ca7072ce7005d035e8da768c87e220a3a6174f;hb=d02e1f6b1f966030f9ec9006dedac7476fc75424;hp=1e569210928b3a484f8d96d568e009f3ff4c70b3;hpb=6f167fe94cbbd6ca72afbef96cb57fe7c14aad5e;p=libfirm diff --git a/ir/be/beinfo.c b/ir/be/beinfo.c index 1e5692109..b6ca7072c 100644 --- a/ir/be/beinfo.c +++ b/ir/be/beinfo.c @@ -24,68 +24,85 @@ */ #include "config.h" +#include + #include "beinfo.h" -#include "bearch_t.h" +#include "bearch.h" +#include "benode.h" +#include "besched.h" #include "irgwalk.h" #include "irnode_t.h" +#include "irdump_t.h" #include "error.h" static copy_attr_func old_phi_copy_attr; void be_info_new_node(ir_node *node) { - if (is_Anchor(node)) - return; + struct obstack *obst; + backend_info_t *info; - struct obstack *obst = get_irg_obstack(current_ir_graph); - backend_info_t *info = obstack_alloc(obst, sizeof(*info)); - sched_info_t *sinfo = &info->sched_info; + /* Projs need no be info, their tuple holds all information */ + if (is_Proj(node)) + return; - memset(info, 0, sizeof(*info)); + obst = be_get_be_obst(current_ir_graph); + info = OALLOCZ(obst, backend_info_t); - sinfo->idx = get_irn_idx(node); - INIT_LIST_HEAD(&sinfo->list); + assert(node->backend_info == NULL); + node->backend_info = info; - if (is_Phi(node)) { + /* Hack! We still have middle end nodes in the backend (which was probably + a bad decision back then), which have no register constraints. + Set some none_requirements here. + */ + if (get_irn_mode(node) != mode_T + && get_irn_opcode(node) <= iro_Last) { 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; } - assert(node->backend_info == NULL); - node->backend_info = info; } -static void new_Phi_copy_attr(const ir_node *old_node, ir_node *new_node) +static void new_phi_copy_attr(ir_graph *irg, const ir_node *old_node, + ir_node *new_node) { - struct obstack *obst = get_irg_obstack(get_irn_irg(new_node)); backend_info_t *old_info = be_get_info(old_node); backend_info_t *new_info = be_get_info(new_node); - old_phi_copy_attr(old_node, new_node); - new_info->out_infos = DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos); + *new_info = *old_info; + + old_phi_copy_attr(irg, old_node, new_node); } -int be_info_equal(const ir_node *node1, const ir_node *node2) +int be_nodes_equal(ir_node *node1, ir_node *node2) { - backend_info_t *info1 = be_get_info(node1); - backend_info_t *info2 = be_get_info(node2); - int len = ARR_LEN(info1->out_infos); - int i; + const backend_info_t *info1 = be_get_info(node1); + const backend_info_t *info2 = be_get_info(node2); + int len = ARR_LEN(info1->out_infos); + int arity = get_irn_arity(node1); + int i; if (ARR_LEN(info2->out_infos) != len) - return 0; + return false; + + assert(arity == get_irn_arity(node2)); + + for (i = 0; i < arity; ++i) { + if (info1->in_reqs[i] != info2->in_reqs[i]) + return false; + } for (i = 0; i < len; ++i) { const reg_out_info_t *out1 = &info1->out_infos[i]; const reg_out_info_t *out2 = &info2->out_infos[i]; if (out1->reg != out2->reg) - return 0; + return false; if (!reg_reqs_equal(out1->req, out2->req)) - return 0; + return false; } - /* TODO: in reqs */ - - return 1; + return true; } static void init_walker(ir_node *node, void *data) @@ -94,21 +111,47 @@ static void init_walker(ir_node *node, void *data) be_info_new_node(node); } -static int initialized = 0; +static bool initialized = false; void be_info_init(void) { - if (initialized == 1) + if (initialized) panic("double initialization of be_info"); old_phi_copy_attr = op_Phi->ops.copy_attr; - op_Phi->ops.copy_attr = new_Phi_copy_attr; - initialized = 1; + op_Phi->ops.copy_attr = new_phi_copy_attr; + initialized = true; + + /* 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; +} + +/** + * Edge hook to dump the schedule edges. + */ +static void sched_edge_hook(FILE *F, ir_node *irn) +{ + if (is_Proj(irn)) + return; + if (get_irn_irg(irn)->be_data == NULL) + 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"); + } } void be_info_init_irg(ir_graph *irg) { irg_walk_anchors(irg, init_walker, NULL, NULL); + + set_dump_node_edge_hook(sched_edge_hook); } void be_info_free(void) @@ -116,9 +159,12 @@ void be_info_free(void) if (!initialized) panic("be_info_free called without prior init"); - assert(op_Phi->ops.copy_attr == new_Phi_copy_attr); + assert(op_Phi->ops.copy_attr == new_phi_copy_attr); op_Phi->ops.copy_attr = old_phi_copy_attr; - initialized = 0; + initialized = false; + + 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)