move-optimizer.h 1.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// 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_MOVE_OPTIMIZER_
#define V8_COMPILER_MOVE_OPTIMIZER_

#include "src/compiler/instruction.h"
#include "src/zone-containers.h"

namespace v8 {
namespace internal {
namespace compiler {

15
class MoveOptimizer final {
16 17 18 19 20 21
 public:
  MoveOptimizer(Zone* local_zone, InstructionSequence* code);
  void Run();

 private:
  typedef ZoneVector<MoveOperands*> MoveOpVector;
22
  typedef ZoneVector<Instruction*> Instructions;
23 24 25 26

  InstructionSequence* code() const { return code_; }
  Zone* local_zone() const { return local_zone_; }
  Zone* code_zone() const { return code()->zone(); }
27 28
  MoveOpVector& temp_vector_0() { return temp_vector_0_; }
  MoveOpVector& temp_vector_1() { return temp_vector_1_; }
29

30
  void CompressBlock(InstructionBlock* blocke);
31 32
  void CompressMoves(MoveOpVector* eliminated, ParallelMove* left,
                     ParallelMove* right);
33
  Instruction* LastInstruction(InstructionBlock* block);
34
  void OptimizeMerge(InstructionBlock* block);
35
  void FinalizeMoves(Instruction* instr);
36 37 38

  Zone* const local_zone_;
  InstructionSequence* const code_;
39
  Instructions to_finalize_;
40 41 42 43 44 45 46 47 48 49 50
  MoveOpVector temp_vector_0_;
  MoveOpVector temp_vector_1_;

  DISALLOW_COPY_AND_ASSIGN(MoveOptimizer);
};

}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_MOVE_OPTIMIZER_