1 /* Copyright (C) 1998 - 2001 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Author: Christian Schaefer, Goetz Lindenmaier
6 ** Optimizations for a whole ir graph, i.e., a procedure.
16 /* Applies local optimizations (see iropt.h) to all nodes in the graph. */
17 void local_optimize_graph (ir_graph *irg);
19 /* Performs dead node elimination by copying the ir graph to a new obstack.
20 Further removes Bad predecesors from Blocks and the corresponding
22 Optimization is only performed if options `optimize' and
23 `opt_dead_node_elimination' are set.
24 The graph may not be in state phase_building. The outs datasturcture
25 is freed, the outs state set to no_outs. (@@@ Change this? -> inconsistent.)
26 Removes old attributes of nodes. Sets link field to NULL.
27 Attention: the numbers assigned to nodes if the library is compiled for
28 development/debugging are not conserved by copying. */
29 void dead_node_elimination(ir_graph *irg);
31 /* Removes Bad Bad predecesors from Blocks and the corresponding
32 inputs to Phi nodes as in dead_node_elimination but without
34 @@@ not implemented! */
35 void remove_bad_predecessors(ir_graph *irg);
37 /* Inlines a method at the given call site.
38 Removes the call node and splits the basic block the call node
39 belongs to. Inserts a copy of the called graph between these nodes.
40 Assumes that call is a Call node in current_ir_graph and that
41 the type in the Call nodes type attribute is the same as the
42 type of the called graph.
43 Further it assumes that all Phi nodes in a block of current_ir_graph
44 are assembled in a "link" list in the link field of the corresponding
45 block nodes. Further assumes that all Proj nodes are in a "link" list
46 in the nodes producing the tuple. (This is only an optical feature
47 for the graph.) Conserves this feature for the old
48 nodes of the graph. This precondition can be established by a call to
49 collect_phisprojs(), see irgmod.h.
50 Called_graph must be unequal to current_ir_graph. Will not inline
52 Sets visited masterflag in current_ir_graph to the max of the flag in
53 current and called graph.
54 Assumes that both, the called and the calling graph are in state
56 It is recommended to call local_optimize_graph after inlining as this
57 function leaves a set of obscure Tuple nodes, e.g. a Proj-Tuple-Jmp
58 combination as control flow operation. */
59 void inline_method(ir_node *call, ir_graph *called_graph);
62 /* Inlines all small methods at call sites where the called address comes
63 from a Const node that references the entity representing the called
65 The size argument is a rough measure for the code size of the method:
66 Methods where the obstack containing the firm graph is smaller than
67 size are inlined. Further only a limited number of calls are inlined.
68 If the method contains more than 1024 inlineable calls none will be
70 Inlining is only performed if flags `optimize' and `inlineing' are set.
71 The graph may not be in state phase_building.
72 It is recommended to call local_optimize_graph after inlining as this
73 function leaves a set of obscure Tuple nodes, e.g. a Proj-Tuple-Jmp
74 combination as control flow operation. */
75 void inline_small_irgs(ir_graph *irg, int size);
77 /* Code Placement. Pinns all floating nodes to a block where they
78 will be executed only if needed. Depends on the flag opt_global_cse.
79 Graph may not be in phase_building. Does not schedule control dead
80 code. Uses dominator information which it computes if the irg is not
81 in state dom_consistent. Destroys the out information as it moves nodes
82 to other blocks. Optimizes Tuples in Control edges. (@@@ This
84 @@@ A more powerful code placement would move operations past Phi nodes
85 out of loops. Further the control flow should be normalized before
86 computing the dominator information so that there exists an optimal block
87 for all operations. */
88 void place_code(ir_graph *irg);
90 /********************************************************************/
91 /* Control flow optimization. */
92 /* Removes empty blocks doing if simplifications and loop simpli- */
93 /* fications. A block is empty if it contains only a Jmp node and */
95 /* Merges single entry single exit blocks with their predecessor */
96 /* and propagates dead control flow by calling equivalent_node. */
97 /* Independent of compiler flag it removes Tuples from cf edges, */
98 /* Bad predecessors form blocks and unnecessary predecessors of End.*/
99 /********************************************************************/
100 void optimize_cf(ir_graph *irg);
103 # endif /* _IRGOPT_H_ */