* Make-lang.in (cp/pt.o): Depend on vecprim.h.
[official-gcc.git] / gcc / tree-flow.h
blobcdf38af822f75c7848439af66a4b29ed379db7bc
1 /* Data and Control Flow Analysis for Trees.
2 Copyright (C) 2001, 2003, 2004, 2005 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 2, 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 COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 #ifndef _TREE_FLOW_H
23 #define _TREE_FLOW_H 1
25 #include "bitmap.h"
26 #include "hard-reg-set.h"
27 #include "basic-block.h"
28 #include "hashtab.h"
29 #include "tree-gimple.h"
30 #include "tree-ssa-operands.h"
31 #include "cgraph.h"
32 #include "ipa-reference.h"
34 /* Forward declare structures for the garbage collector GTY markers. */
35 #ifndef GCC_BASIC_BLOCK_H
36 struct edge_def;
37 typedef struct edge_def *edge;
38 struct basic_block_def;
39 typedef struct basic_block_def *basic_block;
40 #endif
42 /* True if the code is in ssa form. */
43 extern bool in_ssa_p;
45 typedef struct
47 htab_t htab;
48 PTR *slot;
49 PTR *limit;
50 } htab_iterator;
52 /* Iterate through the elements of hashtable HTAB, using htab_iterator ITER,
53 storing each element in RESULT, which is of type TYPE. */
54 #define FOR_EACH_HTAB_ELEMENT(HTAB, RESULT, TYPE, ITER) \
55 for (RESULT = (TYPE) first_htab_element (&(ITER), (HTAB)); \
56 !end_htab_p (&(ITER)); \
57 RESULT = (TYPE) next_htab_element (&(ITER)))
59 /*---------------------------------------------------------------------------
60 Attributes for SSA_NAMEs.
62 NOTE: These structures are stored in struct tree_ssa_name
63 but are only used by the tree optimizers, so it makes better sense
64 to declare them here to avoid recompiling unrelated files when
65 making changes.
66 ---------------------------------------------------------------------------*/
68 /* Aliasing information for SSA_NAMEs representing pointer variables. */
69 struct ptr_info_def GTY(())
71 /* Nonzero if points-to analysis couldn't determine where this pointer
72 is pointing to. */
73 unsigned int pt_anything : 1;
75 /* Nonzero if the value of this pointer escapes the current function. */
76 unsigned int value_escapes_p : 1;
78 /* Nonzero if this pointer is dereferenced. */
79 unsigned int is_dereferenced : 1;
81 /* Nonzero if this pointer points to a global variable. */
82 unsigned int pt_global_mem : 1;
84 /* Nonzero if this pointer points to NULL. */
85 unsigned int pt_null : 1;
87 /* Set of variables that this pointer may point to. */
88 bitmap pt_vars;
90 /* If this pointer has been dereferenced, and points-to information is
91 more precise than type-based aliasing, indirect references to this
92 pointer will be represented by this memory tag, instead of the type
93 tag computed by TBAA. */
94 tree name_mem_tag;
96 /* Mask of reasons this pointer's value escapes the function */
97 unsigned int escape_mask;
101 /*---------------------------------------------------------------------------
102 Tree annotations stored in tree_common.ann
103 ---------------------------------------------------------------------------*/
104 enum tree_ann_type { TREE_ANN_COMMON, VAR_ANN, FUNCTION_ANN, STMT_ANN };
106 struct tree_ann_common_d GTY(())
108 /* Annotation type. */
109 enum tree_ann_type type;
111 /* Auxiliary info specific to a pass. At all times, this
112 should either point to valid data or be NULL. */
113 PTR GTY ((skip (""))) aux;
115 /* The value handle for this expression. Used by GVN-PRE. */
116 tree GTY((skip)) value_handle;
119 /* It is advantageous to avoid things like life analysis for variables which
120 do not need PHI nodes. This enum describes whether or not a particular
121 variable may need a PHI node. */
123 enum need_phi_state {
124 /* This is the default. If we are still in this state after finding
125 all the definition and use sites, then we will assume the variable
126 needs PHI nodes. This is probably an overly conservative assumption. */
127 NEED_PHI_STATE_UNKNOWN,
129 /* This state indicates that we have seen one or more sets of the
130 variable in a single basic block and that the sets dominate all
131 uses seen so far. If after finding all definition and use sites
132 we are still in this state, then the variable does not need any
133 PHI nodes. */
134 NEED_PHI_STATE_NO,
136 /* This state indicates that we have either seen multiple definitions of
137 the variable in multiple blocks, or that we encountered a use in a
138 block that was not dominated by the block containing the set(s) of
139 this variable. This variable is assumed to need PHI nodes. */
140 NEED_PHI_STATE_MAYBE
143 struct subvar;
144 typedef struct subvar *subvar_t;
146 /* This structure represents a fake sub-variable for a structure field. */
147 struct subvar GTY(())
149 /* Fake variable. */
150 tree var;
152 /* Next subvar for this structure. */
153 subvar_t next;
156 struct var_ann_d GTY(())
158 struct tree_ann_common_d common;
160 /* Used by the out of SSA pass to determine whether this variable has
161 been seen yet or not. */
162 unsigned out_of_ssa_tag : 1;
164 /* Used when building root_var structures in tree_ssa_live.[ch]. */
165 unsigned root_var_processed : 1;
167 /* Nonzero if this variable is in the alias set of another variable. */
168 unsigned is_aliased : 1;
170 /* Nonzero if this variable was used after SSA optimizations were
171 applied. We set this when translating out of SSA form. */
172 unsigned used : 1;
174 /* This field indicates whether or not the variable may need PHI nodes.
175 See the enum's definition for more detailed information about the
176 states. */
177 ENUM_BITFIELD (need_phi_state) need_phi_state : 2;
179 /* Used during operand processing to determine if this variable is already
180 in the vuse list. */
181 unsigned in_vuse_list : 1;
183 /* Used during operand processing to determine if this variable is already
184 in the v_may_def list. */
185 unsigned in_v_may_def_list : 1;
187 /* An artificial variable representing the memory location pointed-to by
188 all the pointer symbols that flow-insensitive alias analysis
189 (mostly type-based) considers to be aliased. If the variable is
190 not a pointer or if it is never dereferenced, this must be NULL. */
191 tree symbol_mem_tag;
193 /* Variables that may alias this variable. */
194 VEC(tree, gc) *may_aliases;
196 /* Used when going out of SSA form to indicate which partition this
197 variable represents storage for. */
198 unsigned partition;
200 /* Used by the root-var object in tree-ssa-live.[ch]. */
201 unsigned root_index;
203 /* During into-ssa and the dominator optimizer, this field holds the
204 current version of this variable (an SSA_NAME). */
205 tree current_def;
207 /* If this variable is a structure, this fields holds a list of
208 symbols representing each of the fields of the structure. */
209 subvar_t subvars;
211 /* Mask of values saying the reasons why this variable has escaped
212 the function. */
213 unsigned int escape_mask;
216 struct function_ann_d GTY(())
218 struct tree_ann_common_d common;
220 /* Pointer to the structure that contains the sets of global
221 variables modified by function calls. This field is only used
222 for FUNCTION_DECLs. */
223 ipa_reference_vars_info_t GTY ((skip)) reference_vars_info;
226 typedef struct immediate_use_iterator_d
228 ssa_use_operand_t *imm_use;
229 ssa_use_operand_t *end_p;
230 ssa_use_operand_t iter_node;
231 } imm_use_iterator;
234 /* Use this iterator when simply looking at stmts. Adding, deleting or
235 modifying stmts will cause this iterator to malfunction. */
237 #define FOR_EACH_IMM_USE_FAST(DEST, ITER, SSAVAR) \
238 for ((DEST) = first_readonly_imm_use (&(ITER), (SSAVAR)); \
239 !end_readonly_imm_use_p (&(ITER)); \
240 (DEST) = next_readonly_imm_use (&(ITER)))
243 #define FOR_EACH_IMM_USE_SAFE(DEST, ITER, SSAVAR) \
244 for ((DEST) = first_safe_imm_use (&(ITER), (SSAVAR)); \
245 !end_safe_imm_use_p (&(ITER)); \
246 (DEST) = next_safe_imm_use (&(ITER)))
248 #define BREAK_FROM_SAFE_IMM_USE(ITER) \
250 end_safe_imm_use_traverse (&(ITER)); \
251 break; \
254 struct stmt_ann_d GTY(())
256 struct tree_ann_common_d common;
258 /* Nonzero if the statement has been modified (meaning that the operands
259 need to be scanned again). */
260 unsigned modified : 1;
262 /* Nonzero if the statement makes references to volatile storage. */
263 unsigned has_volatile_ops : 1;
265 /* Nonzero if the statement makes a function call that may clobber global
266 and local addressable variables. */
267 unsigned makes_clobbering_call : 1;
269 /* Basic block that contains this statement. */
270 basic_block bb;
272 /* Operand cache for stmt. */
273 struct stmt_operands_d GTY ((skip (""))) operands;
275 /* Set of variables that have had their address taken in the statement. */
276 bitmap addresses_taken;
278 /* Unique identifier for this statement. These ID's are to be created
279 by each pass on an as-needed basis in any order convenient for the
280 pass which needs statement UIDs. */
281 unsigned int uid;
283 /* Linked list of histograms for value-based profiling. This is really a
284 struct histogram_value*. We use void* to avoid having to export that
285 everywhere, and to avoid having to put it in GC memory. */
287 void * GTY ((skip (""))) histograms;
290 union tree_ann_d GTY((desc ("ann_type ((tree_ann_t)&%h)")))
292 struct tree_ann_common_d GTY((tag ("TREE_ANN_COMMON"))) common;
293 struct var_ann_d GTY((tag ("VAR_ANN"))) vdecl;
294 struct function_ann_d GTY((tag ("FUNCTION_ANN"))) fdecl;
295 struct stmt_ann_d GTY((tag ("STMT_ANN"))) stmt;
298 extern GTY(()) VEC(tree,gc) *modified_noreturn_calls;
300 typedef union tree_ann_d *tree_ann_t;
301 typedef struct var_ann_d *var_ann_t;
302 typedef struct function_ann_d *function_ann_t;
303 typedef struct stmt_ann_d *stmt_ann_t;
305 static inline tree_ann_t tree_ann (tree);
306 static inline tree_ann_t get_tree_ann (tree);
307 static inline var_ann_t var_ann (tree);
308 static inline var_ann_t get_var_ann (tree);
309 static inline function_ann_t function_ann (tree);
310 static inline function_ann_t get_function_ann (tree);
311 static inline stmt_ann_t stmt_ann (tree);
312 static inline stmt_ann_t get_stmt_ann (tree);
313 static inline enum tree_ann_type ann_type (tree_ann_t);
314 static inline basic_block bb_for_stmt (tree);
315 extern void set_bb_for_stmt (tree, basic_block);
316 static inline bool noreturn_call_p (tree);
317 static inline void update_stmt (tree);
318 static inline bool stmt_modified_p (tree);
319 static inline VEC(tree, gc) *may_aliases (tree);
320 static inline int get_lineno (tree);
321 static inline const char *get_filename (tree);
322 static inline bool is_exec_stmt (tree);
323 static inline bool is_label_stmt (tree);
324 static inline bitmap addresses_taken (tree);
326 /*---------------------------------------------------------------------------
327 Structure representing predictions in tree level.
328 ---------------------------------------------------------------------------*/
329 struct edge_prediction GTY((chain_next ("%h.ep_next")))
331 struct edge_prediction *ep_next;
332 edge ep_edge;
333 enum br_predictor ep_predictor;
334 int ep_probability;
337 /* Accessors for basic block annotations. */
338 static inline tree phi_nodes (basic_block);
339 static inline void set_phi_nodes (basic_block, tree);
341 /*---------------------------------------------------------------------------
342 Global declarations
343 ---------------------------------------------------------------------------*/
344 struct int_tree_map GTY(())
347 unsigned int uid;
348 tree to;
351 extern unsigned int int_tree_map_hash (const void *);
352 extern int int_tree_map_eq (const void *, const void *);
354 typedef struct
356 htab_iterator hti;
357 } referenced_var_iterator;
360 /* This macro loops over all the referenced vars, one at a time, putting the
361 current var in VAR. Note: You are not allowed to add referenced variables
362 to the hashtable while using this macro. Doing so may cause it to behave
363 erratically. */
365 #define FOR_EACH_REFERENCED_VAR(VAR, ITER) \
366 for ((VAR) = first_referenced_var (&(ITER)); \
367 !end_referenced_vars_p (&(ITER)); \
368 (VAR) = next_referenced_var (&(ITER)))
371 typedef struct
373 int i;
374 } safe_referenced_var_iterator;
376 /* This macro loops over all the referenced vars, one at a time, putting the
377 current var in VAR. You are allowed to add referenced variables during the
378 execution of this macro, however, the macro will not iterate over them. It
379 requires a temporary vector of trees, VEC, whose lifetime is controlled by
380 the caller. The purpose of the vector is to temporarily store the
381 referenced_variables hashtable so that adding referenced variables does not
382 affect the hashtable. */
384 #define FOR_EACH_REFERENCED_VAR_SAFE(VAR, VEC, ITER) \
385 for ((ITER).i = 0, fill_referenced_var_vec (&(VEC)); \
386 VEC_iterate (tree, (VEC), (ITER).i, (VAR)); \
387 (ITER).i++)
389 /* Array of all variables referenced in the function. */
390 extern GTY((param_is (struct int_tree_map))) htab_t referenced_vars;
392 /* Default defs for undefined symbols. */
393 extern GTY((param_is (struct int_tree_map))) htab_t default_defs;
395 extern tree referenced_var_lookup (unsigned int);
396 #define num_referenced_vars htab_elements (referenced_vars)
397 #define referenced_var(i) referenced_var_lookup (i)
399 /* Array of all SSA_NAMEs used in the function. */
400 extern GTY(()) VEC(tree,gc) *ssa_names;
402 #define num_ssa_names (VEC_length (tree, ssa_names))
403 #define ssa_name(i) (VEC_index (tree, ssa_names, (i)))
405 /* Artificial variable used to model the effects of function calls. */
406 extern GTY(()) tree global_var;
408 /* Call clobbered variables in the function. If bit I is set, then
409 REFERENCED_VARS (I) is call-clobbered. */
410 extern bitmap call_clobbered_vars;
412 /* Addressable variables in the function. If bit I is set, then
413 REFERENCED_VARS (I) has had its address taken. */
414 extern bitmap addressable_vars;
416 /* 'true' after aliases have been computed (see compute_may_aliases). */
417 extern bool aliases_computed_p;
419 /* Macros for showing usage statistics. */
420 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
421 ? (x) \
422 : ((x) < 1024*1024*10 \
423 ? (x) / 1024 \
424 : (x) / (1024*1024))))
426 #define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
428 #define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y))
430 /*---------------------------------------------------------------------------
431 Block iterators
432 ---------------------------------------------------------------------------*/
434 typedef struct {
435 tree_stmt_iterator tsi;
436 basic_block bb;
437 } block_stmt_iterator;
439 static inline block_stmt_iterator bsi_start (basic_block);
440 static inline block_stmt_iterator bsi_last (basic_block);
441 static inline block_stmt_iterator bsi_after_labels (basic_block);
442 block_stmt_iterator bsi_for_stmt (tree);
443 static inline bool bsi_end_p (block_stmt_iterator);
444 static inline void bsi_next (block_stmt_iterator *);
445 static inline void bsi_prev (block_stmt_iterator *);
446 static inline tree bsi_stmt (block_stmt_iterator);
447 static inline tree * bsi_stmt_ptr (block_stmt_iterator);
449 extern void bsi_remove (block_stmt_iterator *, bool);
450 extern void bsi_move_before (block_stmt_iterator *, block_stmt_iterator *);
451 extern void bsi_move_after (block_stmt_iterator *, block_stmt_iterator *);
452 extern void bsi_move_to_bb_end (block_stmt_iterator *, basic_block);
454 enum bsi_iterator_update
456 /* Note that these are intentionally in the same order as TSI_FOO. They
457 mean exactly the same as their TSI_* counterparts. */
458 BSI_NEW_STMT,
459 BSI_SAME_STMT,
460 BSI_CHAIN_START,
461 BSI_CHAIN_END,
462 BSI_CONTINUE_LINKING
465 extern void bsi_insert_before (block_stmt_iterator *, tree,
466 enum bsi_iterator_update);
467 extern void bsi_insert_after (block_stmt_iterator *, tree,
468 enum bsi_iterator_update);
470 extern void bsi_replace (const block_stmt_iterator *, tree, bool);
472 /*---------------------------------------------------------------------------
473 OpenMP Region Tree
474 ---------------------------------------------------------------------------*/
476 /* Parallel region information. Every parallel and workshare
477 directive is enclosed between two markers, the OMP_* directive
478 and a corresponding OMP_RETURN statement. */
480 struct omp_region
482 /* The enclosing region. */
483 struct omp_region *outer;
485 /* First child region. */
486 struct omp_region *inner;
488 /* Next peer region. */
489 struct omp_region *next;
491 /* Block containing the omp directive as its last stmt. */
492 basic_block entry;
494 /* Block containing the OMP_RETURN as its last stmt. */
495 basic_block exit;
497 /* Block containing the OMP_CONTINUE as its last stmt. */
498 basic_block cont;
500 /* If this is a combined parallel+workshare region, this is a list
501 of additional arguments needed by the combined parallel+workshare
502 library call. */
503 tree ws_args;
505 /* The code for the omp directive of this region. */
506 enum tree_code type;
508 /* True if this is a combined parallel+workshare region. */
509 bool is_combined_parallel;
512 extern struct omp_region *root_omp_region;
513 extern struct omp_region *new_omp_region (basic_block, enum tree_code,
514 struct omp_region *);
515 extern void free_omp_regions (void);
517 /*---------------------------------------------------------------------------
518 Function prototypes
519 ---------------------------------------------------------------------------*/
520 /* In tree-cfg.c */
522 /* Location to track pending stmt for edge insertion. */
523 #define PENDING_STMT(e) ((e)->insns.t)
525 extern void delete_tree_cfg_annotations (void);
526 extern void disband_implicit_edges (void);
527 extern bool stmt_ends_bb_p (tree);
528 extern bool is_ctrl_stmt (tree);
529 extern bool is_ctrl_altering_stmt (tree);
530 extern bool computed_goto_p (tree);
531 extern bool simple_goto_p (tree);
532 extern basic_block single_noncomplex_succ (basic_block bb);
533 extern void tree_dump_bb (basic_block, FILE *, int);
534 extern void debug_tree_bb (basic_block);
535 extern basic_block debug_tree_bb_n (int);
536 extern void dump_tree_cfg (FILE *, int);
537 extern void debug_tree_cfg (int);
538 extern void dump_cfg_stats (FILE *);
539 extern void debug_cfg_stats (void);
540 extern void debug_loop_ir (void);
541 extern void print_loop_ir (FILE *);
542 extern void cleanup_dead_labels (void);
543 extern void group_case_labels (void);
544 extern tree first_stmt (basic_block);
545 extern tree last_stmt (basic_block);
546 extern tree *last_stmt_ptr (basic_block);
547 extern tree last_and_only_stmt (basic_block);
548 extern edge find_taken_edge (basic_block, tree);
549 extern basic_block label_to_block_fn (struct function *, tree);
550 #define label_to_block(t) (label_to_block_fn (cfun, t))
551 extern void bsi_insert_on_edge (edge, tree);
552 extern basic_block bsi_insert_on_edge_immediate (edge, tree);
553 extern void bsi_commit_one_edge_insert (edge, basic_block *);
554 extern void bsi_commit_edge_inserts (void);
555 extern void notice_special_calls (tree);
556 extern void clear_special_calls (void);
557 extern void verify_stmts (void);
558 extern tree tree_block_label (basic_block);
559 extern void extract_true_false_edges_from_block (basic_block, edge *, edge *);
560 extern bool tree_duplicate_sese_region (edge, edge, basic_block *, unsigned,
561 basic_block *);
562 extern void add_phi_args_after_copy_bb (basic_block);
563 extern void add_phi_args_after_copy (basic_block *, unsigned);
564 extern bool tree_purge_dead_eh_edges (basic_block);
565 extern bool tree_purge_all_dead_eh_edges (bitmap);
566 extern tree gimplify_val (block_stmt_iterator *, tree, tree);
567 extern tree gimplify_build1 (block_stmt_iterator *, enum tree_code,
568 tree, tree);
569 extern tree gimplify_build2 (block_stmt_iterator *, enum tree_code,
570 tree, tree, tree);
571 extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code,
572 tree, tree, tree, tree);
573 extern void init_empty_tree_cfg (void);
574 extern void fold_cond_expr_cond (void);
575 extern void replace_uses_by (tree, tree);
576 extern void start_recording_case_labels (void);
577 extern void end_recording_case_labels (void);
578 extern basic_block move_sese_region_to_fn (struct function *, basic_block,
579 basic_block);
581 /* In tree-cfgcleanup.c */
582 extern bool cleanup_tree_cfg (void);
583 extern void cleanup_tree_cfg_loop (void);
585 /* In tree-pretty-print.c. */
586 extern void dump_generic_bb (FILE *, basic_block, int, int);
588 /* In tree-dfa.c */
589 extern var_ann_t create_var_ann (tree);
590 extern function_ann_t create_function_ann (tree);
591 extern stmt_ann_t create_stmt_ann (tree);
592 extern tree_ann_t create_tree_ann (tree);
593 extern void dump_dfa_stats (FILE *);
594 extern void debug_dfa_stats (void);
595 extern void debug_referenced_vars (void);
596 extern void dump_referenced_vars (FILE *);
597 extern void dump_variable (FILE *, tree);
598 extern void debug_variable (tree);
599 extern void dump_subvars_for (FILE *, tree);
600 extern void debug_subvars_for (tree);
601 extern tree get_virtual_var (tree);
602 extern void add_referenced_tmp_var (tree);
603 extern void mark_new_vars_to_rename (tree);
604 extern void find_new_referenced_vars (tree *);
606 extern tree make_rename_temp (tree, const char *);
607 extern void set_default_def (tree, tree);
608 extern tree default_def (tree);
609 extern tree default_def_fn (struct function *, tree);
611 /* In tree-phinodes.c */
612 extern void reserve_phi_args_for_new_edge (basic_block);
613 extern tree create_phi_node (tree, basic_block);
614 extern void add_phi_arg (tree, tree, edge);
615 extern void remove_phi_args (edge);
616 extern void remove_phi_node (tree, tree);
617 extern tree phi_reverse (tree);
619 /* In gimple-low.c */
620 extern void record_vars_into (tree, tree);
621 extern void record_vars (tree);
622 extern bool block_may_fallthru (tree);
624 /* In tree-ssa-alias.c */
625 extern void dump_may_aliases_for (FILE *, tree);
626 extern void debug_may_aliases_for (tree);
627 extern void dump_alias_info (FILE *);
628 extern void debug_alias_info (void);
629 extern void dump_points_to_info (FILE *);
630 extern void debug_points_to_info (void);
631 extern void dump_points_to_info_for (FILE *, tree);
632 extern void debug_points_to_info_for (tree);
633 extern bool may_be_aliased (tree);
634 extern bool is_aliased_with (tree, tree);
635 extern struct ptr_info_def *get_ptr_info (tree);
636 extern void add_type_alias (tree, tree);
637 extern void new_type_alias (tree, tree);
638 extern void count_uses_and_derefs (tree, tree, unsigned *, unsigned *, bool *);
639 static inline subvar_t get_subvars_for_var (tree);
640 static inline tree get_subvar_at (tree, unsigned HOST_WIDE_INT);
641 static inline bool ref_contains_array_ref (tree);
642 static inline bool array_ref_contains_indirect_ref (tree);
643 extern tree get_ref_base_and_extent (tree, HOST_WIDE_INT *,
644 HOST_WIDE_INT *, HOST_WIDE_INT *);
645 static inline bool var_can_have_subvars (tree);
646 static inline bool overlap_subvar (unsigned HOST_WIDE_INT,
647 unsigned HOST_WIDE_INT,
648 tree, bool *);
650 /* Call-back function for walk_use_def_chains(). At each reaching
651 definition, a function with this prototype is called. */
652 typedef bool (*walk_use_def_chains_fn) (tree, tree, void *);
655 /* In tree-ssa.c */
656 extern void init_tree_ssa (void);
657 extern edge ssa_redirect_edge (edge, basic_block);
658 extern void flush_pending_stmts (edge);
659 extern bool tree_ssa_useless_type_conversion (tree);
660 extern bool tree_ssa_useless_type_conversion_1 (tree, tree);
661 extern void verify_ssa (bool);
662 extern void delete_tree_ssa (void);
663 extern void register_new_def (tree, VEC(tree,heap) **);
664 extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool);
665 extern bool stmt_references_memory_p (tree);
667 /* In tree-into-ssa.c */
668 void update_ssa (unsigned);
669 void delete_update_ssa (void);
670 void register_new_name_mapping (tree, tree);
671 tree create_new_def_for (tree, tree, def_operand_p);
672 bool need_ssa_update_p (void);
673 bool name_registered_for_update_p (tree);
674 bitmap ssa_names_to_replace (void);
675 void release_ssa_name_after_update_ssa (tree name);
676 void compute_global_livein (bitmap, bitmap);
677 tree duplicate_ssa_name (tree, tree);
678 void mark_sym_for_renaming (tree);
679 void mark_set_for_renaming (bitmap);
680 tree get_current_def (tree);
681 void set_current_def (tree, tree);
683 /* In tree-ssa-ccp.c */
684 bool fold_stmt (tree *);
685 bool fold_stmt_inplace (tree);
686 tree widen_bitfield (tree, tree, tree);
688 /* In tree-vrp.c */
689 tree vrp_evaluate_conditional (tree, bool);
690 void simplify_stmt_using_ranges (tree);
692 /* In tree-ssa-dom.c */
693 extern void dump_dominator_optimization_stats (FILE *);
694 extern void debug_dominator_optimization_stats (void);
695 int loop_depth_of_name (tree);
697 /* In tree-ssa-copy.c */
698 extern void merge_alias_info (tree, tree);
699 extern void propagate_value (use_operand_p, tree);
700 extern void propagate_tree_value (tree *, tree);
701 extern void replace_exp (use_operand_p, tree);
702 extern bool may_propagate_copy (tree, tree);
703 extern bool may_propagate_copy_into_asm (tree);
705 /* Affine iv. */
707 typedef struct
709 /* Iv = BASE + STEP * i. */
710 tree base, step;
712 /* True if this iv does not overflow. */
713 bool no_overflow;
714 } affine_iv;
716 /* Description of number of iterations of a loop. All the expressions inside
717 the structure can be evaluated at the end of the loop's preheader
718 (and due to ssa form, also anywhere inside the body of the loop). */
720 struct tree_niter_desc
722 tree assumptions; /* The boolean expression. If this expression evaluates
723 to false, then the other fields in this structure
724 should not be used; there is no guarantee that they
725 will be correct. */
726 tree may_be_zero; /* The boolean expression. If it evaluates to true,
727 the loop will exit in the first iteration (i.e.
728 its latch will not be executed), even if the niter
729 field says otherwise. */
730 tree niter; /* The expression giving the number of iterations of
731 a loop (provided that assumptions == true and
732 may_be_zero == false), more precisely the number
733 of executions of the latch of the loop. */
734 tree additional_info; /* The boolean expression. Sometimes we use additional
735 knowledge to simplify the other expressions
736 contained in this structure (for example the
737 knowledge about value ranges of operands on entry to
738 the loop). If this is a case, conjunction of such
739 condition is stored in this field, so that we do not
740 lose the information: for example if may_be_zero
741 is (n <= 0) and niter is (unsigned) n, we know
742 that the number of iterations is at most
743 MAX_SIGNED_INT. However if the (n <= 0) assumption
744 is eliminated (by looking at the guard on entry of
745 the loop), then the information would be lost. */
747 /* The simplified shape of the exit condition. The loop exits if
748 CONTROL CMP BOUND is false, where CMP is one of NE_EXPR,
749 LT_EXPR, or GT_EXPR, and step of CONTROL is positive if CMP is
750 LE_EXPR and negative if CMP is GE_EXPR. This information is used
751 by loop unrolling. */
752 affine_iv control;
753 tree bound;
754 enum tree_code cmp;
757 /* In tree-vectorizer.c */
758 void vectorize_loops (struct loops *);
760 /* In tree-ssa-phiopt.c */
761 bool empty_block_p (basic_block);
763 /* In tree-ssa-loop*.c */
765 void tree_ssa_lim (struct loops *);
766 void tree_ssa_unswitch_loops (struct loops *);
767 void canonicalize_induction_variables (struct loops *);
768 void tree_unroll_loops_completely (struct loops *, bool);
769 void tree_ssa_prefetch_arrays (struct loops *);
770 void remove_empty_loops (struct loops *);
771 void tree_ssa_iv_optimize (struct loops *);
773 bool number_of_iterations_exit (struct loop *, edge,
774 struct tree_niter_desc *niter, bool);
775 tree find_loop_niter (struct loop *, edge *);
776 tree loop_niter_by_eval (struct loop *, edge);
777 tree find_loop_niter_by_eval (struct loop *, edge *);
778 void estimate_numbers_of_iterations (struct loops *);
779 bool scev_probably_wraps_p (tree, tree, tree, tree, struct loop *, bool *,
780 bool *);
781 tree convert_step (struct loop *, tree, tree, tree, tree);
782 void free_numbers_of_iterations_estimates (struct loops *);
783 void free_numbers_of_iterations_estimates_loop (struct loop *);
784 void rewrite_into_loop_closed_ssa (bitmap, unsigned);
785 void verify_loop_closed_ssa (void);
786 void loop_commit_inserts (void);
787 bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *);
788 void create_iv (tree, tree, tree, struct loop *, block_stmt_iterator *, bool,
789 tree *, tree *);
790 void split_loop_exit_edge (edge);
791 void compute_phi_arg_on_exit (edge, tree, tree);
792 unsigned force_expr_to_var_cost (tree);
793 basic_block bsi_insert_on_edge_immediate_loop (edge, tree);
794 void standard_iv_increment_position (struct loop *, block_stmt_iterator *,
795 bool *);
796 basic_block ip_end_pos (struct loop *);
797 basic_block ip_normal_pos (struct loop *);
798 bool tree_duplicate_loop_to_header_edge (struct loop *, edge, struct loops *,
799 unsigned int, sbitmap,
800 edge, edge *,
801 unsigned int *, int);
802 struct loop *tree_ssa_loop_version (struct loops *, struct loop *, tree,
803 basic_block *);
804 tree expand_simple_operations (tree);
805 void substitute_in_loop_info (struct loop *, tree, tree);
806 edge single_dom_exit (struct loop *);
807 bool can_unroll_loop_p (struct loop *loop, unsigned factor,
808 struct tree_niter_desc *niter);
809 void tree_unroll_loop (struct loops *, struct loop *, unsigned,
810 edge, struct tree_niter_desc *);
812 /* In tree-ssa-threadedge.c */
813 extern bool potentially_threadable_block (basic_block);
814 extern void thread_across_edge (tree, edge, bool,
815 VEC(tree, heap) **, tree (*) (tree));
817 /* In tree-ssa-loop-im.c */
818 /* The possibilities of statement movement. */
820 enum move_pos
822 MOVE_IMPOSSIBLE, /* No movement -- side effect expression. */
823 MOVE_PRESERVE_EXECUTION, /* Must not cause the non-executed statement
824 become executed -- memory accesses, ... */
825 MOVE_POSSIBLE /* Unlimited movement. */
827 extern enum move_pos movement_possibility (tree);
829 /* The reasons a variable may escape a function. */
830 enum escape_type
832 NO_ESCAPE = 0, /* Doesn't escape. */
833 ESCAPE_STORED_IN_GLOBAL = 1 << 1,
834 ESCAPE_TO_ASM = 1 << 2, /* Passed by address to an assembly
835 statement. */
836 ESCAPE_TO_CALL = 1 << 3, /* Escapes to a function call. */
837 ESCAPE_BAD_CAST = 1 << 4, /* Cast from pointer to integer */
838 ESCAPE_TO_RETURN = 1 << 5, /* Returned from function. */
839 ESCAPE_TO_PURE_CONST = 1 << 6, /* Escapes to a pure or constant
840 function call. */
841 ESCAPE_IS_GLOBAL = 1 << 7, /* Is a global variable. */
842 ESCAPE_IS_PARM = 1 << 8, /* Is an incoming function parameter. */
843 ESCAPE_UNKNOWN = 1 << 9 /* We believe it escapes for some reason
844 not enumerated above. */
847 /* In tree-flow-inline.h */
848 static inline bool is_call_clobbered (tree);
849 static inline void mark_call_clobbered (tree, unsigned int);
850 static inline void set_is_used (tree);
851 static inline bool unmodifiable_var_p (tree);
853 /* In tree-eh.c */
854 extern void make_eh_edges (tree);
855 extern bool tree_could_trap_p (tree);
856 extern bool tree_could_throw_p (tree);
857 extern bool tree_can_throw_internal (tree);
858 extern bool tree_can_throw_external (tree);
859 extern int lookup_stmt_eh_region (tree);
860 extern void add_stmt_to_eh_region (tree, int);
861 extern bool remove_stmt_from_eh_region (tree);
862 extern bool maybe_clean_or_replace_eh_stmt (tree, tree);
864 /* In tree-ssa-pre.c */
865 void add_to_value (tree, tree);
866 void debug_value_expressions (tree);
867 void print_value_expressions (FILE *, tree);
870 /* In tree-vn.c */
871 bool expressions_equal_p (tree, tree);
872 tree get_value_handle (tree);
873 hashval_t vn_compute (tree, hashval_t);
874 void sort_vuses (VEC (tree, gc) *);
875 tree vn_lookup_or_add (tree, tree);
876 tree vn_lookup_or_add_with_vuses (tree, VEC (tree, gc) *);
877 void vn_add (tree, tree);
878 void vn_add_with_vuses (tree, tree, VEC (tree, gc) *);
879 tree vn_lookup (tree, tree);
880 tree vn_lookup_with_vuses (tree, VEC (tree, gc) *);
881 void vn_init (void);
882 void vn_delete (void);
884 /* In tree-ssa-sink.c */
885 bool is_hidden_global_store (tree);
887 /* In tree-sra.c */
888 void insert_edge_copies (tree, basic_block);
889 void sra_insert_before (block_stmt_iterator *, tree);
890 void sra_insert_after (block_stmt_iterator *, tree);
891 void sra_init_cache (void);
892 bool sra_type_can_be_decomposed_p (tree);
894 /* In tree-loop-linear.c */
895 extern void linear_transform_loops (struct loops *);
897 /* In tree-ssa-loop-ivopts.c */
898 bool expr_invariant_in_loop_p (struct loop *, tree);
899 bool multiplier_allowed_in_address_p (HOST_WIDE_INT);
900 unsigned multiply_by_cost (HOST_WIDE_INT, enum machine_mode);
902 /* In tree-ssa-threadupdate.c. */
903 extern bool thread_through_all_blocks (void);
904 extern void register_jump_thread (edge, edge);
906 /* In gimplify.c */
907 tree force_gimple_operand (tree, tree *, bool, tree);
908 tree force_gimple_operand_bsi (block_stmt_iterator *, tree, bool, tree);
910 /* In tree-ssa-structalias.c */
911 bool find_what_p_points_to (tree);
913 /* In tree-ssa-live.c */
914 extern void remove_unused_locals (void);
916 /* In tree-ssa-address.c */
918 /* Affine combination of trees. We keep track of at most MAX_AFF_ELTS elements
919 to make things simpler; this is sufficient in most cases. */
921 #define MAX_AFF_ELTS 8
923 struct affine_tree_combination
925 /* Type of the result of the combination. */
926 tree type;
928 /* Mask modulo that the operations are performed. */
929 unsigned HOST_WIDE_INT mask;
931 /* Constant offset. */
932 unsigned HOST_WIDE_INT offset;
934 /* Number of elements of the combination. */
935 unsigned n;
937 /* Elements and their coefficients. */
938 tree elts[MAX_AFF_ELTS];
939 unsigned HOST_WIDE_INT coefs[MAX_AFF_ELTS];
941 /* Remainder of the expression. */
942 tree rest;
945 /* Description of a memory address. */
947 struct mem_address
949 tree symbol, base, index, step, offset;
952 tree create_mem_ref (block_stmt_iterator *, tree,
953 struct affine_tree_combination *);
954 rtx addr_for_mem_ref (struct mem_address *, bool);
955 void get_address_description (tree, struct mem_address *);
956 tree maybe_fold_tmr (tree);
958 /* This structure is simply used during pushing fields onto the fieldstack
959 to track the offset of the field, since bitpos_of_field gives it relative
960 to its immediate containing type, and we want it relative to the ultimate
961 containing object. */
963 struct fieldoff
965 tree type;
966 tree size;
967 tree decl;
968 HOST_WIDE_INT offset;
970 typedef struct fieldoff fieldoff_s;
972 DEF_VEC_O(fieldoff_s);
973 DEF_VEC_ALLOC_O(fieldoff_s,heap);
974 int push_fields_onto_fieldstack (tree, VEC(fieldoff_s,heap) **,
975 HOST_WIDE_INT, bool *);
976 void sort_fieldstack (VEC(fieldoff_s,heap) *);
978 void init_alias_heapvars (void);
979 void delete_alias_heapvars (void);
981 #include "tree-flow-inline.h"
983 void swap_tree_operands (tree, tree *, tree *);
985 extern void recalculate_used_alone (void);
986 extern bool updating_used_alone;
987 #endif /* _TREE_FLOW_H */