OSDN Git Service

Give credit, where credit is due.
[pf3gnuchains/gcc-fork.git] / gcc / tree-pass.h
1 /* Definitions for describing one tree-ssa optimization pass.
2    Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3    Contributed by Richard Henderson <rth@redhat.com>
4
5 This file is part of GCC.
6
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 2, or (at your option)
10 any later version.
11
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.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22
23 #ifndef GCC_TREE_PASS_H
24 #define GCC_TREE_PASS_H 1
25
26 /* Global variables used to communicate with passes.  */
27 extern FILE *dump_file;
28 extern int dump_flags;
29 extern const char *dump_file_name;
30
31 /* Return the dump_file_info for the given phase.  */
32 extern struct dump_file_info *get_dump_file_info (enum tree_dump_index);
33
34 /* Describe one pass.  */
35 struct tree_opt_pass
36 {
37   /* Terse name of the pass used as a fragment of the dump file name.  */
38   const char *name;
39
40   /* If non-null, this pass and all sub-passes are executed only if
41      the function returns true.  */
42   bool (*gate) (void);
43
44   /* This is the code to run.  If null, then there should be sub-passes
45      otherwise this pass does nothing.  */
46   void (*execute) (void);
47
48   /* A list of sub-passes to run, dependent on gate predicate.  */
49   struct tree_opt_pass *sub;
50
51   /* Next in the list of passes to run, independent of gate predicate.  */
52   struct tree_opt_pass *next;
53
54   /* Static pass number, used as a fragment of the dump file name.  */
55   int static_pass_number;
56
57   /* The timevar id associated with this pass.  */
58   /* ??? Ideally would be dynamically assigned.  */
59   unsigned int tv_id;
60
61   /* Sets of properties input and output from this pass.  */
62   unsigned int properties_required;
63   unsigned int properties_provided;
64   unsigned int properties_destroyed;
65
66   /* Flags indicating common sets things to do before and after.  */
67   unsigned int todo_flags_start;
68   unsigned int todo_flags_finish;
69
70   /* Letter for RTL dumps.  */
71   char letter;
72 };
73
74 /* Define a tree dump switch.  */
75 struct dump_file_info
76 {
77   const char *suffix;           /* suffix to give output file.  */
78   const char *swtch;            /* command line switch */
79   const char *glob;             /* command line glob  */
80   int flags;                    /* user flags */
81   int state;                    /* state of play */
82   int num;                      /* dump file number */
83   int letter;                   /* enabling letter for RTL dumps */
84 };
85
86 /* Pass properties.  */
87 #define PROP_gimple_any         (1 << 0)        /* entire gimple grammar */
88 #define PROP_gimple_lcf         (1 << 1)        /* lowered control flow */
89 #define PROP_gimple_leh         (1 << 2)        /* lowered eh */
90 #define PROP_cfg                (1 << 3)
91 #define PROP_referenced_vars    (1 << 4)
92 #define PROP_pta                (1 << 5)
93 #define PROP_ssa                (1 << 6)
94 #define PROP_no_crit_edges      (1 << 7)
95 #define PROP_rtl                (1 << 8)
96 #define PROP_alias              (1 << 9)
97
98 #define PROP_trees \
99   (PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh)
100
101 /* To-do flags.  */
102 #define TODO_dump_func                  (1 << 0)
103 #define TODO_ggc_collect                (1 << 1)
104 #define TODO_verify_ssa                 (1 << 2) 
105 #define TODO_verify_flow                (1 << 3)
106 #define TODO_verify_stmts               (1 << 4)
107 #define TODO_cleanup_cfg                (1 << 5)
108 #define TODO_verify_loops               (1 << 6)
109 #define TODO_dump_cgraph                (1 << 7)
110
111 /* To-do flags for calls to update_ssa.  */
112
113 /* Update the SSA form inserting PHI nodes for newly exposed symbols
114    and virtual names marked for updating.  When updating real names,
115    only insert PHI nodes for a real name O_j in blocks reached by all
116    the new and old definitions for O_j.  If the iterated dominance
117    frontier for O_j is not pruned, we may end up inserting PHI nodes
118    in blocks that have one or more edges with no incoming definition
119    for O_j.  This would lead to uninitialized warnings for O_j's
120    symbol.  */
121 #define TODO_update_ssa                 (1 << 7)
122
123 /* Update the SSA form without inserting any new PHI nodes at all.
124    This is used by passes that have either inserted all the PHI nodes
125    themselves or passes that need only to patch use-def and def-def
126    chains for virtuals (e.g., DCE).  */
127 #define TODO_update_ssa_no_phi          (1 << 8)
128
129 /* Insert PHI nodes everywhere they are needed.  No prunning of the
130    IDF is done.  This is used by passes that need the PHI nodes for
131    O_j even if it means that some arguments will come from the default
132    definition of O_j's symbol (e.g., pass_linear_transform).
133    
134    WARNING: If you need to use this flag, chances are that your pass
135    may be doing something wrong.  Inserting PHI nodes for an old name
136    where not all edges carry a new replacement may lead to silent
137    codegen errors or spurious uninitialized warnings.  */
138 #define TODO_update_ssa_full_phi        (1 << 9)
139
140 /* Passes that update the SSA form on their own may want to delegate
141    the updating of virtual names to the generic updater.  Since FUD
142    chains are easier to maintain, this simplifies the work they need
143    to do.  NOTE: If this flag is used, any OLD->NEW mappings for real
144    names are explicitly destroyed and only the symbols marked for
145    renaming are processed.  */
146 #define TODO_update_ssa_only_virtuals   (1 << 10)
147
148 #define TODO_update_ssa_any             \
149     (TODO_update_ssa                    \
150      | TODO_update_ssa_no_phi           \
151      | TODO_update_ssa_full_phi         \
152      | TODO_update_ssa_only_virtuals)
153
154 #define TODO_verify_all \
155   (TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts)
156
157 extern void ipa_passes (void);
158 extern void tree_lowering_passes (tree decl);
159
160 extern struct tree_opt_pass pass_mudflap_1;
161 extern struct tree_opt_pass pass_mudflap_2;
162 extern struct tree_opt_pass pass_remove_useless_stmts;
163 extern struct tree_opt_pass pass_lower_cf;
164 extern struct tree_opt_pass pass_lower_eh;
165 extern struct tree_opt_pass pass_build_cfg;
166 extern struct tree_opt_pass pass_tree_profile;
167 extern struct tree_opt_pass pass_referenced_vars;
168 extern struct tree_opt_pass pass_sra;
169 extern struct tree_opt_pass pass_tail_recursion;
170 extern struct tree_opt_pass pass_tail_calls;
171 extern struct tree_opt_pass pass_loop;
172 extern struct tree_opt_pass pass_loop_init;
173 extern struct tree_opt_pass pass_lim;
174 extern struct tree_opt_pass pass_unswitch;
175 extern struct tree_opt_pass pass_iv_canon;
176 extern struct tree_opt_pass pass_scev_cprop;
177 extern struct tree_opt_pass pass_record_bounds;
178 extern struct tree_opt_pass pass_if_conversion;
179 extern struct tree_opt_pass pass_vectorize;
180 extern struct tree_opt_pass pass_complete_unroll;
181 extern struct tree_opt_pass pass_iv_optimize;
182 extern struct tree_opt_pass pass_loop_done;
183 extern struct tree_opt_pass pass_ch;
184 extern struct tree_opt_pass pass_ccp;
185 extern struct tree_opt_pass pass_build_ssa;
186 extern struct tree_opt_pass pass_del_ssa;
187 extern struct tree_opt_pass pass_dominator;
188 extern struct tree_opt_pass pass_dce;
189 extern struct tree_opt_pass pass_cd_dce;
190 extern struct tree_opt_pass pass_merge_phi;
191 extern struct tree_opt_pass pass_may_alias;
192 extern struct tree_opt_pass pass_split_crit_edges;
193 extern struct tree_opt_pass pass_pre;
194 extern struct tree_opt_pass pass_profile;
195 extern struct tree_opt_pass pass_pre_expand;
196 extern struct tree_opt_pass pass_lower_vector_ssa;
197 extern struct tree_opt_pass pass_fold_builtins;
198 extern struct tree_opt_pass pass_stdarg;
199 extern struct tree_opt_pass pass_early_warn_uninitialized;
200 extern struct tree_opt_pass pass_late_warn_uninitialized;
201 extern struct tree_opt_pass pass_cse_reciprocals;
202 extern struct tree_opt_pass pass_warn_function_return;
203 extern struct tree_opt_pass pass_warn_function_noreturn;
204 extern struct tree_opt_pass pass_phiopt;
205 extern struct tree_opt_pass pass_forwprop;
206 extern struct tree_opt_pass pass_redundant_phi;
207 extern struct tree_opt_pass pass_dse;
208 extern struct tree_opt_pass pass_nrv;
209 extern struct tree_opt_pass pass_remove_useless_vars;
210 extern struct tree_opt_pass pass_mark_used_blocks;
211 extern struct tree_opt_pass pass_rename_ssa_copies;
212 extern struct tree_opt_pass pass_expand;
213 extern struct tree_opt_pass pass_rest_of_compilation;
214 extern struct tree_opt_pass pass_sink_code;
215 extern struct tree_opt_pass pass_fre;
216 extern struct tree_opt_pass pass_linear_transform;
217 extern struct tree_opt_pass pass_copy_prop;
218 extern struct tree_opt_pass pass_store_ccp;
219 extern struct tree_opt_pass pass_store_copy_prop;
220 extern struct tree_opt_pass pass_vrp;
221 extern struct tree_opt_pass pass_create_structure_vars;
222 extern struct tree_opt_pass pass_uncprop;
223
224 extern struct tree_opt_pass pass_ipa_inline;
225
226 #endif /* GCC_TREE_PASS_H */