#include "beutil.h"
#include "irpass.h"
#include "irdom.h"
-#include "opt_manage.h"
#include <math.h>
#include "irbackedge_t.h"
/* Find the loops head/the blocks with cfpred outside of the loop */
if (is_Block(node)) {
- const ir_edge_t *edge;
unsigned outs_n = 0;
/* Count innerloop branches */
{
ir_graph *irg;
ir_mode *mode;
- const ir_edge_t *edge;
- const ir_edge_t *next;
assert(orig_block && orig_val && second_block && second_val &&
"no parameter of construct_ssa may be NULL");
ssa_second_def = second_val;
/* Only fix the users of the first, i.e. the original node */
- foreach_out_edge_safe(orig_val, edge, next) {
+ foreach_out_edge_safe(orig_val, edge) {
ir_node *user = get_edge_src_irn(edge);
int j = get_edge_src_pos(edge);
ir_node *user_block = get_nodes_block(user);
unrolling_node_info *info;
assert(nr != 0 && "0 reserved");
- info = (unrolling_node_info*)ir_nodemap_get(&map, n);
+ info = ir_nodemap_get(unrolling_node_info, &map, n);
if (! info) {
ir_node **arr = NEW_ARR_D(ir_node*, &obst, unroll_nr);
memset(arr, 0, unroll_nr * sizeof(ir_node*));
static ir_node *get_unroll_copy(ir_node *n, int nr)
{
ir_node *cp;
- unrolling_node_info *info = (unrolling_node_info *)ir_nodemap_get(&map, n);
+ unrolling_node_info *info = ir_nodemap_get(unrolling_node_info, &map, n);
if (! info)
return NULL;
/* Getter of copy of n for inversion */
static ir_node *get_inversion_copy(ir_node *n)
{
- ir_node *cp = (ir_node *)ir_nodemap_get(&map, n);
+ ir_node *cp = ir_nodemap_get(ir_node, &map, n);
return cp;
}
set_backedge(n, i);
}
}
+ free(ins);
+ free(bes);
}
/* Extends a block by a copy of its pred at pos,
*/
static void find_condition_chain(ir_node *block)
{
- const ir_edge_t *edge;
bool mark = false;
bool has_be = false;
bool jmp_only = true;
DEL_ARR_F(cur_head_outs);
/* Duplicated blocks changed doms */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
+ clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
+ | IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
++stats.inverted;
}
if (!is_Cmp(cmp))
return NULL;
- DB((dbg, LEVEL_5, "projection is %s\n", get_relation_string(get_Proj_proj(projx))));
+ DB((dbg, LEVEL_5, "projection is %s\n", get_relation_string(get_Cmp_relation(cmp))));
switch(get_Proj_proj(projx)) {
case pn_Cond_false:
else
++stats.invariant_unroll;
- clear_irg_state(current_ir_graph, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
+ clear_irg_properties(current_ir_graph, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
DEL_ARR_F(loop_entries);
obstack_free(&obst, NULL);
size_t i;
size_t n_elements;
+ assure_irg_properties(irg,
+ IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES
+ | IR_GRAPH_PROPERTY_CONSISTENT_OUTS
+ | IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
+
set_loop_params();
/* Reset stats for this procedure */
DEL_ARR_F(loops);
ir_free_resources(irg, IR_RESOURCE_IRN_LINK | IR_RESOURCE_PHI_LIST);
+
+ confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_NONE);
}
-static ir_graph_state_t perform_loop_unrolling(ir_graph *irg)
+void do_loop_unrolling(ir_graph *irg)
{
loop_op = loop_op_unrolling;
loop_optimization(irg);
- return 0;
}
-static ir_graph_state_t perform_loop_inversion(ir_graph *irg)
+void do_loop_inversion(ir_graph *irg)
{
loop_op = loop_op_inversion;
loop_optimization(irg);
- return 0;
}
-static ir_graph_state_t perform_loop_peeling(ir_graph *irg)
+void do_loop_peeling(ir_graph *irg)
{
loop_op = loop_op_peeling;
loop_optimization(irg);
- return 0;
}
-static optdesc_t opt_unroll_loops = {
- "unroll-loops",
- IR_GRAPH_STATE_CONSISTENT_OUT_EDGES | IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO,
- perform_loop_unrolling,
-};
-
-static optdesc_t opt_invert_loops = {
- "invert-loops",
- IR_GRAPH_STATE_CONSISTENT_OUT_EDGES | IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO,
- perform_loop_inversion,
-};
-
-static optdesc_t opt_peel_loops = {
- "peel-loops",
- IR_GRAPH_STATE_CONSISTENT_OUT_EDGES | IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO,
- perform_loop_peeling,
-};
-
-void do_loop_unrolling(ir_graph *irg)
-{ perform_irg_optimization(irg, &opt_unroll_loops); }
-
-void do_loop_inversion(ir_graph *irg)
-{ perform_irg_optimization(irg, &opt_invert_loops); }
-
-void do_loop_peeling(ir_graph *irg)
-{ perform_irg_optimization(irg, &opt_peel_loops); }
-
ir_graph_pass_t *loop_inversion_pass(const char *name)
{
return def_graph_pass(name ? name : "loop_inversion", do_loop_inversion);