Commit 15b2fcf1 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

cleanup: Use get_Block_n_cfgpreds()/get_Block_cfgpred() instead of get_irn_arity()/get_irn_n().

parent ea83f105
......@@ -38,7 +38,7 @@
*/
static int count_non_bads(ir_node *node)
{
int arity = get_irn_arity(node);
int arity = get_Block_n_cfgpreds(node);
int count = 0;
int i;
for (i = 0; i < arity; ++i) {
......@@ -55,7 +55,7 @@ static int count_non_bads(ir_node *node)
static void block_remove_bads(ir_node *block)
{
ir_graph *irg = get_irn_irg(block);
const int max = get_irn_arity(block);
const int max = get_Block_n_cfgpreds(block);
const int new_max = count_non_bads(block);
ir_node **new_in = ALLOCAN(ir_node*, new_max);
int i;
......@@ -68,7 +68,7 @@ static void block_remove_bads(ir_node *block)
/* 1. Create a new block without Bad inputs */
for (i = j = 0; i < max; ++i) {
ir_node *block_pred = get_irn_n(block, i);
ir_node *const block_pred = get_Block_cfgpred(block, i);
if (!is_Bad(block_pred)) {
new_in[j++] = block_pred;
}
......@@ -97,8 +97,7 @@ static void block_remove_bads(ir_node *block)
assert(get_irn_arity(phi) == max);
for (i = j = 0; i < max; ++i) {
ir_node *block_pred = get_irn_n(block, i);
ir_node *const block_pred = get_Block_cfgpred(block, i);
if (!is_Bad(block_pred)) {
ir_node *pred = get_irn_n(phi, i);
new_in[j++] = pred;
......@@ -118,7 +117,7 @@ static void collect(ir_node *node, void *env)
firm_collect_block_phis(node, NULL);
if (is_Block(node)) {
ir_node ***blocks_to_process = (ir_node***)env;
int arity = get_irn_arity(node);
int arity = get_Block_n_cfgpreds(node);
int non_bads = count_non_bads(node);
if (arity != non_bads)
ARR_APP1(ir_node*, *blocks_to_process, node);
......
......@@ -200,14 +200,14 @@ static ir_type *get_conv_type(ir_mode *imode, ir_mode *omode)
*/
static void add_block_cf_input_nr(ir_node *block, int nr, ir_node *cf)
{
int i, arity = get_irn_arity(block);
int i, arity = get_Block_n_cfgpreds(block);
ir_node **in;
assert(nr < arity);
NEW_ARR_A(ir_node *, in, arity + 1);
for (i = 0; i < arity; ++i)
in[i] = get_irn_n(block, i);
in[i] = get_Block_cfgpred(block, i);
in[i] = cf;
set_irn_in(block, i + 1, in);
......@@ -231,11 +231,11 @@ static void add_block_cf_input_nr(ir_node *block, int nr, ir_node *cf)
*/
static void add_block_cf_input(ir_node *block, ir_node *tmpl, ir_node *cf)
{
int i, arity = get_irn_arity(block);
int i, arity = get_Block_n_cfgpreds(block);
int nr = 0;
for (i = 0; i < arity; ++i) {
if (get_irn_n(block, i) == tmpl) {
if (get_Block_cfgpred(block, i) == tmpl) {
nr = i;
break;
}
......
......@@ -192,8 +192,8 @@ static void rewire(ir_node* node, int i, int j, ir_node* new_pred)
*/
static void split_block(ir_node* block, int i, int j)
{
ir_node *pred_block = get_nodes_block(get_irn_n(block, i));
int arity = get_irn_arity(block);
ir_node *pred_block = get_nodes_block(get_Block_cfgpred(block, i));
int arity = get_Block_n_cfgpreds(block);
ir_node **ins = ALLOCAN(ir_node*, arity + 1);
int new_pred_arity;
ir_node *phi;
......@@ -213,10 +213,10 @@ static void split_block(ir_node* block, int i, int j)
set_irn_in(phi, k, ins);
}
for (k = 0; k < i; ++k) ins[k] = get_irn_n(block, k);
for (k = 0; k < i; ++k) ins[k] = get_Block_cfgpred(block, k);
ins[k++] = get_irn_n(pred_block, j);
for (; k < arity; ++k) ins[k] = get_irn_n(block, k);
ins[k++] = get_irn_n(block, i);
for (; k < arity; ++k) ins[k] = get_Block_cfgpred(block, k);
ins[k++] = get_Block_cfgpred(block, i);
set_irn_in(block, k, ins);
new_pred_arity = get_irn_arity(pred_block) - 1;
......@@ -245,7 +245,7 @@ static void split_block(ir_node* block, int i, int j)
static void prepare_path(ir_node* block, int i, const ir_node* dependency)
{
ir_node* pred = get_nodes_block(get_irn_n(block, i));
ir_node* pred = get_nodes_block(get_Block_cfgpred(block, i));
int pred_arity;
int j;
......@@ -396,8 +396,8 @@ restart:
} while (phi != NULL);
/* move mux operands into mux_block */
exchange(get_nodes_block(get_irn_n(block, i)), mux_block);
exchange(get_nodes_block(get_irn_n(block, j)), mux_block);
exchange(get_nodes_block(get_Block_cfgpred(block, i)), mux_block);
exchange(get_nodes_block(get_Block_cfgpred(block, j)), mux_block);
if (arity == 2) {
unsigned mark;
......
......@@ -596,11 +596,10 @@ static void extend_ins_by_copy(ir_node *block, int pos)
{
ir_node *new_in;
ir_node *phi;
ir_node *pred;
assert(is_Block(block));
/* Extend block by copy of definition at pos */
pred = get_irn_n(block, pos);
ir_node *const pred = get_Block_cfgpred(block, pos);
new_in = get_inversion_copy(pred);
DB((dbg, LEVEL_5, "Extend block %N by %N cp of %N\n", block, new_in, pred));
extend_irn(block, new_in, false);
......@@ -626,14 +625,10 @@ static void extend_ins_by_copy(ir_node *block, int pos)
/* Returns the number of blocks backedges. With or without alien bes. */
static int get_backedge_n(ir_node *block, bool with_alien)
{
int i;
int be_n = 0;
int arity = get_irn_arity(block);
assert(is_Block(block));
for (i = 0; i < arity; ++i) {
ir_node *pred = get_irn_n(block, i);
int be_n = 0;
int const arity = get_Block_n_cfgpreds(block);
for (int i = 0; i < arity; ++i) {
ir_node *const pred = get_Block_cfgpred(block, i);
if (is_backedge(block, i) && (with_alien || is_in_loop(pred)))
++be_n;
}
......@@ -833,15 +828,14 @@ static void unmark_not_allowed_cc_blocks(void)
for(i = 0; i < blocks; ++i) {
ir_node *block = cc_blocks[i];
int a;
int arity = get_irn_arity(block);
/* Head is an exception. */
if (block == loop_head)
continue;
for(a = 0; a < arity; ++a) {
if (! is_nodes_block_marked(get_irn_n(block, a))) {
int const arity = get_Block_n_cfgpreds(block);
for (int a = 0; a < arity; ++a) {
if (!is_nodes_block_marked(get_Block_cfgpred(block, a))) {
set_Block_mark(block, 0);
--inversion_blocks_in_cc;
DB((dbg, LEVEL_5, "Removed %N from cc (blocks in cc %d)\n",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment