From b617a959a97bd3ec5caeb957480071996ef38a1c Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 16 Nov 2011 19:52:47 +0100 Subject: [PATCH] introduce anchor_first and anchor_last in irg_anchors enum --- ir/ana/irouts.c | 4 ++-- ir/ir/ircons.c | 6 +++--- ir/ir/irtypes.h | 11 +++++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ir/ana/irouts.c b/ir/ana/irouts.c index a7d1999a1..43f3d6a25 100644 --- a/ir/ana/irouts.c +++ b/ir/ana/irouts.c @@ -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); diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 29dded322..452811a94 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -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); } diff --git a/ir/ir/irtypes.h b/ir/ir/irtypes.h index 8d2b1dcb1..53cd474b5 100644 --- a/ir/ir/irtypes.h +++ b/ir/ir/irtypes.h @@ -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 { -- 2.20.1