GCC Middle and Back End API Reference
gimple-range.h
Go to the documentation of this file.
1/* Header file for the GIMPLE range interface.
2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.com>
4 and Aldy Hernandez <aldyh@redhat.com>.
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18You should have received a copy of the GNU General Public License
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
21
22#ifndef GCC_GIMPLE_RANGE_H
23#define GCC_GIMPLE_RANGE_H
24
25#include "ssa.h"
26#include "range.h"
27#include "value-query.h"
28#include "gimple-range-op.h"
29#include "gimple-range-trace.h"
30#include "gimple-range-edge.h"
31#include "gimple-range-fold.h"
32#include "gimple-range-gori.h"
33#include "gimple-range-cache.h"
34
35// This is the basic range generator interface.
36//
37// This base class provides all the API entry points, but only provides
38// functionality at the statement level. Ie, it can calculate ranges on
39// statements, but does no additional lookup.
40//
41// All the range_of_* methods will return a range if the types is
42// supported by the range engine. It may be the full range for the
43// type, AKA varying_p or it may be a refined range. If the range
44// type is not supported, then false is returned. Non-statement
45// related methods return whatever the current global value is.
46
48{
49public:
50 gimple_ranger (bool use_imm_uses = true);
52 virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override;
53 virtual bool range_of_expr (vrange &r, tree name, gimple * = NULL) override;
54 virtual bool range_on_edge (vrange &r, edge e, tree name) override;
55 virtual bool range_on_entry (vrange &r, basic_block bb, tree name) override;
56 virtual bool range_on_exit (vrange &r, basic_block bb, tree name) override;
58 virtual void dump (FILE *f) override;
59 void debug ();
60 void dump_bb (FILE *f, basic_block bb);
62 bool fold_stmt (gimple_stmt_iterator *gsi, tree (*) (tree));
66protected:
67 bool fold_range_internal (vrange &r, gimple *s, tree name);
68 void prefill_name (vrange &r, tree name);
74 friend class path_range_query;
75};
76
77/* Create a new ranger instance and associate it with a function.
78 Each call must be paired with a call to disable_ranger to release
79 resources. If USE_IMM_USES is true, pre-calculate side effects like
80 non-null uses as required using the immediate use chains. */
81extern gimple_ranger *enable_ranger (struct function *m,
82 bool use_imm_uses = true);
83extern void disable_ranger (struct function *);
84
85// DOM based ranger for fast VRP.
86// This must be processed in DOM order, and does only basic range operations.
87
88class dom_ranger : public range_query
89{
90public:
91 dom_ranger ();
92 ~dom_ranger ();
93
94 virtual bool range_of_expr (vrange &r, tree expr, gimple *s = NULL) override;
95 virtual bool range_on_edge (vrange &r, edge e, tree expr) override;
96 virtual bool range_of_stmt (vrange &r, gimple *s, tree name = NULL) override;
97
98
99 void pre_bb (basic_block bb);
100 void post_bb (basic_block bb);
101protected:
103 void range_in_bb (vrange &r, basic_block bb, tree name);
109};
110#endif // GCC_GIMPLE_RANGE_H
Definition cfg.h:177
Definition gimple-range.h:89
range_tracer tracer
Definition gimple-range.h:108
void post_bb(basic_block bb)
Definition gimple-range.cc:922
~dom_ranger()
Definition gimple-range.cc:728
bitmap_obstack m_bitmaps
Definition gimple-range.h:102
void pre_bb(basic_block bb)
Definition gimple-range.cc:870
virtual bool range_of_expr(vrange &r, tree expr, gimple *s=NULL) override
Definition gimple-range.cc:745
vec< ssa_lazy_cache * > m_freelist
Definition gimple-range.h:106
virtual bool range_of_stmt(vrange &r, gimple *s, tree name=NULL) override
Definition gimple-range.cc:826
dom_ranger()
Definition gimple-range.cc:715
virtual bool range_on_edge(vrange &r, edge e, tree expr) override
Definition gimple-range.cc:778
vec< ssa_lazy_cache * > m_bb
Definition gimple-range.h:107
void range_in_bb(vrange &r, basic_block bb, tree name)
Definition gimple-range.cc:805
DISABLE_COPY_AND_ASSIGN(dom_ranger)
ssa_cache m_global
Definition gimple-range.h:105
Definition genmatch.cc:1496
Definition gimple-range.h:48
bool fold_range_internal(vrange &r, gimple *s, tree name)
Definition gimple-range.cc:273
void dump_bb(FILE *f, basic_block bb)
Definition gimple-range.cc:582
basic_block current_bb
Definition gimple-range.h:72
virtual bool range_of_stmt(vrange &r, gimple *, tree name=NULL) override
Definition gimple-range.cc:287
virtual bool range_of_expr(vrange &r, tree name, gimple *=NULL) override
Definition gimple-range.cc:82
vec< tree > m_stmt_list
Definition gimple-range.h:73
range_query & const_query()
Definition gimple-range.cc:76
range_tracer tracer
Definition gimple-range.h:71
virtual bool range_on_exit(vrange &r, basic_block bb, tree name) override
Definition gimple-range.cc:186
void debug()
Definition gimple-range.cc:670
void prefill_stmt_dependencies(tree ssa)
Definition gimple-range.cc:380
virtual void dump(FILE *f) override
Definition gimple-range.cc:659
gimple_ranger(bool use_imm_uses=true)
Definition gimple-range.cc:40
bool fold_stmt(gimple_stmt_iterator *gsi, tree(*)(tree))
Definition gimple-range.cc:478
ranger_cache m_cache
Definition gimple-range.h:70
auto_edge_flag non_executable_edge_flag
Definition gimple-range.h:61
void register_inferred_ranges(gimple *s)
Definition gimple-range.cc:491
void export_global_ranges()
Definition gimple-range.cc:556
~gimple_ranger()
Definition gimple-range.cc:68
void prefill_name(vrange &r, tree name)
Definition gimple-range.cc:358
virtual bool range_on_entry(vrange &r, basic_block bb, tree name) override
Definition gimple-range.cc:156
virtual bool range_on_edge(vrange &r, edge e, tree name) override
Definition gimple-range.cc:220
void register_transitive_inferred_ranges(basic_block bb)
Definition gimple-range.cc:509
Definition gimple-range-path.h:33
Definition value-query.h:55
Definition gimple-range-trace.h:30
Definition gimple-range-cache.h:102
Definition gimple-range-cache.h:57
Definition value-range.h:78
class edge_def * edge
Definition coretypes.h:352
union tree_node * tree
Definition coretypes.h:97
gimple_ranger * enable_ranger(struct function *m, bool use_imm_uses=true)
Definition gimple-range.cc:680
void disable_ranger(struct function *)
Definition gimple-range.cc:695
poly_int< N, C > r
Definition poly-int.h:774
Definition basic-block.h:117
Definition bitmap.h:294
Definition function.h:249
Definition gimple-iterator.h:26
Definition gimple.h:221
Definition vec.h:450
#define NULL
Definition system.h:50