]>
Commit | Line | Data |
---|---|---|
750628d8 DN |
1 | /* Data structures and function declarations for the SSA value propagation |
2 | engine. | |
8d9254fc | 3 | Copyright (C) 2004-2020 Free Software Foundation, Inc. |
750628d8 DN |
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 | |
9dcd6f09 | 10 | the Free Software Foundation; either version 3, or (at your option) |
750628d8 DN |
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 | |
9dcd6f09 NC |
19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
750628d8 DN |
21 | |
22 | #ifndef _TREE_SSA_PROPAGATE_H | |
23 | #define _TREE_SSA_PROPAGATE_H 1 | |
24 | ||
726a989a RB |
25 | /* If SIM_P is true, statement S will be simulated again. */ |
26 | ||
27 | static inline void | |
355fe088 | 28 | prop_set_simulate_again (gimple *s, bool visit_p) |
726a989a RB |
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 | |
355fe088 | 36 | prop_simulate_again_p (gimple *s) |
726a989a RB |
37 | { |
38 | return gimple_visited_p (s); | |
39 | } | |
750628d8 DN |
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. */ | |
750628d8 DN |
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 | |
2a7e31df | 53 | out of the basic block should be marked executable. */ |
750628d8 DN |
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 | ||
744730a4 | 64 | extern bool valid_gimple_rhs_p (tree); |
355fe088 | 65 | extern void move_ssa_defining_stmt_for_defs (gimple *, gimple *); |
744730a4 AM |
66 | extern bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...); |
67 | extern bool update_call_from_tree (gimple_stmt_iterator *, tree); | |
355fe088 | 68 | extern bool stmt_makes_single_store (gimple *); |
744730a4 | 69 | extern bool may_propagate_copy (tree, tree); |
355fe088 | 70 | extern bool may_propagate_copy_into_stmt (gimple *, tree); |
744730a4 AM |
71 | extern bool may_propagate_copy_into_asm (tree); |
72 | extern void propagate_value (use_operand_p, tree); | |
73 | extern void replace_exp (use_operand_p, tree); | |
74 | extern void propagate_tree_value (tree *, tree); | |
75 | extern void propagate_tree_value_into_stmt (gimple_stmt_iterator *, tree); | |
750628d8 | 76 | |
d9a3704a JL |
77 | /* Public interface into the SSA propagation engine. Clients should inherit |
78 | from this class and provide their own visitors. */ | |
79 | ||
80 | class ssa_propagation_engine | |
81 | { | |
82 | public: | |
83 | ||
b95f2911 | 84 | virtual ~ssa_propagation_engine (void) { } |
d9a3704a JL |
85 | |
86 | /* Virtual functions the clients must provide to visit statements | |
87 | and phi nodes respectively. */ | |
88 | virtual enum ssa_prop_result visit_stmt (gimple *, edge *, tree *) = 0; | |
89 | virtual enum ssa_prop_result visit_phi (gphi *) = 0; | |
90 | ||
b95f2911 JL |
91 | /* Main interface into the propagation engine. */ |
92 | void ssa_propagate (void); | |
93 | ||
d9a3704a JL |
94 | private: |
95 | /* Internal implementation details. */ | |
96 | void simulate_stmt (gimple *stmt); | |
d9a3704a | 97 | void simulate_block (basic_block); |
d9a3704a JL |
98 | }; |
99 | ||
e10a635c JL |
100 | class substitute_and_fold_engine |
101 | { | |
102 | public: | |
e944354e RD |
103 | substitute_and_fold_engine (bool fold_all_stmts = false) |
104 | : fold_all_stmts (fold_all_stmts) { } | |
b95f2911 | 105 | virtual ~substitute_and_fold_engine (void) { } |
e10a635c JL |
106 | virtual bool fold_stmt (gimple_stmt_iterator *) { return false; } |
107 | virtual tree get_value (tree) { return NULL_TREE; } | |
b95f2911 | 108 | |
13e08dc9 | 109 | bool substitute_and_fold (basic_block = NULL); |
b95f2911 | 110 | bool replace_uses_in (gimple *); |
e10a635c | 111 | bool replace_phi_args_in (gphi *); |
e944354e RD |
112 | |
113 | /* Users like VRP can set this when they want to perform | |
114 | folding for every propagation. */ | |
115 | bool fold_all_stmts; | |
e10a635c JL |
116 | }; |
117 | ||
750628d8 | 118 | #endif /* _TREE_SSA_PROPAGATE_H */ |