]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gimple-range.h
c++, mingw: Fix up types of dtor hooks to __cxa_{,thread_}atexit/__cxa_throw on mingw...
[thirdparty/gcc.git] / gcc / gimple-range.h
CommitLineData
90e88fd3 1/* Header file for the GIMPLE range interface.
a945c346 2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
90e88fd3
AM
3 Contributed by Andrew MacLeod <amacleod@redhat.com>
4 and Aldy Hernandez <aldyh@redhat.com>.
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 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
4c85ff75
AM
22#ifndef GCC_GIMPLE_RANGE_H
23#define GCC_GIMPLE_RANGE_H
90e88fd3 24
40c7f943 25#include "ssa.h"
90e88fd3 26#include "range.h"
47ea02bb 27#include "value-query.h"
51ce0638 28#include "gimple-range-op.h"
e68c8280 29#include "gimple-range-trace.h"
90e88fd3 30#include "gimple-range-edge.h"
4c85ff75 31#include "gimple-range-fold.h"
90e88fd3
AM
32#include "gimple-range-gori.h"
33#include "gimple-range-cache.h"
90e88fd3
AM
34
35// This is the basic range generator interface.
36//
37// This base class provides all the API entry points, but only provides
38// functionality at the statement level. Ie, it can calculate ranges on
c46b5b0a 39// statements, but does no additional lookup.
90e88fd3
AM
40//
41// All the range_of_* methods will return a range if the types is
42// supported by the range engine. It may be the full range for the
43// type, AKA varying_p or it may be a refined range. If the range
44// type is not supported, then false is returned. Non-statement
45// related methods return whatever the current global value is.
46
90e88fd3
AM
47class gimple_ranger : public range_query
48{
49public:
b7501739 50 gimple_ranger (bool use_imm_uses = true);
5deacf60 51 ~gimple_ranger ();
45c8523d
AH
52 virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override;
53 virtual bool range_of_expr (vrange &r, tree name, gimple * = NULL) override;
54 virtual bool range_on_edge (vrange &r, edge e, tree name) override;
39fe6209
AM
55 virtual bool range_on_entry (vrange &r, basic_block bb, tree name) override;
56 virtual bool range_on_exit (vrange &r, basic_block bb, tree name) override;
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);
71baa009 66 range_query &const_query ();
90e88fd3 67protected:
45c8523d
AH
68 bool fold_range_internal (vrange &r, gimple *s, tree name);
69 void prefill_name (vrange &r, tree name);
5deacf60 70 void prefill_stmt_dependencies (tree ssa);
90e88fd3 71 ranger_cache m_cache;
e68c8280 72 range_tracer tracer;
fc407675 73 basic_block current_bb;
5deacf60 74 vec<tree> m_stmt_list;
b7501739 75 friend class path_range_query;
90e88fd3
AM
76};
77
77bf9f83
MS
78/* Create a new ranger instance and associate it with a function.
79 Each call must be paired with a call to disable_ranger to release
c46b5b0a 80 resources. If USE_IMM_USES is true, pre-calculate side effects like
b7501739
AM
81 non-null uses as required using the immediate use chains. */
82extern gimple_ranger *enable_ranger (struct function *m,
83 bool use_imm_uses = true);
586d6f7a
AH
84extern void disable_ranger (struct function *);
85
53e6d7a3
AM
86class assume_query : public range_query
87{
88public:
89 assume_query ();
90 bool assume_range_p (vrange &r, tree name);
91 virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL);
92 void dump (FILE *f);
93protected:
94 void calculate_stmt (gimple *s, vrange &lhs_range, fur_source &src);
95 void calculate_op (tree op, gimple *s, vrange &lhs, fur_source &src);
96 void calculate_phi (gphi *phi, vrange &lhs_range, fur_source &src);
97 void check_taken_edge (edge e, fur_source &src);
98
0a38f677 99 ssa_lazy_cache global;
53e6d7a3
AM
100 gori_compute m_gori;
101};
102
33033823
AM
103// DOM based ranger for fast VRP.
104// This must be processed in DOM order, and does only basic range operations.
53e6d7a3 105
33033823
AM
106class dom_ranger : public range_query
107{
108public:
109 dom_ranger ();
110 ~dom_ranger ();
111
112 virtual bool range_of_expr (vrange &r, tree expr, gimple *s = NULL) override;
113 virtual bool range_on_edge (vrange &r, edge e, tree expr) override;
114 virtual bool range_of_stmt (vrange &r, gimple *s, tree name = NULL) override;
115
116 bool edge_range (vrange &r, edge e, tree name);
117 void range_in_bb (vrange &r, basic_block bb, tree name);
118
119 void pre_bb (basic_block bb);
120 void post_bb (basic_block bb);
121protected:
122 DISABLE_COPY_AND_ASSIGN (dom_ranger);
123 void maybe_push_edge (edge e, bool edge_0);
124 ssa_cache m_global;
125 gimple_outgoing_range m_out;
126 vec<ssa_lazy_cache *> m_freelist;
127 vec<ssa_lazy_cache *> m_e0;
128 vec<ssa_lazy_cache *> m_e1;
129 bitmap m_pop_list;
130 range_tracer tracer;
131};
4c85ff75 132#endif // GCC_GIMPLE_RANGE_H