blob: 6b6e2e64b6b04499a8c08943f937c4716d1dbb4f [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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.
4
5#ifndef V8_CRANKSHAFT_X87_LITHIUM_GAP_RESOLVER_X87_H_
6#define V8_CRANKSHAFT_X87_LITHIUM_GAP_RESOLVER_X87_H_
7
8#include "src/crankshaft/lithium.h"
9
10namespace v8 {
11namespace internal {
12
13class LCodeGen;
14class LGapResolver;
15
16class LGapResolver final BASE_EMBEDDED {
17 public:
18 explicit LGapResolver(LCodeGen* owner);
19
20 // Resolve a set of parallel moves, emitting assembler instructions.
21 void Resolve(LParallelMove* parallel_move);
22
23 private:
24 // Build the initial list of moves.
25 void BuildInitialMoveList(LParallelMove* parallel_move);
26
27 // Perform the move at the moves_ index in question (possibly requiring
28 // other moves to satisfy dependencies).
29 void PerformMove(int index);
30
31 // Emit any code necessary at the end of a gap move.
32 void Finish();
33
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);
38
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);
42
43 // Emit a move and remove it from the move graph.
44 void EmitMove(int index);
45
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);
49
50 // Ensure that the given operand is not spilled.
51 void EnsureRestored(LOperand* operand);
52
53 // Return a register that can be used as a temp register, spilling
54 // something if necessary.
55 Register EnsureTempRegister();
56
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
59 // register.
60 Register GetFreeRegisterNot(Register reg);
61
62 // Verify that the state is the initial one, ready to resolve a single
63 // parallel move.
64 bool HasBeenReset();
65
66 // Verify the move list before performing moves.
67 void Verify();
68
69 LCodeGen* cgen_;
70
71 // List of moves not yet resolved.
72 ZoneList<LMoveOperands> moves_;
73
74 // Source and destination use counts for the general purpose registers.
75 int source_uses_[Register::kNumRegisters];
76 int destination_uses_[DoubleRegister::kMaxNumRegisters];
77
78 // If we had to spill on demand, the currently spilled register's
79 // allocation index.
80 int spilled_register_;
81};
82
83} // namespace internal
84} // namespace v8
85
86#endif // V8_CRANKSHAFT_X87_LITHIUM_GAP_RESOLVER_X87_H_