Privatize SSA variables into gimple_df.
[official-gcc.git] / gcc / tree-flow.h
blobfad1686f104474b20e329dd11eaba8c9dd2b0413
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 /* Gimple dataflow datastructure. All publically available fields shall have
43 gimple_ accessor defined in tree-flow-inline.h, all publically modifiable
44 fields should have gimple_set accessor. */
45 struct gimple_df GTY(()) {
46 /* Array of all variables referenced in the function. */
47 htab_t GTY((param_is (struct int_tree_map))) referenced_vars;
48 /* A list of all the noreturn calls passed to modify_stmt.
49 cleanup_control_flow uses it to detect cases where a mid-block
50 indirect call has been turned into a noreturn call. When this
51 happens, all the instructions after the call are no longer
52 reachable and must be deleted as dead. */
53 VEC(tree,gc) *modified_noreturn_calls;
54 /* Array of all SSA_NAMEs used in the function. */
55 VEC(tree,gc) *ssa_names;
57 /* Artificial variable used to model the effects of function calls. */
58 tree global_var;
60 /* Artificial variable used to model the effects of nonlocal
61 variables. */
62 tree nonlocal_all;
64 /* Call clobbered variables in the function. If bit I is set, then
65 REFERENCED_VARS (I) is call-clobbered. */
66 bitmap call_clobbered_vars;
68 /* Addressable variables in the function. If bit I is set, then
69 REFERENCED_VARS (I) has had its address taken. Note that
70 CALL_CLOBBERED_VARS and ADDRESSABLE_VARS are not related. An
71 addressable variable is not necessarily call-clobbered (e.g., a
72 local addressable whose address does not escape) and not all
73 call-clobbered variables are addressable (e.g., a local static
74 variable). */
75 bitmap addressable_vars;
77 /* Free list of SSA_NAMEs. */
78 tree free_ssanames;
80 /* Hashtable holding definition for symbol. If this field is not NULL, it
81 means that the first reference to this variable in the function is a
82 USE or a VUSE. In those cases, the SSA renamer creates an SSA name
83 for this variable with an empty defining statement. */
84 htab_t GTY((param_is (struct int_tree_map))) default_defs;
86 /* 'true' after aliases have been computed (see compute_may_aliases). */
87 unsigned int aliases_computed_p : 1;
89 /* True if the code is in ssa form. */
90 unsigned int in_ssa_p : 1;
93 /* Accessors for internal use only. Generic code should use abstraction
94 provided by tree-flow-inline.h or specific modules. */
95 #define FREE_SSANAMES(fun) (fun)->gimple_df->free_ssanames
96 #define SSANAMES(fun) (fun)->gimple_df->ssa_names
97 #define MODIFIED_NORETURN_CALLS(fun) (fun)->gimple_df->modified_noreturn_calls
98 #define DEFAULT_DEFS(fun) (fun)->gimple_df->default_defs
100 typedef struct
102 htab_t htab;
103 PTR *slot;
104 PTR *limit;
105 } htab_iterator;
107 /* Iterate through the elements of hashtable HTAB, using htab_iterator ITER,
108 storing each element in RESULT, which is of type TYPE. */
109 #define FOR_EACH_HTAB_ELEMENT(HTAB, RESULT, TYPE, ITER) \
110 for (RESULT = (TYPE) first_htab_element (&(ITER), (HTAB)); \
111 !end_htab_p (&(ITER)); \
112 RESULT = (TYPE) next_htab_element (&(ITER)))
114 /*---------------------------------------------------------------------------
115 Attributes for SSA_NAMEs.
117 NOTE: These structures are stored in struct tree_ssa_name
118 but are only used by the tree optimizers, so it makes better sense
119 to declare them here to avoid recompiling unrelated files when
120 making changes.
121 ---------------------------------------------------------------------------*/
123 /* Aliasing information for SSA_NAMEs representing pointer variables. */
124 struct ptr_info_def GTY(())
126 /* Nonzero if points-to analysis couldn't determine where this pointer
127 is pointing to. */
128 unsigned int pt_anything : 1;
130 /* Nonzero if the value of this pointer escapes the current function. */
131 unsigned int value_escapes_p : 1;
133 /* Nonzero if this pointer is dereferenced. */
134 unsigned int is_dereferenced : 1;
136 /* Nonzero if this pointer points to a global variable. */
137 unsigned int pt_global_mem : 1;
139 /* Nonzero if this pointer points to NULL. */
140 unsigned int pt_null : 1;
142 /* Set of variables that this pointer may point to. */
143 bitmap pt_vars;
145 /* If this pointer has been dereferenced, and points-to information is
146 more precise than type-based aliasing, indirect references to this
147 pointer will be represented by this memory tag, instead of the type
148 tag computed by TBAA. */
149 tree name_mem_tag;
151 /* Mask of reasons this pointer's value escapes the function */
152 unsigned int escape_mask;
156 /*---------------------------------------------------------------------------
157 Tree annotations stored in tree_common.ann
158 ---------------------------------------------------------------------------*/
159 enum tree_ann_type { TREE_ANN_COMMON, VAR_ANN, FUNCTION_ANN, STMT_ANN };
161 struct tree_ann_common_d GTY(())
163 /* Annotation type. */
164 enum tree_ann_type type;
166 /* Auxiliary info specific to a pass. At all times, this
167 should either point to valid data or be NULL. */
168 PTR GTY ((skip (""))) aux;
170 /* The value handle for this expression. Used by GVN-PRE. */
171 tree GTY((skip)) value_handle;
174 /* It is advantageous to avoid things like life analysis for variables which
175 do not need PHI nodes. This enum describes whether or not a particular
176 variable may need a PHI node. */
178 enum need_phi_state {
179 /* This is the default. If we are still in this state after finding
180 all the definition and use sites, then we will assume the variable
181 needs PHI nodes. This is probably an overly conservative assumption. */
182 NEED_PHI_STATE_UNKNOWN,
184 /* This state indicates that we have seen one or more sets of the
185 variable in a single basic block and that the sets dominate all
186 uses seen so far. If after finding all definition and use sites
187 we are still in this state, then the variable does not need any
188 PHI nodes. */
189 NEED_PHI_STATE_NO,
191 /* This state indicates that we have either seen multiple definitions of
192 the variable in multiple blocks, or that we encountered a use in a
193 block that was not dominated by the block containing the set(s) of
194 this variable. This variable is assumed to need PHI nodes. */
195 NEED_PHI_STATE_MAYBE
198 struct subvar;
199 typedef struct subvar *subvar_t;
201 /* This structure represents a fake sub-variable for a structure field. */
202 struct subvar GTY(())
204 /* Fake variable. */
205 tree var;
207 /* Next subvar for this structure. */
208 subvar_t next;
211 struct var_ann_d GTY(())
213 struct tree_ann_common_d common;
215 /* Used by the out of SSA pass to determine whether this variable has
216 been seen yet or not. */
217 unsigned out_of_ssa_tag : 1;
219 /* Used when building root_var structures in tree_ssa_live.[ch]. */
220 unsigned root_var_processed : 1;
222 /* Nonzero if this variable is in the alias set of another variable. */
223 unsigned is_aliased : 1;
225 /* Nonzero if this variable was used after SSA optimizations were
226 applied. We set this when translating out of SSA form. */
227 unsigned used : 1;
229 /* This field indicates whether or not the variable may need PHI nodes.
230 See the enum's definition for more detailed information about the
231 states. */
232 ENUM_BITFIELD (need_phi_state) need_phi_state : 2;
234 /* Used during operand processing to determine if this variable is already
235 in the vuse list. */
236 unsigned in_vuse_list : 1;
238 /* Used during operand processing to determine if this variable is already
239 in the v_may_def list. */
240 unsigned in_v_may_def_list : 1;
242 /* True for HEAP and PARM_NOALIAS artificial variables. */
243 unsigned is_heapvar : 1;
245 /* An artificial variable representing the memory location pointed-to by
246 all the pointer symbols that flow-insensitive alias analysis
247 (mostly type-based) considers to be aliased. If the variable is
248 not a pointer or if it is never dereferenced, this must be NULL. */
249 tree symbol_mem_tag;
251 /* Variables that may alias this variable. */
252 VEC(tree, gc) *may_aliases;
254 /* Used when going out of SSA form to indicate which partition this
255 variable represents storage for. */
256 unsigned partition;
258 /* Used by the root-var object in tree-ssa-live.[ch]. */
259 unsigned root_index;
261 /* During into-ssa and the dominator optimizer, this field holds the
262 current version of this variable (an SSA_NAME). */
263 tree current_def;
265 /* If this variable is a structure, this fields holds a list of
266 symbols representing each of the fields of the structure. */
267 subvar_t subvars;
269 /* Mask of values saying the reasons why this variable has escaped
270 the function. */
271 unsigned int escape_mask;
274 struct function_ann_d GTY(())
276 struct tree_ann_common_d common;
278 /* Pointer to the structure that contains the sets of global
279 variables modified by function calls. This field is only used
280 for FUNCTION_DECLs. */
281 ipa_reference_vars_info_t GTY ((skip)) reference_vars_info;
284 typedef struct immediate_use_iterator_d
286 /* This is the current use the iterator is processing. */
287 ssa_use_operand_t *imm_use;
288 /* This marks the last use in the list (use node from SSA_NAME) */
289 ssa_use_operand_t *end_p;
290 /* This node is inserted and used to mark the end of the uses for a stmt. */
291 ssa_use_operand_t iter_node;
292 /* This is the next ssa_name to visit. IMM_USE may get removed before
293 the next one is traversed to, so it must be cached early. */
294 ssa_use_operand_t *next_imm_name;
295 } imm_use_iterator;
298 /* Use this iterator when simply looking at stmts. Adding, deleting or
299 modifying stmts will cause this iterator to malfunction. */
301 #define FOR_EACH_IMM_USE_FAST(DEST, ITER, SSAVAR) \
302 for ((DEST) = first_readonly_imm_use (&(ITER), (SSAVAR)); \
303 !end_readonly_imm_use_p (&(ITER)); \
304 (DEST) = next_readonly_imm_use (&(ITER)))
306 /* Use this iterator to visit each stmt which has a use of SSAVAR. */
308 #define FOR_EACH_IMM_USE_STMT(STMT, ITER, SSAVAR) \
309 for ((STMT) = first_imm_use_stmt (&(ITER), (SSAVAR)); \
310 !end_imm_use_stmt_p (&(ITER)); \
311 (STMT) = next_imm_use_stmt (&(ITER)))
313 /* Use this to terminate the FOR_EACH_IMM_USE_STMT loop early. Failure to
314 do so will result in leaving a iterator marker node in the immediate
315 use list, and nothing good will come from that. */
316 #define BREAK_FROM_IMM_USE_STMT(ITER) \
318 end_imm_use_stmt_traverse (&(ITER)); \
319 break; \
323 /* Use this iterator in combination with FOR_EACH_IMM_USE_STMT to
324 get access to each occurrence of ssavar on the stmt returned by
325 that iterator.. for instance:
327 FOR_EACH_IMM_USE_STMT (stmt, iter, var)
329 FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
331 SET_USE (use_p) = blah;
333 update_stmt (stmt);
334 } */
336 #define FOR_EACH_IMM_USE_ON_STMT(DEST, ITER) \
337 for ((DEST) = first_imm_use_on_stmt (&(ITER)); \
338 !end_imm_use_on_stmt_p (&(ITER)); \
339 (DEST) = next_imm_use_on_stmt (&(ITER)))
343 struct stmt_ann_d GTY(())
345 struct tree_ann_common_d common;
347 /* Nonzero if the statement has been modified (meaning that the operands
348 need to be scanned again). */
349 unsigned modified : 1;
351 /* Nonzero if the statement makes references to volatile storage. */
352 unsigned has_volatile_ops : 1;
354 /* Nonzero if the statement makes a function call that may clobber global
355 and local addressable variables. */
356 unsigned makes_clobbering_call : 1;
358 /* Basic block that contains this statement. */
359 basic_block bb;
361 /* Operand cache for stmt. */
362 struct stmt_operands_d GTY ((skip (""))) operands;
364 /* Set of variables that have had their address taken in the statement. */
365 bitmap addresses_taken;
367 /* Unique identifier for this statement. These ID's are to be created
368 by each pass on an as-needed basis in any order convenient for the
369 pass which needs statement UIDs. */
370 unsigned int uid;
372 /* Linked list of histograms for value-based profiling. This is really a
373 struct histogram_value*. We use void* to avoid having to export that
374 everywhere, and to avoid having to put it in GC memory. */
376 void * GTY ((skip (""))) histograms;
379 union tree_ann_d GTY((desc ("ann_type ((tree_ann_t)&%h)")))
381 struct tree_ann_common_d GTY((tag ("TREE_ANN_COMMON"))) common;
382 struct var_ann_d GTY((tag ("VAR_ANN"))) vdecl;
383 struct function_ann_d GTY((tag ("FUNCTION_ANN"))) fdecl;
384 struct stmt_ann_d GTY((tag ("STMT_ANN"))) stmt;
387 typedef union tree_ann_d *tree_ann_t;
388 typedef struct var_ann_d *var_ann_t;
389 typedef struct function_ann_d *function_ann_t;
390 typedef struct stmt_ann_d *stmt_ann_t;
391 typedef struct tree_ann_common_d *tree_ann_common_t;
393 static inline tree_ann_common_t tree_common_ann (tree);
394 static inline tree_ann_common_t get_tree_common_ann (tree);
395 static inline var_ann_t var_ann (tree);
396 static inline var_ann_t get_var_ann (tree);
397 static inline function_ann_t function_ann (tree);
398 static inline function_ann_t get_function_ann (tree);
399 static inline stmt_ann_t stmt_ann (tree);
400 static inline bool has_stmt_ann (tree);
401 static inline stmt_ann_t get_stmt_ann (tree);
402 static inline enum tree_ann_type ann_type (tree_ann_t);
403 static inline basic_block bb_for_stmt (tree);
404 extern void set_bb_for_stmt (tree, basic_block);
405 static inline bool noreturn_call_p (tree);
406 static inline void update_stmt (tree);
407 static inline bool stmt_modified_p (tree);
408 static inline VEC(tree, gc) *may_aliases (tree);
409 static inline int get_lineno (tree);
410 static inline const char *get_filename (tree);
411 static inline bool is_exec_stmt (tree);
412 static inline bool is_label_stmt (tree);
413 static inline bitmap addresses_taken (tree);
415 /*---------------------------------------------------------------------------
416 Structure representing predictions in tree level.
417 ---------------------------------------------------------------------------*/
418 struct edge_prediction GTY((chain_next ("%h.ep_next")))
420 struct edge_prediction *ep_next;
421 edge ep_edge;
422 enum br_predictor ep_predictor;
423 int ep_probability;
426 /* Accessors for basic block annotations. */
427 static inline tree phi_nodes (basic_block);
428 static inline void set_phi_nodes (basic_block, tree);
430 /*---------------------------------------------------------------------------
431 Global declarations
432 ---------------------------------------------------------------------------*/
433 struct int_tree_map GTY(())
436 unsigned int uid;
437 tree to;
440 extern unsigned int int_tree_map_hash (const void *);
441 extern int int_tree_map_eq (const void *, const void *);
443 typedef struct
445 htab_iterator hti;
446 } referenced_var_iterator;
449 /* This macro loops over all the referenced vars, one at a time, putting the
450 current var in VAR. Note: You are not allowed to add referenced variables
451 to the hashtable while using this macro. Doing so may cause it to behave
452 erratically. */
454 #define FOR_EACH_REFERENCED_VAR(VAR, ITER) \
455 for ((VAR) = first_referenced_var (&(ITER)); \
456 !end_referenced_vars_p (&(ITER)); \
457 (VAR) = next_referenced_var (&(ITER)))
460 typedef struct
462 int i;
463 } safe_referenced_var_iterator;
465 /* This macro loops over all the referenced vars, one at a time, putting the
466 current var in VAR. You are allowed to add referenced variables during the
467 execution of this macro, however, the macro will not iterate over them. It
468 requires a temporary vector of trees, VEC, whose lifetime is controlled by
469 the caller. The purpose of the vector is to temporarily store the
470 referenced_variables hashtable so that adding referenced variables does not
471 affect the hashtable. */
473 #define FOR_EACH_REFERENCED_VAR_SAFE(VAR, VEC, ITER) \
474 for ((ITER).i = 0, fill_referenced_var_vec (&(VEC)); \
475 VEC_iterate (tree, (VEC), (ITER).i, (VAR)); \
476 (ITER).i++)
478 extern tree referenced_var_lookup (unsigned int);
479 extern bool referenced_var_check_and_insert (tree);
480 #define num_referenced_vars htab_elements (gimple_referenced_vars (cfun))
481 #define referenced_var(i) referenced_var_lookup (i)
483 #define num_ssa_names (VEC_length (tree, cfun->gimple_df->ssa_names))
484 #define ssa_name(i) (VEC_index (tree, cfun->gimple_df->ssa_names, (i)))
486 /* Macros for showing usage statistics. */
487 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
488 ? (x) \
489 : ((x) < 1024*1024*10 \
490 ? (x) / 1024 \
491 : (x) / (1024*1024))))
493 #define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
495 #define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y))
497 /*---------------------------------------------------------------------------
498 Block iterators
499 ---------------------------------------------------------------------------*/
501 typedef struct {
502 tree_stmt_iterator tsi;
503 basic_block bb;
504 } block_stmt_iterator;
506 static inline block_stmt_iterator bsi_start (basic_block);
507 static inline block_stmt_iterator bsi_last (basic_block);
508 static inline block_stmt_iterator bsi_after_labels (basic_block);
509 block_stmt_iterator bsi_for_stmt (tree);
510 static inline bool bsi_end_p (block_stmt_iterator);
511 static inline void bsi_next (block_stmt_iterator *);
512 static inline void bsi_prev (block_stmt_iterator *);
513 static inline tree bsi_stmt (block_stmt_iterator);
514 static inline tree * bsi_stmt_ptr (block_stmt_iterator);
516 extern void bsi_remove (block_stmt_iterator *, bool);
517 extern void bsi_move_before (block_stmt_iterator *, block_stmt_iterator *);
518 extern void bsi_move_after (block_stmt_iterator *, block_stmt_iterator *);
519 extern void bsi_move_to_bb_end (block_stmt_iterator *, basic_block);
521 enum bsi_iterator_update
523 /* Note that these are intentionally in the same order as TSI_FOO. They
524 mean exactly the same as their TSI_* counterparts. */
525 BSI_NEW_STMT,
526 BSI_SAME_STMT,
527 BSI_CHAIN_START,
528 BSI_CHAIN_END,
529 BSI_CONTINUE_LINKING
532 extern void bsi_insert_before (block_stmt_iterator *, tree,
533 enum bsi_iterator_update);
534 extern void bsi_insert_after (block_stmt_iterator *, tree,
535 enum bsi_iterator_update);
537 extern void bsi_replace (const block_stmt_iterator *, tree, bool);
539 /*---------------------------------------------------------------------------
540 OpenMP Region Tree
541 ---------------------------------------------------------------------------*/
543 /* Parallel region information. Every parallel and workshare
544 directive is enclosed between two markers, the OMP_* directive
545 and a corresponding OMP_RETURN statement. */
547 struct omp_region
549 /* The enclosing region. */
550 struct omp_region *outer;
552 /* First child region. */
553 struct omp_region *inner;
555 /* Next peer region. */
556 struct omp_region *next;
558 /* Block containing the omp directive as its last stmt. */
559 basic_block entry;
561 /* Block containing the OMP_RETURN as its last stmt. */
562 basic_block exit;
564 /* Block containing the OMP_CONTINUE as its last stmt. */
565 basic_block cont;
567 /* If this is a combined parallel+workshare region, this is a list
568 of additional arguments needed by the combined parallel+workshare
569 library call. */
570 tree ws_args;
572 /* The code for the omp directive of this region. */
573 enum tree_code type;
575 /* Schedule kind, only used for OMP_FOR type regions. */
576 enum omp_clause_schedule_kind sched_kind;
578 /* True if this is a combined parallel+workshare region. */
579 bool is_combined_parallel;
582 extern struct omp_region *root_omp_region;
583 extern struct omp_region *new_omp_region (basic_block, enum tree_code,
584 struct omp_region *);
585 extern void free_omp_regions (void);
587 /*---------------------------------------------------------------------------
588 Function prototypes
589 ---------------------------------------------------------------------------*/
590 /* In tree-cfg.c */
592 /* Location to track pending stmt for edge insertion. */
593 #define PENDING_STMT(e) ((e)->insns.t)
595 extern void delete_tree_cfg_annotations (void);
596 extern void disband_implicit_edges (void);
597 extern bool stmt_ends_bb_p (tree);
598 extern bool is_ctrl_stmt (tree);
599 extern bool is_ctrl_altering_stmt (tree);
600 extern bool computed_goto_p (tree);
601 extern bool simple_goto_p (tree);
602 extern bool tree_can_make_abnormal_goto (tree);
603 extern basic_block single_noncomplex_succ (basic_block bb);
604 extern void tree_dump_bb (basic_block, FILE *, int);
605 extern void debug_tree_bb (basic_block);
606 extern basic_block debug_tree_bb_n (int);
607 extern void dump_tree_cfg (FILE *, int);
608 extern void debug_tree_cfg (int);
609 extern void dump_cfg_stats (FILE *);
610 extern void debug_cfg_stats (void);
611 extern void debug_loop_ir (void);
612 extern void print_loop_ir (FILE *);
613 extern void cleanup_dead_labels (void);
614 extern void group_case_labels (void);
615 extern tree first_stmt (basic_block);
616 extern tree last_stmt (basic_block);
617 extern tree *last_stmt_ptr (basic_block);
618 extern tree last_and_only_stmt (basic_block);
619 extern edge find_taken_edge (basic_block, tree);
620 extern basic_block label_to_block_fn (struct function *, tree);
621 #define label_to_block(t) (label_to_block_fn (cfun, t))
622 extern void bsi_insert_on_edge (edge, tree);
623 extern basic_block bsi_insert_on_edge_immediate (edge, tree);
624 extern void bsi_commit_one_edge_insert (edge, basic_block *);
625 extern void bsi_commit_edge_inserts (void);
626 extern void notice_special_calls (tree);
627 extern void clear_special_calls (void);
628 extern void verify_stmts (void);
629 extern tree tree_block_label (basic_block);
630 extern void extract_true_false_edges_from_block (basic_block, edge *, edge *);
631 extern bool tree_duplicate_sese_region (edge, edge, basic_block *, unsigned,
632 basic_block *);
633 extern void add_phi_args_after_copy_bb (basic_block);
634 extern void add_phi_args_after_copy (basic_block *, unsigned);
635 extern bool tree_purge_dead_abnormal_call_edges (basic_block);
636 extern bool tree_purge_dead_eh_edges (basic_block);
637 extern bool tree_purge_all_dead_eh_edges (bitmap);
638 extern tree gimplify_val (block_stmt_iterator *, tree, tree);
639 extern tree gimplify_build1 (block_stmt_iterator *, enum tree_code,
640 tree, tree);
641 extern tree gimplify_build2 (block_stmt_iterator *, enum tree_code,
642 tree, tree, tree);
643 extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code,
644 tree, tree, tree, tree);
645 extern void init_empty_tree_cfg (void);
646 extern void fold_cond_expr_cond (void);
647 extern void make_abnormal_goto_edges (basic_block, bool);
648 extern void replace_uses_by (tree, tree);
649 extern void start_recording_case_labels (void);
650 extern void end_recording_case_labels (void);
651 extern basic_block move_sese_region_to_fn (struct function *, basic_block,
652 basic_block);
654 /* In tree-cfgcleanup.c */
655 extern bool cleanup_tree_cfg (void);
656 extern void cleanup_tree_cfg_loop (void);
658 /* In tree-pretty-print.c. */
659 extern void dump_generic_bb (FILE *, basic_block, int, int);
661 /* In tree-dfa.c */
662 extern var_ann_t create_var_ann (tree);
663 extern function_ann_t create_function_ann (tree);
664 extern stmt_ann_t create_stmt_ann (tree);
665 extern tree_ann_common_t create_tree_common_ann (tree);
666 extern void dump_dfa_stats (FILE *);
667 extern void debug_dfa_stats (void);
668 extern void debug_referenced_vars (void);
669 extern void dump_referenced_vars (FILE *);
670 extern void dump_variable (FILE *, tree);
671 extern void debug_variable (tree);
672 extern void dump_subvars_for (FILE *, tree);
673 extern void debug_subvars_for (tree);
674 extern tree get_virtual_var (tree);
675 extern void add_referenced_var (tree);
676 extern void mark_new_vars_to_rename (tree);
677 extern void find_new_referenced_vars (tree *);
679 extern tree make_rename_temp (tree, const char *);
680 extern void set_default_def (tree, tree);
681 extern tree gimple_default_def (struct function *, tree);
683 /* In tree-phinodes.c */
684 extern void reserve_phi_args_for_new_edge (basic_block);
685 extern tree create_phi_node (tree, basic_block);
686 extern void add_phi_arg (tree, tree, edge);
687 extern void remove_phi_args (edge);
688 extern void remove_phi_node (tree, tree);
689 extern tree phi_reverse (tree);
691 /* In gimple-low.c */
692 extern void record_vars_into (tree, tree);
693 extern void record_vars (tree);
694 extern bool block_may_fallthru (tree);
696 /* In tree-ssa-alias.c */
697 extern void dump_may_aliases_for (FILE *, tree);
698 extern void debug_may_aliases_for (tree);
699 extern void dump_alias_info (FILE *);
700 extern void debug_alias_info (void);
701 extern void dump_points_to_info (FILE *);
702 extern void debug_points_to_info (void);
703 extern void dump_points_to_info_for (FILE *, tree);
704 extern void debug_points_to_info_for (tree);
705 extern bool may_be_aliased (tree);
706 extern bool is_aliased_with (tree, tree);
707 extern struct ptr_info_def *get_ptr_info (tree);
708 extern void new_type_alias (tree, tree, tree);
709 extern void count_uses_and_derefs (tree, tree, unsigned *, unsigned *, bool *);
710 static inline subvar_t get_subvars_for_var (tree);
711 static inline tree get_subvar_at (tree, unsigned HOST_WIDE_INT);
712 static inline bool ref_contains_array_ref (tree);
713 static inline bool array_ref_contains_indirect_ref (tree);
714 extern tree get_ref_base_and_extent (tree, HOST_WIDE_INT *,
715 HOST_WIDE_INT *, HOST_WIDE_INT *);
716 static inline bool var_can_have_subvars (tree);
717 static inline bool overlap_subvar (unsigned HOST_WIDE_INT,
718 unsigned HOST_WIDE_INT,
719 tree, bool *);
721 /* Call-back function for walk_use_def_chains(). At each reaching
722 definition, a function with this prototype is called. */
723 typedef bool (*walk_use_def_chains_fn) (tree, tree, void *);
726 /* In tree-ssa.c */
727 extern void init_tree_ssa (void);
728 extern edge ssa_redirect_edge (edge, basic_block);
729 extern void flush_pending_stmts (edge);
730 extern bool tree_ssa_useless_type_conversion (tree);
731 extern bool tree_ssa_useless_type_conversion_1 (tree, tree);
732 extern void verify_ssa (bool);
733 extern void delete_tree_ssa (void);
734 extern void register_new_def (tree, VEC(tree,heap) **);
735 extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool);
736 extern bool stmt_references_memory_p (tree);
738 /* In tree-into-ssa.c */
739 void update_ssa (unsigned);
740 void delete_update_ssa (void);
741 void register_new_name_mapping (tree, tree);
742 tree create_new_def_for (tree, tree, def_operand_p);
743 bool need_ssa_update_p (void);
744 bool name_mappings_registered_p (void);
745 bool name_registered_for_update_p (tree);
746 bitmap ssa_names_to_replace (void);
747 void release_ssa_name_after_update_ssa (tree name);
748 void compute_global_livein (bitmap, bitmap);
749 tree duplicate_ssa_name (tree, tree);
750 void mark_sym_for_renaming (tree);
751 void mark_set_for_renaming (bitmap);
752 tree get_current_def (tree);
753 void set_current_def (tree, tree);
755 /* In tree-ssa-ccp.c */
756 bool fold_stmt (tree *);
757 bool fold_stmt_inplace (tree);
758 tree widen_bitfield (tree, tree, tree);
760 /* In tree-vrp.c */
761 tree vrp_evaluate_conditional (tree, bool);
762 void simplify_stmt_using_ranges (tree);
764 /* In tree-ssa-dom.c */
765 extern void dump_dominator_optimization_stats (FILE *);
766 extern void debug_dominator_optimization_stats (void);
767 int loop_depth_of_name (tree);
769 /* In tree-ssa-copy.c */
770 extern void merge_alias_info (tree, tree);
771 extern void propagate_value (use_operand_p, tree);
772 extern void propagate_tree_value (tree *, tree);
773 extern void replace_exp (use_operand_p, tree);
774 extern bool may_propagate_copy (tree, tree);
775 extern bool may_propagate_copy_into_asm (tree);
777 /* Affine iv. */
779 typedef struct
781 /* Iv = BASE + STEP * i. */
782 tree base, step;
784 /* True if this iv does not overflow. */
785 bool no_overflow;
786 } affine_iv;
788 /* Description of number of iterations of a loop. All the expressions inside
789 the structure can be evaluated at the end of the loop's preheader
790 (and due to ssa form, also anywhere inside the body of the loop). */
792 struct tree_niter_desc
794 tree assumptions; /* The boolean expression. If this expression evaluates
795 to false, then the other fields in this structure
796 should not be used; there is no guarantee that they
797 will be correct. */
798 tree may_be_zero; /* The boolean expression. If it evaluates to true,
799 the loop will exit in the first iteration (i.e.
800 its latch will not be executed), even if the niter
801 field says otherwise. */
802 tree niter; /* The expression giving the number of iterations of
803 a loop (provided that assumptions == true and
804 may_be_zero == false), more precisely the number
805 of executions of the latch of the loop. */
806 tree additional_info; /* The boolean expression. Sometimes we use additional
807 knowledge to simplify the other expressions
808 contained in this structure (for example the
809 knowledge about value ranges of operands on entry to
810 the loop). If this is a case, conjunction of such
811 condition is stored in this field, so that we do not
812 lose the information: for example if may_be_zero
813 is (n <= 0) and niter is (unsigned) n, we know
814 that the number of iterations is at most
815 MAX_SIGNED_INT. However if the (n <= 0) assumption
816 is eliminated (by looking at the guard on entry of
817 the loop), then the information would be lost. */
819 /* The simplified shape of the exit condition. The loop exits if
820 CONTROL CMP BOUND is false, where CMP is one of NE_EXPR,
821 LT_EXPR, or GT_EXPR, and step of CONTROL is positive if CMP is
822 LE_EXPR and negative if CMP is GE_EXPR. This information is used
823 by loop unrolling. */
824 affine_iv control;
825 tree bound;
826 enum tree_code cmp;
829 /* In tree-vectorizer.c */
830 unsigned vectorize_loops (void);
831 extern bool vect_can_force_dr_alignment_p (tree, unsigned int);
832 extern tree get_vectype_for_scalar_type (tree);
834 /* In tree-ssa-phiopt.c */
835 bool empty_block_p (basic_block);
837 /* In tree-ssa-loop*.c */
839 void tree_ssa_lim (void);
840 unsigned int tree_ssa_unswitch_loops (void);
841 unsigned int canonicalize_induction_variables (void);
842 unsigned int tree_unroll_loops_completely (bool);
843 unsigned int tree_ssa_prefetch_arrays (void);
844 unsigned int remove_empty_loops (void);
845 void tree_ssa_iv_optimize (void);
847 bool number_of_iterations_exit (struct loop *, edge,
848 struct tree_niter_desc *niter, bool);
849 tree find_loop_niter (struct loop *, edge *);
850 tree loop_niter_by_eval (struct loop *, edge);
851 tree find_loop_niter_by_eval (struct loop *, edge *);
852 void estimate_numbers_of_iterations (void);
853 bool scev_probably_wraps_p (tree, tree, tree, struct loop *, bool);
854 bool convert_affine_scev (struct loop *, tree, tree *, tree *, tree, bool);
856 bool nowrap_type_p (tree);
857 enum ev_direction {EV_DIR_GROWS, EV_DIR_DECREASES, EV_DIR_UNKNOWN};
858 enum ev_direction scev_direction (tree);
860 void free_numbers_of_iterations_estimates (void);
861 void free_numbers_of_iterations_estimates_loop (struct loop *);
862 void rewrite_into_loop_closed_ssa (bitmap, unsigned);
863 void verify_loop_closed_ssa (void);
864 bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *);
865 void create_iv (tree, tree, tree, struct loop *, block_stmt_iterator *, bool,
866 tree *, tree *);
867 void split_loop_exit_edge (edge);
868 unsigned force_expr_to_var_cost (tree);
869 void standard_iv_increment_position (struct loop *, block_stmt_iterator *,
870 bool *);
871 basic_block ip_end_pos (struct loop *);
872 basic_block ip_normal_pos (struct loop *);
873 bool tree_duplicate_loop_to_header_edge (struct loop *, edge,
874 unsigned int, sbitmap,
875 edge, edge *,
876 unsigned int *, int);
877 struct loop *tree_ssa_loop_version (struct loop *, tree,
878 basic_block *);
879 tree expand_simple_operations (tree);
880 void substitute_in_loop_info (struct loop *, tree, tree);
881 edge single_dom_exit (struct loop *);
882 bool can_unroll_loop_p (struct loop *loop, unsigned factor,
883 struct tree_niter_desc *niter);
884 void tree_unroll_loop (struct loop *, unsigned,
885 edge, struct tree_niter_desc *);
886 bool contains_abnormal_ssa_name_p (tree);
888 /* In tree-ssa-threadedge.c */
889 extern bool potentially_threadable_block (basic_block);
890 extern void thread_across_edge (tree, edge, bool,
891 VEC(tree, heap) **, tree (*) (tree));
893 /* In tree-ssa-loop-im.c */
894 /* The possibilities of statement movement. */
896 enum move_pos
898 MOVE_IMPOSSIBLE, /* No movement -- side effect expression. */
899 MOVE_PRESERVE_EXECUTION, /* Must not cause the non-executed statement
900 become executed -- memory accesses, ... */
901 MOVE_POSSIBLE /* Unlimited movement. */
903 extern enum move_pos movement_possibility (tree);
905 /* The reasons a variable may escape a function. */
906 enum escape_type
908 NO_ESCAPE = 0, /* Doesn't escape. */
909 ESCAPE_STORED_IN_GLOBAL = 1 << 1,
910 ESCAPE_TO_ASM = 1 << 2, /* Passed by address to an assembly
911 statement. */
912 ESCAPE_TO_CALL = 1 << 3, /* Escapes to a function call. */
913 ESCAPE_BAD_CAST = 1 << 4, /* Cast from pointer to integer */
914 ESCAPE_TO_RETURN = 1 << 5, /* Returned from function. */
915 ESCAPE_TO_PURE_CONST = 1 << 6, /* Escapes to a pure or constant
916 function call. */
917 ESCAPE_IS_GLOBAL = 1 << 7, /* Is a global variable. */
918 ESCAPE_IS_PARM = 1 << 8, /* Is an incoming function parameter. */
919 ESCAPE_UNKNOWN = 1 << 9 /* We believe it escapes for some reason
920 not enumerated above. */
923 /* In tree-flow-inline.h */
924 static inline bool is_call_clobbered (tree);
925 static inline void mark_call_clobbered (tree, unsigned int);
926 static inline void set_is_used (tree);
927 static inline bool unmodifiable_var_p (tree);
929 /* In tree-eh.c */
930 extern void make_eh_edges (tree);
931 extern bool tree_could_trap_p (tree);
932 extern bool tree_could_throw_p (tree);
933 extern bool tree_can_throw_internal (tree);
934 extern bool tree_can_throw_external (tree);
935 extern int lookup_stmt_eh_region (tree);
936 extern void add_stmt_to_eh_region (tree, int);
937 extern bool remove_stmt_from_eh_region (tree);
938 extern bool maybe_clean_or_replace_eh_stmt (tree, tree);
940 /* In tree-ssa-pre.c */
941 void add_to_value (tree, tree);
942 void debug_value_expressions (tree);
943 void print_value_expressions (FILE *, tree);
946 /* In tree-vn.c */
947 bool expressions_equal_p (tree, tree);
948 static inline tree get_value_handle (tree);
949 hashval_t vn_compute (tree, hashval_t);
950 void sort_vuses (VEC (tree, gc) *);
951 tree vn_lookup_or_add (tree, tree);
952 tree vn_lookup_or_add_with_vuses (tree, VEC (tree, gc) *);
953 void vn_add (tree, tree);
954 void vn_add_with_vuses (tree, tree, VEC (tree, gc) *);
955 tree vn_lookup (tree, tree);
956 tree vn_lookup_with_vuses (tree, VEC (tree, gc) *);
957 void vn_init (void);
958 void vn_delete (void);
960 /* In tree-ssa-sink.c */
961 bool is_hidden_global_store (tree);
963 /* In tree-sra.c */
964 void insert_edge_copies (tree, basic_block);
965 void sra_insert_before (block_stmt_iterator *, tree);
966 void sra_insert_after (block_stmt_iterator *, tree);
967 void sra_init_cache (void);
968 bool sra_type_can_be_decomposed_p (tree);
970 /* In tree-loop-linear.c */
971 extern void linear_transform_loops (void);
973 /* In tree-ssa-loop-ivopts.c */
974 bool expr_invariant_in_loop_p (struct loop *, tree);
975 bool multiplier_allowed_in_address_p (HOST_WIDE_INT, enum machine_mode);
976 unsigned multiply_by_cost (HOST_WIDE_INT, enum machine_mode);
978 /* In tree-ssa-threadupdate.c. */
979 extern bool thread_through_all_blocks (void);
980 extern void register_jump_thread (edge, edge);
982 /* In gimplify.c */
983 tree force_gimple_operand (tree, tree *, bool, tree);
984 tree force_gimple_operand_bsi (block_stmt_iterator *, tree, bool, tree);
986 /* In tree-ssa-structalias.c */
987 bool find_what_p_points_to (tree);
989 /* In tree-ssa-live.c */
990 extern void remove_unused_locals (void);
992 /* In tree-ssa-address.c */
994 /* Affine combination of trees. We keep track of at most MAX_AFF_ELTS elements
995 to make things simpler; this is sufficient in most cases. */
997 #define MAX_AFF_ELTS 8
999 struct affine_tree_combination
1001 /* Type of the result of the combination. */
1002 tree type;
1004 /* Mask modulo that the operations are performed. */
1005 unsigned HOST_WIDE_INT mask;
1007 /* Constant offset. */
1008 unsigned HOST_WIDE_INT offset;
1010 /* Number of elements of the combination. */
1011 unsigned n;
1013 /* Elements and their coefficients. */
1014 tree elts[MAX_AFF_ELTS];
1015 unsigned HOST_WIDE_INT coefs[MAX_AFF_ELTS];
1017 /* Remainder of the expression. */
1018 tree rest;
1021 /* Description of a memory address. */
1023 struct mem_address
1025 tree symbol, base, index, step, offset;
1028 tree create_mem_ref (block_stmt_iterator *, tree,
1029 struct affine_tree_combination *);
1030 rtx addr_for_mem_ref (struct mem_address *, bool);
1031 void get_address_description (tree, struct mem_address *);
1032 tree maybe_fold_tmr (tree);
1034 /* This structure is simply used during pushing fields onto the fieldstack
1035 to track the offset of the field, since bitpos_of_field gives it relative
1036 to its immediate containing type, and we want it relative to the ultimate
1037 containing object. */
1039 struct fieldoff
1041 tree type;
1042 tree size;
1043 tree decl;
1044 HOST_WIDE_INT offset;
1046 typedef struct fieldoff fieldoff_s;
1048 DEF_VEC_O(fieldoff_s);
1049 DEF_VEC_ALLOC_O(fieldoff_s,heap);
1050 int push_fields_onto_fieldstack (tree, VEC(fieldoff_s,heap) **,
1051 HOST_WIDE_INT, bool *);
1052 void sort_fieldstack (VEC(fieldoff_s,heap) *);
1054 void init_alias_heapvars (void);
1055 void delete_alias_heapvars (void);
1057 #include "tree-flow-inline.h"
1059 void swap_tree_operands (tree, tree *, tree *);
1061 extern void recalculate_used_alone (void);
1062 extern bool updating_used_alone;
1064 int least_common_multiple (int, int);
1066 #endif /* _TREE_FLOW_H */