blob: c9a3289d6b26ab625f6b13bc4525d857358c3082 [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// 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_MOVE_OPTIMIZER_
6#define V8_COMPILER_MOVE_OPTIMIZER_
7
8#include "src/compiler/instruction.h"
9#include "src/zone-containers.h"
10
11namespace v8 {
12namespace internal {
13namespace compiler {
14
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000015class MoveOptimizer final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040016 public:
17 MoveOptimizer(Zone* local_zone, InstructionSequence* code);
18 void Run();
19
20 private:
21 typedef ZoneVector<MoveOperands*> MoveOpVector;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000022 typedef ZoneVector<Instruction*> Instructions;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040023
24 InstructionSequence* code() const { return code_; }
25 Zone* local_zone() const { return local_zone_; }
26 Zone* code_zone() const { return code()->zone(); }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000027 MoveOpVector& local_vector() { return local_vector_; }
Emily Bernierd0a1eb72015-03-24 16:35:39 -040028
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000029 void CompressBlock(InstructionBlock* blocke);
30 void CompressMoves(ParallelMove* left, ParallelMove* right);
31 const Instruction* LastInstruction(const InstructionBlock* block) const;
32 void OptimizeMerge(InstructionBlock* block);
33 void FinalizeMoves(Instruction* instr);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040034
35 Zone* const local_zone_;
36 InstructionSequence* const code_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000037 Instructions to_finalize_;
38 MoveOpVector local_vector_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040039
40 DISALLOW_COPY_AND_ASSIGN(MoveOptimizer);
41};
42
43} // namespace compiler
44} // namespace internal
45} // namespace v8
46
47#endif // V8_COMPILER_MOVE_OPTIMIZER_