GCC Middle and Back End API Reference
gimple-range-infer.h
Go to the documentation of this file.
1/* Header file for gimple range inference.
2 Copyright (C) 2022-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_GIMPLE_RANGE_SIDE_H
22#define GCC_GIMPLE_RANGE_SIDE_H
23
24// Inferred ranges are ranges which are applied to use operands as a by product
25// of executing an operation.
26
27// This class manages an on-demand summary of inferred ranges for a statement.
28// It can be instantiated as required and provides a list of inferred ranges.
29// New inferred ranges should be added in the constructor of this class.
30
32{
33public:
34 gimple_infer_range (gimple *s, bool use_rangeops = false);
36 inline unsigned num () const { return num_args; }
37 inline tree name (unsigned index) const
38 { gcc_checking_assert (index < num_args); return m_names[index]; }
39 inline const vrange& range (unsigned index) const
40 { gcc_checking_assert (index < num_args); return m_ranges[index]; }
41private:
43 void add_nonzero (tree name);
44 void check_assume_func (gcall *call);
45 unsigned num_args;
46 static const int size_limit = 10;
49 inline void bump_index () { if (num_args < size_limit - 1) num_args++; }
50 friend class non_null_wrapper;
51};
52
53// This is the basic infer oracle API. Default functionaility does nothing.
54
56{
57public:
59 virtual ~infer_range_oracle () { }
60 virtual void add_ranges (gimple *, gimple_infer_range &) { }
61 virtual bool has_range_p (basic_block, tree = NULL_TREE) { return false; }
63 { return false; }
64};
65
66// This class manages a list of inferred ranges for each basic block.
67// As inferences are made, they can be registered to a block and later
68// queried. When constructed with a TRUE flag, immediate uses chains are
69// followed the first time a name is referenced and block populated if
70// there are any inferred ranges.
71
73{
74public:
75 infer_range_manager (bool do_search);
76 virtual ~infer_range_manager ();
77 virtual void add_ranges (gimple *s, gimple_infer_range &ir);
78 virtual bool has_range_p (basic_block bb, tree name = NULL_TREE);
79 virtual bool maybe_adjust_range (vrange &r, tree name, basic_block bb);
80private:
81 void add_range (tree name, gimple *s, const vrange &r);
82 void add_nonzero (tree name, gimple *s);
84 {
85 public:
86 bitmap m_names; // list of names with an outgoing range.
89 exit_range *find_ptr (tree name);
90 };
91 void register_all_uses (tree name);
92 vec <exit_range_head> m_on_exit;
93 const vrange &get_nonzero (tree name);
94 vec <vrange *> m_nonzero;
99};
100
101#endif // GCC_GIMPLE_RANGE_SIDE_H
Definition value-range.h:757
Definition gimple-range-infer.cc:247
Definition gimple-range-infer.h:32
tree name(unsigned index) const
Definition gimple-range-infer.h:37
Value_Range m_ranges[size_limit]
Definition gimple-range-infer.h:48
unsigned num() const
Definition gimple-range-infer.h:36
tree m_names[size_limit]
Definition gimple-range-infer.h:47
void add_nonzero(tree name)
Definition gimple-range-infer.cc:144
static const int size_limit
Definition gimple-range-infer.h:46
void check_assume_func(gcall *call)
Definition gimple-range-infer.cc:82
gimple_infer_range(gimple *s, bool use_rangeops=false)
Definition gimple-range-infer.cc:160
unsigned num_args
Definition gimple-range-infer.h:45
const vrange & range(unsigned index) const
Definition gimple-range-infer.h:39
void add_range(tree name, vrange &range)
Definition gimple-range-infer.cc:130
void bump_index()
Definition gimple-range-infer.h:49
Definition gimple-range-infer.h:84
class exit_range * head
Definition gimple-range-infer.h:87
exit_range * find_ptr(tree name)
Definition gimple-range-infer.cc:260
bitmap m_names
Definition gimple-range-infer.h:86
int m_num_ranges
Definition gimple-range-infer.h:88
Definition gimple-range-infer.h:73
void add_range(tree name, gimple *s, const vrange &r)
Definition gimple-range-infer.cc:375
bitmap_obstack m_bitmaps
Definition gimple-range-infer.h:96
vec< exit_range_head > m_on_exit
Definition gimple-range-infer.h:92
void add_nonzero(tree name, gimple *s)
Definition gimple-range-infer.cc:427
virtual void add_ranges(gimple *s, gimple_infer_range &ir)
Definition gimple-range-infer.cc:366
class vrange_allocator * m_range_allocator
Definition gimple-range-infer.h:98
virtual bool maybe_adjust_range(vrange &r, tree name, basic_block bb)
Definition gimple-range-infer.cc:350
bitmap m_seen
Definition gimple-range-infer.h:95
void register_all_uses(tree name)
Definition gimple-range-infer.cc:435
virtual ~infer_range_manager()
Definition gimple-range-infer.cc:297
const vrange & get_nonzero(tree name)
Definition gimple-range-infer.cc:310
virtual bool has_range_p(basic_block bb, tree name=NULL_TREE)
Definition gimple-range-infer.cc:328
vec< vrange * > m_nonzero
Definition gimple-range-infer.h:94
struct obstack m_list_obstack
Definition gimple-range-infer.h:97
infer_range_manager(bool do_search)
Definition gimple-range-infer.cc:277
Definition gimple-range-infer.h:56
virtual ~infer_range_oracle()
Definition gimple-range-infer.h:59
infer_range_oracle()
Definition gimple-range-infer.h:58
virtual bool has_range_p(basic_block, tree=NULL_TREE)
Definition gimple-range-infer.h:61
virtual bool maybe_adjust_range(vrange &, tree, basic_block)
Definition gimple-range-infer.h:62
virtual void add_ranges(gimple *, gimple_infer_range &)
Definition gimple-range-infer.h:60
Definition gimple-range-infer.cc:50
Definition value-range-storage.h:28
Definition value-range.h:78
class bitmap_head * bitmap
Definition coretypes.h:51
union tree_node * tree
Definition coretypes.h:97
static struct obstack obstack
Definition gcc.cc:357
poly_int< N, C > r
Definition poly-int.h:770
Definition basic-block.h:117
Definition bitmap.h:294
Definition gimple.h:353
Definition gimple.h:225
#define gcc_checking_assert(EXPR)
Definition system.h:828
#define NULL_TREE
Definition tree.h:317