aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-trace.h
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2021-07-30 15:15:29 -0400
committerAndrew MacLeod <amacleod@redhat.com>2021-08-17 19:28:42 -0400
commite68c8280fa2e1b7071378cfdd876155c73ec944f (patch)
tree0ae12a1714e30ae84386e81130f2902117bf71bd /gcc/gimple-range-trace.h
parentb48d4e6818674898f90d9358378c127511ef0f9f (diff)
downloadgcc-e68c8280fa2e1b7071378cfdd876155c73ec944f.zip
gcc-e68c8280fa2e1b7071378cfdd876155c73ec944f.tar.gz
gcc-e68c8280fa2e1b7071378cfdd876155c73ec944f.tar.bz2
Abstract tracing routines into a class.
Generalize range tracing into a class and integrae it with gimple_ranger. Remove the old derived trace_ranger class. * Makefile.in (OBJS): Add gimple-range-trace.o. * gimple-range-cache.h (enable_new_values): Remove unused prototype. * gimple-range-fold.cc: Adjust headers. * gimple-range-trace.cc: New. * gimple-range-trace.h: New. * gimple-range.cc (gimple_ranger::gimple_ranger): Enable tracer. (gimple_ranger::range_of_expr): Add tracing. (gimple_ranger::range_on_entry): Ditto. (gimple_ranger::range_on_exit): Ditto. (gimple_ranger::range_on_edge): Ditto. (gimple_ranger::fold_range_internal): Ditto. (gimple_ranger::dump_bb): Do not calculate edge range twice. (trace_ranger::*): Remove. (enable_ranger): Never create a trace_ranger. (debug_seed_ranger): Move to gimple-range-trace.cc. (dump_ranger): Ditto. (debug_ranger): Ditto. * gimple-range.h: Include gimple-range-trace.h. (range_on_entry, range_on_exit): No longer virtual. (class trace_ranger): Remove. (DEBUG_RANGE_CACHE): Move to gimple-range-trace.h.
Diffstat (limited to 'gcc/gimple-range-trace.h')
-rw-r--r--gcc/gimple-range-trace.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/gcc/gimple-range-trace.h b/gcc/gimple-range-trace.h
new file mode 100644
index 0000000..6f89fcc
--- /dev/null
+++ b/gcc/gimple-range-trace.h
@@ -0,0 +1,64 @@
+/* Header file for the GIMPLE range tracing/debugging facilties.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ Contributed by Andrew MacLeod <amacleod@redhat.com>
+ and Aldy Hernandez <aldyh@redhat.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_GIMPLE_RANGE_TRACE_H
+#define GCC_GIMPLE_RANGE_TRACE_H
+
+// This class manages range tracing for the ranger and gori components.
+// Tracing will provide a unique integer index whenever a new trace
+// is started. This can be used to identify where a calculation has gone wrong.
+
+class range_tracer
+{
+public:
+ range_tracer (const char *name = "");
+ unsigned header (const char *str);
+ void trailer (unsigned counter, const char *caller, bool result, tree name,
+ const irange &r);
+ void print (unsigned counter, const char *str);
+ inline void enable_trace () { tracing = true; }
+ inline void disable_trace () { tracing = false; }
+ virtual void breakpoint (unsigned index);
+private:
+ unsigned do_header (const char *str);
+ void print_prefix (unsigned idx, bool blanks);
+ static const unsigned bump = 2;
+ unsigned indent;
+ static const unsigned name_len = 100;
+ char component[name_len];
+ bool tracing;
+};
+
+
+// If tracing is enabled, start a new trace header, returning the trace index.
+// Otherwise return 0.
+
+inline unsigned
+range_tracer::header (const char *str)
+{
+ if (tracing)
+ return do_header (str);
+ return 0;
+}
+
+#define DEBUG_RANGE_CACHE (dump_file && (param_evrp_mode & EVRP_MODE_DEBUG))
+
+#endif // GCC_GIMPLE_RANGE_TRACE_H