1 // Copyright 2013 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_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_
6 #define V8_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_
10 #include "src/arm64/delayed-masm-arm64.h"
11 #include "src/lithium.h"
19 class DelayedGapMasm : public DelayedMasm {
21 DelayedGapMasm(LCodeGen* owner, MacroAssembler* masm)
22 : DelayedMasm(owner, masm, root) {
23 // We use the root register as an extra scratch register.
24 // The root register has two advantages:
25 // - It is not in crankshaft allocatable registers list, so it can't
26 // interfere with the allocatable registers.
27 // - We don't need to push it on the stack, as we can reload it with its
28 // value once we have finish.
34 class LGapResolver BASE_EMBEDDED {
36 explicit LGapResolver(LCodeGen* owner);
38 // Resolve a set of parallel moves, emitting assembler instructions.
39 void Resolve(LParallelMove* parallel_move);
42 // Build the initial list of moves.
43 void BuildInitialMoveList(LParallelMove* parallel_move);
45 // Perform the move at the moves_ index in question (possibly requiring
46 // other moves to satisfy dependencies).
47 void PerformMove(int index);
49 // If a cycle is found in the series of moves, save the blocking value to
50 // a scratch register. The cycle must be found by hitting the root of the
51 // depth-first search.
52 void BreakCycle(int index);
54 // After a cycle has been resolved, restore the value from the scratch
55 // register to its proper destination.
58 // Emit a move and remove it from the move graph.
59 void EmitMove(int index);
61 // Emit a move from one stack slot to another.
62 void EmitStackSlotMove(int index) {
63 masm_.StackSlotMove(moves_[index].source(), moves_[index].destination());
66 // Verify the move list before performing moves.
69 // Registers used to solve cycles.
70 const Register& SavedValueRegister() {
71 ASSERT(!masm_.ScratchRegister().IsAllocatable());
72 return masm_.ScratchRegister();
74 // The scratch register is used to break cycles and to store constant.
75 // These two methods switch from one mode to the other.
76 void AcquireSavedValueRegister() { masm_.AcquireScratchRegister(); }
77 void ReleaseSavedValueRegister() { masm_.ReleaseScratchRegister(); }
78 const FPRegister& SavedFPValueRegister() {
79 // We use the Crankshaft floating-point scratch register to break a cycle
80 // involving double values as the MacroAssembler will not need it for the
81 // operations performed by the gap resolver.
82 ASSERT(!crankshaft_fp_scratch.IsAllocatable());
83 return crankshaft_fp_scratch;
89 // List of moves not yet resolved.
90 ZoneList<LMoveOperands> moves_;
94 LOperand* saved_destination_;
97 } } // namespace v8::internal
99 #endif // V8_ARM64_LITHIUM_GAP_RESOLVER_ARM64_H_