summaryrefslogtreecommitdiffhomepage
path: root/ir/stat
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2014-02-13 16:38:46 +0100
committerChristoph Mallon <christoph.mallon@gmx.de>2014-02-17 14:11:15 +0100
commit0ea8b7276a18cf5cdaa89cf6b054faa60086f9a0 (patch)
tree01d0462aed83d8b63097e7091b1feafde5f683b1 /ir/stat
parentcc281f880e6e186609e3c0222dca4dfca968f1f6 (diff)
Add and use foreach_irn_pred{,_r}().
Diffstat (limited to 'ir/stat')
-rw-r--r--ir/stat/dags.c13
-rw-r--r--ir/stat/firmstat.c30
-rw-r--r--ir/stat/pattern.c7
3 files changed, 12 insertions, 38 deletions
diff --git a/ir/stat/dags.c b/ir/stat/dags.c
index a987d70..e72b494 100644
--- a/ir/stat/dags.c
+++ b/ir/stat/dags.c
@@ -119,7 +119,6 @@ static dag_entry_t *new_dag_entry(dag_env_t *dag_env, ir_node *node)
static void find_dag_roots(ir_node *node, void *env)
{
dag_env_t *dag_env = (dag_env_t*)env;
- int i, arity;
dag_entry_t *entry;
ir_node *block;
@@ -136,9 +135,7 @@ static void find_dag_roots(ir_node *node, void *env)
/* Phi nodes always references nodes from "other" block */
if (is_Phi(node)) {
if (get_irn_mode(node) != mode_M) {
- for (i = 0, arity = get_irn_arity(node); i < arity; ++i) {
- ir_node *prev = get_irn_n(node, i);
-
+ foreach_irn_in(node, i, prev) {
if (is_Phi(prev))
continue;
@@ -157,9 +154,7 @@ static void find_dag_roots(ir_node *node, void *env)
}
}
} else {
-
- for (i = 0, arity = get_irn_arity(node); i < arity; ++i) {
- ir_node *prev = get_irn_n(node, i);
+ foreach_irn_in(node, i, prev) {
ir_mode *mode = get_irn_mode(prev);
if (mode == mode_X || mode == mode_M)
@@ -193,7 +188,6 @@ static void find_dag_roots(ir_node *node, void *env)
static void connect_dags(ir_node *node, void *env)
{
dag_env_t *dag_env = (dag_env_t*)env;
- int i, arity;
ir_node *block;
dag_entry_t *entry;
ir_mode *mode;
@@ -236,8 +230,7 @@ static void connect_dags(ir_node *node, void *env)
}
/* put the predecessors into the same DAG as the current */
- for (i = 0, arity = get_irn_arity(node); i < arity; ++i) {
- ir_node *prev = get_irn_n(node, i);
+ foreach_irn_in(node, i, prev) {
ir_mode *mode = get_irn_mode(prev);
if (is_Phi(prev))
diff --git a/ir/stat/firmstat.c b/ir/stat/firmstat.c
index 61ef7e0..d04617b 100644
--- a/ir/stat/firmstat.c
+++ b/ir/stat/firmstat.c
@@ -592,11 +592,9 @@ static void undate_block_info(ir_node *node, graph_entry_t *graph)
{
ir_node *block;
block_entry_t *b_entry;
- int i, arity;
/* check for block */
if (is_Block(node)) {
- arity = get_irn_arity(node);
b_entry = block_get_entry(&graph->recalc_cnts, get_irn_node_nr(node), graph->block_hash);
/* mark start end block to allow to filter them out */
if (node == get_irg_start_block(graph->irg))
@@ -605,8 +603,7 @@ static void undate_block_info(ir_node *node, graph_entry_t *graph)
b_entry->is_end = 1;
/* count all incoming edges */
- for (i = 0; i < arity; ++i) {
- ir_node *pred = get_irn_n(node, i);
+ foreach_irn_in(node, i, pred) {
ir_node *other_block = get_nodes_block(pred);
block_entry_t *b_entry_other = block_get_entry(&graph->recalc_cnts, get_irn_node_nr(other_block), graph->block_hash);
@@ -631,14 +628,8 @@ static void undate_block_info(ir_node *node, graph_entry_t *graph)
if (is_End(node))
return;
- arity = get_irn_arity(node);
-
- for (i = 0; i < arity; ++i) {
- ir_node *pred = get_irn_n(node, i);
- ir_node *other_block;
-
- other_block = get_nodes_block(pred);
-
+ foreach_irn_in(node, i, pred) {
+ ir_node *const other_block = get_nodes_block(pred);
if (other_block == block)
cnt_inc(&b_entry->cnt[bcnt_edges]); /* a in block edge */
else {
@@ -872,7 +863,7 @@ static void update_node_stat(ir_node *node, void *env)
node_entry_t *entry;
ir_op *op = stat_get_irn_op(node);
- int i, arity = get_irn_arity(node);
+ int arity = get_irn_arity(node);
entry = opcode_get_entry(op, graph->opcode_hash);
@@ -899,7 +890,7 @@ static void update_node_stat(ir_node *node, void *env)
break;
case iro_Phi:
/* check for non-strict Phi nodes */
- for (i = arity - 1; i >= 0; --i) {
+ for (int i = arity - 1; i >= 0; --i) {
ir_node *pred = get_Phi_pred(node, i);
if (is_Unknown(pred)) {
/* found an Unknown predecessor, graph is not strict */
@@ -913,11 +904,7 @@ static void update_node_stat(ir_node *node, void *env)
/* we want to count the constant IN nodes, not the CSE'ed constant's itself */
if (status->stat_options & FIRMSTAT_COUNT_CONSTS) {
- int i;
-
- for (i = get_irn_arity(node) - 1; i >= 0; --i) {
- ir_node *pred = get_irn_n(node, i);
-
+ foreach_irn_in_r(node, i, pred) {
if (is_Const(pred)) {
/* check properties of constants */
stat_update_const(status, pred, graph);
@@ -1019,7 +1006,6 @@ static void mark_address_calc(ir_node *node, void *env)
{
graph_entry_t *graph = (graph_entry_t*)env;
ir_mode *mode = get_irn_op_mode(node);
- int i, n;
unsigned mark_preds = MARK_REF_NON_ADR;
if (! mode_is_data(mode))
@@ -1043,9 +1029,7 @@ static void mark_address_calc(ir_node *node, void *env)
}
/* mark all predecessors */
- for (i = 0, n = get_irn_arity(node); i < n; ++i) {
- ir_node *pred = get_irn_n(node, i);
-
+ foreach_irn_in(node, i, pred) {
mode = get_irn_op_mode(pred);
if (! mode_is_data(mode))
continue;
diff --git a/ir/stat/pattern.c b/ir/stat/pattern.c
index f5be62e..a6bec3c 100644
--- a/ir/stat/pattern.c
+++ b/ir/stat/pattern.c
@@ -400,7 +400,6 @@ static int _encode_node(ir_node *node, int max_depth, codec_env_t *env)
{
addr_entry_t entry, *r_entry;
set_entry *s_entry;
- int i, preds;
int res, depth;
unsigned code = get_irn_opcode(node);
@@ -456,7 +455,7 @@ static int _encode_node(ir_node *node, int max_depth, codec_env_t *env)
return max_depth;
}
- preds = get_irn_arity(node);
+ int const preds = get_irn_arity(node);
put_code(env->buf, preds);
res = INT_MAX;
@@ -482,9 +481,7 @@ static int _encode_node(ir_node *node, int max_depth, codec_env_t *env)
if (depth < res)
res = depth;
} else {
- for (i = 0; i < preds; ++i) {
- ir_node *n = get_irn_n(node, i);
-
+ foreach_irn_in(node, i, n) {
depth = _encode_node(n, max_depth, env);
if (depth < res)
res = depth;