]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/value-query.h
[prange] Reword dispatch error message
[thirdparty/gcc.git] / gcc / value-query.h
CommitLineData
6eda9fa5 1/* Support routines for value queries.
a945c346 2 Copyright (C) 2020-2024 Free Software Foundation, Inc.
6eda9fa5
AH
3 Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 Andrew Macleod <amacleod@redhat.com>.
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 3, or (at your option)
11any later version.
12
13GCC is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
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/>. */
21
22#ifndef GCC_QUERY_H
23#define GCC_QUERY_H
24
3aaa69e5
AM
25#include "value-relation.h"
26
6eda9fa5 27// The value_query class is used by optimization passes that require
c46b5b0a 28// valueizing SSA names in terms of a tree value, but have no need
6eda9fa5
AH
29// for ranges.
30//
31// value_of_expr must be provided. The default for value_on_edge and
32// value_of_stmt is to call value_of_expr.
33//
34// This implies the valuation is global in nature. If a pass can make
35// use of more specific information, it can override the other queries.
36//
37// Proper usage of the correct query in passes will enable other
38// valuation mechanisms to produce more precise results.
39
6eda9fa5
AH
40// The range_query class is used by optimization passes which are
41// range aware.
42//
43// range_of_expr must be provided. The default for range_on_edge and
44// range_of_stmt is to call range_of_expr. If a pass can make use of
45// more specific information, then it can override the other queries.
46//
47// The default for the value_* routines is to call the equivalent
48// range_* routines, check if the range is a singleton, and return it
49// if so.
50//
51// The get_value_range method is currently provided for compatibility
52// with vr-values. It will be deprecated when possible.
53
61964139 54class range_query
6eda9fa5
AH
55{
56public:
57 range_query ();
58 virtual ~range_query ();
59
61964139
AM
60 virtual tree value_of_expr (tree expr, gimple * = NULL);
61 virtual tree value_on_edge (edge, tree expr);
62 virtual tree value_of_stmt (gimple *, tree name = NULL);
39fe6209
AM
63 virtual tree value_on_entry (basic_block, tree expr);
64 virtual tree value_on_exit (basic_block, tree expr);
6eda9fa5
AH
65
66 // These are the range equivalents of the value_* methods. Instead
67 // of returning a singleton, they calculate a range and return it in
68 // R. TRUE is returned on success or FALSE if no range was found.
69 //
70 // Note that range_of_expr must always return TRUE unless ranges are
7c097d18 71 // unsupported for EXPR's type (supports_type_p is false).
45c8523d
AH
72 virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL) = 0;
73 virtual bool range_on_edge (vrange &r, edge, tree expr);
74 virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL);
39fe6209
AM
75 virtual bool range_on_entry (vrange &r, basic_block bb, tree expr);
76 virtual bool range_on_exit (vrange &r, basic_block bb, tree expr);
6eda9fa5 77
3aaa69e5
AM
78 // Query if there is any relation between SSA1 and SSA2.
79 relation_kind query_relation (gimple *s, tree ssa1, tree ssa2,
80 bool get_range = true);
81 relation_kind query_relation (edge e, tree ssa1, tree ssa2,
82 bool get_range = true);
83 // If present, Access relation oracle for more advanced uses.
84 inline relation_oracle *oracle () const { return m_oracle; }
85
586d6f7a 86 virtual void dump (FILE *);
6eda9fa5
AH
87
88protected:
39fe6209
AM
89 bool get_tree_range (vrange &v, tree expr, gimple *stmt,
90 basic_block bbentry = NULL, basic_block bbexit = NULL);
91 bool invoke_range_of_expr (vrange &v, tree expr, gimple *stmt,
92 basic_block bbentry, basic_block bbexit);
45c8523d 93 bool get_arith_expr_range (vrange &r, tree expr, gimple *stmt);
3aaa69e5 94 relation_oracle *m_oracle;
6eda9fa5
AH
95};
96
13dbaefe
AH
97// Global ranges for SSA names using SSA_NAME_RANGE_INFO.
98
99class global_range_query : public range_query
100{
101public:
45c8523d 102 bool range_of_expr (vrange &r, tree expr, gimple * = NULL) override;
13dbaefe
AH
103};
104
105extern global_range_query global_ranges;
56af35de
AM
106
107inline range_query *
108get_global_range_query ()
109{
110 return &global_ranges;
111}
112
113/* Returns the currently active range access class. When there is no active
114 range class, global ranges are used. Never returns null. */
115
116ATTRIBUTE_RETURNS_NONNULL inline range_query *
117get_range_query (const struct function *fun)
118{
175d5285 119 return (fun && fun->x_range_query) ? fun->x_range_query : &global_ranges;
56af35de
AM
120}
121
99f3ad2e
AM
122// Query the global range of NAME in function F. Default to cfun.
123extern void gimple_range_global (vrange &v, tree name,
124 struct function *f = cfun);
13dbaefe 125
6eda9fa5 126#endif // GCC_QUERY_H