/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
- *
* This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
*/
/**
*/
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) {
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;
/* 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;
}
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;
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);
}
}
-int remove_bads(ir_graph *irg)
+void remove_bads(ir_graph *irg)
{
size_t i;
size_t n_to_process;
edges_deactivate(irg);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
- return 1;
}
-
- return 0;
+ add_irg_properties(irg, IR_GRAPH_PROPERTY_NO_BADS);
}