1 /* Support routines for value queries.
2 Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Andrew Macleod <amacleod@redhat.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
25 // The value_query class is used by optimization passes that require
26 // valueizing SSA names in terms of a tree value, but have no neeed
29 // value_of_expr must be provided. The default for value_on_edge and
30 // value_of_stmt is to call value_of_expr.
32 // This implies the valuation is global in nature. If a pass can make
33 // use of more specific information, it can override the other queries.
35 // Proper usage of the correct query in passes will enable other
36 // valuation mechanisms to produce more precise results.
42 // Return the singleton expression for NAME at a gimple statement,
43 // or NULL if none found.
44 virtual tree
value_of_expr (tree name
, gimple
* = NULL
) = 0;
45 // Return the singleton expression for NAME at an edge, or NULL if
47 virtual tree
value_on_edge (edge
, tree name
);
48 // Return the singleton expression for the LHS of a gimple
49 // statement, assuming an (optional) initial value of NAME. Returns
50 // NULL if none found.
52 // Note that this method calculates the range the LHS would have
53 // *after* the statement has executed.
54 virtual tree
value_of_stmt (gimple
*, tree name
= NULL
);
57 DISABLE_COPY_AND_ASSIGN (value_query
);
60 // The range_query class is used by optimization passes which are
63 // range_of_expr must be provided. The default for range_on_edge and
64 // range_of_stmt is to call range_of_expr. If a pass can make use of
65 // more specific information, then it can override the other queries.
67 // The default for the value_* routines is to call the equivalent
68 // range_* routines, check if the range is a singleton, and return it
71 // The get_value_range method is currently provided for compatibility
72 // with vr-values. It will be deprecated when possible.
74 class range_query
: public value_query
78 virtual ~range_query ();
80 virtual tree
value_of_expr (tree name
, gimple
* = NULL
) OVERRIDE
;
81 virtual tree
value_on_edge (edge
, tree name
) OVERRIDE
;
82 virtual tree
value_of_stmt (gimple
*, tree name
= NULL
) OVERRIDE
;
84 // These are the range equivalents of the value_* methods. Instead
85 // of returning a singleton, they calculate a range and return it in
86 // R. TRUE is returned on success or FALSE if no range was found.
88 // Note that range_of_expr must always return TRUE unless ranges are
89 // unsupported for NAME's type (supports_type_p is false).
90 virtual bool range_of_expr (irange
&r
, tree name
, gimple
* = NULL
) = 0;
91 virtual bool range_on_edge (irange
&r
, edge
, tree name
);
92 virtual bool range_of_stmt (irange
&r
, gimple
*, tree name
= NULL
);
94 // DEPRECATED: This method is used from vr-values. The plan is to
95 // rewrite all uses of it to the above API.
96 virtual const class value_range_equiv
*get_value_range (const_tree
,
100 class value_range_equiv
*allocate_value_range_equiv ();
101 void free_value_range_equiv (class value_range_equiv
*);
104 class equiv_allocator
*equiv_alloc
;
107 #endif // GCC_QUERY_H