1169689Skan/* Definitions for describing one tree-ssa optimization pass.
2169689Skan   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3169689Skan   Contributed by Richard Henderson <rth@redhat.com>
4169689Skan
5169689SkanThis file is part of GCC.
6169689Skan
7169689SkanGCC is free software; you can redistribute it and/or modify
8169689Skanit under the terms of the GNU General Public License as published by
9169689Skanthe Free Software Foundation; either version 2, or (at your option)
10169689Skanany later version.
11169689Skan
12169689SkanGCC is distributed in the hope that it will be useful,
13169689Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of
14169689SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15169689SkanGNU General Public License for more details.
16169689Skan
17169689SkanYou should have received a copy of the GNU General Public License
18169689Skanalong with GCC; see the file COPYING.  If not, write to
19169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
20169689SkanBoston, MA 02110-1301, USA.  */
21169689Skan
22169689Skan
23169689Skan#ifndef GCC_TREE_PASS_H
24169689Skan#define GCC_TREE_PASS_H 1
25169689Skan
26169689Skan/* In tree-dump.c */
27169689Skan
28169689Skan/* Different tree dump places.  When you add new tree dump places,
29169689Skan   extend the DUMP_FILES array in tree-dump.c.  */
30169689Skanenum tree_dump_index
31169689Skan{
32169689Skan  TDI_none,			/* No dump */
33169689Skan  TDI_cgraph,                   /* dump function call graph.  */
34169689Skan  TDI_tu,			/* dump the whole translation unit.  */
35169689Skan  TDI_class,			/* dump class hierarchy.  */
36169689Skan  TDI_original,			/* dump each function before optimizing it */
37169689Skan  TDI_generic,			/* dump each function after genericizing it */
38169689Skan  TDI_nested,			/* dump each function after unnesting it */
39169689Skan  TDI_inlined,			/* dump each function after inlining
40169689Skan				   within it.  */
41169689Skan  TDI_vcg,			/* create a VCG graph file for each
42169689Skan				   function's flowgraph.  */
43169689Skan  TDI_tree_all,                 /* enable all the GENERIC/GIMPLE dumps.  */
44169689Skan  TDI_rtl_all,                  /* enable all the RTL dumps.  */
45169689Skan  TDI_ipa_all,                  /* enable all the IPA dumps.  */
46169689Skan
47169689Skan  TDI_end
48169689Skan};
49169689Skan
50169689Skan/* Bit masks to control dumping. Not all values are applicable to
51169689Skan   all dumps. Add new ones at the end. When you define new
52169689Skan   values, extend the DUMP_OPTIONS array in tree-dump.c */
53169689Skan#define TDF_ADDRESS	(1 << 0)	/* dump node addresses */
54169689Skan#define TDF_SLIM	(1 << 1)	/* don't go wild following links */
55169689Skan#define TDF_RAW  	(1 << 2)	/* don't unparse the function */
56169689Skan#define TDF_DETAILS	(1 << 3)	/* show more detailed info about
57169689Skan					   each pass */
58169689Skan#define TDF_STATS	(1 << 4)	/* dump various statistics about
59169689Skan					   each pass */
60169689Skan#define TDF_BLOCKS	(1 << 5)	/* display basic block boundaries */
61169689Skan#define TDF_VOPS	(1 << 6)	/* display virtual operands */
62169689Skan#define TDF_LINENO	(1 << 7)	/* display statement line numbers */
63169689Skan#define TDF_UID		(1 << 8)	/* display decl UIDs */
64169689Skan
65169689Skan#define TDF_TREE	(1 << 9)	/* is a tree dump */
66169689Skan#define TDF_RTL		(1 << 10)	/* is a RTL dump */
67169689Skan#define TDF_IPA		(1 << 11)	/* is an IPA dump */
68169689Skan#define TDF_STMTADDR	(1 << 12)	/* Address of stmt.  */
69169689Skan
70169689Skan#define TDF_GRAPH	(1 << 13)	/* a graph dump is being emitted */
71169689Skan
72169689Skanextern char *get_dump_file_name (enum tree_dump_index);
73169689Skanextern int dump_enabled_p (enum tree_dump_index);
74169689Skanextern int dump_initialized_p (enum tree_dump_index);
75169689Skanextern FILE *dump_begin (enum tree_dump_index, int *);
76169689Skanextern void dump_end (enum tree_dump_index, FILE *);
77169689Skanextern void dump_node (tree, int, FILE *);
78169689Skanextern int dump_switch_p (const char *);
79169689Skanextern const char *dump_flag_name (enum tree_dump_index);
80169689Skan
81169689Skan/* Global variables used to communicate with passes.  */
82169689Skanextern FILE *dump_file;
83169689Skanextern int dump_flags;
84169689Skanextern const char *dump_file_name;
85169689Skan
86169689Skan/* Return the dump_file_info for the given phase.  */
87169689Skanextern struct dump_file_info *get_dump_file_info (enum tree_dump_index);
88169689Skan
89169689Skan/* Describe one pass.  */
90169689Skanstruct tree_opt_pass
91169689Skan{
92169689Skan  /* Terse name of the pass used as a fragment of the dump file name.  */
93169689Skan  const char *name;
94169689Skan
95169689Skan  /* If non-null, this pass and all sub-passes are executed only if
96169689Skan     the function returns true.  */
97169689Skan  bool (*gate) (void);
98169689Skan
99169689Skan  /* This is the code to run.  If null, then there should be sub-passes
100169689Skan     otherwise this pass does nothing.  The return value contains
101169689Skan     TODOs to execute in addition to those in TODO_flags_finish.   */
102169689Skan  unsigned int (*execute) (void);
103169689Skan
104169689Skan  /* A list of sub-passes to run, dependent on gate predicate.  */
105169689Skan  struct tree_opt_pass *sub;
106169689Skan
107169689Skan  /* Next in the list of passes to run, independent of gate predicate.  */
108169689Skan  struct tree_opt_pass *next;
109169689Skan
110169689Skan  /* Static pass number, used as a fragment of the dump file name.  */
111169689Skan  int static_pass_number;
112169689Skan
113169689Skan  /* The timevar id associated with this pass.  */
114169689Skan  /* ??? Ideally would be dynamically assigned.  */
115169689Skan  unsigned int tv_id;
116169689Skan
117169689Skan  /* Sets of properties input and output from this pass.  */
118169689Skan  unsigned int properties_required;
119169689Skan  unsigned int properties_provided;
120169689Skan  unsigned int properties_destroyed;
121169689Skan
122169689Skan  /* Flags indicating common sets things to do before and after.  */
123169689Skan  unsigned int todo_flags_start;
124169689Skan  unsigned int todo_flags_finish;
125169689Skan
126169689Skan  /* Letter for RTL dumps.  */
127169689Skan  char letter;
128169689Skan};
129169689Skan
130169689Skan/* Define a tree dump switch.  */
131169689Skanstruct dump_file_info
132169689Skan{
133169689Skan  const char *suffix;           /* suffix to give output file.  */
134169689Skan  const char *swtch;            /* command line switch */
135169689Skan  const char *glob;             /* command line glob  */
136169689Skan  int flags;                    /* user flags */
137169689Skan  int state;                    /* state of play */
138169689Skan  int num;                      /* dump file number */
139169689Skan  int letter;                   /* enabling letter for RTL dumps */
140169689Skan};
141169689Skan
142169689Skan/* Pass properties.  */
143169689Skan#define PROP_gimple_any		(1 << 0)	/* entire gimple grammar */
144169689Skan#define PROP_gimple_lcf		(1 << 1)	/* lowered control flow */
145169689Skan#define PROP_gimple_leh		(1 << 2)	/* lowered eh */
146169689Skan#define PROP_cfg		(1 << 3)
147169689Skan#define PROP_referenced_vars	(1 << 4)
148169689Skan#define PROP_pta		(1 << 5)
149169689Skan#define PROP_ssa		(1 << 6)
150169689Skan#define PROP_no_crit_edges      (1 << 7)
151169689Skan#define PROP_rtl		(1 << 8)
152169689Skan#define PROP_alias		(1 << 9)
153169689Skan#define PROP_gimple_lomp	(1 << 10)	/* lowered OpenMP directives */
154169689Skan#define PROP_smt_usage          (1 << 11)       /* which SMT's are
155169689Skan						   used alone.  */
156169689Skan
157169689Skan#define PROP_trees \
158169689Skan  (PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | PROP_gimple_lomp)
159169689Skan
160169689Skan/* To-do flags.  */
161169689Skan#define TODO_dump_func			(1 << 0)
162169689Skan#define TODO_ggc_collect		(1 << 1)
163169689Skan#define TODO_verify_ssa			(1 << 2)
164169689Skan#define TODO_verify_flow		(1 << 3)
165169689Skan#define TODO_verify_stmts		(1 << 4)
166169689Skan#define TODO_cleanup_cfg        	(1 << 5)
167169689Skan#define TODO_verify_loops		(1 << 6)
168169689Skan#define TODO_dump_cgraph		(1 << 7)
169169689Skan
170169689Skan/* To-do flags for calls to update_ssa.  */
171169689Skan
172169689Skan/* Update the SSA form inserting PHI nodes for newly exposed symbols
173169689Skan   and virtual names marked for updating.  When updating real names,
174169689Skan   only insert PHI nodes for a real name O_j in blocks reached by all
175169689Skan   the new and old definitions for O_j.  If the iterated dominance
176169689Skan   frontier for O_j is not pruned, we may end up inserting PHI nodes
177169689Skan   in blocks that have one or more edges with no incoming definition
178169689Skan   for O_j.  This would lead to uninitialized warnings for O_j's
179169689Skan   symbol.  */
180169689Skan#define TODO_update_ssa			(1 << 8)
181169689Skan
182169689Skan/* Update the SSA form without inserting any new PHI nodes at all.
183169689Skan   This is used by passes that have either inserted all the PHI nodes
184169689Skan   themselves or passes that need only to patch use-def and def-def
185169689Skan   chains for virtuals (e.g., DCE).  */
186169689Skan#define TODO_update_ssa_no_phi		(1 << 9)
187169689Skan
188169689Skan/* Insert PHI nodes everywhere they are needed.  No pruning of the
189169689Skan   IDF is done.  This is used by passes that need the PHI nodes for
190169689Skan   O_j even if it means that some arguments will come from the default
191169689Skan   definition of O_j's symbol (e.g., pass_linear_transform).
192169689Skan
193169689Skan   WARNING: If you need to use this flag, chances are that your pass
194169689Skan   may be doing something wrong.  Inserting PHI nodes for an old name
195169689Skan   where not all edges carry a new replacement may lead to silent
196169689Skan   codegen errors or spurious uninitialized warnings.  */
197169689Skan#define TODO_update_ssa_full_phi	(1 << 10)
198169689Skan
199169689Skan/* Passes that update the SSA form on their own may want to delegate
200169689Skan   the updating of virtual names to the generic updater.  Since FUD
201169689Skan   chains are easier to maintain, this simplifies the work they need
202169689Skan   to do.  NOTE: If this flag is used, any OLD->NEW mappings for real
203169689Skan   names are explicitly destroyed and only the symbols marked for
204169689Skan   renaming are processed.  */
205169689Skan#define TODO_update_ssa_only_virtuals	(1 << 11)
206169689Skan
207169689Skan/* Some passes leave unused local variables that can be removed from
208169689Skan   cfun->unexpanded_var_list.  This reduces the size of dump files and
209169689Skan   the memory footprint for VAR_DECLs.  */
210169689Skan#define TODO_remove_unused_locals	(1 << 12)
211169689Skan
212169689Skan/* Internally used for the first in a sequence of passes.  It is set
213169689Skan   for the passes that are handed to register_dump_files.  */
214169689Skan#define TODO_set_props			(1 << 13)
215169689Skan
216169689Skan/* Set by passes that may make SMT's that were previously never used
217169689Skan   in statements, used.  */
218169689Skan#define TODO_update_smt_usage           (1 << 14)
219169689Skan
220169689Skan#define TODO_update_ssa_any		\
221169689Skan    (TODO_update_ssa			\
222169689Skan     | TODO_update_ssa_no_phi		\
223169689Skan     | TODO_update_ssa_full_phi		\
224169689Skan     | TODO_update_ssa_only_virtuals)
225169689Skan
226169689Skan#define TODO_verify_all \
227169689Skan  (TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts)
228169689Skan
229169689Skanextern void tree_lowering_passes (tree decl);
230169689Skan
231169689Skanextern struct tree_opt_pass pass_mudflap_1;
232169689Skanextern struct tree_opt_pass pass_mudflap_2;
233169689Skanextern struct tree_opt_pass pass_remove_useless_stmts;
234169689Skanextern struct tree_opt_pass pass_lower_cf;
235169689Skanextern struct tree_opt_pass pass_lower_eh;
236169689Skanextern struct tree_opt_pass pass_build_cfg;
237169689Skanextern struct tree_opt_pass pass_tree_profile;
238169689Skanextern struct tree_opt_pass pass_early_tree_profile;
239169689Skanextern struct tree_opt_pass pass_cleanup_cfg;
240169689Skanextern struct tree_opt_pass pass_referenced_vars;
241169689Skanextern struct tree_opt_pass pass_sra;
242169689Skanextern struct tree_opt_pass pass_tail_recursion;
243169689Skanextern struct tree_opt_pass pass_tail_calls;
244169689Skanextern struct tree_opt_pass pass_tree_loop;
245169689Skanextern struct tree_opt_pass pass_tree_loop_init;
246169689Skanextern struct tree_opt_pass pass_lim;
247169689Skanextern struct tree_opt_pass pass_tree_unswitch;
248169689Skanextern struct tree_opt_pass pass_iv_canon;
249169689Skanextern struct tree_opt_pass pass_scev_cprop;
250169689Skanextern struct tree_opt_pass pass_empty_loop;
251169689Skanextern struct tree_opt_pass pass_record_bounds;
252169689Skanextern struct tree_opt_pass pass_if_conversion;
253169689Skanextern struct tree_opt_pass pass_vectorize;
254169689Skanextern struct tree_opt_pass pass_complete_unroll;
255169689Skanextern struct tree_opt_pass pass_loop_prefetch;
256169689Skanextern struct tree_opt_pass pass_iv_optimize;
257169689Skanextern struct tree_opt_pass pass_tree_loop_done;
258169689Skanextern struct tree_opt_pass pass_ch;
259169689Skanextern struct tree_opt_pass pass_ccp;
260169689Skanextern struct tree_opt_pass pass_phi_only_cprop;
261169689Skanextern struct tree_opt_pass pass_build_ssa;
262169689Skanextern struct tree_opt_pass pass_del_ssa;
263169689Skanextern struct tree_opt_pass pass_dominator;
264169689Skanextern struct tree_opt_pass pass_dce;
265169689Skanextern struct tree_opt_pass pass_dce_loop;
266169689Skanextern struct tree_opt_pass pass_cd_dce;
267169689Skanextern struct tree_opt_pass pass_merge_phi;
268169689Skanextern struct tree_opt_pass pass_may_alias;
269169689Skanextern struct tree_opt_pass pass_split_crit_edges;
270169689Skanextern struct tree_opt_pass pass_pre;
271169689Skanextern struct tree_opt_pass pass_profile;
272169689Skanextern struct tree_opt_pass pass_lower_complex_O0;
273169689Skanextern struct tree_opt_pass pass_lower_complex;
274169689Skanextern struct tree_opt_pass pass_lower_vector;
275169689Skanextern struct tree_opt_pass pass_lower_vector_ssa;
276169689Skanextern struct tree_opt_pass pass_lower_omp;
277169689Skanextern struct tree_opt_pass pass_expand_omp;
278169689Skanextern struct tree_opt_pass pass_object_sizes;
279169689Skanextern struct tree_opt_pass pass_fold_builtins;
280169689Skanextern struct tree_opt_pass pass_stdarg;
281169689Skanextern struct tree_opt_pass pass_early_warn_uninitialized;
282169689Skanextern struct tree_opt_pass pass_late_warn_uninitialized;
283169689Skanextern struct tree_opt_pass pass_cse_reciprocals;
284169689Skanextern struct tree_opt_pass pass_warn_function_return;
285169689Skanextern struct tree_opt_pass pass_warn_function_noreturn;
286169689Skanextern struct tree_opt_pass pass_phiopt;
287169689Skanextern struct tree_opt_pass pass_forwprop;
288169689Skanextern struct tree_opt_pass pass_redundant_phi;
289169689Skanextern struct tree_opt_pass pass_dse;
290169689Skanextern struct tree_opt_pass pass_nrv;
291169689Skanextern struct tree_opt_pass pass_mark_used_blocks;
292169689Skanextern struct tree_opt_pass pass_rename_ssa_copies;
293169689Skanextern struct tree_opt_pass pass_expand;
294169689Skanextern struct tree_opt_pass pass_rest_of_compilation;
295169689Skanextern struct tree_opt_pass pass_sink_code;
296169689Skanextern struct tree_opt_pass pass_fre;
297169689Skanextern struct tree_opt_pass pass_linear_transform;
298169689Skanextern struct tree_opt_pass pass_copy_prop;
299169689Skanextern struct tree_opt_pass pass_store_ccp;
300169689Skanextern struct tree_opt_pass pass_store_copy_prop;
301169689Skanextern struct tree_opt_pass pass_vrp;
302169689Skanextern struct tree_opt_pass pass_create_structure_vars;
303169689Skanextern struct tree_opt_pass pass_uncprop;
304169689Skanextern struct tree_opt_pass pass_return_slot;
305169689Skanextern struct tree_opt_pass pass_reassoc;
306169689Skanextern struct tree_opt_pass pass_rebuild_cgraph_edges;
307169689Skanextern struct tree_opt_pass pass_reset_cc_flags;
308169689Skan
309169689Skan/* IPA Passes */
310169689Skanextern struct tree_opt_pass pass_ipa_cp;
311169689Skanextern struct tree_opt_pass pass_ipa_inline;
312169689Skanextern struct tree_opt_pass pass_early_ipa_inline;
313169689Skanextern struct tree_opt_pass pass_ipa_reference;
314169689Skanextern struct tree_opt_pass pass_ipa_pure_const;
315169689Skanextern struct tree_opt_pass pass_ipa_type_escape;
316169689Skanextern struct tree_opt_pass pass_ipa_pta;
317169689Skanextern struct tree_opt_pass pass_early_local_passes;
318169689Skan
319169689Skanextern struct tree_opt_pass pass_all_optimizations;
320169689Skanextern struct tree_opt_pass pass_cleanup_cfg_post_optimizing;
321169689Skanextern struct tree_opt_pass pass_free_cfg_annotations;
322169689Skanextern struct tree_opt_pass pass_free_datastructures;
323169689Skanextern struct tree_opt_pass pass_init_datastructures;
324169689Skanextern struct tree_opt_pass pass_fixup_cfg;
325169689Skan
326169689Skanextern struct tree_opt_pass pass_init_function;
327169689Skanextern struct tree_opt_pass pass_jump;
328169689Skanextern struct tree_opt_pass pass_insn_locators_initialize;
329169689Skanextern struct tree_opt_pass pass_rtl_eh;
330169689Skanextern struct tree_opt_pass pass_initial_value_sets;
331169689Skanextern struct tree_opt_pass pass_unshare_all_rtl;
332169689Skanextern struct tree_opt_pass pass_instantiate_virtual_regs;
333169689Skanextern struct tree_opt_pass pass_jump2;
334169689Skanextern struct tree_opt_pass pass_cse;
335169689Skanextern struct tree_opt_pass pass_gcse;
336169689Skanextern struct tree_opt_pass pass_jump_bypass;
337169689Skanextern struct tree_opt_pass pass_profiling;
338169689Skanextern struct tree_opt_pass pass_rtl_ifcvt;
339169689Skanextern struct tree_opt_pass pass_tracer;
340169689Skan
341169689Skanextern struct tree_opt_pass pass_loop2;
342169689Skanextern struct tree_opt_pass pass_rtl_loop_init;
343169689Skanextern struct tree_opt_pass pass_rtl_move_loop_invariants;
344169689Skanextern struct tree_opt_pass pass_rtl_unswitch;
345169689Skanextern struct tree_opt_pass pass_rtl_unroll_and_peel_loops;
346169689Skanextern struct tree_opt_pass pass_rtl_doloop;
347169689Skanextern struct tree_opt_pass pass_rtl_loop_done;
348169689Skan
349169689Skanextern struct tree_opt_pass pass_web;
350169689Skanextern struct tree_opt_pass pass_cse2;
351169689Skanextern struct tree_opt_pass pass_life;
352169689Skanextern struct tree_opt_pass pass_combine;
353169689Skanextern struct tree_opt_pass pass_if_after_combine;
354169689Skanextern struct tree_opt_pass pass_partition_blocks;
355169689Skanextern struct tree_opt_pass pass_partition_blocks;
356169689Skanextern struct tree_opt_pass pass_regmove;
357169689Skanextern struct tree_opt_pass pass_split_all_insns;
358169689Skanextern struct tree_opt_pass pass_mode_switching;
359169689Skanextern struct tree_opt_pass pass_see;
360169689Skanextern struct tree_opt_pass pass_recompute_reg_usage;
361169689Skanextern struct tree_opt_pass pass_sms;
362169689Skanextern struct tree_opt_pass pass_sched;
363169689Skanextern struct tree_opt_pass pass_local_alloc;
364169689Skanextern struct tree_opt_pass pass_global_alloc;
365169689Skanextern struct tree_opt_pass pass_postreload;
366169689Skanextern struct tree_opt_pass pass_clean_state;
367169689Skanextern struct tree_opt_pass pass_branch_prob;
368169689Skanextern struct tree_opt_pass pass_value_profile_transformations;
369169689Skanextern struct tree_opt_pass pass_remove_death_notes;
370169689Skanextern struct tree_opt_pass pass_postreload_cse;
371169689Skanextern struct tree_opt_pass pass_gcse2;
372169689Skanextern struct tree_opt_pass pass_flow2;
373169689Skanextern struct tree_opt_pass pass_stack_adjustments;
374169689Skanextern struct tree_opt_pass pass_peephole2;
375169689Skanextern struct tree_opt_pass pass_if_after_reload;
376169689Skanextern struct tree_opt_pass pass_regrename;
377169689Skanextern struct tree_opt_pass pass_reorder_blocks;
378169689Skanextern struct tree_opt_pass pass_branch_target_load_optimize;
379169689Skanextern struct tree_opt_pass pass_leaf_regs;
380169689Skanextern struct tree_opt_pass pass_sched2;
381169689Skanextern struct tree_opt_pass pass_stack_regs;
382169689Skanextern struct tree_opt_pass pass_compute_alignments;
383169689Skanextern struct tree_opt_pass pass_duplicate_computed_gotos;
384169689Skanextern struct tree_opt_pass pass_variable_tracking;
385169689Skanextern struct tree_opt_pass pass_free_cfg;
386169689Skanextern struct tree_opt_pass pass_machine_reorg;
387169689Skanextern struct tree_opt_pass pass_purge_lineno_notes;
388169689Skanextern struct tree_opt_pass pass_cleanup_barriers;
389169689Skanextern struct tree_opt_pass pass_delay_slots;
390169689Skanextern struct tree_opt_pass pass_split_for_shorten_branches;
391169689Skanextern struct tree_opt_pass pass_split_before_regstack;
392169689Skanextern struct tree_opt_pass pass_convert_to_eh_region_ranges;
393169689Skanextern struct tree_opt_pass pass_shorten_branches;
394169689Skanextern struct tree_opt_pass pass_set_nothrow_function_flags;
395169689Skanextern struct tree_opt_pass pass_final;
396169689Skanextern struct tree_opt_pass pass_rtl_seqabstr;
397169689Skan
398169689Skan/* The root of the compilation pass tree, once constructed.  */
399169689Skanextern struct tree_opt_pass *all_passes, *all_ipa_passes, *all_lowering_passes;
400169689Skan
401169689Skanextern void execute_pass_list (struct tree_opt_pass *);
402169689Skanextern void execute_ipa_pass_list (struct tree_opt_pass *);
403169689Skan
404169689Skan#endif /* GCC_TREE_PASS_H */
405