type *called_frame;
if (!get_optimize() || !get_opt_inline()) return;
- /** Turn off optimizations, this can cause problems when allocating new nodes. **/
+ /* -- Turn off optimizations, this can cause problems when allocating new nodes. -- */
rem_opt = get_optimize();
set_optimize(0);
if (get_irg_outs_state(current_ir_graph) == outs_consistent)
set_irg_outs_inconsistent(current_ir_graph);
- /** Check preconditions **/
+ /* -- Check preconditions -- */
assert(get_irn_op(call) == op_Call);
- /* @@@ TODO does not work for InterfaceIII.java after cgana
+ /* @@@ does not work for InterfaceIII.java after cgana
assert(get_Call_type(call) == get_entity_type(get_irg_ent(called_graph)));
assert(smaller_type(get_entity_type(get_irg_ent(called_graph)),
get_Call_type(call)));
if (called_graph == current_ir_graph) return;
-/**
+/* --
the procedure and later replaces the Start node of the called graph.
Post_call is the old Call node and collects the results of the called
- graph. Both will end up being a tuple. **/
+ graph. Both will end up being a tuple. -- */
post_bl = get_nodes_Block(call);
set_irg_current_block(current_ir_graph, post_bl);
/* XxMxPxP of Start + parameter of Call */
pre_call = new_Tuple(5, in);
post_call = call;
-/**
+/* --
The new block gets the ins of the old block, pre_call and all its
- predecessors and all Phi nodes. **/
+ predecessors and all Phi nodes. -- */
part_block(pre_call);
- /** Prepare state for dead node elimination **/
+ /* -- Prepare state for dead node elimination -- */
/* Visited flags in calling irg must be >= flag in called irg.
Else walker and arity computation will not work. */
if (get_irg_visited(current_ir_graph) <= get_irg_visited(called_graph))
/* Initialize for compaction of in arrays */
inc_irg_block_visited(current_ir_graph);
- /*** Replicate local entities of the called_graph ***/
+ /* -- Replicate local entities of the called_graph -- */
/* copy the entities. */
called_frame = get_irg_frame_type(called_graph);
for (i = 0; i < get_class_n_members(called_frame); i++) {
to inline, calling this inline will not visit the inlined nodes. */
set_irg_visited(current_ir_graph, get_irg_visited(current_ir_graph)-1);
- /** Performing dead node elimination inlines the graph **/
+ /* -- Performing dead node elimination inlines the graph -- */
/* Copies the nodes to the obstack of current_ir_graph. Updates links to new
entities. */
/* @@@ endless loops are not copied!! -- they should be, I think... */
set_irg_block_visited(called_graph, get_irg_block_visited(current_ir_graph));
set_Block_block_visited(get_irg_start_block(called_graph), 0);
- /*** Merge the end of the inlined procedure with the call site ***/
+ /* -- Merge the end of the inlined procedure with the call site -- */
/* We will turn the old Call node into a Tuple with the following
predecessors:
-1: Block of Tuple.
3: Phi of Exception memories.
*/
- /** Precompute some values **/
+ /* -- Precompute some values -- */
end_bl = get_new_node(get_irg_end_block(called_graph));
end = get_new_node(get_irg_end(called_graph));
arity = get_irn_arity(end_bl); /* arity = n_exc + n_ret */
set_irg_current_block(current_ir_graph, post_bl); /* just to make sure */
- /** archive keepalives **/
+ /* -- archive keepalives -- */
for (i = 0; i < get_irn_arity(end); i++)
add_End_keepalive(get_irg_end(current_ir_graph), get_irn_n(end, i));
/* The new end node will die, but the in array is not on the obstack ... */
free_End(end);
-/**
- Return nodes by Jump nodes. **/
+/* --
+ Return nodes by Jump nodes. -- */
n_ret = 0;
for (i = 0; i < arity; i++) {
ir_node *ret;
}
set_irn_in(post_bl, n_ret, cf_pred);
-/**
- turned into a tuple. **/
+/* --
+ turned into a tuple. -- */
turn_into_tuple(post_call, 4);
/* First the Memory-Phi */
n_ret = 0;
free(res_pred);
free(cf_pred);
-/**
+/* --
If the exception control flow from the Call directly branched to the
end block we now have the following control flow predecessor pattern:
ProjX -> Tuple -> Jmp.
We must remove the Jmp along with it's empty block and add Jmp's
- predecessors as predecessors of this end block. ***/
+ predecessors as predecessors of this end block. -- */
/* find the problematic predecessor of the end block. */
end_bl = get_irg_end_block(current_ir_graph);
for (i = 0; i < get_Block_n_cfgpreds(end_bl); i++) {
free(cf_pred);
}
- /** Turn cse back on. **/
+ /* -- Turn cse back on. -- */
set_optimize(rem_opt);
}
/* Copyright (C) 1998 - 2001 by Universitaet Karlsruhe
* All rights reserved.
-*
-* Author: Christian Schaefer, Goetz Lindenmaier
+*/
+
+/**
+* @file irgopts.h
*
* Optimizations for a whole ir graph, i.e., a procedure.
+*
+* @author Christian Schaefer, Goetz Lindenmaier
*/
/* $Id$ */
# include "irgraph.h"
-/* Applies local optimizations (see iropt.h) to all nodes in the graph. */
+/** Applies local optimizations (see iropt.h) to all nodes in the graph. */
void local_optimize_graph (ir_graph *irg);
-/* Performs dead node elimination by copying the ir graph to a new obstack.
+/** Performs dead node elimination by copying the ir graph to a new obstack.
+
Further removes Bad predecesors from Blocks and the corresponding
inputs to Phi nodes.
Optimization is only performed if options `optimize' and
`opt_dead_node_elimination' are set.
The graph may not be in state phase_building. The outs datasturcture
- is freed, the outs state set to no_outs. (@@@ Change this? -> inconsistent.)
+ is freed, the outs state set to no_outs.
+ @todo Change this? -> inconsistent.
+
Backedge information is conserved.
Removes old attributes of nodes. Sets link field to NULL.
Attention: the numbers assigned to nodes if the library is compiled for
development/debugging are not conserved by copying. */
void dead_node_elimination(ir_graph *irg);
-/* Removes Bad Bad predecesors from Blocks and the corresponding
+/** Removes Bad Bad predecesors from Blocks and the corresponding
inputs to Phi nodes as in dead_node_elimination but without
copying the graph.
- @@@ not implemented! */
+
+ @todo not implemented! */
void remove_bad_predecessors(ir_graph *irg);
-/* Inlines a method at the given call site.
+/** Inlines a method at the given call site.
+
Removes the call node and splits the basic block the call node
belongs to. Inserts a copy of the called graph between these nodes.
Assumes that call is a Call node in current_ir_graph and that
combination as control flow operation. */
void inline_method(ir_node *call, ir_graph *called_graph);
-/* Inlines all small methods at call sites where the called address comes
+/** Inlines all small methods at call sites where the called address comes
from a Const node that references the entity representing the called
method.
The size argument is a rough measure for the code size of the method:
combination as control flow operation. */
void inline_small_irgs(ir_graph *irg, int size);
-/* Code Placement. Pinns all floating nodes to a block where they
+/** Code Placement. Pinns all floating nodes to a block where they
will be executed only if needed. Depends on the flag opt_global_cse.
Graph may not be in phase_building. Does not schedule control dead
code. Uses dominator information which it computes if the irg is not
in state dom_consistent. Destroys the out information as it moves nodes
- to other blocks. Optimizes Tuples in Control edges. (@@@ This
- is not tested!)
+ to other blocks. Optimizes Tuples in Control edges.
+ @todo This is not tested!
+
Call remove_critical_cf_edges() before place_code(). This normalizes
the control flow graph so that for all operations a basic block exists
where they can be optimally placed.
- @@@ A more powerful code placement would move operations past Phi nodes
+
+ @todo A more powerful code placement would move operations past Phi nodes
out of loops. */
void place_code(ir_graph *irg);
-/********************************************************************/
-/* Control flow optimization. */
-/* Removes empty blocks doing if simplifications and loop simpli- */
-/* fications. A block is empty if it contains only a Jmp node and */
-/* Phi nodes. */
-/* Merges single entry single exit blocks with their predecessor */
-/* and propagates dead control flow by calling equivalent_node. */
-/* Independent of compiler flag it removes Tuples from cf edges, */
-/* Bad predecessors form blocks and unnecessary predecessors of End.*/
-/* @@@ So far destroys backedge information. */
-/********************************************************************/
+/** Control flow optimization.
+ * Removes empty blocks doing if simplifications and loop simplifications.
+ * A block is empty if it contains only a Jmp node and
+ * Phi nodes.
+ * Merges single entry single exit blocks with their predecessor
+ * and propagates dead control flow by calling equivalent_node.
+ * Independent of compiler flag it removes Tuples from cf edges,
+ * Bad predecessors form blocks and unnecessary predecessors of End.
+ *
+ * @bug So far destroys backedge information.
+ */
void optimize_cf(ir_graph *irg);
-/* Places an empty basic block on critical control flow edges thereby
+/** Places an empty basic block on critical control flow edges thereby
removing them.
+
A critical control flow edge is an edge from a block with several
control exits to a block with several control entries (See Muchnic
p. 407).
- @@@ not yet implemented!!! */
+
+ @todo not yet implemented!!! */
void remove_critical_cf_edges(ir_graph *irg);
# endif /* _IRGOPT_H_ */