]>
Commit | Line | Data |
---|---|---|
fcc7c636 | 1 | /* Header file for jump threading path solver. |
a945c346 | 2 | Copyright (C) 2021-2024 Free Software Foundation, Inc. |
fcc7c636 AH |
3 | Contributed by Aldy Hernandez <aldyh@redhat.com>. |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 3, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING3. If not see | |
19 | <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | #ifndef GCC_TREE_SSA_THREADSOLVER_H | |
22 | #define GCC_TREE_SSA_THREADSOLVER_H | |
23 | ||
24 | // This class is a basic block path solver. Given a set of BBs | |
25 | // indicating a path through the CFG, range_of_expr and range_of_stmt | |
26 | // will calculate the range of an SSA or STMT as if the BBs in the | |
27 | // path would have been executed in order. | |
28 | // | |
fcc7c636 AH |
29 | // Note that the blocks are in reverse order, thus the exit block is |
30 | // path[0]. | |
31 | ||
32 | class path_range_query : public range_query | |
33 | { | |
34 | public: | |
011d0a03 AH |
35 | path_range_query (class gimple_ranger &ranger, |
36 | const vec<basic_block> &path, | |
37 | const bitmap_head *dependencies = NULL, | |
38 | bool resolve = true); | |
39 | path_range_query (gimple_ranger &ranger, bool resolve = true); | |
fcc7c636 | 40 | virtual ~path_range_query (); |
011d0a03 | 41 | void reset_path (const vec<basic_block> &, const bitmap_head *dependencies); |
45c8523d AH |
42 | bool range_of_expr (vrange &r, tree name, gimple * = NULL) override; |
43 | bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override; | |
90ef1535 | 44 | bool unreachable_path_p (); |
9db0bcd9 | 45 | void dump (FILE *) override; |
fcc7c636 AH |
46 | void debug (); |
47 | ||
48 | private: | |
45c8523d | 49 | bool internal_range_of_expr (vrange &r, tree name, gimple *); |
011d0a03 AH |
50 | void compute_ranges (const bitmap_head *dependencies); |
51 | void compute_exit_dependencies (bitmap_head *dependencies); | |
97cfb54c | 52 | bool defined_outside_path (tree name); |
45c8523d | 53 | void range_on_path_entry (vrange &r, tree name); |
75d053df | 54 | path_oracle *get_path_oracle () { return (path_oracle *)m_oracle; } |
90ef1535 | 55 | |
fcc7c636 | 56 | // Cache manipulation. |
45c8523d | 57 | bool get_cache (vrange &r, tree name); |
fcc7c636 | 58 | |
83668368 | 59 | // Methods to compute ranges for the given path. |
45c8523d | 60 | bool range_defined_in_block (vrange &, tree name, basic_block bb); |
83668368 | 61 | void compute_ranges_in_block (basic_block bb); |
b7a23949 | 62 | void compute_ranges_in_phis (basic_block bb); |
410e8742 | 63 | void adjust_for_non_null_uses (basic_block bb); |
45c8523d | 64 | void ssa_range_in_phi (vrange &r, gphi *phi); |
2f0b6a97 | 65 | void compute_outgoing_relations (basic_block bb, basic_block next); |
83668368 | 66 | void compute_phi_relations (basic_block bb, basic_block prev); |
eb5ee646 | 67 | void maybe_register_phi_relation (gphi *, edge e); |
3856c6e2 AH |
68 | bool add_to_exit_dependencies (tree name, bitmap dependencies); |
69 | bool exit_dependency_p (tree name); | |
fcdf49a0 | 70 | bool ssa_defined_in_bb (tree name, basic_block bb); |
eb5ee646 | 71 | bool relations_may_be_invalidated (edge); |
fcc7c636 AH |
72 | |
73 | // Path navigation. | |
b0c83d59 AH |
74 | basic_block entry_bb () { return m_path[m_path.length () - 1]; } |
75 | basic_block exit_bb () { return m_path[0]; } | |
76 | basic_block curr_bb () { return m_path[m_pos]; } | |
77 | basic_block prev_bb () { return m_path[m_pos + 1]; } | |
78 | basic_block next_bb () { return m_path[m_pos - 1]; } | |
79 | bool at_entry () { return m_pos == m_path.length () - 1; } | |
fcc7c636 AH |
80 | bool at_exit () { return m_pos == 0; } |
81 | void move_next () { --m_pos; } | |
82 | ||
83 | // Range cache for SSA names. | |
0a38f677 | 84 | ssa_lazy_cache m_cache; |
fcc7c636 AH |
85 | |
86 | // Path being analyzed. | |
b0c83d59 | 87 | auto_vec<basic_block> m_path; |
fcc7c636 | 88 | |
3856c6e2 AH |
89 | // This is a list of SSA names that may have relevant context |
90 | // information for solving the final conditional along the path. | |
91 | // Ranges for these SSA names are pre-calculated and cached during a | |
92 | // top-down traversal of the path, and are then used to answer | |
93 | // questions at the path exit. | |
94 | auto_bitmap m_exit_dependencies; | |
95 | ||
96 | // A ranger used to resolve ranges for SSA names whose values come | |
97 | // from outside the path. | |
011d0a03 | 98 | gimple_ranger &m_ranger; |
f46d3363 AH |
99 | |
100 | // Current path position. | |
101 | unsigned m_pos; | |
102 | ||
103 | // Use ranger to resolve anything not known on entry. | |
104 | bool m_resolve; | |
90ef1535 AH |
105 | |
106 | // Set if there were any undefined expressions while pre-calculating path. | |
107 | bool m_undefined_path; | |
fcc7c636 AH |
108 | }; |
109 | ||
110 | #endif // GCC_TREE_SSA_THREADSOLVER_H |