]>
Commit | Line | Data |
---|---|---|
90e88fd3 | 1 | /* Header file for the GIMPLE range interface. |
aeee4812 | 2 | Copyright (C) 2019-2023 Free Software Foundation, Inc. |
90e88fd3 AM |
3 | Contributed by Andrew MacLeod <amacleod@redhat.com> |
4 | and Aldy Hernandez <aldyh@redhat.com>. | |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 3, or (at your option) any later | |
11 | version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
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/>. */ | |
21 | ||
4c85ff75 AM |
22 | #ifndef GCC_GIMPLE_RANGE_H |
23 | #define GCC_GIMPLE_RANGE_H | |
90e88fd3 | 24 | |
90e88fd3 | 25 | #include "range.h" |
47ea02bb | 26 | #include "value-query.h" |
51ce0638 | 27 | #include "gimple-range-op.h" |
e68c8280 | 28 | #include "gimple-range-trace.h" |
90e88fd3 | 29 | #include "gimple-range-edge.h" |
4c85ff75 | 30 | #include "gimple-range-fold.h" |
90e88fd3 AM |
31 | #include "gimple-range-gori.h" |
32 | #include "gimple-range-cache.h" | |
90e88fd3 AM |
33 | |
34 | // This is the basic range generator interface. | |
35 | // | |
36 | // This base class provides all the API entry points, but only provides | |
37 | // functionality at the statement level. Ie, it can calculate ranges on | |
38 | // statements, but does no additonal lookup. | |
39 | // | |
40 | // All the range_of_* methods will return a range if the types is | |
41 | // supported by the range engine. It may be the full range for the | |
42 | // type, AKA varying_p or it may be a refined range. If the range | |
43 | // type is not supported, then false is returned. Non-statement | |
44 | // related methods return whatever the current global value is. | |
45 | ||
90e88fd3 AM |
46 | class gimple_ranger : public range_query |
47 | { | |
48 | public: | |
b7501739 | 49 | gimple_ranger (bool use_imm_uses = true); |
5deacf60 | 50 | ~gimple_ranger (); |
45c8523d AH |
51 | virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override; |
52 | virtual bool range_of_expr (vrange &r, tree name, gimple * = NULL) override; | |
53 | virtual bool range_on_edge (vrange &r, edge e, tree name) override; | |
6fd485d1 | 54 | virtual void update_stmt (gimple *) override; |
45c8523d AH |
55 | void range_on_entry (vrange &r, basic_block bb, tree name); |
56 | void range_on_exit (vrange &r, basic_block bb, tree name); | |
90e88fd3 | 57 | void export_global_ranges (); |
47ea02bb | 58 | inline gori_compute &gori () { return m_cache.m_gori; } |
ff171cb1 | 59 | virtual void dump (FILE *f) override; |
257fd033 | 60 | void debug (); |
35c78c6f | 61 | void dump_bb (FILE *f, basic_block bb); |
053e1d64 | 62 | auto_edge_flag non_executable_edge_flag; |
fc407675 | 63 | bool fold_stmt (gimple_stmt_iterator *gsi, tree (*) (tree)); |
156d7d8d | 64 | void register_inferred_ranges (gimple *s); |
c8381199 | 65 | void register_transitive_inferred_ranges (basic_block bb); |
90e88fd3 | 66 | protected: |
45c8523d AH |
67 | bool fold_range_internal (vrange &r, gimple *s, tree name); |
68 | void prefill_name (vrange &r, tree name); | |
5deacf60 | 69 | void prefill_stmt_dependencies (tree ssa); |
90e88fd3 | 70 | ranger_cache m_cache; |
e68c8280 | 71 | range_tracer tracer; |
fc407675 | 72 | basic_block current_bb; |
5deacf60 | 73 | vec<tree> m_stmt_list; |
b7501739 | 74 | friend class path_range_query; |
90e88fd3 AM |
75 | }; |
76 | ||
77bf9f83 MS |
77 | /* Create a new ranger instance and associate it with a function. |
78 | Each call must be paired with a call to disable_ranger to release | |
b7501739 AM |
79 | resources. If USE_IMM_USES is true, pre-calculate sideffects like |
80 | non-null uses as required using the immediate use chains. */ | |
81 | extern gimple_ranger *enable_ranger (struct function *m, | |
82 | bool use_imm_uses = true); | |
586d6f7a AH |
83 | extern void disable_ranger (struct function *); |
84 | ||
53e6d7a3 AM |
85 | class assume_query : public range_query |
86 | { | |
87 | public: | |
88 | assume_query (); | |
89 | bool assume_range_p (vrange &r, tree name); | |
90 | virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL); | |
91 | void dump (FILE *f); | |
92 | protected: | |
93 | void calculate_stmt (gimple *s, vrange &lhs_range, fur_source &src); | |
94 | void calculate_op (tree op, gimple *s, vrange &lhs, fur_source &src); | |
95 | void calculate_phi (gphi *phi, vrange &lhs_range, fur_source &src); | |
96 | void check_taken_edge (edge e, fur_source &src); | |
97 | ||
98 | ssa_global_cache global; | |
99 | gori_compute m_gori; | |
100 | }; | |
101 | ||
102 | ||
4c85ff75 | 103 | #endif // GCC_GIMPLE_RANGE_H |