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
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 ();
90protected:
92};
93
94// This class provides all the caches a global ranger may need, and makes
95// them available for gori-computes to query so outgoing edges can be
96// properly calculated.
97
99{
100public:
102 ~ranger_cache ();
103
104 bool range_of_expr (vrange &r, tree name, gimple *stmt) final override;
105 bool range_on_edge (vrange &r, edge e, tree expr) final override;
106 bool block_range (vrange &r, basic_block bb, tree name, bool calc = true);
107
108 bool get_global_range (vrange &r, tree name) const;
109 bool get_global_range (vrange &r, tree name, bool &current_p);
110 void set_global_range (tree name, const vrange &r, bool changed = true);
112
114
115 void register_inferred_value (const vrange &r, tree name, basic_block bb);
119
120 void dump_bb (FILE *f, basic_block bb);
121 virtual void dump (FILE *f) override;
122private:
127 void propagate_cache (tree name);
128
130 {
131 RFD_NONE, // Only look at current block cache.
132 RFD_READ_ONLY, // Scan DOM tree, do not write to cache.
133 RFD_FILL // Scan DOM tree, updating important nodes.
134 };
135 bool range_from_dom (vrange &r, tree name, basic_block bb, enum rfd_mode);
136 void resolve_dom (vrange &r, tree name, basic_block bb);
137 void range_of_def (vrange &r, tree name, basic_block bb = NULL);
138 void entry_range (vrange &r, tree expr, basic_block bb, enum rfd_mode);
139 void exit_range (vrange &r, tree expr, basic_block bb, enum rfd_mode);
140 bool edge_range (vrange &r, edge e, tree name, enum rfd_mode);
141
144};
145
146#endif // GCC_SSA_RANGE_CACHE_H
#define BITMAP_ALLOC
Definition bitmap.h:492
bool bitmap_empty_p(const_bitmap map)
Definition bitmap.h:393
#define BITMAP_FREE(BITMAP)
Definition bitmap.h:513
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 gimple-range-gori.h:165
Definition gimple-range-infer.h:58
Definition value-query.h:55
Definition gimple-range-cache.h:99
bool range_from_dom(vrange &r, tree name, basic_block bb, enum rfd_mode)
Definition gimple-range-cache.cc:1641
void propagate_cache(tree name)
Definition gimple-range-cache.cc:1269
void entry_range(vrange &r, tree expr, basic_block bb, enum rfd_mode)
Definition gimple-range-cache.cc:1136
void register_inferred_value(const vrange &r, tree name, basic_block bb)
Definition gimple-range-cache.cc:1781
bool get_global_range(vrange &r, tree name) const
Definition gimple-range-cache.cc:1015
bool range_on_edge(vrange &r, edge e, tree expr) final override
Definition gimple-range-cache.cc:1218
ranger_cache(int not_executable_flag, bool use_imm_uses)
Definition gimple-range-cache.cc:952
void fill_block_cache(tree name, basic_block bb, basic_block def_bb)
Definition gimple-range-cache.cc:1408
void apply_inferred_ranges(gimple *s)
Definition gimple-range-cache.cc:1800
vec< basic_block > m_workback
Definition gimple-range-cache.h:142
class update_list * m_update
Definition gimple-range-cache.h:143
rfd_mode
Definition gimple-range-cache.h:130
@ RFD_NONE
Definition gimple-range-cache.h:131
@ RFD_FILL
Definition gimple-range-cache.h:133
@ RFD_READ_ONLY
Definition gimple-range-cache.h:132
virtual void dump(FILE *f) override
Definition gimple-range-cache.cc:992
bool range_of_expr(vrange &r, tree name, gimple *stmt) final override
Definition gimple-range-cache.cc:1194
void set_global_range(tree name, const vrange &r, bool changed=true)
Definition gimple-range-cache.cc:1070
range_query & const_query()
Definition gimple-range-cache.h:111
void dump_bb(FILE *f, basic_block bb)
Definition gimple-range-cache.cc:1003
ssa_cache m_globals
Definition gimple-range-cache.h:123
gori_compute m_gori
Definition gimple-range-cache.h:117
void resolve_dom(vrange &r, tree name, basic_block bb)
Definition gimple-range-cache.cc:1604
block_range_cache m_on_entry
Definition gimple-range-cache.h:124
~ranger_cache()
Definition gimple-range-cache.cc:979
bool edge_range(vrange &r, edge e, tree name, enum rfd_mode)
Definition gimple-range-cache.cc:1177
class temporal_cache * m_temporal
Definition gimple-range-cache.h:125
void range_of_def(vrange &r, tree name, basic_block bb=NULL)
Definition gimple-range-cache.cc:1115
infer_range_manager m_exit
Definition gimple-range-cache.h:118
bool block_range(vrange &r, basic_block bb, tree name, bool calc=true)
Definition gimple-range-cache.cc:1230
void propagate_updated_value(tree name, basic_block bb)
Definition gimple-range-cache.cc:1365
void exit_range(vrange &r, tree expr, basic_block bb, enum rfd_mode)
Definition gimple-range-cache.cc:1156
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:745
virtual bool has_range(tree name) const
Definition gimple-range-cache.cc:689
virtual void clear()
Definition gimple-range-cache.cc:753
virtual bool set_range(tree name, const vrange &r)
Definition gimple-range-cache.cc:698
~ssa_lazy_cache()
Definition gimple-range-cache.h:82
bool empty_p() const
Definition gimple-range-cache.h:83
bitmap active_p
Definition gimple-range-cache.h:91
virtual bool get_range(vrange &r, tree name) const
Definition gimple-range-cache.cc:735
ssa_lazy_cache()
Definition gimple-range-cache.h:81
virtual bool merge_range(tree name, const vrange &r)
Definition gimple-range-cache.cc:717
Definition gimple-range-cache.cc:769
Definition gimple-range-cache.cc:877
Definition value-range-storage.h:28
Definition value-range.h:78
class edge_def * edge
Definition coretypes.h:342
class bitmap_head * bitmap
Definition coretypes.h:51
union tree_node * tree
Definition coretypes.h:97
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
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:1437