tree-ssa-propagate.h revision 169689
1234353Sdim/* Data structures and function declarations for the SSA value propagation
2193323Sed   engine.
3353358Sdim   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4353358Sdim   Contributed by Diego Novillo <dnovillo@redhat.com>
5353358Sdim
6193323SedThis file is part of GCC.
7193323Sed
8193323SedGCC is free software; you can redistribute it and/or modify
9224145Sdimit under the terms of the GNU General Public License as published by
10193323Sedthe Free Software Foundation; either version 2, or (at your option)
11193323Sedany later version.
12193323Sed
13321369SdimGCC is distributed in the hope that it will be useful,
14321369Sdimbut WITHOUT ANY WARRANTY; without even the implied warranty of
15251662SdimMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16276479SdimGNU General Public License for more details.
17251662Sdim
18341825SdimYou should have received a copy of the GNU General Public License
19341825Sdimalong with GCC; see the file COPYING.  If not, write to
20341825Sdimthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
21251662SdimBoston, MA 02110-1301, USA.  */
22251662Sdim
23251662Sdim#ifndef _TREE_SSA_PROPAGATE_H
24251662Sdim#define _TREE_SSA_PROPAGATE_H 1
25226633Sdim
26251662Sdim/* Use the TREE_VISITED bitflag to mark statements and PHI nodes that
27224145Sdim   have been deemed varying and should not be simulated again.  */
28276479Sdim#define DONT_SIMULATE_AGAIN(T)	TREE_VISITED (T)
29276479Sdim
30276479Sdim/* Lattice values used for propagation purposes.  Specific instances
31276479Sdim   of a propagation engine must return these values from the statement
32224145Sdim   and PHI visit functions to direct the engine.  */
33224145Sdimenum ssa_prop_result {
34224145Sdim    /* The statement produces nothing of interest.  No edges will be
35224145Sdim       added to the work lists.  */
36251662Sdim    SSA_PROP_NOT_INTERESTING,
37251662Sdim
38288943Sdim    /* The statement produces an interesting value.  The set SSA_NAMEs
39288943Sdim       returned by SSA_PROP_VISIT_STMT should be added to
40288943Sdim       INTERESTING_SSA_EDGES.  If the statement being visited is a
41288943Sdim       conditional jump, SSA_PROP_VISIT_STMT should indicate which edge
42288943Sdim       out of the basic block should be marked executable.  */
43251662Sdim    SSA_PROP_INTERESTING,
44288943Sdim
45288943Sdim    /* The statement produces a varying (i.e., useless) value and
46288943Sdim       should not be simulated again.  If the statement being visited
47288943Sdim       is a conditional jump, all the edges coming out of the block
48251662Sdim       will be considered executable.  */
49288943Sdim    SSA_PROP_VARYING
50288943Sdim};
51288943Sdim
52261991Sdim
53261991Sdimstruct prop_value_d {
54288943Sdim    /* Lattice value.  Each propagator is free to define its own
55288943Sdim       lattice and this field is only meaningful while propagating.
56288943Sdim       It will not be used by substitute_and_fold.  */
57261991Sdim    unsigned lattice_val;
58280031Sdim
59288943Sdim    /* Propagated value.  */
60288943Sdim    tree value;
61280031Sdim
62341825Sdim    /* If this value is held in an SSA name for a non-register
63341825Sdim       variable, this field holds the actual memory reference
64341825Sdim       associated with this value.  This field is taken from
65341825Sdim       the LHS of the assignment that generated the associated SSA
66341825Sdim       name.  However, in the case of PHI nodes, this field is copied
67341825Sdim       from the PHI arguments (assuming that all the arguments have
68327952Sdim       the same memory reference).  See replace_vuses_in for a more
69234353Sdim       detailed description.  */
70321369Sdim    tree mem_ref;
71327952Sdim};
72360784Sdim
73280031Sdimtypedef struct prop_value_d prop_value_t;
74288943Sdim
75353358Sdim
76277320Sdim/* Type of value ranges.  See value_range_d for a description of these
77360784Sdim   types.  */
78360784Sdimenum value_range_type { VR_UNDEFINED, VR_RANGE, VR_ANTI_RANGE, VR_VARYING };
79360784Sdim
80360784Sdim/* Range of values that can be associated with an SSA_NAME after VRP
81360784Sdim   has executed.  */
82360784Sdimstruct value_range_d
83360784Sdim{
84360784Sdim  /* Lattice value represented by this range.  */
85335799Sdim  enum value_range_type type;
86335799Sdim
87335799Sdim  /* Minimum and maximum values represented by this range.  These
88276479Sdim     values should be interpreted as follows:
89280031Sdim
90193323Sed	- If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must
91280031Sdim	  be NULL.
92280031Sdim
93280031Sdim	- If TYPE == VR_RANGE then MIN holds the minimum value and
94280031Sdim	  MAX holds the maximum value of the range [MIN, MAX].
95280031Sdim
96276479Sdim	- If TYPE == ANTI_RANGE the variable is known to NOT
97276479Sdim	  take any values in the range [MIN, MAX].  */
98276479Sdim  tree min;
99276479Sdim  tree max;
100224145Sdim
101226633Sdim  /* Set of SSA names whose value ranges are equivalent to this one.
102309124Sdim     This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE.  */
103276479Sdim  bitmap equiv;
104226633Sdim};
105226633Sdim
106261991Sdimtypedef struct value_range_d value_range_t;
107261991Sdim
108261991Sdim
109261991Sdim/* Call-back functions used by the value propagation engine.  */
110261991Sdimtypedef enum ssa_prop_result (*ssa_prop_visit_stmt_fn) (tree, edge *, tree *);
111353358Sdimtypedef enum ssa_prop_result (*ssa_prop_visit_phi_fn) (tree);
112353358Sdim
113353358Sdim
114353358Sdim/* In tree-ssa-propagate.c  */
115353358Sdimvoid ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
116276479Sdimtree get_rhs (tree);
117276479Sdimbool set_rhs (tree *, tree);
118276479Sdimtree first_vdef (tree);
119276479Sdimbool stmt_makes_single_load (tree);
120276479Sdimbool stmt_makes_single_store (tree);
121276479Sdimprop_value_t *get_value_loaded_by (tree, prop_value_t *);
122327952Sdimbool replace_uses_in (tree, bool *, prop_value_t *);
123327952Sdimvoid substitute_and_fold (prop_value_t *, bool);
124327952Sdim
125341825Sdim#endif /* _TREE_SSA_PROPAGATE_H  */
126341825Sdim