move-optimizer.h 1.86 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
  MoveOpVector& local_vector() { return local_vector_; }
28

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
  // Consolidate moves into the first gap.
  void CompressGaps(Instruction* instr);

  // Attempt to push down to the last instruction those moves that can.
  void CompressBlock(InstructionBlock* block);

  // Consolidate moves into the first gap.
  void CompressMoves(ParallelMove* left, MoveOpVector* right);

  // Push down those moves in the gap of from that do not change the
  // semantics of the from instruction, nor the semantics of the moves
  // that remain behind.
  void MigrateMoves(Instruction* to, Instruction* from);

  void RemoveClobberedDestinations(Instruction* instruction);

mtrofin's avatar
mtrofin committed
45
  const Instruction* LastInstruction(const InstructionBlock* block) const;
46 47

  // Consolidate common moves appearing accross all predecessors of a block.
48
  void OptimizeMerge(InstructionBlock* block);
49
  void FinalizeMoves(Instruction* instr);
50 51 52

  Zone* const local_zone_;
  InstructionSequence* const code_;
53
  MoveOpVector local_vector_;
54 55 56 57 58 59 60 61 62

  DISALLOW_COPY_AND_ASSIGN(MoveOptimizer);
};

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

#endif  // V8_COMPILER_MOVE_OPTIMIZER_