1 /* Data and Control Flow Analysis for Trees.
2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@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)
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 #define _TREE_FLOW_H 1
26 #include "basic-block.h"
29 #include "tree-ssa-operands.h"
31 #include "ipa-reference.h"
32 #include "tree-ssa-alias.h"
33 #include "tree-cfgcleanup.h"
35 #include "tree-pretty-print.h"
36 #include "gimple-low.h"
37 #include "tree-into-ssa.h"
39 /* This structure is used to map a gimple statement to a label,
40 or list of labels to represent transaction restart. */
42 struct GTY(()) tm_restart_node
{
47 /* Gimple dataflow datastructure. All publicly available fields shall have
48 gimple_ accessor defined in tree-flow-inline.h, all publicly modifiable
49 fields should have gimple_set accessor. */
50 struct GTY(()) gimple_df
{
51 /* A vector of all the noreturn calls passed to modify_stmt.
52 cleanup_control_flow uses it to detect cases where a mid-block
53 indirect call has been turned into a noreturn call. When this
54 happens, all the instructions after the call are no longer
55 reachable and must be deleted as dead. */
56 vec
<gimple
, va_gc
> *modified_noreturn_calls
;
58 /* Array of all SSA_NAMEs used in the function. */
59 vec
<tree
, va_gc
> *ssa_names
;
61 /* Artificial variable used for the virtual operand FUD chain. */
64 /* The PTA solution for the ESCAPED artificial variable. */
65 struct pt_solution escaped
;
67 /* A map of decls to artificial ssa-names that point to the partition
69 struct pointer_map_t
* GTY((skip(""))) decls_to_pointers
;
71 /* Free list of SSA_NAMEs. */
72 vec
<tree
, va_gc
> *free_ssanames
;
74 /* Hashtable holding definition for symbol. If this field is not NULL, it
75 means that the first reference to this variable in the function is a
76 USE or a VUSE. In those cases, the SSA renamer creates an SSA name
77 for this variable with an empty defining statement. */
78 htab_t
GTY((param_is (union tree_node
))) default_defs
;
80 /* True if there are any symbols that need to be renamed. */
81 unsigned int ssa_renaming_needed
: 1;
83 /* True if all virtual operands need to be renamed. */
84 unsigned int rename_vops
: 1;
86 /* True if the code is in ssa form. */
87 unsigned int in_ssa_p
: 1;
89 /* True if IPA points-to information was computed for this function. */
90 unsigned int ipa_pta
: 1;
92 struct ssa_operands ssa_operands
;
94 /* Map gimple stmt to tree label (or list of labels) for transaction
96 htab_t
GTY ((param_is (struct tm_restart_node
))) tm_restart
;
99 static inline int get_lineno (const_gimple
);
101 /*---------------------------------------------------------------------------
103 ---------------------------------------------------------------------------*/
104 struct int_tree_map
{
109 /* Macros for showing usage statistics. */
110 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
112 : ((x) < 1024*1024*10 \
114 : (x) / (1024*1024))))
116 #define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
118 #define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y))
120 /*---------------------------------------------------------------------------
122 ---------------------------------------------------------------------------*/
124 /* Parallel region information. Every parallel and workshare
125 directive is enclosed between two markers, the OMP_* directive
126 and a corresponding OMP_RETURN statement. */
130 /* The enclosing region. */
131 struct omp_region
*outer
;
133 /* First child region. */
134 struct omp_region
*inner
;
136 /* Next peer region. */
137 struct omp_region
*next
;
139 /* Block containing the omp directive as its last stmt. */
142 /* Block containing the OMP_RETURN as its last stmt. */
145 /* Block containing the OMP_CONTINUE as its last stmt. */
148 /* If this is a combined parallel+workshare region, this is a list
149 of additional arguments needed by the combined parallel+workshare
151 vec
<tree
, va_gc
> *ws_args
;
153 /* The code for the omp directive of this region. */
154 enum gimple_code type
;
156 /* Schedule kind, only used for OMP_FOR type regions. */
157 enum omp_clause_schedule_kind sched_kind
;
159 /* True if this is a combined parallel+workshare region. */
160 bool is_combined_parallel
;
163 extern struct omp_region
*root_omp_region
;
164 extern struct omp_region
*new_omp_region (basic_block
, enum gimple_code
,
165 struct omp_region
*);
166 extern void free_omp_regions (void);
167 void omp_expand_local (basic_block
);
168 tree
copy_var_decl (tree
, tree
, tree
);
170 /*---------------------------------------------------------------------------
172 ---------------------------------------------------------------------------*/
175 /* Location to track pending stmt for edge insertion. */
176 #define PENDING_STMT(e) ((e)->insns.g)
178 extern void delete_tree_cfg_annotations (void);
179 extern bool stmt_ends_bb_p (gimple
);
180 extern bool is_ctrl_stmt (gimple
);
181 extern bool is_ctrl_altering_stmt (gimple
);
182 extern bool simple_goto_p (gimple
);
183 extern bool stmt_can_make_abnormal_goto (gimple
);
184 extern basic_block
single_noncomplex_succ (basic_block bb
);
185 extern void gimple_dump_bb (FILE *, basic_block
, int, int);
186 extern void gimple_debug_bb (basic_block
);
187 extern basic_block
gimple_debug_bb_n (int);
188 extern void gimple_dump_cfg (FILE *, int);
189 extern void gimple_debug_cfg (int);
190 extern void dump_cfg_stats (FILE *);
191 extern void dot_cfg (void);
192 extern void debug_cfg_stats (void);
193 extern void debug_loops (int);
194 extern void debug_loop (struct loop
*, int);
195 extern void debug (struct loop
&ref
);
196 extern void debug (struct loop
*ptr
);
197 extern void debug_verbose (struct loop
&ref
);
198 extern void debug_verbose (struct loop
*ptr
);
199 extern void debug_loop_num (unsigned, int);
200 extern void print_loops (FILE *, int);
201 extern void print_loops_bb (FILE *, basic_block
, int, int);
202 extern void cleanup_dead_labels (void);
203 extern void group_case_labels_stmt (gimple
);
204 extern void group_case_labels (void);
205 extern gimple
first_stmt (basic_block
);
206 extern gimple
last_stmt (basic_block
);
207 extern gimple
last_and_only_stmt (basic_block
);
208 extern edge
find_taken_edge (basic_block
, tree
);
209 extern basic_block
label_to_block_fn (struct function
*, tree
);
210 #define label_to_block(t) (label_to_block_fn (cfun, t))
211 extern void notice_special_calls (gimple
);
212 extern void clear_special_calls (void);
213 extern void verify_gimple_in_seq (gimple_seq
);
214 extern void verify_gimple_in_cfg (struct function
*);
215 extern tree
gimple_block_label (basic_block
);
216 extern void extract_true_false_edges_from_block (basic_block
, edge
*, edge
*);
217 extern bool gimple_duplicate_sese_region (edge
, edge
, basic_block
*, unsigned,
218 basic_block
*, bool);
219 extern bool gimple_duplicate_sese_tail (edge
, edge
, basic_block
*, unsigned,
221 extern void gather_blocks_in_sese_region (basic_block entry
, basic_block exit
,
222 vec
<basic_block
> *bbs_p
);
223 extern void add_phi_args_after_copy_bb (basic_block
);
224 extern void add_phi_args_after_copy (basic_block
*, unsigned, edge
);
225 extern bool gimple_purge_dead_eh_edges (basic_block
);
226 extern bool gimple_purge_all_dead_eh_edges (const_bitmap
);
227 extern bool gimple_purge_dead_abnormal_call_edges (basic_block
);
228 extern bool gimple_purge_all_dead_abnormal_call_edges (const_bitmap
);
229 extern tree
gimplify_build1 (gimple_stmt_iterator
*, enum tree_code
,
231 extern tree
gimplify_build2 (gimple_stmt_iterator
*, enum tree_code
,
233 extern tree
gimplify_build3 (gimple_stmt_iterator
*, enum tree_code
,
234 tree
, tree
, tree
, tree
);
235 extern void init_empty_tree_cfg (void);
236 extern void init_empty_tree_cfg_for_function (struct function
*);
237 extern void fold_cond_expr_cond (void);
238 extern void make_abnormal_goto_edges (basic_block
, bool);
239 extern void replace_uses_by (tree
, tree
);
240 extern void start_recording_case_labels (void);
241 extern void end_recording_case_labels (void);
242 extern basic_block
move_sese_region_to_fn (struct function
*, basic_block
,
244 void remove_edge_and_dominated_blocks (edge
);
245 bool tree_node_can_be_shared (tree
);
247 /* In tree-ssa-loop-ch.c */
248 bool do_while_loop_p (struct loop
*);
254 /* Iv = BASE + STEP * i. */
257 /* True if this iv does not overflow. */
261 /* Description of number of iterations of a loop. All the expressions inside
262 the structure can be evaluated at the end of the loop's preheader
263 (and due to ssa form, also anywhere inside the body of the loop). */
265 struct tree_niter_desc
267 tree assumptions
; /* The boolean expression. If this expression evaluates
268 to false, then the other fields in this structure
269 should not be used; there is no guarantee that they
271 tree may_be_zero
; /* The boolean expression. If it evaluates to true,
272 the loop will exit in the first iteration (i.e.
273 its latch will not be executed), even if the niter
274 field says otherwise. */
275 tree niter
; /* The expression giving the number of iterations of
276 a loop (provided that assumptions == true and
277 may_be_zero == false), more precisely the number
278 of executions of the latch of the loop. */
279 double_int max
; /* The upper bound on the number of iterations of
282 /* The simplified shape of the exit condition. The loop exits if
283 CONTROL CMP BOUND is false, where CMP is one of NE_EXPR,
284 LT_EXPR, or GT_EXPR, and step of CONTROL is positive if CMP is
285 LE_EXPR and negative if CMP is GE_EXPR. This information is used
286 by loop unrolling. */
293 /* In tree-ssa-loop*.c */
295 unsigned int tree_ssa_lim (void);
296 unsigned int tree_ssa_unswitch_loops (void);
297 unsigned int canonicalize_induction_variables (void);
298 unsigned int tree_unroll_loops_completely (bool, bool);
299 unsigned int tree_ssa_prefetch_arrays (void);
300 void tree_ssa_iv_optimize (void);
301 unsigned tree_predictive_commoning (void);
302 tree
canonicalize_loop_ivs (struct loop
*, tree
*, bool);
303 bool parallelize_loops (void);
305 bool loop_only_exit_p (const struct loop
*, const_edge
);
306 bool number_of_iterations_exit (struct loop
*, edge
,
307 struct tree_niter_desc
*niter
, bool,
308 bool every_iteration
= true);
309 tree
find_loop_niter (struct loop
*, edge
*);
310 tree
loop_niter_by_eval (struct loop
*, edge
);
311 tree
find_loop_niter_by_eval (struct loop
*, edge
*);
312 void estimate_numbers_of_iterations (void);
313 bool scev_probably_wraps_p (tree
, tree
, gimple
, struct loop
*, bool);
314 bool convert_affine_scev (struct loop
*, tree
, tree
*, tree
*, gimple
, bool);
316 bool nowrap_type_p (tree
);
317 enum ev_direction
{EV_DIR_GROWS
, EV_DIR_DECREASES
, EV_DIR_UNKNOWN
};
318 enum ev_direction
scev_direction (const_tree
);
320 void free_numbers_of_iterations_estimates (void);
321 void free_numbers_of_iterations_estimates_loop (struct loop
*);
322 void rewrite_into_loop_closed_ssa (bitmap
, unsigned);
323 void verify_loop_closed_ssa (bool);
324 bool for_each_index (tree
*, bool (*) (tree
, tree
*, void *), void *);
325 void create_iv (tree
, tree
, tree
, struct loop
*, gimple_stmt_iterator
*, bool,
327 basic_block
split_loop_exit_edge (edge
);
328 void standard_iv_increment_position (struct loop
*, gimple_stmt_iterator
*,
330 basic_block
ip_end_pos (struct loop
*);
331 basic_block
ip_normal_pos (struct loop
*);
332 bool gimple_duplicate_loop_to_header_edge (struct loop
*, edge
,
333 unsigned int, sbitmap
,
336 struct loop
*slpeel_tree_duplicate_loop_to_edge_cfg (struct loop
*, edge
);
337 tree
expand_simple_operations (tree
);
338 void substitute_in_loop_info (struct loop
*, tree
, tree
);
339 edge
single_dom_exit (struct loop
*);
340 bool can_unroll_loop_p (struct loop
*loop
, unsigned factor
,
341 struct tree_niter_desc
*niter
);
342 void tree_unroll_loop (struct loop
*, unsigned,
343 edge
, struct tree_niter_desc
*);
344 typedef void (*transform_callback
)(struct loop
*, void *);
345 void tree_transform_and_unroll_loop (struct loop
*, unsigned,
346 edge
, struct tree_niter_desc
*,
347 transform_callback
, void *);
348 bool contains_abnormal_ssa_name_p (tree
);
349 bool stmt_dominates_stmt_p (gimple
, gimple
);
351 /* In tree-ssa-threadedge.c */
352 extern void threadedge_initialize_values (void);
353 extern void threadedge_finalize_values (void);
354 extern vec
<tree
> ssa_name_values
;
355 #define SSA_NAME_VALUE(x) \
356 (SSA_NAME_VERSION (x) < ssa_name_values.length () \
357 ? ssa_name_values[SSA_NAME_VERSION (x)] \
359 extern void set_ssa_name_value (tree
, tree
);
360 extern bool potentially_threadable_block (basic_block
);
361 extern void thread_across_edge (gimple
, edge
, bool,
362 vec
<tree
> *, tree (*) (gimple
, gimple
));
363 extern void propagate_threaded_block_debug_into (basic_block
, basic_block
);
365 /* In tree-ssa-loop-im.c */
366 /* The possibilities of statement movement. */
370 MOVE_IMPOSSIBLE
, /* No movement -- side effect expression. */
371 MOVE_PRESERVE_EXECUTION
, /* Must not cause the non-executed statement
372 become executed -- memory accesses, ... */
373 MOVE_POSSIBLE
/* Unlimited movement. */
375 extern enum move_pos
movement_possibility (gimple
);
376 char *get_lsm_tmp_name (tree
, unsigned);
378 /* In tree-flow-inline.h */
379 static inline bool unmodifiable_var_p (const_tree
);
380 static inline bool ref_contains_array_ref (const_tree
);
383 extern void make_eh_edges (gimple
);
384 extern bool make_eh_dispatch_edges (gimple
);
385 extern edge
redirect_eh_edge (edge
, basic_block
);
386 extern void redirect_eh_dispatch_edge (gimple
, edge
, basic_block
);
387 extern bool stmt_could_throw_p (gimple
);
388 extern bool stmt_can_throw_internal (gimple
);
389 extern bool stmt_can_throw_external (gimple
);
390 extern void add_stmt_to_eh_lp_fn (struct function
*, gimple
, int);
391 extern void add_stmt_to_eh_lp (gimple
, int);
392 extern bool remove_stmt_from_eh_lp (gimple
);
393 extern bool remove_stmt_from_eh_lp_fn (struct function
*, gimple
);
394 extern int lookup_stmt_eh_lp_fn (struct function
*, gimple
);
395 extern int lookup_stmt_eh_lp (gimple
);
396 extern bool maybe_clean_eh_stmt_fn (struct function
*, gimple
);
397 extern bool maybe_clean_eh_stmt (gimple
);
398 extern bool maybe_clean_or_replace_eh_stmt (gimple
, gimple
);
399 extern bool maybe_duplicate_eh_stmt_fn (struct function
*, gimple
,
400 struct function
*, gimple
,
401 struct pointer_map_t
*, int);
402 extern bool maybe_duplicate_eh_stmt (gimple
, gimple
);
403 extern bool verify_eh_edges (gimple
);
404 extern bool verify_eh_dispatch_edge (gimple
);
405 extern void maybe_remove_unreachable_handlers (void);
407 /* In tree-ssa-pre.c */
408 void debug_value_expressions (unsigned int);
410 /* In tree-loop-linear.c */
411 extern void linear_transform_loops (void);
412 extern unsigned perfect_loop_nest_depth (struct loop
*);
415 extern void graphite_transform_loops (void);
417 /* In tree-data-ref.c */
418 extern void tree_check_data_deps (void);
420 /* In tree-ssa-loop-ivopts.c */
421 bool expr_invariant_in_loop_p (struct loop
*, tree
);
422 bool stmt_invariant_in_loop_p (struct loop
*, gimple
);
423 struct loop
*outermost_invariant_loop_for_expr (struct loop
*, tree
);
424 bool multiplier_allowed_in_address_p (HOST_WIDE_INT
, enum machine_mode
,
426 bool may_be_nonaddressable_p (tree expr
);
429 tree
force_gimple_operand_1 (tree
, gimple_seq
*, gimple_predicate
, tree
);
430 tree
force_gimple_operand (tree
, gimple_seq
*, bool, tree
);
431 tree
force_gimple_operand_gsi_1 (gimple_stmt_iterator
*, tree
,
432 gimple_predicate
, tree
,
433 bool, enum gsi_iterator_update
);
434 tree
force_gimple_operand_gsi (gimple_stmt_iterator
*, tree
, bool, tree
,
435 bool, enum gsi_iterator_update
);
436 tree
gimple_fold_indirect_ref (tree
);
438 /* In tree-ssa-live.c */
439 extern void remove_unused_locals (void);
440 extern void dump_scope_blocks (FILE *, int);
441 extern void debug_scope_blocks (int);
442 extern void debug_scope_block (tree
, int);
444 /* In tree-ssa-address.c */
446 /* Description of a memory address. */
450 tree symbol
, base
, index
, step
, offset
;
453 struct affine_tree_combination
;
454 tree
create_mem_ref (gimple_stmt_iterator
*, tree
,
455 struct affine_tree_combination
*, tree
, tree
, tree
, bool);
456 rtx
addr_for_mem_ref (struct mem_address
*, addr_space_t
, bool);
457 void get_address_description (tree
, struct mem_address
*);
458 tree
maybe_fold_tmr (tree
);
460 unsigned int execute_fixup_cfg (void);
462 /* In ipa-pure-const.c */
463 void warn_function_noreturn (tree
);
465 /* In tree-parloops.c */
466 bool parallelized_function_p (tree
);
468 #include "tree-flow-inline.h"
470 #endif /* _TREE_FLOW_H */