belive: Remove unused functions and macros.
[libfirm] / ir / be / beinfo.c
index 953458f..332173e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
@@ -20,7 +20,6 @@
 /**
  * @file
  * @author      Matthias Braun
- * @version     $Id$
  */
 #include "config.h"
 
 #include "irdump_t.h"
 #include "error.h"
 
-static copy_attr_func  old_phi_copy_attr;
+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);
        node->backend_info = info;
 
-       /* 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.
+       /*
+        * Set backend info for some middleend nodes which still appear in
+        * backend graphs
         */
-       if (get_irn_mode(node) != mode_T
-                       && get_irn_opcode(node) <= iro_Last) {
+       switch (get_irn_opcode(node)) {
+       case iro_Block:
+       case iro_Dummy:
+       case iro_NoMem:
+       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;
+       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[0].req = arch_no_register_req;
+               break;
+       default:
+               break;
        }
 }
 
@@ -75,12 +91,13 @@ static void new_phi_copy_attr(ir_graph *irg, const ir_node *old_node,
        old_phi_copy_attr(irg, old_node, new_node);
 }
 
-int be_nodes_equal(ir_node *node1, ir_node *node2)
+int be_nodes_equal(const ir_node *node1, const ir_node *node2)
 {
        const backend_info_t *info1 = be_get_info(node1);
        const backend_info_t *info2 = be_get_info(node2);
        size_t                len   = ARR_LEN(info1->out_infos);
-       size_t                arity = get_irn_arity(node1);
+       int                   arity = get_irn_arity(node1);
+       int                   in;
        size_t                i;
 
        if (ARR_LEN(info2->out_infos) != len)
@@ -88,8 +105,8 @@ int be_nodes_equal(ir_node *node1, ir_node *node2)
 
        assert(arity == get_irn_arity(node2));
 
-       for (i = 0; i < arity; ++i) {
-               if (info1->in_reqs[i] != info2->in_reqs[i])
+       for (in = 0; in < arity; ++in) {
+               if (info1->in_reqs[in] != info2->in_reqs[in])
                        return false;
        }
 
@@ -107,8 +124,9 @@ int be_nodes_equal(ir_node *node1, 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;
@@ -130,20 +148,20 @@ void be_info_init(void)
 /**
  * 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))
                return;
        if (get_irn_irg(irn)->be_data == NULL)
                return;
 
-       if (sched_is_scheduled(irn) && sched_has_prev(irn)) {
+       if (sched_is_scheduled(irn) && sched_has_prev(irn) && !is_Block(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");
+               fprintf(F, "edge:{sourcename: ");
+               print_nodeid(F, irn);
+               fprintf(F, " targetname: ");
+               print_nodeid(F, prev);
+               fprintf(F, " color:magenta}\n");
        }
 }
 
@@ -157,7 +175,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;