GCC Middle and Back End API Reference
tree-ssa-propagate.h
Go to the documentation of this file.
1/* Data structures and function declarations for the SSA value propagation
2 engine.
3 Copyright (C) 2004-2025 Free Software Foundation, Inc.
4 Contributed by Diego Novillo <dnovillo@redhat.com>
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 3, or (at your option)
11any later version.
12
13GCC is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along 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#include "value-query.h"
26
27/* If SIM_P is true, statement S will be simulated again. */
28
29inline void
31{
32 gimple_set_visited (s, visit_p);
33}
34
35/* Return true if statement T should be simulated again. */
36
37inline bool
39{
40 return gimple_visited_p (s);
41}
42
43/* Lattice values used for propagation purposes. Specific instances
44 of a propagation engine must return these values from the statement
45 and PHI visit functions to direct the engine. */
47 /* The statement produces nothing of interest. No edges will be
48 added to the work lists. */
50
51 /* The statement produces an interesting value. The set SSA_NAMEs
52 returned by SSA_PROP_VISIT_STMT should be added to
53 INTERESTING_SSA_EDGES. If the statement being visited is a
54 conditional jump, SSA_PROP_VISIT_STMT should indicate which edge
55 out of the basic block should be marked executable. */
57
58 /* The statement produces a varying (i.e., useless) value and
59 should not be simulated again. If the statement being visited
60 is a conditional jump, all the edges coming out of the block
61 will be considered executable. */
63};
64
65
67extern bool stmt_makes_single_store (gimple *);
68extern bool may_propagate_copy (tree, tree, bool = false);
71extern void replace_exp (use_operand_p, tree);
72extern void propagate_tree_value (tree *, tree);
74
75/* Public interface into the SSA propagation engine. Clients should inherit
76 from this class and provide their own visitors. */
77
79{
80 public:
81
82 virtual ~ssa_propagation_engine (void) { }
83
84 /* Virtual functions the clients must provide to visit statements
85 and phi nodes respectively. */
86 virtual enum ssa_prop_result visit_stmt (gimple *, edge *, tree *) = 0;
87 virtual enum ssa_prop_result visit_phi (gphi *) = 0;
88
89 /* Main interface into the propagation engine. */
90 void ssa_propagate (void);
91
92 private:
93 /* Internal implementation details. */
94 void simulate_stmt (gimple *stmt);
96};
97
99{
100 public:
103
104 virtual tree value_of_expr (tree expr, gimple * = NULL) override = 0;
105 virtual tree value_on_edge (edge, tree expr) override;
106 virtual tree value_of_stmt (gimple *, tree name = NULL) override;
107 virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL) override;
108
110 virtual bool fold_stmt (gimple_stmt_iterator *) { return false; }
111
113 bool replace_uses_in (gimple *);
114 bool replace_phi_args_in (gphi *);
115
116 virtual void pre_fold_bb (basic_block) { }
117 virtual void post_fold_bb (basic_block) { }
118 virtual void pre_fold_stmt (gimple *) { }
119 virtual void post_new_stmt (gimple *) { }
120
122
123 /* Users like VRP can set this when they want to perform
124 folding for every propagation. */
126};
127
128#endif /* _TREE_SSA_PROPAGATE_H */
Definition genmatch.cc:1506
range_query()
Definition value-query.cc:271
Definition tree-ssa-propagate.h:79
virtual enum ssa_prop_result visit_phi(gphi *)=0
void simulate_block(basic_block)
Definition tree-ssa-propagate.cc:302
void simulate_stmt(gimple *stmt)
Definition tree-ssa-propagate.cc:201
void ssa_propagate(void)
Definition tree-ssa-propagate.cc:435
virtual enum ssa_prop_result visit_stmt(gimple *, edge *, tree *)=0
virtual ~ssa_propagation_engine(void)
Definition tree-ssa-propagate.h:82
virtual void pre_fold_bb(basic_block)
Definition tree-ssa-propagate.h:116
bool fold_all_stmts
Definition tree-ssa-propagate.h:125
virtual bool range_of_expr(vrange &r, tree expr, gimple *=NULL) override
Definition tree-ssa-propagate.cc:558
bool replace_uses_in(gimple *)
Definition tree-ssa-propagate.cc:567
virtual void pre_fold_stmt(gimple *)
Definition tree-ssa-propagate.h:118
virtual void post_fold_bb(basic_block)
Definition tree-ssa-propagate.h:117
virtual ~substitute_and_fold_engine(void)
Definition tree-ssa-propagate.h:109
virtual tree value_of_stmt(gimple *, tree name=NULL) override
Definition tree-ssa-propagate.cc:545
virtual tree value_on_edge(edge, tree expr) override
Definition tree-ssa-propagate.cc:539
bool substitute_and_fold(basic_block=NULL)
Definition tree-ssa-propagate.cc:986
virtual void post_new_stmt(gimple *)
Definition tree-ssa-propagate.h:119
bool replace_phi_args_in(gphi *)
Definition tree-ssa-propagate.cc:602
bool propagate_into_phi_args(basic_block)
Definition tree-ssa-propagate.cc:724
substitute_and_fold_engine(bool fold_all_stmts=false)
Definition tree-ssa-propagate.h:101
virtual bool fold_stmt(gimple_stmt_iterator *)
Definition tree-ssa-propagate.h:110
virtual tree value_of_expr(tree expr, gimple *=NULL) override=0
Definition value-range.h:78
struct basic_block_def * basic_block
Definition coretypes.h:372
class edge_def * edge
Definition coretypes.h:369
union tree_node * tree
Definition coretypes.h:97
void gimple_set_visited(gimple *stmt, bool visited_p)
Definition gimple.h:2008
bool gimple_visited_p(gimple *stmt)
Definition gimple.h:2026
poly_int< N, C > r
Definition poly-int.h:774
Definition gimple-iterator.h:26
Definition gimple.h:221
Definition gimple.h:461
#define NULL
Definition system.h:50
ssa_use_operand_t * use_operand_p
Definition tree-ssa-operands.h:30
bool prop_simulate_again_p(gimple *s)
Definition tree-ssa-propagate.h:38
void move_ssa_defining_stmt_for_defs(gimple *, gimple *)
bool may_propagate_copy_into_stmt(gimple *, tree)
Definition tree-ssa-propagate.cc:1099
void propagate_tree_value(tree *, tree)
Definition tree-ssa-propagate.cc:1190
bool may_propagate_copy(tree, tree, bool=false)
Definition tree-ssa-propagate.cc:1046
void propagate_value(use_operand_p, tree)
Definition tree-ssa-propagate.cc:1167
void propagate_tree_value_into_stmt(gimple_stmt_iterator *, tree)
Definition tree-ssa-propagate.cc:1206
bool stmt_makes_single_store(gimple *)
Definition tree-ssa-propagate.cc:502
void replace_exp(use_operand_p, tree)
Definition tree-ssa-propagate.cc:1151
ssa_prop_result
Definition tree-ssa-propagate.h:46
@ SSA_PROP_INTERESTING
Definition tree-ssa-propagate.h:56
@ SSA_PROP_VARYING
Definition tree-ssa-propagate.h:62
@ SSA_PROP_NOT_INTERESTING
Definition tree-ssa-propagate.h:49
void prop_set_simulate_again(gimple *s, bool visit_p)
Definition tree-ssa-propagate.h:30