]> gcc.gnu.org Git - gcc.git/blame - gcc/gimple-range-cache.h
Range invariant global values are also always current.
[gcc.git] / gcc / gimple-range-cache.h
CommitLineData
90e88fd3 1/* Header file for gimple ranger SSA cache.
99dee823 2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
90e88fd3
AM
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
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.
30
31class non_null_ref
32{
33public:
34 non_null_ref ();
35 ~non_null_ref ();
a7943ea9 36 bool non_null_deref_p (tree name, basic_block bb, bool search_dom = true);
90e88fd3
AM
37private:
38 vec <bitmap> m_nn;
39 void process_name (tree name);
40 bitmap_obstack m_bitmaps;
41};
42
43// This class manages a vector of pointers to ssa_block ranges. It
44// provides the basis for the "range on entry" cache for all
45// SSA names.
46
47class block_range_cache
48{
49public:
50 block_range_cache ();
51 ~block_range_cache ();
52
53 void set_bb_range (tree name, const basic_block bb, const irange &r);
90e88fd3
AM
54 bool get_bb_range (irange &r, tree name, const basic_block bb);
55 bool bb_range_p (tree name, const basic_block bb);
56
57 void dump (FILE *f);
58 void dump (FILE *f, basic_block bb, bool print_varying = true);
59private:
60 vec<class ssa_block_ranges *> m_ssa_ranges;
61 ssa_block_ranges &get_block_ranges (tree name);
220929c0 62 ssa_block_ranges *query_block_ranges (tree name);
90e88fd3
AM
63 irange_allocator *m_irange_allocator;
64};
65
66// This global cache is used with the range engine as markers for what
67// has been visited during this incarnation. Once the ranger evaluates
68// a name, it is typically not re-evaluated again.
69
70class ssa_global_cache
71{
72public:
73 ssa_global_cache ();
74 ~ssa_global_cache ();
75 bool get_global_range (irange &r, tree name) const;
ea7df355 76 bool set_global_range (tree name, const irange &r);
90e88fd3
AM
77 void clear_global_range (tree name);
78 void clear ();
79 void dump (FILE *f = stderr);
80private:
81 vec<irange *> m_tab;
82 class irange_allocator *m_irange_allocator;
83};
84
85// This class provides all the caches a global ranger may need, and makes
86// them available for gori-computes to query so outgoing edges can be
87// properly calculated.
88
329d2f0d 89class ranger_cache : public gori_compute
90e88fd3
AM
90{
91public:
ea7df355 92 ranger_cache (class gimple_ranger &q);
90e88fd3
AM
93 ~ranger_cache ();
94
95 virtual void ssa_range_in_bb (irange &r, tree name, basic_block bb);
96 bool block_range (irange &r, basic_block bb, tree name, bool calc = true);
97
220929c0 98 bool get_global_range (irange &r, tree name) const;
e86fd6a1 99 bool get_non_stale_global_range (irange &r, tree name);
220929c0
AM
100 void set_global_range (tree name, const irange &r);
101
90e88fd3 102 non_null_ref m_non_null;
220929c0
AM
103
104 void dump (FILE *f, bool dump_gori = true);
105 void dump (FILE *f, basic_block bb);
90e88fd3 106private:
220929c0
AM
107 ssa_global_cache m_globals;
108 block_range_cache m_on_entry;
e86fd6a1 109 class temporal_cache *m_temporal;
90e88fd3
AM
110 void add_to_update (basic_block bb);
111 void fill_block_cache (tree name, basic_block bb, basic_block def_bb);
ea7df355
AM
112 void propagate_cache (tree name);
113
114 void propagate_updated_value (tree name, basic_block bb);
90e88fd3
AM
115
116 vec<basic_block> m_workback;
117 vec<basic_block> m_update_list;
118
119 // Iterative "poor value" calculations.
120 struct update_record
121 {
122 basic_block bb; // Block which value needs to be calculated in.
123 tree calc; // SSA_NAME which needs its value calculated.
124 };
125 bool push_poor_value (basic_block bb, tree name);
126 vec<update_record> m_poor_value_list;
ea7df355 127 class gimple_ranger &query;
90e88fd3
AM
128};
129
130#endif // GCC_SSA_RANGE_CACHE_H
This page took 0.417721 seconds and 5 git commands to generate.