# include "iropt.h"
# include "ircons.h"
-# include "irgwalk.h"
+# include "irgmod.h"
+# include "irvrfy.h"
# include "tv.h"
+/* Make types visible to allow most efficient access */
+# include "entity_t.h"
+
/* Trivial inlineable routine for copy propagation.
Does follow Ids, needed to optimize inlined code. */
static inline ir_node *
} /* end equivalent_node() */
-#if 0
/* tries several [inplace] [optimizing] transformations and returns a
equivalent node. The difference to equivalent_node is that these
transformations _do_ generate new nodes, and thus the old node must
transform_node (ir_node *n)
{
- ir_node *a, *b;
+ ir_node *a = NULL, *b;
tarval *ta, *tb;
switch (get_irn_opcode(n)) {
case iro_DivMod: {
+
int evaluated = 0;
- ir_mode *mode = get_irn_mode(a);
+ ir_mode *mode;
a = get_DivMod_left(n);
b = get_DivMod_right(n);
+ mode = get_irn_mode(a);
if (!( mode_is_int(get_irn_mode(a))
&& mode_is_int(get_irn_mode(b))))
ir_node *mem = get_DivMod_mem(n);
turn_into_tuple(n, 4);
set_Tuple_pred(n, 0, mem);
- set_Tuple_pred(n, 1, new_Bad());
+ set_Tuple_pred(n, 1, new_Bad()); /* no exception */
set_Tuple_pred(n, 2, a);
set_Tuple_pred(n, 3, b);
+ assert(get_nodes_Block(n));
}
}
break;
}
}
break;
- case iro_Eor: {
+ case iro_Eor: { /* @@@ not tested as boolean Eor not allowed any more. */
a = get_Eor_left(n);
b = get_Eor_right(n);
&& (get_irn_op(a) == op_Proj)
&& (get_irn_mode(a) == mode_b)
&& (tarval_classify (computed_value (b)) == 1)
- && (get_irn_op(get_Proj_pred(a)) == iro_Cmp))
+ && (get_irn_op(get_Proj_pred(a)) == op_Cmp))
/* The Eor negates a Cmp. The Cmp has the negated result anyways! */
n = new_r_Proj(current_ir_graph, get_nodes_Block(n), get_Proj_pred(a),
mode_b, get_negated_pnc(get_Proj_proj(a)));
n = new_r_Not(current_ir_graph, get_nodes_Block(n), a, mode_b);
}
break;
- case iro_Not: {
+ case iro_Not: { /* @@@ not tested as boolean Eor not allowed any more. */
a = get_Not_op(n);
if ( (get_irn_mode(n) == mode_b)
&& (get_irn_op(a) == op_Proj)
&& (get_irn_mode(a) == mode_b)
- && (get_irn_op(get_Proj_pred(a)) == iro_Cmp))
+ && (get_irn_op(get_Proj_pred(a)) == op_Cmp))
/* We negate a Cmp. The Cmp has the negated result anyways! */
n = new_r_Proj(current_ir_graph, get_nodes_Block(n), get_Proj_pred(a),
mode_b, get_negated_pnc(get_Proj_proj(a)));
break;
default: ;
}
+ return n;
}
-#endif
/***************** Common Subexpression Elimination *****************/
tarval *tv;
ir_node *old_n = n;
+ if ((!get_optimize()) && (get_irn_op(n) != op_Phi)) return n;
+
/* if not optimize return n */
if (n == NULL) {
printf(" attention: empty node!!! \n");
/** common subexpression elimination **/
/* Checks whether n is already available. */
- /* The block input is used to distinguish different subexpressions. Right
+ /* The block input is used to distinguish different subexpressions. Right
now all nodes are pinned to blocks, i.e., the cse only finds common
subexpressions within a block. */
/* The AmRoq fiasco returns n here. Martin's version doesn't. */
}
-#if 0
- /* Some more constant expression evaluation. */
+ /* Some more constant expression evaluation that does not allow to
+ free the node. */
if (get_opt_constant_folding())
n = transform_node (n);
-#endif
/* Remove nodes with dead (Bad) input. */
n = gigo (n);
/* Now we can verify the node, as it has no dead inputs any more. */
- ir_vrfy(n);
+ irn_vrfy(n);
/* Now we have a legal, useful node. Enter it in hash table for cse */
if (get_opt_cse()) {
pdeq_putr (current_ir_graph->keep.living, n);
}
#endif
-
return n;
}
/* Remove nodes with dead (Bad) input. */
n = gigo (n);
/* Now we can verify the node, as it has no dead inputs any more. */
- ir_vrfy(n);
+ irn_vrfy(n);
/* Now we have a legal, useful node. Enter it in hash table for cse */
if (get_opt_cse()) {
return n;
}
-
-
-void
-optimize_in_place_wrapper (ir_node *n, void *env) {
- int i;
- ir_node *optimized;
-
- /* optimize all sons after recursion, i.e., the sons' sons are
- optimized already. */
- for (i = -1; i < get_irn_arity(n); i++) {
- optimized = optimize_in_place(get_irn_n(n, i));
- set_irn_n(n, i, optimized);
- }
-}
-
-
-void
-optimize_graph (ir_graph *irg)
-{
- ir_graph *rem = current_ir_graph;
- current_ir_graph = irg;
-
- /* walk over the graph */
- irg_walk(irg->end, NULL, optimize_in_place_wrapper, NULL);
-
- current_ir_graph = rem;
-}