1 /* Header file for gimple range inference.
2 Copyright (C) 2022-2023 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
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
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
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
);
43 void check_assume_func (gcall
*call
);
45 static const int size_limit
= 10;
46 tree m_names
[size_limit
];
47 Value_Range m_ranges
[size_limit
];
48 inline void bump_index () { if (num_args
< size_limit
- 1) num_args
++; }
51 // This class manages a list of inferred ranges for each basic block.
52 // As inferences are made, they can be registered to a block and later
53 // queried. When constructed with a TRUE flag, immediate uses chains are
54 // followed the first time a name is referenced and block populated if
55 // there are any inferred ranges.
57 class infer_range_manager
60 infer_range_manager (bool do_search
);
61 ~infer_range_manager ();
62 void add_range (tree name
, basic_block bb
, const vrange
&r
);
63 void add_nonzero (tree name
, basic_block bb
);
64 bool has_range_p (tree name
, basic_block bb
);
65 bool has_range_p (basic_block bb
);
66 bool maybe_adjust_range (vrange
&r
, tree name
, basic_block bb
);
71 bitmap m_names
; // list of names with an outgoing range.
72 class exit_range
*head
;
74 exit_range
*find_ptr (tree name
);
76 void register_all_uses (tree name
);
77 vec
<exit_range_head
> m_on_exit
;
78 const vrange
&get_nonzero (tree name
);
79 vec
<vrange
*> m_nonzero
;
81 bitmap_obstack m_bitmaps
;
82 struct obstack m_list_obstack
;
83 class vrange_allocator
*m_range_allocator
;
86 #endif // GCC_GIMPLE_RANGE_SIDE_H