GCC Middle and Back End API Reference
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>.
6This file is part of GCC.
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
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.
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/>. */
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"
35// This is the basic range generator interface.
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.
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.
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 void range_on_entry (vrange &r, basic_block bb, tree name);
56 void range_on_exit (vrange &r, basic_block bb, tree name);
58 inline gori_compute &gori () { return m_cache.m_gori; }
59 virtual void dump (FILE *f) override;
60 void debug ();
61 void dump_bb (FILE *f, basic_block bb);
63 bool fold_stmt (gimple_stmt_iterator *gsi, tree (*) (tree));
68 bool fold_range_internal (vrange &r, gimple *s, tree name);
69 void prefill_name (vrange &r, tree name);
75 friend class path_range_query;
78/* Create a new ranger instance and associate it with a function.
79 Each call must be paired with a call to disable_ranger to release
80 resources. If USE_IMM_USES is true, pre-calculate side effects like
81 non-null uses as required using the immediate use chains. */
82extern gimple_ranger *enable_ranger (struct function *m,
83 bool use_imm_uses = true);
84extern void disable_ranger (struct function *);
89 assume_query ();
90 bool assume_range_p (vrange &r, tree name);
91 virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL);
92 void dump (FILE *f);
95 void calculate_op (tree op, gimple *s, vrange &lhs, fur_source &src);
96 void calculate_phi (gphi *phi, vrange &lhs_range, fur_source &src);
97 void check_taken_edge (edge e, fur_source &src);
103// DOM based ranger for fast VRP.
104// This must be processed in DOM order, and does only basic range operations.
109 dom_ranger ();
110 ~dom_ranger ();
112 virtual bool range_of_expr (vrange &r, tree expr, gimple *s = NULL) override;
113 virtual bool range_on_edge (vrange &r, edge e, tree expr) override;
114 virtual bool range_of_stmt (vrange &r, gimple *s, tree name = NULL) override;
116 bool edge_range (vrange &r, edge e, tree name);
117 void range_in_bb (vrange &r, basic_block bb, tree name);
119 void pre_bb (basic_block bb);
120 void post_bb (basic_block bb);
123 void maybe_push_edge (edge e, bool edge_0);
132#endif // GCC_GIMPLE_RANGE_H
Definition gimple-range.h:87
gori_compute m_gori
Definition gimple-range.h:100
ssa_lazy_cache global
Definition gimple-range.h:99
void dump(FILE *f)
Definition gimple-range.cc:874
void check_taken_edge(edge e, fur_source &src)
Definition gimple-range.cc:832
bool assume_range_p(vrange &r, tree name)
Definition gimple-range.cc:716
virtual bool range_of_expr(vrange &r, tree expr, gimple *=NULL)
Definition gimple-range.cc:726
Definition gimple-range.cc:740
void calculate_stmt(gimple *s, vrange &lhs_range, fur_source &src)
Definition gimple-range.cc:846
void calculate_op(tree op, gimple *s, vrange &lhs, fur_source &src)
Definition gimple-range.cc:776
void calculate_phi(gphi *phi, vrange &lhs_range, fur_source &src)
Definition gimple-range.cc:795
Definition cfg.h:177
Definition gimple-range.h:107
range_tracer tracer
Definition gimple-range.h:130
void post_bb(basic_block bb)
Definition gimple-range.cc:1194
Definition gimple-range.cc:918
void pre_bb(basic_block bb)
Definition gimple-range.cc:1155
virtual bool range_of_expr(vrange &r, tree expr, gimple *s=NULL) override
Definition gimple-range.cc:936
vec< ssa_lazy_cache * > m_freelist
Definition gimple-range.h:126
virtual bool range_of_stmt(vrange &r, gimple *s, tree name=NULL) override
Definition gimple-range.cc:1051
Definition gimple-range.cc:903
virtual bool range_on_edge(vrange &r, edge e, tree expr) override
Definition gimple-range.cc:993
vec< ssa_lazy_cache * > m_e1
Definition gimple-range.h:128
gimple_outgoing_range m_out
Definition gimple-range.h:125
void maybe_push_edge(edge e, bool edge_0)
Definition gimple-range.cc:1130
bool edge_range(vrange &r, edge e, tree name)
Definition gimple-range.cc:969
bitmap m_pop_list
Definition gimple-range.h:129
void range_in_bb(vrange &r, basic_block bb, tree name)
Definition gimple-range.cc:1018
vec< ssa_lazy_cache * > m_e0
Definition gimple-range.h:127
ssa_cache m_global
Definition gimple-range.h:124
Definition genmatch.cc:845
Definition gimple-range-fold.h:98
Definition gimple-range-edge.h:39
Definition gimple-range.h:48
bool fold_range_internal(vrange &r, gimple *s, tree name)
Definition gimple-range.cc:261
void dump_bb(FILE *f, basic_block bb)
Definition gimple-range.cc:590
basic_block current_bb
Definition gimple-range.h:73
virtual bool range_of_stmt(vrange &r, gimple *, tree name=NULL) override
Definition gimple-range.cc:275
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:74
range_query & const_query()
Definition gimple-range.cc:76
gori_compute & gori()
Definition gimple-range.h:58
void range_on_entry(vrange &r, basic_block bb, tree name)
Definition gimple-range.cc:148
range_tracer tracer
Definition gimple-range.h:72
void debug()
Definition gimple-range.cc:678
void prefill_stmt_dependencies(tree ssa)
Definition gimple-range.cc:368
virtual void dump(FILE *f) override
Definition gimple-range.cc:667
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:466
ranger_cache m_cache
Definition gimple-range.h:71
auto_edge_flag non_executable_edge_flag
Definition gimple-range.h:62
void range_on_exit(vrange &r, basic_block bb, tree name)
Definition gimple-range.cc:175
void register_inferred_ranges(gimple *s)
Definition gimple-range.cc:479
void export_global_ranges()
Definition gimple-range.cc:551
Definition gimple-range.cc:68
void prefill_name(vrange &r, tree name)
Definition gimple-range.cc:346
virtual bool range_on_edge(vrange &r, edge e, tree name) override
Definition gimple-range.cc:208
void register_transitive_inferred_ranges(basic_block bb)
Definition gimple-range.cc:504
Definition gimple-range-gori.h:165
Definition gimple-range-path.h:33
Definition value-query.h:55
Definition gimple-range-trace.h:30
Definition gimple-range-cache.h:99
gori_compute m_gori
Definition gimple-range-cache.h:117
Definition gimple-range-cache.h:57
Definition gimple-range-cache.h:79
Definition value-range.h:76
class edge_def * edge
Definition coretypes.h:342
class bitmap_head * bitmap
Definition coretypes.h:51
union tree_node * tree
Definition coretypes.h:97
Definition ggc.h:184
gimple_ranger * enable_ranger(struct function *m, bool use_imm_uses=true)
Definition gimple-range.cc:688
void disable_ranger(struct function *)
Definition gimple-range.cc:703
poly_int< N, C > r
Definition poly-int.h:770
Definition basic-block.h:117
Definition function.h:249
Definition gimple-iterator.h:26
Definition gimple.h:225
Definition gimple.h:461
Definition vec.h:450
#define NULL
Definition system.h:50