1 // Copyright 2011 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.
5 #ifndef V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_
6 #define V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_
8 #include "src/lithium.h"
16 class LGapResolver final BASE_EMBEDDED {
18 explicit LGapResolver(LCodeGen* owner);
20 // Resolve a set of parallel moves, emitting assembler instructions.
21 void Resolve(LParallelMove* parallel_move);
24 // Build the initial list of moves.
25 void BuildInitialMoveList(LParallelMove* parallel_move);
27 // Perform the move at the moves_ index in question (possibly requiring
28 // other moves to satisfy dependencies).
29 void PerformMove(int index);
31 // Emit any code necessary at the end of a gap move.
34 // Add or delete a move from the move graph without emitting any code.
35 // Used to build up the graph and remove trivial moves.
36 void AddMove(LMoveOperands move);
37 void RemoveMove(int index);
39 // Report the count of uses of operand as a source in a not-yet-performed
40 // move. Used to rebuild use counts.
41 int CountSourceUses(LOperand* operand);
43 // Emit a move and remove it from the move graph.
44 void EmitMove(int index);
46 // Execute a move by emitting a swap of two operands. The move from
47 // source to destination is removed from the move graph.
48 void EmitSwap(int index);
50 // Ensure that the given operand is not spilled.
51 void EnsureRestored(LOperand* operand);
53 // Return a register that can be used as a temp register, spilling
54 // something if necessary.
55 Register EnsureTempRegister();
57 // Return a known free register different from the given one (which could
58 // be no_reg---returning any free register), or no_reg if there is no such
60 Register GetFreeRegisterNot(Register reg);
62 // Verify that the state is the initial one, ready to resolve a single
66 // Verify the move list before performing moves.
71 // List of moves not yet resolved.
72 ZoneList<LMoveOperands> moves_;
74 // Source and destination use counts for the general purpose registers.
75 int source_uses_[Register::kMaxNumAllocatableRegisters];
76 int destination_uses_[Register::kMaxNumAllocatableRegisters];
78 // If we had to spill on demand, the currently spilled register's
80 int spilled_register_;
83 } } // namespace v8::internal
85 #endif // V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_