OSDN Git Service

* c-common.c, cfgexpand.c, cgraphunit.c, defaults.h,
[pf3gnuchains/gcc-fork.git] / gcc / tree-flow.h
1 /* Data and Control Flow Analysis for Trees.
2    Copyright (C) 2001, 2003, 2004 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, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, 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
32 /* Forward declare structures for the garbage collector GTY markers.  */
33 #ifndef GCC_BASIC_BLOCK_H
34 struct edge_def;
35 typedef struct edge_def *edge;
36 struct basic_block_def;
37 typedef struct basic_block_def *basic_block;
38 #endif
39
40 /*---------------------------------------------------------------------------
41                       Attributes for SSA_NAMEs.
42   
43   NOTE: These structures are stored in struct tree_ssa_name
44   but are only used by the tree optimizers, so it makes better sense
45   to declare them here to avoid recompiling unrelated files when
46   making changes.
47 ---------------------------------------------------------------------------*/
48
49 /* Aliasing information for SSA_NAMEs representing pointer variables.  */
50 struct ptr_info_def GTY(())
51 {
52   /* Nonzero if points-to analysis couldn't determine where this pointer
53      is pointing to.  */
54   unsigned int pt_anything : 1;
55
56   /* Nonzero if this pointer is the result of a call to malloc.  */
57   unsigned int pt_malloc : 1;
58
59   /* Nonzero if the value of this pointer escapes the current function.  */
60   unsigned int value_escapes_p : 1;
61
62   /* Nonzero if this pointer is dereferenced.  */
63   unsigned int is_dereferenced : 1;
64
65   /* Nonzero if this pointer points to a global variable.  */
66   unsigned int pt_global_mem : 1;
67
68   /* Set of variables that this pointer may point to.  */
69   bitmap pt_vars;
70
71   /* If this pointer has been dereferenced, and points-to information is
72      more precise than type-based aliasing, indirect references to this
73      pointer will be represented by this memory tag, instead of the type
74      tag computed by TBAA.  */
75   tree name_mem_tag;
76 };
77
78
79 /*---------------------------------------------------------------------------
80                    Tree annotations stored in tree_common.ann
81 ---------------------------------------------------------------------------*/
82 enum tree_ann_type { TREE_ANN_COMMON, VAR_ANN, STMT_ANN };
83
84 struct tree_ann_common_d GTY(())
85 {
86   /* Annotation type.  */
87   enum tree_ann_type type;
88
89  /* Auxiliary info specific to a pass.  At all times, this
90     should either point to valid data or be NULL.  */
91   PTR GTY ((skip (""))) aux;
92
93   /* The value handle for this expression.  Used by GVN-PRE.  */
94   tree GTY((skip)) value_handle;
95 };
96
97 /* It is advantageous to avoid things like life analysis for variables which
98    do not need PHI nodes.  This enum describes whether or not a particular
99    variable may need a PHI node.  */
100
101 enum need_phi_state {
102   /* This is the default.  If we are still in this state after finding
103      all the definition and use sites, then we will assume the variable
104      needs PHI nodes.  This is probably an overly conservative assumption.  */
105   NEED_PHI_STATE_UNKNOWN,
106
107   /* This state indicates that we have seen one or more sets of the 
108      variable in a single basic block and that the sets dominate all
109      uses seen so far.  If after finding all definition and use sites
110      we are still in this state, then the variable does not need any
111      PHI nodes.  */
112   NEED_PHI_STATE_NO,
113
114   /* This state indicates that we have either seen multiple definitions of
115      the variable in multiple blocks, or that we encountered a use in a
116      block that was not dominated by the block containing the set(s) of
117      this variable.  This variable is assumed to need PHI nodes.  */
118   NEED_PHI_STATE_MAYBE
119 };
120
121
122 /* When computing aliasing information, we represent the memory pointed-to
123    by pointers with artificial variables called "memory tags" (MT).  There
124    are two kinds of tags: type and name.  Type tags (TMT) are used in
125    type-based alias analysis, they represent all the pointed-to locations
126    and variables of the same alias set class.  Name tags (NMT) are used in
127    flow-sensitive points-to alias analysis, they represent the variables
128    and memory locations pointed-to by a specific SSA_NAME pointer.  */
129 enum mem_tag_kind {
130   /* This variable is not a memory tag.  */
131   NOT_A_TAG,
132
133   /* This variable is a type memory tag (TMT).  */
134   TYPE_TAG,
135
136   /* This variable is a name memory tag (NMT).  */
137   NAME_TAG
138 };
139
140 struct var_ann_d GTY(())
141 {
142   struct tree_ann_common_d common;
143
144   /* Used by the out of SSA pass to determine whether this variable has
145      been seen yet or not.  */
146   unsigned out_of_ssa_tag : 1;
147
148   /* Used when building root_var structures in tree_ssa_live.[ch].  */
149   unsigned root_var_processed : 1;
150
151   /* If nonzero, this variable is a memory tag.  */
152   ENUM_BITFIELD (mem_tag_kind) mem_tag_kind : 2;
153
154   /* Nonzero if this variable is an alias tag that represents references to
155      other variables (i.e., this variable appears in the MAY_ALIASES array
156      of other variables).  */
157   unsigned is_alias_tag : 1;
158
159   /* Nonzero if this variable was used after SSA optimizations were
160      applied.  We set this when translating out of SSA form.  */
161   unsigned used : 1;
162
163   /* This field indicates whether or not the variable may need PHI nodes.
164      See the enum's definition for more detailed information about the
165      states.  */
166   ENUM_BITFIELD (need_phi_state) need_phi_state : 2;
167
168   /* An artificial variable representing the memory location pointed-to by
169      all the pointers that TBAA (type-based alias analysis) considers
170      to be aliased.  If the variable is not a pointer or if it is never
171      dereferenced, this must be NULL.  */
172   tree type_mem_tag;
173
174   /* Variables that may alias this variable.  */
175   varray_type may_aliases;
176
177   /* Unique ID of this variable.  */
178   size_t uid;
179
180   /* Used when going out of SSA form to indicate which partition this
181      variable represents storage for.  */
182   unsigned partition;
183
184   /* Used by the root-var object in tree-ssa-live.[ch].  */
185   unsigned root_index;
186
187   /* Default definition for this symbol.  If this field is not NULL, it
188      means that the first reference to this variable in the function is a
189      USE or a VUSE.  In those cases, the SSA renamer creates an SSA name
190      for this variable with an empty defining statement.  */
191   tree default_def;
192
193   /* During into-ssa and the dominator optimizer, this field holds the
194      current version of this variable (an SSA_NAME). 
195
196      This was previously two varrays (one in into-ssa the other in the
197      dominator optimizer).  That is wasteful, particularly since the
198      dominator optimizer calls into-ssa resulting in having two varrays
199      live at the same time and this can happen for each call to the
200      dominator optimizer.  */
201   tree current_def;
202 };
203
204
205 struct dataflow_d GTY(())
206 {
207   /* Immediate uses.  This is a list of all the statements and PHI nodes
208      that are immediately reached by the definitions made in this
209      statement.  */
210   varray_type immediate_uses;
211
212   /* Use this array for very small numbers of uses instead of the varray.  */
213   tree uses[2];
214
215   /* Reached uses.  This is a list of all the possible program statements
216      that may be reached directly or indirectly by definitions made in this
217      statement.  Notice that this is a superset of IMMEDIATE_USES.
218      For instance, given the following piece of code:
219
220             1   a1 = 10;
221             2   if (a1 > 3)
222             3     a2 = a1 + 5;
223             4   a3 = PHI (a1, a2)
224             5   b1 = a3 - 2;
225
226      IMMEDIATE_USES for statement #1 are all those statements that use a1
227      directly (i.e., #2, #3 and #4).  REACHED_USES for statement #1 also
228      includes statement #5 because 'a1' could reach 'a3' via the PHI node
229      at statement #4.  The set of REACHED_USES is then the transitive
230      closure over all the PHI nodes in the IMMEDIATE_USES set.  */
231
232   /* Reaching definitions.  Similarly to REACHED_USES, the set
233      REACHING_DEFS is the set of all the statements that make definitions
234      that may reach this statement.  Notice that we don't need to have a
235      similar entry for immediate definitions, as these are represented by
236      the SSA_NAME nodes themselves (each SSA_NAME node contains a pointer
237      to the statement that makes that definition).  */
238 };
239
240 typedef struct dataflow_d *dataflow_t;
241
242
243 struct stmt_ann_d GTY(())
244 {
245   struct tree_ann_common_d common;
246
247   /* Nonzero if the statement has been modified (meaning that the operands
248      need to be scanned again).  */
249   unsigned modified : 1;
250
251   /* Nonzero if the statement makes aliased loads.  */
252   unsigned makes_aliased_loads : 1;
253
254   /* Nonzero if the statement makes aliased stores.  */
255   unsigned makes_aliased_stores : 1;
256
257   /* Nonzero if the statement makes references to volatile storage.  */
258   unsigned has_volatile_ops : 1;
259
260   /* Nonzero if the statement makes a function call that may clobber global
261      and local addressable variables.  */
262   unsigned makes_clobbering_call : 1;
263
264   /* Basic block that contains this statement.  */
265   basic_block GTY ((skip (""))) bb;
266
267   struct stmt_operands_d operands;
268
269   /* Dataflow information.  */
270   dataflow_t df;
271
272   /* Set of variables that have had their address taken in the statement.  */
273   bitmap addresses_taken;
274
275   /* Unique identifier for this statement.  These ID's are to be created
276      by each pass on an as-needed basis in any order convenient for the
277      pass which needs statement UIDs.  */
278   unsigned int uid;
279 };
280
281 union tree_ann_d GTY((desc ("ann_type ((tree_ann_t)&%h)")))
282 {
283   struct tree_ann_common_d GTY((tag ("TREE_ANN_COMMON"))) common;
284   struct var_ann_d GTY((tag ("VAR_ANN"))) decl;
285   struct stmt_ann_d GTY((tag ("STMT_ANN"))) stmt;
286 };
287
288 typedef union tree_ann_d *tree_ann_t;
289 typedef struct var_ann_d *var_ann_t;
290 typedef struct stmt_ann_d *stmt_ann_t;
291
292 static inline tree_ann_t tree_ann (tree);
293 static inline tree_ann_t get_tree_ann (tree);
294 static inline var_ann_t var_ann (tree);
295 static inline var_ann_t get_var_ann (tree);
296 static inline stmt_ann_t stmt_ann (tree);
297 static inline stmt_ann_t get_stmt_ann (tree);
298 static inline enum tree_ann_type ann_type (tree_ann_t);
299 static inline basic_block bb_for_stmt (tree);
300 extern void set_bb_for_stmt (tree, basic_block);
301 static inline void modify_stmt (tree);
302 static inline void unmodify_stmt (tree);
303 static inline bool stmt_modified_p (tree);
304 static inline varray_type may_aliases (tree);
305 static inline int get_lineno (tree);
306 static inline const char *get_filename (tree);
307 static inline bool is_exec_stmt (tree);
308 static inline bool is_label_stmt (tree);
309 static inline v_may_def_optype get_v_may_def_ops (stmt_ann_t);
310 static inline vuse_optype get_vuse_ops (stmt_ann_t);
311 static inline use_optype get_use_ops (stmt_ann_t);
312 static inline def_optype get_def_ops (stmt_ann_t);
313 static inline bitmap addresses_taken (tree);
314 static inline int num_immediate_uses (dataflow_t);
315 static inline tree immediate_use (dataflow_t, int);
316 static inline dataflow_t get_immediate_uses (tree);
317 static inline void set_default_def (tree, tree);
318 static inline tree default_def (tree);
319
320 /*---------------------------------------------------------------------------
321                   Structure representing predictions in tree level.
322 ---------------------------------------------------------------------------*/
323 struct edge_prediction GTY((chain_next ("%h.next")))
324 {
325   struct edge_prediction *next;
326   edge edge;
327   enum br_predictor predictor;
328   int probability;
329 };
330
331 /*---------------------------------------------------------------------------
332                   Block annotations stored in basic_block.tree_annotations
333 ---------------------------------------------------------------------------*/
334 struct bb_ann_d GTY(())
335 {
336   /* Chain of PHI nodes for this block.  */
337   tree phi_nodes;
338
339   /* Number of predecessors for this block.  This is only valid during
340      SSA rewriting.  It is not maintained after conversion into SSA form.  */
341   int num_preds;
342
343   /* Nonzero if this block is forwardable during cfg cleanups.  This is also
344      used to detect loops during cfg cleanups.  */
345   unsigned forwardable: 1;
346
347   /* Nonzero if this block contains an escape point (see is_escape_site).  */
348   unsigned has_escape_site : 1;
349
350   /* Nonzero if one or more incoming edges to this block should be threaded
351      to an outgoing edge of this block.  */
352   unsigned incoming_edge_threaded : 1;
353
354   struct edge_prediction *predictions;
355 };
356
357 typedef struct bb_ann_d *bb_ann_t;
358
359 /* Accessors for basic block annotations.  */
360 static inline bb_ann_t bb_ann (basic_block);
361 static inline tree phi_nodes (basic_block);
362 static inline void set_phi_nodes (basic_block, tree);
363
364 /*---------------------------------------------------------------------------
365                               Global declarations
366 ---------------------------------------------------------------------------*/
367 /* Array of all variables referenced in the function.  */
368 extern GTY(()) varray_type referenced_vars;
369
370 #define num_referenced_vars VARRAY_ACTIVE_SIZE (referenced_vars)
371 #define referenced_var(i) VARRAY_TREE (referenced_vars, i)
372
373 /* Array of all SSA_NAMEs used in the function.  */
374 extern GTY(()) varray_type ssa_names;
375
376 #define num_ssa_names VARRAY_ACTIVE_SIZE (ssa_names)
377 #define ssa_name(i) VARRAY_TREE (ssa_names, i)
378
379 /* Artificial variable used to model the effects of function calls.  */
380 extern GTY(()) tree global_var;
381
382 /* Call clobbered variables in the function.  If bit I is set, then
383    REFERENCED_VARS (I) is call-clobbered.  */
384 extern bitmap call_clobbered_vars;
385
386 /* Addressable variables in the function.  If bit I is set, then
387    REFERENCED_VARS (I) has had its address taken.  */
388 extern bitmap addressable_vars;
389
390 /* 'true' after aliases have been computed (see compute_may_aliases).  */
391 extern bool aliases_computed_p;
392
393 /* Macros for showing usage statistics.  */
394 #define SCALE(x) ((unsigned long) ((x) < 1024*10        \
395                   ? (x)                                 \
396                   : ((x) < 1024*1024*10                 \
397                      ? (x) / 1024                       \
398                      : (x) / (1024*1024))))
399
400 #define LABEL(x) ((x) < 1024*10 ? 'b' : ((x) < 1024*1024*10 ? 'k' : 'M'))
401
402 #define PERCENT(x,y) ((float)(x) * 100.0 / (float)(y))
403
404
405 /*---------------------------------------------------------------------------
406                               Block iterators
407 ---------------------------------------------------------------------------*/
408
409 typedef struct {
410   tree_stmt_iterator tsi;
411   basic_block bb;
412 } block_stmt_iterator;
413
414 static inline block_stmt_iterator bsi_start (basic_block);
415 static inline block_stmt_iterator bsi_last (basic_block);
416 static inline block_stmt_iterator bsi_after_labels (basic_block);
417 block_stmt_iterator stmt_for_bsi (tree);
418 static inline bool bsi_end_p (block_stmt_iterator);
419 static inline void bsi_next (block_stmt_iterator *);
420 static inline void bsi_prev (block_stmt_iterator *);
421 static inline tree bsi_stmt (block_stmt_iterator);
422 static inline tree * bsi_stmt_ptr (block_stmt_iterator);
423
424 extern void bsi_remove (block_stmt_iterator *);
425 extern void bsi_move_before (block_stmt_iterator *, block_stmt_iterator *);
426 extern void bsi_move_after (block_stmt_iterator *, block_stmt_iterator *);
427 extern void bsi_move_to_bb_end (block_stmt_iterator *, basic_block);
428
429 enum bsi_iterator_update
430 {
431   /* Note that these are intentionally in the same order as TSI_FOO.  They
432      mean exactly the same as their TSI_* counterparts.  */
433   BSI_NEW_STMT,
434   BSI_SAME_STMT,
435   BSI_CHAIN_START,
436   BSI_CHAIN_END,
437   BSI_CONTINUE_LINKING
438 };
439
440 extern void bsi_insert_before (block_stmt_iterator *, tree,
441                                enum bsi_iterator_update);
442 extern void bsi_insert_after (block_stmt_iterator *, tree,
443                               enum bsi_iterator_update);
444
445 extern void bsi_replace (const block_stmt_iterator *, tree, bool);
446
447 /*---------------------------------------------------------------------------
448                               Function prototypes
449 ---------------------------------------------------------------------------*/
450 /* In tree-cfg.c  */
451
452 /* Location to track pending stmt for edge insertion.  */
453 #define PENDING_STMT(e) ((e)->insns.t)
454
455 extern void delete_tree_cfg_annotations (void);
456 extern void disband_implicit_edges (void);
457 extern bool stmt_ends_bb_p (tree);
458 extern bool is_ctrl_stmt (tree);
459 extern bool is_ctrl_altering_stmt (tree);
460 extern bool computed_goto_p (tree);
461 extern bool simple_goto_p (tree);
462 extern void tree_dump_bb (basic_block, FILE *, int);
463 extern void debug_tree_bb (basic_block);
464 extern basic_block debug_tree_bb_n (int);
465 extern void dump_tree_cfg (FILE *, int);
466 extern void debug_tree_cfg (int);
467 extern void dump_cfg_stats (FILE *);
468 extern void debug_cfg_stats (void);
469 extern void debug_loop_ir (void);
470 extern void print_loop_ir (FILE *);
471 extern void cleanup_dead_labels (void);
472 extern void group_case_labels (void);
473 extern bool cleanup_tree_cfg (void);
474 extern tree first_stmt (basic_block);
475 extern tree last_stmt (basic_block);
476 extern tree *last_stmt_ptr (basic_block);
477 extern tree last_and_only_stmt (basic_block);
478 extern edge find_taken_edge (basic_block, tree);
479 extern void cfg_remove_useless_stmts (void);
480 extern edge thread_edge (edge, basic_block);
481 extern basic_block label_to_block (tree);
482 extern void tree_optimize_tail_calls (bool, enum tree_dump_index);
483 extern edge tree_block_forwards_to (basic_block bb);
484 extern void bsi_insert_on_edge (edge, tree);
485 extern basic_block bsi_insert_on_edge_immediate (edge, tree);
486 extern void bsi_commit_edge_inserts (int *);
487 extern void notice_special_calls (tree);
488 extern void clear_special_calls (void);
489 extern void verify_stmts (void);
490 extern tree tree_block_label (basic_block bb);
491 extern void extract_true_false_edges_from_block (basic_block, edge *, edge *);
492 extern bool tree_purge_dead_eh_edges (basic_block);
493 extern bool tree_purge_all_dead_eh_edges (bitmap);
494 extern tree gimplify_val (block_stmt_iterator *, tree, tree);
495 extern tree gimplify_build1 (block_stmt_iterator *, enum tree_code,
496                              tree, tree);
497 extern tree gimplify_build2 (block_stmt_iterator *, enum tree_code,
498                              tree, tree, tree);
499 extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code,
500                              tree, tree, tree, tree);
501
502 /* In tree-pretty-print.c.  */
503 extern void dump_generic_bb (FILE *, basic_block, int, int);
504
505 /* In tree-dfa.c  */
506 extern var_ann_t create_var_ann (tree);
507 extern stmt_ann_t create_stmt_ann (tree);
508 extern tree_ann_t create_tree_ann (tree);
509 extern tree create_phi_node (tree, basic_block);
510 extern void add_phi_arg (tree *, tree, edge);
511 extern void remove_phi_arg (tree, basic_block);
512 extern void remove_phi_arg_num (tree, int);
513 extern void remove_phi_node (tree, tree, basic_block);
514 extern void remove_all_phi_nodes_for (bitmap);
515 extern void dump_dfa_stats (FILE *);
516 extern void debug_dfa_stats (void);
517 extern void debug_referenced_vars (void);
518 extern void dump_referenced_vars (FILE *);
519 extern void dump_variable (FILE *, tree);
520 extern void debug_variable (tree);
521 extern void dump_immediate_uses (FILE *);
522 extern void debug_immediate_uses (void);
523 extern void dump_immediate_uses_for (FILE *, tree);
524 extern void debug_immediate_uses_for (tree);
525 extern void compute_immediate_uses (int, bool (*)(tree));
526 extern void free_df (void);
527 extern tree get_virtual_var (tree);
528 extern void add_referenced_tmp_var (tree var);
529 extern void mark_new_vars_to_rename (tree, bitmap);
530 extern void redirect_immediate_uses (tree, tree);
531 extern tree make_rename_temp (tree, const char *);
532
533 /* Flags used when computing reaching definitions and reached uses.  */
534 #define TDFA_USE_OPS            1 << 0
535 #define TDFA_USE_VOPS           1 << 1
536
537 /* In gimple-low.c  */
538 struct lower_data;
539 extern void lower_stmt_body (tree, struct lower_data *);
540 extern void record_vars (tree);
541 extern bool block_may_fallthru (tree block);
542
543 /* In tree-ssa-alias.c  */
544 extern void dump_may_aliases_for (FILE *, tree);
545 extern void debug_may_aliases_for (tree);
546 extern void dump_alias_info (FILE *);
547 extern void debug_alias_info (void);
548 extern void dump_points_to_info (FILE *);
549 extern void debug_points_to_info (void);
550 extern void dump_points_to_info_for (FILE *, tree);
551 extern void debug_points_to_info_for (tree);
552 extern bool may_be_aliased (tree);
553
554 /* Call-back function for walk_use_def_chains().  At each reaching
555    definition, a function with this prototype is called.  */
556 typedef bool (*walk_use_def_chains_fn) (tree, tree, void *);
557
558 /* In tree-ssa.c  */
559 extern void init_tree_ssa (void);
560 extern void dump_reaching_defs (FILE *);
561 extern void debug_reaching_defs (void);
562 extern void dump_tree_ssa (FILE *);
563 extern void debug_tree_ssa (void);
564 extern void debug_def_blocks (void);
565 extern void dump_tree_ssa_stats (FILE *);
566 extern void debug_tree_ssa_stats (void);
567 extern void ssa_remove_edge (edge);
568 extern edge ssa_redirect_edge (edge, basic_block);
569 extern bool tree_ssa_useless_type_conversion (tree);
570 extern bool tree_ssa_useless_type_conversion_1 (tree, tree);
571 extern void verify_ssa (void);
572 extern void delete_tree_ssa (void);
573 extern void register_new_def (tree, varray_type *);
574 extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool);
575 extern void kill_redundant_phi_nodes (void);
576
577 /* In tree-into-ssa.c  */
578 extern void rewrite_into_ssa (bool);
579 extern void rewrite_ssa_into_ssa (void);
580
581 void compute_global_livein (bitmap, bitmap);
582 tree duplicate_ssa_name (tree, tree);
583
584 /* In tree-ssa-ccp.c  */
585 bool fold_stmt (tree *);
586 tree widen_bitfield (tree, tree, tree);
587
588 /* In tree-ssa-dom.c  */
589 extern void dump_dominator_optimization_stats (FILE *);
590 extern void debug_dominator_optimization_stats (void);
591
592 /* In tree-ssa-copy.c  */
593 extern void propagate_value (use_operand_p, tree);
594 extern void propagate_tree_value (tree *, tree);
595 extern void replace_exp (use_operand_p, tree);
596 extern bool may_propagate_copy (tree, tree);
597
598 /* Description of number of iterations of a loop.  All the expressions inside
599    the structure can be evaluated at the end of the loop's preheader
600    (and due to ssa form, also anywhere inside the body of the loop).  */
601
602 struct tree_niter_desc
603 {
604   tree assumptions;     /* The boolean expression.  If this expression evalutes
605                            to false, then the other fields in this structure
606                            should not be used; there is no guarantee that they
607                            will be correct.  */
608   tree may_be_zero;     /* The boolean expression.  If it evaluates to true,
609                            the loop will exit in the first iteration (i.e.
610                            its latch will not be executed), even if the niter
611                            field says otherwise.  */
612   tree niter;           /* The expression giving the number of iterations of
613                            a loop (provided that assumptions == true and
614                            may_be_zero == false), more precisely the number
615                            of executions of the latch of the loop.  */
616   tree additional_info; /* The boolean expression.  Sometimes we use additional
617                            knowledge to simplify the other expressions
618                            contained in this structure (for example the
619                            knowledge about value ranges of operands on entry to
620                            the loop).  If this is a case, conjunction of such
621                            condition is stored in this field, so that we do not
622                            lose the information: for example if may_be_zero
623                            is (n <= 0) and niter is (unsigned) n, we know
624                            that the number of iterations is at most
625                            MAX_SIGNED_INT.  However if the (n <= 0) assumption
626                            is eliminated (by looking at the guard on entry of
627                            the loop), then the information would be lost.  */
628 };
629
630 /* In tree-vectorizer.c */
631 void vectorize_loops (struct loops *);
632
633 /* In tree-ssa-phiopt.c */
634 bool empty_block_p (basic_block);
635
636 /* In tree-ssa-loop*.c  */
637
638 void tree_ssa_lim (struct loops *);
639 void canonicalize_induction_variables (struct loops *);
640 void tree_unroll_loops_completely (struct loops *);
641 void tree_ssa_iv_optimize (struct loops *);
642
643 void number_of_iterations_cond (tree, tree, tree, enum tree_code, tree, tree,
644                                 struct tree_niter_desc *);
645 bool number_of_iterations_exit (struct loop *, edge,
646                                 struct tree_niter_desc *niter);
647 tree loop_niter_by_eval (struct loop *, edge);
648 tree find_loop_niter_by_eval (struct loop *, edge *);
649 void estimate_numbers_of_iterations (struct loops *);
650 tree can_count_iv_in_wider_type (struct loop *, tree, tree, tree, tree);
651 void free_numbers_of_iterations_estimates (struct loops *);
652 void rewrite_into_loop_closed_ssa (void);
653 void verify_loop_closed_ssa (void);
654 void loop_commit_inserts (void);
655 bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *);
656 void create_iv (tree, tree, tree, struct loop *, block_stmt_iterator *, bool,
657                 tree *, tree *);
658 void split_loop_exit_edge (edge);
659 basic_block bsi_insert_on_edge_immediate_loop (edge, tree);
660 void standard_iv_increment_position (struct loop *, block_stmt_iterator *,
661                                      bool *);
662 basic_block ip_end_pos (struct loop *);
663 basic_block ip_normal_pos (struct loop *);
664
665 /* In tree-ssa-loop-im.c  */
666 /* The possibilities of statement movement.  */
667
668 enum move_pos
669   {
670     MOVE_IMPOSSIBLE,            /* No movement -- side effect expression.  */
671     MOVE_PRESERVE_EXECUTION,    /* Must not cause the non-executed statement
672                                    become executed -- memory accesses, ... */
673     MOVE_POSSIBLE               /* Unlimited movement.  */
674   };
675 extern enum move_pos movement_possibility (tree);
676
677 /* In tree-if-conv.c  */
678 bool tree_if_conversion (struct loop *, bool);
679
680
681 /* In tree-flow-inline.h  */
682 static inline int phi_arg_from_edge (tree, edge);
683 static inline bool is_call_clobbered (tree);
684 static inline void mark_call_clobbered (tree);
685 static inline void set_is_used (tree);
686
687 /* In tree-eh.c  */
688 extern void make_eh_edges (tree);
689 extern bool tree_could_trap_p (tree);
690 extern bool tree_could_throw_p (tree);
691 extern bool tree_can_throw_internal (tree);
692 extern bool tree_can_throw_external (tree);
693 extern int lookup_stmt_eh_region (tree);
694 extern void add_stmt_to_eh_region (tree, int);
695 extern bool remove_stmt_from_eh_region (tree);
696 extern bool maybe_clean_eh_stmt (tree);
697
698 /* In tree-ssa-pre.c  */
699 void add_to_value (tree, tree);
700 void debug_value_expressions (tree);
701 void print_value_expressions (FILE *, tree);
702
703
704 /* In tree-vn.c  */
705 bool expressions_equal_p (tree, tree);
706 tree get_value_handle (tree);
707 hashval_t vn_compute (tree, hashval_t, vuse_optype);
708 tree vn_lookup_or_add (tree, vuse_optype);
709 void vn_add (tree, tree, vuse_optype);
710 tree vn_lookup (tree, vuse_optype);
711 void vn_init (void);
712 void vn_delete (void);
713
714
715 /* In tree-sra.c  */
716 void insert_edge_copies (tree stmt, basic_block bb);
717
718 /* In tree-ssa-operands.c  */
719 extern void build_ssa_operands (tree, stmt_ann_t, stmt_operands_p, 
720                                 stmt_operands_p);
721
722 /* In gimplify.c  */
723
724 tree force_gimple_operand (tree, tree *, bool, tree);
725
726 #include "tree-flow-inline.h"
727
728 #endif /* _TREE_FLOW_H  */