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_
18 class LGapResolver V8_FINAL BASE_EMBEDDED {
20 explicit LGapResolver(LCodeGen* owner);
22 // Resolve a set of parallel moves, emitting assembler instructions.
23 void Resolve(LParallelMove* parallel_move);
26 // Build the initial list of moves.
27 void BuildInitialMoveList(LParallelMove* parallel_move);
29 // Perform the move at the moves_ index in question (possibly requiring
30 // other moves to satisfy dependencies).
31 void PerformMove(int index);
33 // Emit any code necessary at the end of a gap move.
36 // Add or delete a move from the move graph without emitting any code.
37 // Used to build up the graph and remove trivial moves.
38 void AddMove(LMoveOperands move);
39 void RemoveMove(int index);
41 // Report the count of uses of operand as a source in a not-yet-performed
42 // move. Used to rebuild use counts.
43 int CountSourceUses(LOperand* operand);
45 // Emit a move and remove it from the move graph.
46 void EmitMove(int index);
48 // Execute a move by emitting a swap of two operands. The move from
49 // source to destination is removed from the move graph.
50 void EmitSwap(int index);
52 // Ensure that the given operand is not spilled.
53 void EnsureRestored(LOperand* operand);
55 // Return a register that can be used as a temp register, spilling
56 // something if necessary.
57 Register EnsureTempRegister();
59 // Return a known free register different from the given one (which could
60 // be no_reg---returning any free register), or no_reg if there is no such
62 Register GetFreeRegisterNot(Register reg);
64 // Verify that the state is the initial one, ready to resolve a single
68 // Verify the move list before performing moves.
73 // List of moves not yet resolved.
74 ZoneList<LMoveOperands> moves_;
76 // Source and destination use counts for the general purpose registers.
77 int source_uses_[Register::kMaxNumAllocatableRegisters];
78 int destination_uses_[Register::kMaxNumAllocatableRegisters];
80 // If we had to spill on demand, the currently spilled register's
82 int spilled_register_;
85 } } // namespace v8::internal
87 #endif // V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_