summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.h
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2021-01-06 12:35:31 -0800
committer Alex Light <allight@google.com> 2021-01-08 22:35:17 +0000
commitdc281e776c0395b54200c62626f90417f092a2bf (patch)
tree5e0a458e7ec1968f365b5a6dcc7454d417f11416 /compiler/optimizing/nodes.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/nodes.h')
-rw-r--r--compiler/optimizing/nodes.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 125f86be81..73db7e541f 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -33,6 +33,7 @@
#include "base/stl_util.h"
#include "base/transform_array_ref.h"
#include "art_method.h"
+#include "block_namer.h"
#include "class_root.h"
#include "compilation_kind.h"
#include "data_type.h"
@@ -423,6 +424,9 @@ class HGraph : public ArenaObject<kArenaAllocGraph> {
blocks_.reserve(kDefaultNumberOfBlocks);
}
+ std::ostream& Dump(std::ostream& os,
+ std::optional<std::reference_wrapper<const BlockNamer>> namer = std::nullopt);
+
ArenaAllocator* GetAllocator() const { return allocator_; }
ArenaStack* GetArenaStack() const { return arena_stack_; }
@@ -881,6 +885,10 @@ class HGraph : public ArenaObject<kArenaAllocGraph> {
DISALLOW_COPY_AND_ASSIGN(HGraph);
};
+inline std::ostream& operator<<(std::ostream& os, HGraph& graph) {
+ return graph.Dump(os);
+}
+
class HLoopInformation : public ArenaObject<kArenaAllocLoopInfo> {
public:
HLoopInformation(HBasicBlock* header, HGraph* graph)
@@ -2112,6 +2120,8 @@ class HEnvironment : public ArenaObject<kArenaAllocEnvironment> {
DISALLOW_COPY_AND_ASSIGN(HEnvironment);
};
+std::ostream& operator<<(std::ostream& os, const HInstruction& rhs);
+
class HInstruction : public ArenaObject<kArenaAllocInstruction> {
public:
#define DECLARE_KIND(type, super) k##type,
@@ -2147,6 +2157,21 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> {
std::ostream& Dump(std::ostream& os, bool dump_args = false);
+ // Helper for dumping without argument information using operator<<
+ struct NoArgsDump {
+ const HInstruction* ins;
+ };
+ NoArgsDump DumpWithoutArgs() const {
+ return NoArgsDump{this};
+ }
+ // Helper for dumping with argument information using operator<<
+ struct ArgsDump {
+ const HInstruction* ins;
+ };
+ ArgsDump DumpWithArgs() const {
+ return ArgsDump{this};
+ }
+
HInstruction* GetNext() const { return next_; }
HInstruction* GetPrevious() const { return previous_; }
@@ -2672,6 +2697,10 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> {
friend class HInstructionList;
};
std::ostream& operator<<(std::ostream& os, HInstruction::InstructionKind rhs);
+std::ostream& operator<<(std::ostream& os, const HInstruction::NoArgsDump rhs);
+std::ostream& operator<<(std::ostream& os, const HInstruction::ArgsDump rhs);
+std::ostream& operator<<(std::ostream& os, const HUseList<HInstruction*>& lst);
+std::ostream& operator<<(std::ostream& os, const HUseList<HEnvironment*>& lst);
// Iterates over the instructions, while preserving the next instruction
// in case the current instruction gets removed from the list by the user