OSDN Git Service

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