summaryrefslogtreecommitdiff
path: root/compiler/optimizing/graph_visualizer.h
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2021-01-06 12:35:31 -0800
committerAlex Light <allight@google.com>2021-01-08 22:35:17 +0000
commitdc281e776c0395b54200c62626f90417f092a2bf (patch)
tree5e0a458e7ec1968f365b5a6dcc7454d417f11416 /compiler/optimizing/graph_visualizer.h
parentda946fc92b3f6f9664167ef3a0f1324694417b71 (diff)
Add operator<< for HGraph and HInstructions.
Include helpers for printing arguments as well. Test: ./test.py --host Change-Id: I692fd5bd32a8a39da0defd9454d56ccf2480f229
Diffstat (limited to 'compiler/optimizing/graph_visualizer.h')
-rw-r--r--compiler/optimizing/graph_visualizer.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler/optimizing/graph_visualizer.h b/compiler/optimizing/graph_visualizer.h
index b83e88740c..3429c11cbd 100644
--- a/compiler/optimizing/graph_visualizer.h
+++ b/compiler/optimizing/graph_visualizer.h
@@ -17,11 +17,13 @@
#ifndef ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_
#define ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_
+#include <functional>
#include <ostream>
#include "arch/instruction_set.h"
#include "base/arena_containers.h"
#include "base/value_object.h"
+#include "block_namer.h"
namespace art {
@@ -101,10 +103,12 @@ class HGraphVisualizer : public ValueObject {
public:
HGraphVisualizer(std::ostream* output,
HGraph* graph,
- const CodeGenerator* codegen);
+ const CodeGenerator* codegen,
+ std::optional<std::reference_wrapper<const BlockNamer>> namer = std::nullopt);
void PrintHeader(const char* method_name) const;
void DumpGraph(const char* pass_name, bool is_after_pass, bool graph_in_bad_state) const;
+ void DumpGraphDebug() const;
void DumpGraphWithDisassembly() const;
// C1visualizer file format does not support inserting arbitrary metadata into a cfg
@@ -115,9 +119,21 @@ class HGraphVisualizer : public ValueObject {
static void DumpInstruction(std::ostream* output, HGraph* graph, HInstruction* instruction);
private:
+ class OptionalDefaultNamer final : public BlockNamer {
+ public:
+ explicit OptionalDefaultNamer(std::optional<std::reference_wrapper<const BlockNamer>> inner)
+ : namer_(inner) {}
+
+ std::ostream& PrintName(std::ostream& os, HBasicBlock* blk) const override;
+
+ private:
+ std::optional<std::reference_wrapper<const BlockNamer>> namer_;
+ };
+
std::ostream* const output_;
HGraph* const graph_;
const CodeGenerator* codegen_;
+ OptionalDefaultNamer namer_;
DISALLOW_COPY_AND_ASSIGN(HGraphVisualizer);
};