1// Copyright 2013 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_GRAPH_VISUALIZER_H_
6#define V8_COMPILER_GRAPH_VISUALIZER_H_
7
8#include <stdio.h>
9#include <iosfwd>
10#include <memory>
11
12#include "src/globals.h"
13
14namespace v8 {
15namespace internal {
16
17class CompilationInfo;
18
19namespace compiler {
20
21class Graph;
22class InstructionSequence;
23class RegisterAllocationData;
24class Schedule;
25class SourcePositionTable;
26
27std::unique_ptr<char[]> GetVisualizerLogFileName(CompilationInfo* info,
28                                                 const char* phase,
29                                                 const char* suffix);
30
31struct AsJSON {
32  AsJSON(const Graph& g, SourcePositionTable* p) : graph(g), positions(p) {}
33  const Graph& graph;
34  const SourcePositionTable* positions;
35};
36
37V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const AsJSON& ad);
38
39struct AsRPO {
40  explicit AsRPO(const Graph& g) : graph(g) {}
41  const Graph& graph;
42};
43
44V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const AsRPO& ad);
45
46struct AsC1VCompilation {
47  explicit AsC1VCompilation(const CompilationInfo* info) : info_(info) {}
48  const CompilationInfo* info_;
49};
50
51
52struct AsC1V {
53  AsC1V(const char* phase, const Schedule* schedule,
54        const SourcePositionTable* positions = nullptr,
55        const InstructionSequence* instructions = nullptr)
56      : schedule_(schedule),
57        instructions_(instructions),
58        positions_(positions),
59        phase_(phase) {}
60  const Schedule* schedule_;
61  const InstructionSequence* instructions_;
62  const SourcePositionTable* positions_;
63  const char* phase_;
64};
65
66struct AsC1VRegisterAllocationData {
67  explicit AsC1VRegisterAllocationData(
68      const char* phase, const RegisterAllocationData* data = nullptr)
69      : phase_(phase), data_(data) {}
70  const char* phase_;
71  const RegisterAllocationData* data_;
72};
73
74std::ostream& operator<<(std::ostream& os, const AsC1VCompilation& ac);
75std::ostream& operator<<(std::ostream& os, const AsC1V& ac);
76std::ostream& operator<<(std::ostream& os,
77                         const AsC1VRegisterAllocationData& ac);
78
79}  // namespace compiler
80}  // namespace internal
81}  // namespace v8
82
83#endif  // V8_COMPILER_GRAPH_VISUALIZER_H_
84