summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/nodes.cc')
-rw-r--r--compiler/optimizing/nodes.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index e3e4589b63..d57eaf0b60 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -1312,6 +1312,44 @@ void HEnvironment::ReplaceInput(HInstruction* replacement, size_t index) {
orig_instr->FixUpUserRecordsAfterEnvUseRemoval(before_use_node);
}
+std::ostream& HInstruction::Dump(std::ostream& os, bool dump_args) {
+ HGraph* graph = GetBlock()->GetGraph();
+ HGraphVisualizer::DumpInstruction(&os, graph, this);
+ if (dump_args) {
+ // Allocate memory from local ScopedArenaAllocator.
+ ScopedArenaAllocator allocator(graph->GetArenaStack());
+ // Instructions that we already visited. We print each instruction only once.
+ ArenaBitVector visited(
+ &allocator, graph->GetCurrentInstructionId(), /* expandable= */ false, kArenaAllocMisc);
+ visited.ClearAllBits();
+ visited.SetBit(GetId());
+ // Keep a queue of instructions with their indentations.
+ ScopedArenaDeque<std::pair<HInstruction*, size_t>> queue(allocator.Adapter(kArenaAllocMisc));
+ auto add_args = [&queue](HInstruction* instruction, size_t indentation) {
+ for (HInstruction* arg : ReverseRange(instruction->GetInputs())) {
+ queue.emplace_front(arg, indentation);
+ }
+ };
+ add_args(this, /*indentation=*/ 1u);
+ while (!queue.empty()) {
+ HInstruction* instruction;
+ size_t indentation;
+ std::tie(instruction, indentation) = queue.front();
+ queue.pop_front();
+ if (!visited.IsBitSet(instruction->GetId())) {
+ visited.SetBit(instruction->GetId());
+ os << '\n';
+ for (size_t i = 0; i != indentation; ++i) {
+ os << " ";
+ }
+ HGraphVisualizer::DumpInstruction(&os, graph, instruction);
+ add_args(instruction, indentation + 1u);
+ }
+ }
+ }
+ return os;
+}
+
HInstruction* HInstruction::GetNextDisregardingMoves() const {
HInstruction* next = GetNext();
while (next != nullptr && next->IsParallelMove()) {