1 /* Header file for the GIMPLE range interface.
2 Copyright (C) 2019-2021 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.com>
4 and Aldy Hernandez <aldyh@redhat.com>.
6 This file is part of GCC.
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
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
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/>. */
22 #ifndef GCC_GIMPLE_RANGE_H
23 #define GCC_GIMPLE_RANGE_H
27 #include "value-query.h"
29 #include "gimple-range-edge.h"
30 #include "gimple-range-fold.h"
31 #include "gimple-range-gori.h"
32 #include "gimple-range-cache.h"
34 // This is the basic range generator interface.
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.
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.
47 class gimple_ranger
: public range_query
51 virtual bool range_of_stmt (irange
&r
, gimple
*, tree name
= NULL
) OVERRIDE
;
52 virtual bool range_of_expr (irange
&r
, tree name
, gimple
* = NULL
) OVERRIDE
;
53 virtual bool range_on_edge (irange
&r
, edge e
, tree name
) OVERRIDE
;
54 virtual void range_on_entry (irange
&r
, basic_block bb
, tree name
);
55 virtual void range_on_exit (irange
&r
, basic_block bb
, tree name
);
56 void export_global_ranges ();
57 inline gori_compute
&gori () { return m_cache
.m_gori
; }
58 virtual void dump (FILE *f
) OVERRIDE
;
59 void dump_bb (FILE *f
, basic_block bb
);
61 bool fold_range_internal (irange
&r
, gimple
*s
, tree name
);
66 // This class overloads the ranger routines to provide tracing facilties
67 // Entry and exit values to each of the APIs is placed in the dumpfile.
69 class trace_ranger
: public gimple_ranger
73 virtual bool range_of_stmt (irange
&r
, gimple
*s
, tree name
= NULL_TREE
);
74 virtual bool range_of_expr (irange
&r
, tree name
, gimple
*s
= NULL
);
75 virtual bool range_on_edge (irange
&r
, edge e
, tree name
);
76 virtual void range_on_entry (irange
&r
, basic_block bb
, tree name
);
77 virtual void range_on_exit (irange
&r
, basic_block bb
, tree name
);
79 static const unsigned bump
= 2;
81 unsigned trace_count
; // Current trace index count.
83 bool dumping (unsigned counter
, bool trailing
= false);
84 bool trailer (unsigned counter
, const char *caller
, bool result
, tree name
,
88 // Flag to enable debugging the various internal Caches.
89 #define DEBUG_RANGE_CACHE (dump_file && (param_evrp_mode & EVRP_MODE_DEBUG))
91 extern gimple_ranger
*enable_ranger (struct function
*);
92 extern void disable_ranger (struct function
*);
94 #endif // GCC_GIMPLE_RANGE_H