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_GAP_RESOLVER_H_ |
| 6 | #define V8_COMPILER_GAP_RESOLVER_H_ |
| 7 | |
| 8 | #include "src/compiler/instruction.h" |
| 9 | |
| 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | namespace compiler { |
| 13 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 14 | class GapResolver final { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 15 | public: |
| 16 | // Interface used by the gap resolver to emit moves and swaps. |
| 17 | class Assembler { |
| 18 | public: |
| 19 | virtual ~Assembler() {} |
| 20 | |
| 21 | // Assemble move. |
| 22 | virtual void AssembleMove(InstructionOperand* source, |
| 23 | InstructionOperand* destination) = 0; |
| 24 | // Assemble swap. |
| 25 | virtual void AssembleSwap(InstructionOperand* source, |
| 26 | InstructionOperand* destination) = 0; |
| 27 | }; |
| 28 | |
| 29 | explicit GapResolver(Assembler* assembler) : assembler_(assembler) {} |
| 30 | |
| 31 | // Resolve a set of parallel moves, emitting assembler instructions. |
| 32 | void Resolve(ParallelMove* parallel_move) const; |
| 33 | |
| 34 | private: |
| 35 | // Perform the given move, possibly requiring other moves to satisfy |
| 36 | // dependencies. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 37 | void PerformMove(ParallelMove* moves, MoveOperands* move) const; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 38 | |
| 39 | // Assembler used to emit moves and save registers. |
| 40 | Assembler* const assembler_; |
| 41 | }; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 42 | |
| 43 | } // namespace compiler |
| 44 | } // namespace internal |
| 45 | } // namespace v8 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 46 | |
| 47 | #endif // V8_COMPILER_GAP_RESOLVER_H_ |