Daily bump.
[official-gcc.git] / gcc / gimple-range-path.h
blobb73549f01a5e93c0160587a09e80e80db127c439
1 /* Header file for jump threading path solver.
2 Copyright (C) 2021 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com>.
5 This file is part of GCC.
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.
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.
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/>. */
21 #ifndef GCC_TREE_SSA_THREADSOLVER_H
22 #define GCC_TREE_SSA_THREADSOLVER_H
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.
29 // Note that the blocks are in reverse order, thus the exit block is
30 // path[0].
32 class path_range_query : public range_query
34 public:
35 path_range_query (class gimple_ranger &ranger, bool resolve);
36 virtual ~path_range_query ();
37 void compute_ranges (const vec<basic_block> &, const bitmap_head *imports = NULL);
38 void compute_ranges (edge e);
39 bool range_of_expr (irange &r, tree name, gimple * = NULL) override;
40 bool range_of_stmt (irange &r, gimple *, tree name = NULL) override;
41 bool unreachable_path_p ();
42 void dump (FILE *) override;
43 void debug ();
45 private:
46 bool internal_range_of_expr (irange &r, tree name, gimple *);
47 bool defined_outside_path (tree name);
48 void range_on_path_entry (irange &r, tree name);
49 path_oracle *get_path_oracle () { return (path_oracle *)m_oracle; }
51 // Cache manipulation.
52 void set_cache (const irange &r, tree name);
53 bool get_cache (irange &r, tree name);
54 void clear_cache (tree name);
56 // Methods to compute ranges for the given path.
57 bool range_defined_in_block (irange &, tree name, basic_block bb);
58 void compute_ranges_in_block (basic_block bb);
59 void adjust_for_non_null_uses (basic_block bb);
60 void ssa_range_in_phi (irange &r, gphi *phi);
61 void compute_outgoing_relations (basic_block bb, basic_block next);
62 void compute_phi_relations (basic_block bb, basic_block prev);
63 void maybe_register_phi_relation (gphi *, tree arg);
64 void add_copies_to_imports ();
65 bool add_to_imports (tree name, bitmap imports);
66 inline bool import_p (tree name);
68 // Path navigation.
69 void set_path (const vec<basic_block> &);
70 basic_block entry_bb () { return m_path[m_path.length () - 1]; }
71 basic_block exit_bb () { return m_path[0]; }
72 basic_block curr_bb () { return m_path[m_pos]; }
73 basic_block prev_bb () { return m_path[m_pos + 1]; }
74 basic_block next_bb () { return m_path[m_pos - 1]; }
75 bool at_entry () { return m_pos == m_path.length () - 1; }
76 bool at_exit () { return m_pos == 0; }
77 void move_next () { --m_pos; }
79 // Range cache for SSA names.
80 ssa_global_cache *m_cache;
82 // Set for each SSA that has an active entry in the cache.
83 bitmap m_has_cache_entry;
85 // Path being analyzed.
86 auto_vec<basic_block> m_path;
88 auto_bitmap m_imports;
89 gimple_ranger &m_ranger;
90 non_null_ref m_non_null;
92 // Current path position.
93 unsigned m_pos;
95 // Use ranger to resolve anything not known on entry.
96 bool m_resolve;
98 // Set if there were any undefined expressions while pre-calculating path.
99 bool m_undefined_path;
102 // Return TRUE if NAME is in the import bitmap.
104 bool
105 path_range_query::import_p (tree name)
107 return (TREE_CODE (name) == SSA_NAME
108 && bitmap_bit_p (m_imports, SSA_NAME_VERSION (name)));
111 #endif // GCC_TREE_SSA_THREADSOLVER_H