]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/tree-ssa-threadedge.h
Correct a function pre/postcondition [PR102403].
[thirdparty/gcc.git] / gcc / tree-ssa-threadedge.h
CommitLineData
c1bf2a39 1/* Header file for SSA jump threading.
99dee823 2 Copyright (C) 2013-2021 Free Software Foundation, Inc.
c1bf2a39
AM
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_TREE_SSA_THREADEDGE_H
21#define GCC_TREE_SSA_THREADEDGE_H
22
573e20aa
AH
23// Class used to maintain path state in the jump threader and pass it
24// to the jump threader simplifier.
25
26class jt_state
27{
28public:
29 jt_state (class const_and_copies *,
30 class avail_exprs_stack *,
31 class evrp_range_analyzer *);
32 void push (edge);
33 void pop ();
34 void register_equiv (tree dest, tree src, bool update_range = false);
35 void register_equivs_on_edge (edge e);
36 void record_ranges_from_stmt (gimple *stmt, bool temporary);
37
38private:
39 const_and_copies *m_copies;
40 avail_exprs_stack *m_exprs;
41 evrp_range_analyzer *m_evrp;
42};
43
d8ea4703
AH
44// This is the high level threader. The entry point is
45// thread_outgoing_edges(), which calculates and registers paths to be
46// threaded. When all candidates have been registered,
47// thread_through_all_blocks() is called to actually change the CFG.
48
49class jump_threader
50{
51public:
573e20aa 52 jump_threader (class jump_threader_simplifier *, class jt_state *);
d8ea4703
AH
53 ~jump_threader ();
54 void thread_outgoing_edges (basic_block);
55 void remove_jump_threads_including (edge_def *);
56 bool thread_through_all_blocks (bool may_peel_loop_headers);
57
58private:
59 tree simplify_control_stmt_condition (edge, gimple *);
60 tree simplify_control_stmt_condition_1 (edge,
61 gimple *,
62 tree op0,
63 tree_code cond_code,
64 tree op1,
65 unsigned limit);
66
67 bool thread_around_empty_blocks (vec<class jump_thread_edge *> *path,
68 edge, bitmap visited);
69 int thread_through_normal_block (vec<jump_thread_edge *> *path,
70 edge, bitmap visited);
71 void thread_across_edge (edge);
72 bool record_temporary_equivalences_from_phis (edge);
73 gimple *record_temporary_equivalences_from_stmts_at_dest (edge);
74
75 // Dummy condition to avoid creating lots of throw away statements.
76 gcond *dummy_cond;
77
5485bbeb 78 class fwd_jt_path_registry *m_registry;
d8ea4703 79 jump_threader_simplifier *m_simplifier;
573e20aa 80 jt_state *m_state;
d8ea4703
AH
81};
82
83// Statement simplifier callback for the jump threader.
84
85class jump_threader_simplifier
86{
87public:
573e20aa 88 jump_threader_simplifier (class vr_values *v);
d8ea4703 89 virtual ~jump_threader_simplifier () { }
573e20aa 90 virtual tree simplify (gimple *, gimple *, basic_block, jt_state *);
d8ea4703
AH
91
92protected:
93 vr_values *m_vr_values;
d8ea4703
AH
94};
95
96extern void propagate_threaded_block_debug_into (basic_block, basic_block);
2e96b5f1 97extern bool single_succ_to_potentially_threadable_block (basic_block);
d8ea4703
AH
98
99// ?? All this ssa_name_values stuff is the store of values for
100// avail_exprs_stack and const_and_copies, so it really belongs in the
101// jump_threader class. However, it's probably not worth touching
102// this, since all this windable state is slated to go with the
103// ranger.
c1bf2a39
AM
104extern vec<tree> ssa_name_values;
105#define SSA_NAME_VALUE(x) \
106 (SSA_NAME_VERSION (x) < ssa_name_values.length () \
107 ? ssa_name_values[SSA_NAME_VERSION (x)] \
108 : NULL_TREE)
109extern void set_ssa_name_value (tree, tree);
c1bf2a39
AM
110
111#endif /* GCC_TREE_SSA_THREADEDGE_H */