1 /* Header file for gimple ranger SSA cache.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@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_SSA_RANGE_CACHE_H
22 #define GCC_SSA_RANGE_CACHE_H
24 #include "gimple-range-gori.h"
26 // Class used to track non-null references of an SSA name. A vector
27 // of bitmaps indexed by SSA name is maintained. When indexed by
28 // basic block, an on-bit indicates there is a non-null dereference
29 // for that SSA in that block.
36 bool non_null_deref_p (tree name
, basic_block bb
, bool search_dom
= true);
37 bool adjust_range (irange
&r
, tree name
, basic_block bb
,
38 bool search_dom
= true);
41 void process_name (tree name
);
42 bitmap_obstack m_bitmaps
;
45 // This class manages a vector of pointers to ssa_block ranges. It
46 // provides the basis for the "range on entry" cache for all
49 class block_range_cache
53 ~block_range_cache ();
55 bool set_bb_range (tree name
, const_basic_block bb
, const irange
&r
);
56 bool get_bb_range (irange
&r
, tree name
, const_basic_block bb
);
57 bool bb_range_p (tree name
, const_basic_block bb
);
60 void dump (FILE *f
, basic_block bb
, bool print_varying
= true);
62 vec
<class ssa_block_ranges
*> m_ssa_ranges
;
63 ssa_block_ranges
&get_block_ranges (tree name
);
64 ssa_block_ranges
*query_block_ranges (tree name
);
65 irange_allocator
*m_irange_allocator
;
66 bitmap_obstack m_bitmaps
;
69 // This global cache is used with the range engine as markers for what
70 // has been visited during this incarnation. Once the ranger evaluates
71 // a name, it is typically not re-evaluated again.
73 class ssa_global_cache
78 bool get_global_range (irange
&r
, tree name
) const;
79 bool set_global_range (tree name
, const irange
&r
);
80 void clear_global_range (tree name
);
82 void dump (FILE *f
= stderr
);
85 class irange_allocator
*m_irange_allocator
;
88 // This class provides all the caches a global ranger may need, and makes
89 // them available for gori-computes to query so outgoing edges can be
90 // properly calculated.
92 class ranger_cache
: public range_query
98 virtual bool range_of_expr (irange
&r
, tree name
, gimple
*stmt
);
99 virtual bool range_on_edge (irange
&r
, edge e
, tree expr
);
100 bool block_range (irange
&r
, basic_block bb
, tree name
, bool calc
= true);
102 bool get_global_range (irange
&r
, tree name
) const;
103 bool get_non_stale_global_range (irange
&r
, tree name
);
104 void set_global_range (tree name
, const irange
&r
);
106 non_null_ref m_non_null
;
109 void dump_bb (FILE *f
, basic_block bb
);
110 virtual void dump (FILE *f
) OVERRIDE
;
112 ssa_global_cache m_globals
;
113 block_range_cache m_on_entry
;
114 class temporal_cache
*m_temporal
;
115 void add_to_update (basic_block bb
);
116 void fill_block_cache (tree name
, basic_block bb
, basic_block def_bb
);
117 void propagate_cache (tree name
);
119 void range_of_def (irange
&r
, tree name
, basic_block bb
= NULL
);
120 void entry_range (irange
&r
, tree expr
, basic_block bb
);
121 void exit_range (irange
&r
, tree expr
, basic_block bb
);
123 void propagate_updated_value (tree name
, basic_block bb
);
126 vec
<basic_block
> m_workback
;
127 vec
<basic_block
> m_update_list
;
130 #endif // GCC_SSA_RANGE_CACHE_H