GCC Middle and Back End API Reference
gimple-range-cache.h
Go to the documentation of this file.
1/* Header file for gimple ranger SSA cache.
2 Copyright (C) 2017-2024 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_SSA_RANGE_CACHE_H
22#define GCC_SSA_RANGE_CACHE_H
23
24#include "gimple-range-gori.h"
25#include "gimple-range-infer.h"
26#include "gimple-range-phi.h"
27
28// This class manages a vector of pointers to ssa_block ranges. It
29// provides the basis for the "range on entry" cache for all
30// SSA names.
31
33{
34public:
37
38 bool set_bb_range (tree name, const_basic_block bb, const vrange &v);
39 bool get_bb_range (vrange &v, tree name, const_basic_block bb);
40 bool bb_range_p (tree name, const_basic_block bb);
41
42 void dump (FILE *f);
43 void dump (FILE *f, basic_block bb, bool print_varying = true);
44private:
50};
51
52// This global cache is used with the range engine as markers for what
53// has been visited during this incarnation. Once the ranger evaluates
54// a name, it is typically not re-evaluated again.
55
56class ssa_cache : public range_query
57{
58public:
59 ssa_cache ();
60 ~ssa_cache ();
61 virtual bool has_range (tree name) const;
62 virtual bool get_range (vrange &r, tree name) const;
63 virtual bool set_range (tree name, const vrange &r);
64 virtual bool merge_range (tree name, const vrange &r);
65 virtual void clear_range (tree name);
66 virtual void clear ();
67 void dump (FILE *f = stderr);
68 virtual bool range_of_expr (vrange &r, tree expr, gimple *stmt = NULL);
69protected:
72};
73
74// This is the same as global cache, except it maintains an active bitmap
75// rather than depending on a zero'd out vector of pointers. This is better
76// for sparsely/lightly used caches.
77
79{
80public:
83 inline bool empty_p () const { return bitmap_empty_p (active_p); }
84 virtual bool has_range (tree name) const;
85 virtual bool set_range (tree name, const vrange &r);
86 virtual bool merge_range (tree name, const vrange &r);
87 virtual bool get_range (vrange &r, tree name) const;
88 virtual void clear_range (tree name);
89 virtual void clear ();
90 void merge (const ssa_lazy_cache &);
91protected:
95};
96
97// This class provides all the caches a global ranger may need, and makes
98// them available for gori-computes to query so outgoing edges can be
99// properly calculated.
100
102{
103public:
104 ranger_cache (int not_executable_flag, bool use_imm_uses);
105 ~ranger_cache ();
106
107 bool range_of_expr (vrange &r, tree name, gimple *stmt) final override;
108 bool range_on_edge (vrange &r, edge e, tree expr) final override;
109 bool block_range (vrange &r, basic_block bb, tree name, bool calc = true);
110
111 bool get_global_range (vrange &r, tree name) const;
112 bool get_global_range (vrange &r, tree name, bool &current_p);
113 void set_global_range (tree name, const vrange &r, bool changed = true);
115
117
118 void register_inferred_value (const vrange &r, tree name, basic_block bb);
120
121 void dump_bb (FILE *f, basic_block bb);
122 virtual void dump (FILE *f) override;
123private:
127 void fill_block_cache (tree name, basic_block bb, basic_block def_bb);
128 void propagate_cache (tree name);
129
131 {
132 RFD_NONE, // Only look at current block cache.
133 RFD_READ_ONLY, // Scan DOM tree, do not write to cache.
134 RFD_FILL // Scan DOM tree, updating important nodes.
135 };
136 bool range_from_dom (vrange &r, tree name, basic_block bb, enum rfd_mode);
137 void resolve_dom (vrange &r, tree name, basic_block bb);
138 void range_of_def (vrange &r, tree name, basic_block bb = NULL);
139 void entry_range (vrange &r, tree expr, basic_block bb, enum rfd_mode);
140 void exit_range (vrange &r, tree expr, basic_block bb, enum rfd_mode);
141 bool edge_range (vrange &r, edge e, tree name, enum rfd_mode);
142
145};
146
147#endif // GCC_SSA_RANGE_CACHE_H
bool bitmap_empty_p(const_bitmap map)
Definition bitmap.h:393
Definition gimple-range-cache.h:33
~block_range_cache()
Definition gimple-range-cache.cc:376
vec< class ssa_block_ranges * > m_ssa_ranges
Definition gimple-range-cache.h:45
void dump(FILE *f)
Definition gimple-range-cache.cc:465
class vrange_allocator * m_range_allocator
Definition gimple-range-cache.h:48
bool get_bb_range(vrange &v, tree name, const_basic_block bb)
Definition gimple-range-cache.cc:443
bool set_bb_range(tree name, const_basic_block bb, const vrange &v)
Definition gimple-range-cache.cc:388
ssa_block_ranges & get_block_ranges(tree name)
block_range_cache()
Definition gimple-range-cache.cc:366
ssa_block_ranges * query_block_ranges(tree name)
Definition gimple-range-cache.cc:429
bool bb_range_p(tree name, const_basic_block bb)
Definition gimple-range-cache.cc:454
bitmap_obstack m_bitmaps
Definition gimple-range-cache.h:49
Definition genmatch.cc:845
Definition value-query.h:55
Definition gimple-range-cache.h:102
bool range_from_dom(vrange &r, tree name, basic_block bb, enum rfd_mode)
Definition gimple-range-cache.cc:1681
void propagate_cache(tree name)
Definition gimple-range-cache.cc:1312
void entry_range(vrange &r, tree expr, basic_block bb, enum rfd_mode)
Definition gimple-range-cache.cc:1179
void register_inferred_value(const vrange &r, tree name, basic_block bb)
Definition gimple-range-cache.cc:1821
bool get_global_range(vrange &r, tree name) const
Definition gimple-range-cache.cc:1058
bool range_on_edge(vrange &r, edge e, tree expr) final override
Definition gimple-range-cache.cc:1261
ranger_cache(int not_executable_flag, bool use_imm_uses)
Definition gimple-range-cache.cc:998
void fill_block_cache(tree name, basic_block bb, basic_block def_bb)
Definition gimple-range-cache.cc:1451
void apply_inferred_ranges(gimple *s)
Definition gimple-range-cache.cc:1840
vec< basic_block > m_workback
Definition gimple-range-cache.h:143
class update_list * m_update
Definition gimple-range-cache.h:144
rfd_mode
Definition gimple-range-cache.h:131
@ RFD_NONE
Definition gimple-range-cache.h:132
@ RFD_FILL
Definition gimple-range-cache.h:134
@ RFD_READ_ONLY
Definition gimple-range-cache.h:133
virtual void dump(FILE *f) override
Definition gimple-range-cache.cc:1036
bool range_of_expr(vrange &r, tree name, gimple *stmt) final override
Definition gimple-range-cache.cc:1237
void set_global_range(tree name, const vrange &r, bool changed=true)
Definition gimple-range-cache.cc:1113
range_query & const_query()
Definition gimple-range-cache.h:114
void dump_bb(FILE *f, basic_block bb)
Definition gimple-range-cache.cc:1047
ssa_cache m_globals
Definition gimple-range-cache.h:124
void resolve_dom(vrange &r, tree name, basic_block bb)
Definition gimple-range-cache.cc:1644
block_range_cache m_on_entry
Definition gimple-range-cache.h:125
~ranger_cache()
Definition gimple-range-cache.cc:1023
bool edge_range(vrange &r, edge e, tree name, enum rfd_mode)
Definition gimple-range-cache.cc:1220
class temporal_cache * m_temporal
Definition gimple-range-cache.h:126
void range_of_def(vrange &r, tree name, basic_block bb=NULL)
Definition gimple-range-cache.cc:1158
bool block_range(vrange &r, basic_block bb, tree name, bool calc=true)
Definition gimple-range-cache.cc:1273
void propagate_updated_value(tree name, basic_block bb)
Definition gimple-range-cache.cc:1408
void exit_range(vrange &r, tree expr, basic_block bb, enum rfd_mode)
Definition gimple-range-cache.cc:1199
Definition gimple-range-cache.cc:46
Definition gimple-range-cache.h:57
virtual bool has_range(tree name) const
Definition gimple-range-cache.cc:571
virtual void clear_range(tree name)
Definition gimple-range-cache.cc:647
vrange_allocator * m_range_allocator
Definition gimple-range-cache.h:71
ssa_cache()
Definition gimple-range-cache.cc:540
virtual bool set_range(tree name, const vrange &r)
Definition gimple-range-cache.cc:600
void dump(FILE *f=stderr)
Definition gimple-range-cache.cc:667
vec< vrange_storage * > m_tab
Definition gimple-range-cache.h:70
virtual bool get_range(vrange &r, tree name) const
Definition gimple-range-cache.cc:583
~ssa_cache()
Definition gimple-range-cache.cc:548
virtual bool range_of_expr(vrange &r, tree expr, gimple *stmt=NULL)
Definition gimple-range-cache.cc:558
virtual void clear()
Definition gimple-range-cache.cc:658
virtual bool merge_range(tree name, const vrange &r)
Definition gimple-range-cache.cc:618
Definition gimple-range-cache.h:79
virtual void clear_range(tree name)
Definition gimple-range-cache.cc:789
virtual bool has_range(tree name) const
Definition gimple-range-cache.cc:715
bitmap_obstack m_bitmaps
Definition gimple-range-cache.h:92
virtual void clear()
Definition gimple-range-cache.cc:797
bitmap_obstack * m_ob
Definition gimple-range-cache.h:93
virtual bool set_range(tree name, const vrange &r)
Definition gimple-range-cache.cc:724
~ssa_lazy_cache()
Definition gimple-range-cache.cc:704
void merge(const ssa_lazy_cache &)
Definition gimple-range-cache.cc:763
bool empty_p() const
Definition gimple-range-cache.h:83
bitmap active_p
Definition gimple-range-cache.h:94
virtual bool get_range(vrange &r, tree name) const
Definition gimple-range-cache.cc:779
ssa_lazy_cache(bitmap_obstack *ob=NULL)
Definition gimple-range-cache.cc:689
virtual bool merge_range(tree name, const vrange &r)
Definition gimple-range-cache.cc:743
Definition gimple-range-cache.cc:813
Definition gimple-range-cache.cc:921
Definition value-range-storage.h:28
Definition value-range.h:78
class edge_def * edge
Definition coretypes.h:343
class bitmap_head * bitmap
Definition coretypes.h:51
union tree_node * tree
Definition coretypes.h:97
poly_int< N, C > r
Definition poly-int.h:770
Definition basic-block.h:117
Definition bitmap.h:294
Definition gimple.h:225
Definition vec.h:450
#define NULL
Definition system.h:50
static bitmap changed
Definition tree-ssa-structalias.cc:1445