2007-12-17 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / tree-pass.h
blob91b1594aa84f04864d723e334adb47416e1bb108
1 /* Definitions for describing one tree-ssa optimization pass.
2 Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
3 Contributed by Richard Henderson <rth@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 #ifndef GCC_TREE_PASS_H
23 #define GCC_TREE_PASS_H 1
25 /* In tree-dump.c */
27 /* Different tree dump places. When you add new tree dump places,
28 extend the DUMP_FILES array in tree-dump.c. */
29 enum tree_dump_index
31 TDI_none, /* No dump */
32 TDI_cgraph, /* dump function call graph. */
33 TDI_tu, /* dump the whole translation unit. */
34 TDI_class, /* dump class hierarchy. */
35 TDI_original, /* dump each function before optimizing it */
36 TDI_generic, /* dump each function after genericizing it */
37 TDI_nested, /* dump each function after unnesting it */
38 TDI_inlined, /* dump each function after inlining
39 within it. */
40 TDI_vcg, /* create a VCG graph file for each
41 function's flowgraph. */
42 TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */
43 TDI_rtl_all, /* enable all the RTL dumps. */
44 TDI_ipa_all, /* enable all the IPA dumps. */
46 TDI_end
49 /* Bit masks to control dumping. Not all values are applicable to
50 all dumps. Add new ones at the end. When you define new
51 values, extend the DUMP_OPTIONS array in tree-dump.c */
52 #define TDF_ADDRESS (1 << 0) /* dump node addresses */
53 #define TDF_SLIM (1 << 1) /* don't go wild following links */
54 #define TDF_RAW (1 << 2) /* don't unparse the function */
55 #define TDF_DETAILS (1 << 3) /* show more detailed info about
56 each pass */
57 #define TDF_STATS (1 << 4) /* dump various statistics about
58 each pass */
59 #define TDF_BLOCKS (1 << 5) /* display basic block boundaries */
60 #define TDF_VOPS (1 << 6) /* display virtual operands */
61 #define TDF_LINENO (1 << 7) /* display statement line numbers */
62 #define TDF_UID (1 << 8) /* display decl UIDs */
64 #define TDF_TREE (1 << 9) /* is a tree dump */
65 #define TDF_RTL (1 << 10) /* is a RTL dump */
66 #define TDF_IPA (1 << 11) /* is an IPA dump */
67 #define TDF_STMTADDR (1 << 12) /* Address of stmt. */
69 #define TDF_GRAPH (1 << 13) /* a graph dump is being emitted */
70 #define TDF_MEMSYMS (1 << 14) /* display memory symbols in expr.
71 Implies TDF_VOPS. */
73 #define TDF_DIAGNOSTIC (1 << 15) /* A dump to be put in a diagnostic
74 message. */
76 extern char *get_dump_file_name (enum tree_dump_index);
77 extern int dump_enabled_p (enum tree_dump_index);
78 extern int dump_initialized_p (enum tree_dump_index);
79 extern FILE *dump_begin (enum tree_dump_index, int *);
80 extern void dump_end (enum tree_dump_index, FILE *);
81 extern void dump_node (const_tree, int, FILE *);
82 extern int dump_switch_p (const char *);
83 extern const char *dump_flag_name (enum tree_dump_index);
85 /* Global variables used to communicate with passes. */
86 extern FILE *dump_file;
87 extern int dump_flags;
88 extern const char *dump_file_name;
90 /* Return the dump_file_info for the given phase. */
91 extern struct dump_file_info *get_dump_file_info (enum tree_dump_index);
93 /* Describe one pass. */
94 struct tree_opt_pass
96 /* Terse name of the pass used as a fragment of the dump file name. */
97 const char *name;
99 /* If non-null, this pass and all sub-passes are executed only if
100 the function returns true. */
101 bool (*gate) (void);
103 /* This is the code to run. If null, then there should be sub-passes
104 otherwise this pass does nothing. The return value contains
105 TODOs to execute in addition to those in TODO_flags_finish. */
106 unsigned int (*execute) (void);
108 /* A list of sub-passes to run, dependent on gate predicate. */
109 struct tree_opt_pass *sub;
111 /* Next in the list of passes to run, independent of gate predicate. */
112 struct tree_opt_pass *next;
114 /* Static pass number, used as a fragment of the dump file name. */
115 int static_pass_number;
117 /* The timevar id associated with this pass. */
118 /* ??? Ideally would be dynamically assigned. */
119 unsigned int tv_id;
121 /* Sets of properties input and output from this pass. */
122 unsigned int properties_required;
123 unsigned int properties_provided;
124 unsigned int properties_destroyed;
126 /* Flags indicating common sets things to do before and after. */
127 unsigned int todo_flags_start;
128 unsigned int todo_flags_finish;
130 /* Letter for RTL dumps. */
131 char letter;
134 /* Define a tree dump switch. */
135 struct dump_file_info
137 const char *suffix; /* suffix to give output file. */
138 const char *swtch; /* command line switch */
139 const char *glob; /* command line glob */
140 int flags; /* user flags */
141 int state; /* state of play */
142 int num; /* dump file number */
143 int letter; /* enabling letter for RTL dumps */
146 /* Pass properties. */
147 #define PROP_gimple_any (1 << 0) /* entire gimple grammar */
148 #define PROP_gimple_lcf (1 << 1) /* lowered control flow */
149 #define PROP_gimple_leh (1 << 2) /* lowered eh */
150 #define PROP_cfg (1 << 3)
151 #define PROP_referenced_vars (1 << 4)
152 #define PROP_ssa (1 << 5)
153 #define PROP_no_crit_edges (1 << 6)
154 #define PROP_rtl (1 << 7)
155 #define PROP_alias (1 << 8)
156 #define PROP_gimple_lomp (1 << 9) /* lowered OpenMP directives */
158 #define PROP_trees \
159 (PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | PROP_gimple_lomp)
161 /* To-do flags. */
162 #define TODO_dump_func (1 << 0)
163 #define TODO_ggc_collect (1 << 1)
164 #define TODO_verify_ssa (1 << 2)
165 #define TODO_verify_flow (1 << 3)
166 #define TODO_verify_stmts (1 << 4)
167 #define TODO_cleanup_cfg (1 << 5)
168 #define TODO_verify_loops (1 << 6)
169 #define TODO_dump_cgraph (1 << 7)
170 #define TODO_remove_functions (1 << 8)
171 #define TODO_rebuild_frequencies (1 << 9)
173 /* To-do flags for calls to update_ssa. */
175 /* Update the SSA form inserting PHI nodes for newly exposed symbols
176 and virtual names marked for updating. When updating real names,
177 only insert PHI nodes for a real name O_j in blocks reached by all
178 the new and old definitions for O_j. If the iterated dominance
179 frontier for O_j is not pruned, we may end up inserting PHI nodes
180 in blocks that have one or more edges with no incoming definition
181 for O_j. This would lead to uninitialized warnings for O_j's
182 symbol. */
183 #define TODO_update_ssa (1 << 10)
185 /* Update the SSA form without inserting any new PHI nodes at all.
186 This is used by passes that have either inserted all the PHI nodes
187 themselves or passes that need only to patch use-def and def-def
188 chains for virtuals (e.g., DCE). */
189 #define TODO_update_ssa_no_phi (1 << 11)
191 /* Insert PHI nodes everywhere they are needed. No pruning of the
192 IDF is done. This is used by passes that need the PHI nodes for
193 O_j even if it means that some arguments will come from the default
194 definition of O_j's symbol (e.g., pass_linear_transform).
196 WARNING: If you need to use this flag, chances are that your pass
197 may be doing something wrong. Inserting PHI nodes for an old name
198 where not all edges carry a new replacement may lead to silent
199 codegen errors or spurious uninitialized warnings. */
200 #define TODO_update_ssa_full_phi (1 << 12)
202 /* Passes that update the SSA form on their own may want to delegate
203 the updating of virtual names to the generic updater. Since FUD
204 chains are easier to maintain, this simplifies the work they need
205 to do. NOTE: If this flag is used, any OLD->NEW mappings for real
206 names are explicitly destroyed and only the symbols marked for
207 renaming are processed. */
208 #define TODO_update_ssa_only_virtuals (1 << 13)
210 /* Some passes leave unused local variables that can be removed from
211 cfun->unexpanded_var_list. This reduces the size of dump files and
212 the memory footprint for VAR_DECLs. */
213 #define TODO_remove_unused_locals (1 << 14)
215 /* Internally used for the first in a sequence of passes. It is set
216 for the passes that are handed to register_dump_files. */
217 #define TODO_set_props (1 << 15)
219 /* Call df_finish at the end of the pass. This is done after all of
220 the dumpers have been allowed to run so that they have access to
221 the instance before it is destroyed. */
222 #define TODO_df_finish (1 << 16)
224 /* Call df_verify at the end of the pass if checking is enabled. */
225 #define TODO_df_verify (1 << 17)
227 /* Internally used for the first instance of a pass. */
228 #define TODO_mark_first_instance (1 << 18)
230 /* Rebuild aliasing info. */
231 #define TODO_rebuild_alias (1 << 19)
233 #define TODO_update_ssa_any \
234 (TODO_update_ssa \
235 | TODO_update_ssa_no_phi \
236 | TODO_update_ssa_full_phi \
237 | TODO_update_ssa_only_virtuals)
239 #define TODO_verify_all \
240 (TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts)
242 extern void tree_lowering_passes (tree decl);
244 extern struct tree_opt_pass pass_mudflap_1;
245 extern struct tree_opt_pass pass_mudflap_2;
246 extern struct tree_opt_pass pass_remove_useless_stmts;
247 extern struct tree_opt_pass pass_lower_cf;
248 extern struct tree_opt_pass pass_lower_eh;
249 extern struct tree_opt_pass pass_build_cfg;
250 extern struct tree_opt_pass pass_tree_profile;
251 extern struct tree_opt_pass pass_early_tree_profile;
252 extern struct tree_opt_pass pass_cleanup_cfg;
253 extern struct tree_opt_pass pass_referenced_vars;
254 extern struct tree_opt_pass pass_sra;
255 extern struct tree_opt_pass pass_sra_early;
256 extern struct tree_opt_pass pass_tail_recursion;
257 extern struct tree_opt_pass pass_tail_calls;
258 extern struct tree_opt_pass pass_tree_loop;
259 extern struct tree_opt_pass pass_tree_loop_init;
260 extern struct tree_opt_pass pass_lim;
261 extern struct tree_opt_pass pass_tree_unswitch;
262 extern struct tree_opt_pass pass_predcom;
263 extern struct tree_opt_pass pass_iv_canon;
264 extern struct tree_opt_pass pass_scev_cprop;
265 extern struct tree_opt_pass pass_empty_loop;
266 extern struct tree_opt_pass pass_record_bounds;
267 extern struct tree_opt_pass pass_if_conversion;
268 extern struct tree_opt_pass pass_vectorize;
269 extern struct tree_opt_pass pass_complete_unroll;
270 extern struct tree_opt_pass pass_loop_prefetch;
271 extern struct tree_opt_pass pass_iv_optimize;
272 extern struct tree_opt_pass pass_tree_loop_done;
273 extern struct tree_opt_pass pass_ch;
274 extern struct tree_opt_pass pass_ccp;
275 extern struct tree_opt_pass pass_phi_only_cprop;
276 extern struct tree_opt_pass pass_build_ssa;
277 extern struct tree_opt_pass pass_del_ssa;
278 extern struct tree_opt_pass pass_dominator;
279 extern struct tree_opt_pass pass_dce;
280 extern struct tree_opt_pass pass_dce_loop;
281 extern struct tree_opt_pass pass_cd_dce;
282 extern struct tree_opt_pass pass_merge_phi;
283 extern struct tree_opt_pass pass_split_crit_edges;
284 extern struct tree_opt_pass pass_pre;
285 extern struct tree_opt_pass pass_profile;
286 extern struct tree_opt_pass pass_lower_complex_O0;
287 extern struct tree_opt_pass pass_lower_complex;
288 extern struct tree_opt_pass pass_lower_vector;
289 extern struct tree_opt_pass pass_lower_vector_ssa;
290 extern struct tree_opt_pass pass_lower_omp;
291 extern struct tree_opt_pass pass_expand_omp;
292 extern struct tree_opt_pass pass_object_sizes;
293 extern struct tree_opt_pass pass_fold_builtins;
294 extern struct tree_opt_pass pass_stdarg;
295 extern struct tree_opt_pass pass_early_warn_uninitialized;
296 extern struct tree_opt_pass pass_late_warn_uninitialized;
297 extern struct tree_opt_pass pass_cse_reciprocals;
298 extern struct tree_opt_pass pass_cse_sincos;
299 extern struct tree_opt_pass pass_convert_to_rsqrt;
300 extern struct tree_opt_pass pass_warn_function_return;
301 extern struct tree_opt_pass pass_warn_function_noreturn;
302 extern struct tree_opt_pass pass_phiopt;
303 extern struct tree_opt_pass pass_forwprop;
304 extern struct tree_opt_pass pass_phiprop;
305 extern struct tree_opt_pass pass_tree_ifcombine;
306 extern struct tree_opt_pass pass_dse;
307 extern struct tree_opt_pass pass_nrv;
308 extern struct tree_opt_pass pass_mark_used_blocks;
309 extern struct tree_opt_pass pass_rename_ssa_copies;
310 extern struct tree_opt_pass pass_expand;
311 extern struct tree_opt_pass pass_rest_of_compilation;
312 extern struct tree_opt_pass pass_sink_code;
313 extern struct tree_opt_pass pass_fre;
314 extern struct tree_opt_pass pass_linear_transform;
315 extern struct tree_opt_pass pass_check_data_deps;
316 extern struct tree_opt_pass pass_copy_prop;
317 extern struct tree_opt_pass pass_store_ccp;
318 extern struct tree_opt_pass pass_store_copy_prop;
319 extern struct tree_opt_pass pass_vrp;
320 extern struct tree_opt_pass pass_create_structure_vars;
321 extern struct tree_opt_pass pass_uncprop;
322 extern struct tree_opt_pass pass_return_slot;
323 extern struct tree_opt_pass pass_reassoc;
324 extern struct tree_opt_pass pass_rebuild_cgraph_edges;
325 extern struct tree_opt_pass pass_build_cgraph_edges;
326 extern struct tree_opt_pass pass_reset_cc_flags;
328 /* IPA Passes */
329 extern struct tree_opt_pass pass_ipa_matrix_reorg;
330 extern struct tree_opt_pass pass_ipa_cp;
331 extern struct tree_opt_pass pass_ipa_inline;
332 extern struct tree_opt_pass pass_ipa_early_inline;
333 extern struct tree_opt_pass pass_ipa_reference;
334 extern struct tree_opt_pass pass_ipa_pure_const;
335 extern struct tree_opt_pass pass_ipa_type_escape;
336 extern struct tree_opt_pass pass_ipa_pta;
337 extern struct tree_opt_pass pass_early_local_passes;
338 extern struct tree_opt_pass pass_ipa_increase_alignment;
339 extern struct tree_opt_pass pass_ipa_function_and_variable_visibility;
341 extern struct tree_opt_pass pass_all_optimizations;
342 extern struct tree_opt_pass pass_cleanup_cfg_post_optimizing;
343 extern struct tree_opt_pass pass_free_cfg_annotations;
344 extern struct tree_opt_pass pass_free_datastructures;
345 extern struct tree_opt_pass pass_init_datastructures;
346 extern struct tree_opt_pass pass_fixup_cfg;
348 extern struct tree_opt_pass pass_init_function;
349 extern struct tree_opt_pass pass_jump;
350 extern struct tree_opt_pass pass_rtl_eh;
351 extern struct tree_opt_pass pass_initial_value_sets;
352 extern struct tree_opt_pass pass_unshare_all_rtl;
353 extern struct tree_opt_pass pass_instantiate_virtual_regs;
354 extern struct tree_opt_pass pass_rtl_fwprop;
355 extern struct tree_opt_pass pass_rtl_fwprop_addr;
356 extern struct tree_opt_pass pass_jump2;
357 extern struct tree_opt_pass pass_lower_subreg;
358 extern struct tree_opt_pass pass_cse;
359 extern struct tree_opt_pass pass_fast_rtl_dce;
360 extern struct tree_opt_pass pass_ud_rtl_dce;
361 extern struct tree_opt_pass pass_rtl_dce;
362 extern struct tree_opt_pass pass_rtl_dse1;
363 extern struct tree_opt_pass pass_rtl_dse2;
364 extern struct tree_opt_pass pass_rtl_dse3;
365 extern struct tree_opt_pass pass_gcse;
366 extern struct tree_opt_pass pass_jump_bypass;
367 extern struct tree_opt_pass pass_profiling;
368 extern struct tree_opt_pass pass_rtl_ifcvt;
369 extern struct tree_opt_pass pass_tracer;
371 extern struct tree_opt_pass pass_into_cfg_layout_mode;
372 extern struct tree_opt_pass pass_outof_cfg_layout_mode;
374 extern struct tree_opt_pass pass_loop2;
375 extern struct tree_opt_pass pass_rtl_loop_init;
376 extern struct tree_opt_pass pass_rtl_move_loop_invariants;
377 extern struct tree_opt_pass pass_rtl_unswitch;
378 extern struct tree_opt_pass pass_rtl_unroll_and_peel_loops;
379 extern struct tree_opt_pass pass_rtl_doloop;
380 extern struct tree_opt_pass pass_rtl_loop_done;
382 extern struct tree_opt_pass pass_web;
383 extern struct tree_opt_pass pass_cse2;
384 extern struct tree_opt_pass pass_df_initialize_opt;
385 extern struct tree_opt_pass pass_df_initialize_no_opt;
386 extern struct tree_opt_pass pass_regclass_init;
387 extern struct tree_opt_pass pass_subregs_of_mode_init;
388 extern struct tree_opt_pass pass_subregs_of_mode_finish;
389 extern struct tree_opt_pass pass_inc_dec;
390 extern struct tree_opt_pass pass_stack_ptr_mod;
391 extern struct tree_opt_pass pass_initialize_regs;
392 extern struct tree_opt_pass pass_combine;
393 extern struct tree_opt_pass pass_if_after_combine;
394 extern struct tree_opt_pass pass_partition_blocks;
395 extern struct tree_opt_pass pass_match_asm_constraints;
396 extern struct tree_opt_pass pass_regmove;
397 extern struct tree_opt_pass pass_split_all_insns;
398 extern struct tree_opt_pass pass_lower_subreg2;
399 extern struct tree_opt_pass pass_mode_switching;
400 extern struct tree_opt_pass pass_see;
401 extern struct tree_opt_pass pass_sms;
402 extern struct tree_opt_pass pass_sched;
403 extern struct tree_opt_pass pass_local_alloc;
404 extern struct tree_opt_pass pass_global_alloc;
405 extern struct tree_opt_pass pass_ira;
406 extern struct tree_opt_pass pass_postreload;
407 extern struct tree_opt_pass pass_clean_state;
408 extern struct tree_opt_pass pass_branch_prob;
409 extern struct tree_opt_pass pass_value_profile_transformations;
410 extern struct tree_opt_pass pass_postreload_cse;
411 extern struct tree_opt_pass pass_gcse2;
412 extern struct tree_opt_pass pass_split_after_reload;
413 extern struct tree_opt_pass pass_branch_target_load_optimize1;
414 extern struct tree_opt_pass pass_thread_prologue_and_epilogue;
415 extern struct tree_opt_pass pass_stack_adjustments;
416 extern struct tree_opt_pass pass_peephole2;
417 extern struct tree_opt_pass pass_if_after_reload;
418 extern struct tree_opt_pass pass_regrename;
419 extern struct tree_opt_pass pass_cprop_hardreg;
420 extern struct tree_opt_pass pass_reorder_blocks;
421 extern struct tree_opt_pass pass_branch_target_load_optimize2;
422 extern struct tree_opt_pass pass_leaf_regs;
423 extern struct tree_opt_pass pass_split_before_sched2;
424 extern struct tree_opt_pass pass_sched2;
425 extern struct tree_opt_pass pass_stack_regs;
426 extern struct tree_opt_pass pass_stack_regs_run;
427 extern struct tree_opt_pass pass_df_finish;
428 extern struct tree_opt_pass pass_compute_alignments;
429 extern struct tree_opt_pass pass_duplicate_computed_gotos;
430 extern struct tree_opt_pass pass_variable_tracking;
431 extern struct tree_opt_pass pass_free_cfg;
432 extern struct tree_opt_pass pass_machine_reorg;
433 extern struct tree_opt_pass pass_cleanup_barriers;
434 extern struct tree_opt_pass pass_delay_slots;
435 extern struct tree_opt_pass pass_split_for_shorten_branches;
436 extern struct tree_opt_pass pass_split_before_regstack;
437 extern struct tree_opt_pass pass_convert_to_eh_region_ranges;
438 extern struct tree_opt_pass pass_shorten_branches;
439 extern struct tree_opt_pass pass_set_nothrow_function_flags;
440 extern struct tree_opt_pass pass_final;
441 extern struct tree_opt_pass pass_rtl_seqabstr;
442 extern struct tree_opt_pass pass_release_ssa_names;
443 extern struct tree_opt_pass pass_early_inline;
444 extern struct tree_opt_pass pass_inline_parameters;
445 extern struct tree_opt_pass pass_apply_inline;
446 extern struct tree_opt_pass pass_all_early_optimizations;
448 /* The root of the compilation pass tree, once constructed. */
449 extern struct tree_opt_pass *all_passes, *all_ipa_passes, *all_lowering_passes;
451 extern void execute_pass_list (struct tree_opt_pass *);
452 extern void execute_ipa_pass_list (struct tree_opt_pass *);
453 extern void print_current_pass (FILE *);
454 extern void debug_pass (void);
456 /* Set to true if the pass is called the first time during compilation of the
457 current function. Note that using this information in the optimization
458 passes is considered not to be clean, and it should be avoided if possible.
459 This flag is currently used to prevent loops from being peeled repeatedly
460 in jump threading; it will be removed once we preserve loop structures
461 throughout the compilation -- we will be able to mark the affected loops
462 directly in jump threading, and avoid peeling them next time. */
463 extern bool first_pass_instance;
465 #endif /* GCC_TREE_PASS_H */