1169689Skan/* Data structures and function declarations for the SSA value propagation 2169689Skan engine. 3169689Skan Copyright (C) 2004, 2005 Free Software Foundation, Inc. 4169689Skan Contributed by Diego Novillo <dnovillo@redhat.com> 5169689Skan 6169689SkanThis file is part of GCC. 7169689Skan 8169689SkanGCC is free software; you can redistribute it and/or modify 9169689Skanit under the terms of the GNU General Public License as published by 10169689Skanthe Free Software Foundation; either version 2, or (at your option) 11169689Skanany later version. 12169689Skan 13169689SkanGCC is distributed in the hope that it will be useful, 14169689Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of 15169689SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16169689SkanGNU General Public License for more details. 17169689Skan 18169689SkanYou should have received a copy of the GNU General Public License 19169689Skanalong with GCC; see the file COPYING. If not, write to 20169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 21169689SkanBoston, MA 02110-1301, USA. */ 22169689Skan 23169689Skan#ifndef _TREE_SSA_PROPAGATE_H 24169689Skan#define _TREE_SSA_PROPAGATE_H 1 25169689Skan 26169689Skan/* Use the TREE_VISITED bitflag to mark statements and PHI nodes that 27169689Skan have been deemed varying and should not be simulated again. */ 28169689Skan#define DONT_SIMULATE_AGAIN(T) TREE_VISITED (T) 29169689Skan 30169689Skan/* Lattice values used for propagation purposes. Specific instances 31169689Skan of a propagation engine must return these values from the statement 32169689Skan and PHI visit functions to direct the engine. */ 33169689Skanenum ssa_prop_result { 34169689Skan /* The statement produces nothing of interest. No edges will be 35169689Skan added to the work lists. */ 36169689Skan SSA_PROP_NOT_INTERESTING, 37169689Skan 38169689Skan /* The statement produces an interesting value. The set SSA_NAMEs 39169689Skan returned by SSA_PROP_VISIT_STMT should be added to 40169689Skan INTERESTING_SSA_EDGES. If the statement being visited is a 41169689Skan conditional jump, SSA_PROP_VISIT_STMT should indicate which edge 42169689Skan out of the basic block should be marked executable. */ 43169689Skan SSA_PROP_INTERESTING, 44169689Skan 45169689Skan /* The statement produces a varying (i.e., useless) value and 46169689Skan should not be simulated again. If the statement being visited 47169689Skan is a conditional jump, all the edges coming out of the block 48169689Skan will be considered executable. */ 49169689Skan SSA_PROP_VARYING 50169689Skan}; 51169689Skan 52169689Skan 53169689Skanstruct prop_value_d { 54169689Skan /* Lattice value. Each propagator is free to define its own 55169689Skan lattice and this field is only meaningful while propagating. 56169689Skan It will not be used by substitute_and_fold. */ 57169689Skan unsigned lattice_val; 58169689Skan 59169689Skan /* Propagated value. */ 60169689Skan tree value; 61169689Skan 62169689Skan /* If this value is held in an SSA name for a non-register 63169689Skan variable, this field holds the actual memory reference 64169689Skan associated with this value. This field is taken from 65169689Skan the LHS of the assignment that generated the associated SSA 66169689Skan name. However, in the case of PHI nodes, this field is copied 67169689Skan from the PHI arguments (assuming that all the arguments have 68169689Skan the same memory reference). See replace_vuses_in for a more 69169689Skan detailed description. */ 70169689Skan tree mem_ref; 71169689Skan}; 72169689Skan 73169689Skantypedef struct prop_value_d prop_value_t; 74169689Skan 75169689Skan 76169689Skan/* Type of value ranges. See value_range_d for a description of these 77169689Skan types. */ 78169689Skanenum value_range_type { VR_UNDEFINED, VR_RANGE, VR_ANTI_RANGE, VR_VARYING }; 79169689Skan 80169689Skan/* Range of values that can be associated with an SSA_NAME after VRP 81169689Skan has executed. */ 82169689Skanstruct value_range_d 83169689Skan{ 84169689Skan /* Lattice value represented by this range. */ 85169689Skan enum value_range_type type; 86169689Skan 87169689Skan /* Minimum and maximum values represented by this range. These 88169689Skan values should be interpreted as follows: 89169689Skan 90169689Skan - If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must 91169689Skan be NULL. 92169689Skan 93169689Skan - If TYPE == VR_RANGE then MIN holds the minimum value and 94169689Skan MAX holds the maximum value of the range [MIN, MAX]. 95169689Skan 96169689Skan - If TYPE == ANTI_RANGE the variable is known to NOT 97169689Skan take any values in the range [MIN, MAX]. */ 98169689Skan tree min; 99169689Skan tree max; 100169689Skan 101169689Skan /* Set of SSA names whose value ranges are equivalent to this one. 102169689Skan This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */ 103169689Skan bitmap equiv; 104169689Skan}; 105169689Skan 106169689Skantypedef struct value_range_d value_range_t; 107169689Skan 108169689Skan 109169689Skan/* Call-back functions used by the value propagation engine. */ 110169689Skantypedef enum ssa_prop_result (*ssa_prop_visit_stmt_fn) (tree, edge *, tree *); 111169689Skantypedef enum ssa_prop_result (*ssa_prop_visit_phi_fn) (tree); 112169689Skan 113169689Skan 114169689Skan/* In tree-ssa-propagate.c */ 115169689Skanvoid ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn); 116169689Skantree get_rhs (tree); 117169689Skanbool set_rhs (tree *, tree); 118169689Skantree first_vdef (tree); 119169689Skanbool stmt_makes_single_load (tree); 120169689Skanbool stmt_makes_single_store (tree); 121169689Skanprop_value_t *get_value_loaded_by (tree, prop_value_t *); 122169689Skanbool replace_uses_in (tree, bool *, prop_value_t *); 123169689Skanvoid substitute_and_fold (prop_value_t *, bool); 124169689Skan 125169689Skan#endif /* _TREE_SSA_PROPAGATE_H */ 126