Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1 | // 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 | |
| 15 | namespace v8 { |
| 16 | namespace internal { |
| 17 | namespace compiler { |
| 18 | |
| 19 | // Clients of this interface shouldn't depend on lots of compiler internals. |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 20 | class CallDescriptor; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 21 | class Graph; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 22 | class InstructionSequence; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 23 | class Linkage; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 24 | class PipelineData; |
| 25 | class RegisterConfiguration; |
| 26 | class Schedule; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 27 | |
| 28 | class 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 35 | // 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 Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 51 | |
| 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 59 | static Handle<Code> GenerateCodeForTesting(CompilationInfo* info, |
| 60 | CallDescriptor* call_descriptor, |
| 61 | Graph* graph, Schedule* schedule); |
| 62 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 63 | CompilationInfo* info_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 64 | 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 Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 71 | |
| 72 | CompilationInfo* info() const { return info_; } |
| 73 | Isolate* isolate() { return info_->isolate(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 74 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 75 | 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 Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 80 | }; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 81 | |
| 82 | } // namespace compiler |
| 83 | } // namespace internal |
| 84 | } // namespace v8 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 85 | |
| 86 | #endif // V8_COMPILER_PIPELINE_H_ |