OSDN Git Service

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