pipeline.h 2.68 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_PIPELINE_H_
#define V8_COMPILER_PIPELINE_H_

8 9
// Clients of this interface shouldn't depend on lots of compiler internals.
// Do not include anything from src/compiler here!
10 11 12 13 14 15
#include "src/compiler.h"

namespace v8 {
namespace internal {
namespace compiler {

16
class CallDescriptor;
17
class Graph;
18
class InstructionSequence;
19
class Linkage;
20
class PipelineData;
21
class RegisterConfiguration;
22 23 24 25
class Schedule;

class Pipeline {
 public:
26
  explicit Pipeline(CompilationInfo* info) : info_(info) {}
27 28 29 30

  // Run the entire pipeline and generate a handle to a code object.
  Handle<Code> GenerateCode();

31 32 33 34 35
  // Run the pipeline on a machine graph and generate code. If {schedule} is
  // {nullptr}, then compute a new schedule for code generation.
  static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
                                             Graph* graph,
                                             Schedule* schedule = nullptr);
36

37 38
  // Run the pipeline on a machine graph and generate code. If {schedule} is
  // {nullptr}, then compute a new schedule for code generation.
39 40
  static Handle<Code> GenerateCodeForTesting(Isolate* isolate,
                                             CallDescriptor* call_descriptor,
41 42 43 44 45 46 47
                                             Graph* graph,
                                             Schedule* schedule = nullptr);

  // Run just the register allocator phases.
  static bool AllocateRegistersForTesting(const RegisterConfiguration* config,
                                          InstructionSequence* sequence,
                                          bool run_verifier);
48

49
 private:
50 51 52 53
  static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
                                             CallDescriptor* call_descriptor,
                                             Graph* graph, Schedule* schedule);

54
  CompilationInfo* info_;
55 56 57 58 59 60 61
  PipelineData* data_;

  // Helpers for executing pipeline phases.
  template <typename Phase>
  void Run();
  template <typename Phase, typename Arg0>
  void Run(Arg0 arg_0);
62

63 64 65
  CompilationInfo* info() const { return info_; }
  Isolate* isolate() { return info_->isolate(); }

66
  void BeginPhaseKind(const char* phase_kind);
67
  void RunPrintAndVerify(const char* phase, bool untyped = false);
68
  Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor);
69 70
  void AllocateRegisters(const RegisterConfiguration* config,
                         bool run_verifier);
71
};
72 73 74 75

}  // namespace compiler
}  // namespace internal
}  // namespace v8
76 77

#endif  // V8_COMPILER_PIPELINE_H_