introduce anchor_first and anchor_last in irg_anchors enum
authorMatthias Braun <matze@braunis.de>
Wed, 16 Nov 2011 18:52:47 +0000 (19:52 +0100)
committerMatthias Braun <matze@braunis.de>
Wed, 16 Nov 2011 18:52:47 +0000 (19:52 +0100)
ir/ana/irouts.c
ir/ir/ircons.c
ir/ir/irtypes.h

index a7d1999..43f3d6a 100644 (file)
@@ -348,7 +348,7 @@ static int count_outs(ir_graph *irg)
 
        /* Now handle anchored nodes. We need the out count of those
           even if they are not visible. */
-       for (i = anchor_last - 1; i >= 0; --i) {
+       for (i = anchor_last; i >= anchor_first; --i) {
                n = get_irg_anchor(irg, i);
                if (!irn_visited_else_mark(n)) {
                        n->out = (ir_def_use_edge*) INT_TO_PTR(1);
@@ -423,7 +423,7 @@ static ir_def_use_edge *set_out_edges(ir_graph *irg, ir_def_use_edge *free)
        free = _set_out_edges(get_irg_end(irg), free);
 
        /* handle anchored nodes */
-       for (i = anchor_last - 1; i >= 0; --i) {
+       for (i = anchor_last; i >= anchor_first; --i) {
                n = get_irg_anchor(irg, i);
                if (!irn_visited_else_mark(n)) {
                        size_t n_outs = PTR_TO_INT(n->out);
index 29dded3..452811a 100644 (file)
@@ -775,11 +775,11 @@ ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
 
 ir_node *new_r_Anchor(ir_graph *irg)
 {
-       ir_node *in[anchor_last];
+       ir_node *in[anchor_last+1];
        ir_node *res;
        size_t   i;
        memset(in, 0, sizeof(in));
-       res = new_ir_node(NULL, irg, NULL, op_Anchor, mode_ANY, anchor_last, in);
+       res = new_ir_node(NULL, irg, NULL, op_Anchor, mode_ANY, anchor_last+1, in);
        res->attr.anchor.irg.irg = irg;
 
        /* hack to get get_irn_irg working: set block to ourself and allow
@@ -787,7 +787,7 @@ ir_node *new_r_Anchor(ir_graph *irg)
        res->in[0] = res;
 
        /* we can't have NULL inputs so reference ourselfes for now */
-       for (i = 0; i < (size_t)anchor_last; ++i) {
+       for (i = 0; i <= (size_t)anchor_last; ++i) {
                set_irn_n(res, i, res);
        }
 
index 8d2b1dc..53cd474 100644 (file)
@@ -483,8 +483,10 @@ typedef irg_edge_info_t irg_edges_info_t[EDGE_KIND_LAST];
 /**
  * Index constants for nodes that can be accessed through the graph anchor node.
  */
-enum irg_anchors {
-       anchor_end_block = 0,    /**< block the end node will belong to, same as Anchors block */
+typedef enum irg_anchors {
+       anchor_first,
+       anchor_end_block = anchor_first, /**< block the end node will belong to,
+                                             same as Anchors block */
        anchor_start_block,      /**< block the start node will belong to */
        anchor_end,              /**< end node of this ir_graph */
        anchor_start,            /**< start node of this ir_graph */
@@ -493,8 +495,9 @@ enum irg_anchors {
        anchor_initial_mem,      /**< initial memory of this graph */
        anchor_args,             /**< methods arguments */
        anchor_no_mem,           /**< NoMem node of this ir_graph, the one and only in this graph */
-       anchor_last
-};
+       anchor_last = anchor_no_mem
+} irg_anchors;
+ENUM_COUNTABLE(irg_anchors)
 
 /** A callgraph entry for callees. */
 typedef struct cg_callee_entry {