blob: 73053dc18ec959c6f0c442485d10a8fd045f4046 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2014 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_PIPELINE_H_
6#define V8_COMPILER_PIPELINE_H_
7
8#include "src/v8.h"
9
10#include "src/compiler.h"
11
12// Note: TODO(turbofan) implies a performance improvement opportunity,
13// and TODO(name) implies an incomplete implementation
14
15namespace v8 {
16namespace internal {
17namespace compiler {
18
19// Clients of this interface shouldn't depend on lots of compiler internals.
Emily Bernierd0a1eb72015-03-24 16:35:39 -040020class CallDescriptor;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000021class Graph;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040022class InstructionSequence;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000023class Linkage;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040024class PipelineData;
25class RegisterConfiguration;
26class Schedule;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000027
28class Pipeline {
29 public:
30 explicit Pipeline(CompilationInfo* info) : info_(info) {}
31
32 // Run the entire pipeline and generate a handle to a code object.
33 Handle<Code> GenerateCode();
34
Emily Bernierd0a1eb72015-03-24 16:35:39 -040035 // Run the pipeline on a machine graph and generate code. If {schedule} is
36 // {nullptr}, then compute a new schedule for code generation.
37 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
38 Graph* graph,
39 Schedule* schedule = nullptr);
40
41 // Run the pipeline on a machine graph and generate code. If {schedule} is
42 // {nullptr}, then compute a new schedule for code generation.
43 static Handle<Code> GenerateCodeForTesting(CallDescriptor* call_descriptor,
44 Graph* graph,
45 Schedule* schedule = nullptr);
46
47 // Run just the register allocator phases.
48 static bool AllocateRegistersForTesting(const RegisterConfiguration* config,
49 InstructionSequence* sequence,
50 bool run_verifier);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000051
52 static inline bool SupportedBackend() { return V8_TURBOFAN_BACKEND != 0; }
53 static inline bool SupportedTarget() { return V8_TURBOFAN_TARGET != 0; }
54
55 static void SetUp();
56 static void TearDown();
57
58 private:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040059 static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
60 CallDescriptor* call_descriptor,
61 Graph* graph, Schedule* schedule);
62
Ben Murdochb8a8cc12014-11-26 15:28:44 +000063 CompilationInfo* info_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040064 PipelineData* data_;
65
66 // Helpers for executing pipeline phases.
67 template <typename Phase>
68 void Run();
69 template <typename Phase, typename Arg0>
70 void Run(Arg0 arg_0);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000071
72 CompilationInfo* info() const { return info_; }
73 Isolate* isolate() { return info_->isolate(); }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000074
Emily Bernierd0a1eb72015-03-24 16:35:39 -040075 void BeginPhaseKind(const char* phase_kind);
76 void RunPrintAndVerify(const char* phase, bool untyped = false);
77 void GenerateCode(Linkage* linkage);
78 void AllocateRegisters(const RegisterConfiguration* config,
79 bool run_verifier);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000080};
Emily Bernierd0a1eb72015-03-24 16:35:39 -040081
82} // namespace compiler
83} // namespace internal
84} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +000085
86#endif // V8_COMPILER_PIPELINE_H_