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
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
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 // Only SSA names passed in IMPORTS are precomputed, and can be
32 // Note that the blocks are in reverse order, thus the exit block is
35 class path_range_query
: public range_query
38 path_range_query (class gimple_ranger
&ranger
);
39 virtual ~path_range_query ();
40 void precompute_ranges (const vec
<basic_block
> &path
,
41 const bitmap_head
*imports
);
42 bool range_of_expr (irange
&r
, tree name
, gimple
* = NULL
) override
;
43 bool range_of_stmt (irange
&r
, gimple
*, tree name
= NULL
) override
;
44 void dump (FILE *) override
;
48 // Cache manipulation.
49 void set_cache (const irange
&r
, tree name
);
50 bool get_cache (irange
&r
, tree name
);
51 void clear_cache (tree name
);
53 // Methods to precompute ranges for the given path.
54 bool range_defined_in_block (irange
&, tree name
, basic_block bb
);
55 void precompute_ranges_in_block (basic_block bb
);
56 void ssa_range_in_phi (irange
&r
, gphi
*phi
);
59 void set_path (const vec
<basic_block
> &);
60 basic_block
entry_bb () { return (*m_path
)[m_path
->length () - 1]; }
61 basic_block
exit_bb () { return (*m_path
)[0]; }
62 basic_block
curr_bb () { return (*m_path
)[m_pos
]; }
63 basic_block
prev_bb () { return (*m_path
)[m_pos
+ 1]; }
64 basic_block
next_bb () { return (*m_path
)[m_pos
- 1]; }
65 bool at_entry () { return m_pos
== m_path
->length () - 1; }
66 bool at_exit () { return m_pos
== 0; }
67 void move_next () { --m_pos
; }
69 // Range cache for SSA names.
70 ssa_global_cache
*m_cache
;
72 // Set for each SSA that has an active entry in the cache.
73 bitmap m_has_cache_entry
;
75 // Path being analyzed.
76 const vec
<basic_block
> *m_path
;
78 // Current path position.
81 const bitmap_head
*m_imports
;
82 gimple_ranger
&m_ranger
;
85 #endif // GCC_TREE_SSA_THREADSOLVER_H