c++: trivial formatting cleanups
[official-gcc.git] / gcc / gimple-range-infer.h
blob468b7d112868fbcf264cc502cc338bc5c80637e8
1 /* Header file for gimple range inference.
2 Copyright (C) 2022 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_GIMPLE_RANGE_SIDE_H
22 #define GCC_GIMPLE_RANGE_SIDE_H
24 // Inferred ranges are ranges which are applied to use operands as a by product
25 // of executing an operation.
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.
31 class gimple_infer_range
33 public:
34 gimple_infer_range (gimple *s);
35 inline unsigned num () const { return num_args; }
36 inline tree name (unsigned index) const
37 { gcc_checking_assert (index < num_args); return m_names[index]; }
38 inline const vrange& range (unsigned index) const
39 { gcc_checking_assert (index < num_args); return m_ranges[index]; }
40 void add_range (tree name, vrange &range);
41 void add_nonzero (tree name);
42 private:
43 unsigned num_args;
44 static const int size_limit = 10;
45 tree m_names[size_limit];
46 Value_Range m_ranges[size_limit];
47 inline void bump_index () { if (num_args < size_limit - 1) num_args++; }
50 // This class manages a list of inferred ranges for each basic block.
51 // As inferences are made, they can be registered to a block and later
52 // queried. When constructed with a TRUE flag, immediate uses chains are
53 // followed the first time a name is referenced and block populated if
54 // there are any inferred ranges.
56 class infer_range_manager
58 public:
59 infer_range_manager (bool do_search);
60 ~infer_range_manager ();
61 void add_range (tree name, basic_block bb, const vrange &r);
62 void add_nonzero (tree name, basic_block bb);
63 bool has_range_p (tree name, basic_block bb);
64 bool maybe_adjust_range (vrange &r, tree name, basic_block bb);
65 private:
66 class exit_range_head
68 public:
69 bitmap m_names; // list of names with an outgoing range.
70 class exit_range *head;
71 int m_num_ranges;
72 exit_range *find_ptr (tree name);
74 void register_all_uses (tree name);
75 vec <exit_range_head> m_on_exit;
76 const vrange &get_nonzero (tree name);
77 vec <vrange *> m_nonzero;
78 bitmap m_seen;
79 bitmap_obstack m_bitmaps;
80 struct obstack m_list_obstack;
81 class obstack_vrange_allocator *m_range_allocator;
84 #endif // GCC_GIMPLE_RANGE_SIDE_H