class optrecord_json_writer;
namespace selftest { class temp_dump_context; }
+class debug_dump_context;
/* A class for handling the various dump_* calls.
class dump_context
{
friend class selftest::temp_dump_context;
+ friend class debug_dump_context;
public:
static dump_context &get () { return *s_current; }
auto_vec<stashed_item> m_stashed_items;
};
+/* An RAII-style class for use in debug dumpers for temporarily using a
+ different dump_context. It enables full details and outputs to
+ stderr instead of the currently active dump_file. */
+
+class debug_dump_context
+{
+ public:
+ debug_dump_context ();
+ ~debug_dump_context ();
+
+ private:
+ dump_context m_context;
+ dump_context *m_saved;
+ dump_flags_t m_saved_flags;
+ dump_flags_t m_saved_pflags;
+ FILE *m_saved_file;
+};
+
+
#if CHECKING_P
namespace selftest {
return num_enabled > 0;
}
+/* debug_dump_context's ctor. Temporarily override the dump_context
+ (to forcibly enable output to stderr). */
+
+debug_dump_context::debug_dump_context ()
+: m_context (),
+ m_saved (&dump_context::get ()),
+ m_saved_flags (dump_flags),
+ m_saved_pflags (pflags),
+ m_saved_file (dump_file)
+{
+ set_dump_file (stderr);
+ dump_context::s_current = &m_context;
+ pflags = dump_flags = MSG_ALL_KINDS | MSG_ALL_PRIORITIES;
+ dump_context::get ().refresh_dumps_are_enabled ();
+}
+
+/* debug_dump_context's dtor. Restore the saved dump_context. */
+
+debug_dump_context::~debug_dump_context ()
+{
+ set_dump_file (m_saved_file);
+ dump_context::s_current = m_saved;
+ dump_flags = m_saved_flags;
+ pflags = m_saved_pflags;
+ dump_context::get ().refresh_dumps_are_enabled ();
+}
+
+
#if CHECKING_P
namespace selftest {
#include "vec-perm-indices.h"
#include "gimple-fold.h"
#include "internal-fn.h"
+#include "dump-context.h"
/* Initialize a SLP node. */
return node;
}
-/* Dump a slp tree NODE using flags specified in DUMP_KIND. */
+/* Dump a single SLP tree NODE. */
static void
vect_print_slp_tree (dump_flags_t dump_kind, dump_location_t loc,
- slp_tree node, hash_set<slp_tree> &visited)
+ slp_tree node)
{
unsigned i, j;
- stmt_vec_info stmt_info;
slp_tree child;
+ stmt_vec_info stmt_info;
tree op;
- if (visited.add (node))
- return;
-
dump_metadata_t metadata (dump_kind, loc.get_impl_location ());
dump_user_location_t user_loc = loc.get_user_location ();
dump_printf_loc (metadata, user_loc, "node%s %p (max_nunits=%u, refcnt=%u)\n",
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
dump_printf (dump_kind, " %p", (void *)child);
dump_printf (dump_kind, "\n");
+}
+
+DEBUG_FUNCTION void
+debug (slp_tree node)
+{
+ debug_dump_context ctx;
+ vect_print_slp_tree (MSG_NOTE,
+ dump_location_t::from_location_t (UNKNOWN_LOCATION),
+ node);
+}
+
+/* Dump a slp tree NODE using flags specified in DUMP_KIND. */
+
+static void
+vect_print_slp_graph (dump_flags_t dump_kind, dump_location_t loc,
+ slp_tree node, hash_set<slp_tree> &visited)
+{
+ unsigned i;
+ slp_tree child;
+
+ if (visited.add (node))
+ return;
+
+ vect_print_slp_tree (dump_kind, loc, node);
+
FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
- vect_print_slp_tree (dump_kind, loc, child, visited);
+ vect_print_slp_graph (dump_kind, loc, child, visited);
}
static void
-vect_print_slp_tree (dump_flags_t dump_kind, dump_location_t loc,
- slp_tree node)
+vect_print_slp_graph (dump_flags_t dump_kind, dump_location_t loc,
+ slp_tree entry)
{
hash_set<slp_tree> visited;
- vect_print_slp_tree (dump_kind, loc, node, visited);
+ vect_print_slp_graph (dump_kind, loc, entry, visited);
}
/* Mark the tree rooted at NODE with PURE_SLP. */
{
dump_printf_loc (MSG_NOTE, vect_location,
"Final SLP tree for instance:\n");
- vect_print_slp_tree (MSG_NOTE, vect_location,
- SLP_INSTANCE_TREE (new_instance));
+ vect_print_slp_graph (MSG_NOTE, vect_location,
+ SLP_INSTANCE_TREE (new_instance));
}
return true;