]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gimple-range-cache.h
[PATCH v1 1/1] RISC-V: Nan-box the result of movbf on soft-bf16
[thirdparty/gcc.git] / gcc / gimple-range-cache.h
CommitLineData
90e88fd3 1/* Header file for gimple ranger SSA cache.
a945c346 2 Copyright (C) 2017-2024 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"
156d7d8d 25#include "gimple-range-infer.h"
1cd5bc38 26#include "gimple-range-phi.h"
c6bb1db7 27
90e88fd3
AM
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
32class block_range_cache
33{
34public:
35 block_range_cache ();
36 ~block_range_cache ();
37
45c8523d
AH
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);
d242acc3 40 bool bb_range_p (tree name, const_basic_block bb);
90e88fd3
AM
41
42 void dump (FILE *f);
43 void dump (FILE *f, basic_block bb, bool print_varying = true);
44private:
45 vec<class ssa_block_ranges *> m_ssa_ranges;
46 ssa_block_ranges &get_block_ranges (tree name);
220929c0 47 ssa_block_ranges *query_block_ranges (tree name);
3ae9def0 48 class vrange_allocator *m_range_allocator;
9858cd1a 49 bitmap_obstack m_bitmaps;
90e88fd3
AM
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
71baa009 56class ssa_cache : public range_query
90e88fd3
AM
57{
58public:
8a3590e5
AM
59 ssa_cache ();
60 ~ssa_cache ();
46a594b9
AM
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);
72fb44ca 64 virtual bool merge_range (tree name, const vrange &r);
46a594b9
AM
65 virtual void clear_range (tree name);
66 virtual void clear ();
90e88fd3 67 void dump (FILE *f = stderr);
72fb44ca 68 virtual bool range_of_expr (vrange &r, tree expr, gimple *stmt = NULL);
0a38f677 69protected:
e1366a7e 70 vec<vrange_storage *> m_tab;
d8474337 71 vrange_allocator *m_range_allocator;
90e88fd3
AM
72};
73
0a38f677
AM
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.
0a38f677 77
46a594b9 78class ssa_lazy_cache : public ssa_cache
0a38f677
AM
79{
80public:
81 inline ssa_lazy_cache () { active_p = BITMAP_ALLOC (NULL); }
82 inline ~ssa_lazy_cache () { BITMAP_FREE (active_p); }
72fb44ca 83 inline bool empty_p () const { return bitmap_empty_p (active_p); }
46a594b9
AM
84 virtual bool has_range (tree name) const;
85 virtual bool set_range (tree name, const vrange &r);
72fb44ca 86 virtual bool merge_range (tree name, const vrange &r);
46a594b9
AM
87 virtual bool get_range (vrange &r, tree name) const;
88 virtual void clear_range (tree name);
89 virtual void clear ();
0a38f677 90protected:
0a38f677
AM
91 bitmap active_p;
92};
93
90e88fd3
AM
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
47ea02bb 98class ranger_cache : public range_query
90e88fd3
AM
99{
100public:
b7501739 101 ranger_cache (int not_executable_flag, bool use_imm_uses);
90e88fd3
AM
102 ~ranger_cache ();
103
26f77c4d
DM
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;
45c8523d 106 bool block_range (vrange &r, basic_block bb, tree name, bool calc = true);
90e88fd3 107
45c8523d
AH
108 bool get_global_range (vrange &r, tree name) const;
109 bool get_global_range (vrange &r, tree name, bool &current_p);
257c2be7 110 void set_global_range (tree name, const vrange &r, bool changed = true);
71baa009 111 range_query &const_query () { return m_globals; }
220929c0 112
cb596fd4
AM
113 void propagate_updated_value (tree name, basic_block bb);
114
c8381199 115 void register_inferred_value (const vrange &r, tree name, basic_block bb);
156d7d8d 116 void apply_inferred_ranges (gimple *s);
47ea02bb 117 gori_compute m_gori;
156d7d8d 118 infer_range_manager m_exit;
220929c0 119
47ea02bb 120 void dump_bb (FILE *f, basic_block bb);
ff171cb1 121 virtual void dump (FILE *f) override;
90e88fd3 122private:
8a3590e5 123 ssa_cache m_globals;
220929c0 124 block_range_cache m_on_entry;
e86fd6a1 125 class temporal_cache *m_temporal;
90e88fd3 126 void fill_block_cache (tree name, basic_block bb, basic_block def_bb);
ea7df355
AM
127 void propagate_cache (tree name);
128
6b156044
AM
129 enum rfd_mode
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 };
45c8523d 135 bool range_from_dom (vrange &r, tree name, basic_block bb, enum rfd_mode);
b0cc57cd 136 void resolve_dom (vrange &r, tree name, basic_block bb);
45c8523d
AH
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);
2e0f3246 141
90e88fd3 142 vec<basic_block> m_workback;
98244c68 143 class update_list *m_update;
90e88fd3
AM
144};
145
146#endif // GCC_SSA_RANGE_CACHE_H