OSDN Git Service

2008-08-22 Bob Duff <duff@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-propagate.h
1 /* Data structures and function declarations for the SSA value propagation
2    engine.
3    Copyright (C) 2004, 2005, 2007 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 3, 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 COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 #ifndef _TREE_SSA_PROPAGATE_H
23 #define _TREE_SSA_PROPAGATE_H 1
24
25 /* If SIM_P is true, statement S will be simulated again.  */
26
27 static inline void
28 prop_set_simulate_again (gimple s, bool visit_p)
29 {
30   gimple_set_visited (s, visit_p);
31 }
32
33 /* Return true if statement T should be simulated again.  */
34
35 static inline bool
36 prop_simulate_again_p (gimple s)
37 {
38   return gimple_visited_p (s);
39 }
40
41 /* Lattice values used for propagation purposes.  Specific instances
42    of a propagation engine must return these values from the statement
43    and PHI visit functions to direct the engine.  */
44 enum ssa_prop_result {
45     /* The statement produces nothing of interest.  No edges will be
46        added to the work lists.  */
47     SSA_PROP_NOT_INTERESTING,
48
49     /* The statement produces an interesting value.  The set SSA_NAMEs
50        returned by SSA_PROP_VISIT_STMT should be added to
51        INTERESTING_SSA_EDGES.  If the statement being visited is a
52        conditional jump, SSA_PROP_VISIT_STMT should indicate which edge
53        out of the basic block should be marked executable.  */
54     SSA_PROP_INTERESTING,
55
56     /* The statement produces a varying (i.e., useless) value and
57        should not be simulated again.  If the statement being visited
58        is a conditional jump, all the edges coming out of the block
59        will be considered executable.  */
60     SSA_PROP_VARYING
61 };
62
63
64 struct prop_value_d {
65     /* Lattice value.  Each propagator is free to define its own
66        lattice and this field is only meaningful while propagating.
67        It will not be used by substitute_and_fold.  */
68     unsigned lattice_val;
69
70     /* Propagated value.  */
71     tree value;
72
73     /* If this value is held in an SSA name for a non-register
74        variable, this field holds the actual memory reference
75        associated with this value.  This field is taken from 
76        the LHS of the assignment that generated the associated SSA
77        name.  However, in the case of PHI nodes, this field is copied
78        from the PHI arguments (assuming that all the arguments have
79        the same memory reference).  See replace_vuses_in for a more
80        detailed description.  */
81     tree mem_ref;
82 };
83
84 typedef struct prop_value_d prop_value_t;
85
86
87 /* Type of value ranges.  See value_range_d for a description of these
88    types.  */
89 enum value_range_type { VR_UNDEFINED, VR_RANGE, VR_ANTI_RANGE, VR_VARYING };
90
91 /* Range of values that can be associated with an SSA_NAME after VRP
92    has executed.  */
93 struct value_range_d
94 {
95   /* Lattice value represented by this range.  */
96   enum value_range_type type;
97
98   /* Minimum and maximum values represented by this range.  These
99      values should be interpreted as follows:
100
101         - If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must
102           be NULL.
103
104         - If TYPE == VR_RANGE then MIN holds the minimum value and
105           MAX holds the maximum value of the range [MIN, MAX].
106
107         - If TYPE == ANTI_RANGE the variable is known to NOT
108           take any values in the range [MIN, MAX].  */
109   tree min;
110   tree max;
111
112   /* Set of SSA names whose value ranges are equivalent to this one.
113      This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE.  */
114   bitmap equiv;
115 };
116
117 typedef struct value_range_d value_range_t;
118
119
120 /* Call-back functions used by the value propagation engine.  */
121 typedef enum ssa_prop_result (*ssa_prop_visit_stmt_fn) (gimple, edge *, tree *);
122 typedef enum ssa_prop_result (*ssa_prop_visit_phi_fn) (gimple);
123
124
125 /* In tree-ssa-propagate.c  */
126 void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
127 bool valid_gimple_rhs_p (tree);
128 bool valid_gimple_call_p (tree);
129 void move_ssa_defining_stmt_for_defs (gimple, gimple);
130 bool update_call_from_tree (gimple_stmt_iterator *, tree);
131 tree first_vdef (gimple);
132 bool stmt_makes_single_load (gimple);
133 bool stmt_makes_single_store (gimple);
134 prop_value_t *get_value_loaded_by (gimple, prop_value_t *);
135 bool substitute_and_fold (prop_value_t *, bool);
136
137 #endif /* _TREE_SSA_PROPAGATE_H  */