OSDN Git Service

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