Commit 05298900 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[liftoff] Simplify ParallelRegisterMove

We often want to pass a list of moves of fixed length. Instead of
constructing an array on the caller's stack and passing it via
{ArrayVector}, we should just pass it via {std::initializer_list}. This
also avoids to spell out the internal name
{LiftoffAssembler::ParallelRegisterMoveTuple}.

R=thibaudm@chromium.org

Bug: v8:10576
Change-Id: Ibe7ac5a5a02686533333cb45652cbb2b99ad9c60
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2287498
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68799}
parent 6327b261
...@@ -949,9 +949,8 @@ void LiftoffAssembler::AtomicLoad(LiftoffRegister dst, Register src_addr, ...@@ -949,9 +949,8 @@ void LiftoffAssembler::AtomicLoad(LiftoffRegister dst, Register src_addr,
ldrexd(dst_low, dst_high, actual_addr); ldrexd(dst_low, dst_high, actual_addr);
dmb(ISH); dmb(ISH);
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{ ParallelRegisterMove(
{dst, LiftoffRegister::ForPair(dst_low, dst_high), kWasmI64}}; {{dst, LiftoffRegister::ForPair(dst_low, dst_high), kWasmI64}});
ParallelRegisterMove(ArrayVector(reg_moves));
} }
void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg, void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg,
...@@ -1071,15 +1070,13 @@ inline void AtomicI64CompareExchange(LiftoffAssembler* lasm, ...@@ -1071,15 +1070,13 @@ inline void AtomicI64CompareExchange(LiftoffAssembler* lasm,
__ SpillRegisters(dst_addr, offset, result_low, result_high, new_value_low, __ SpillRegisters(dst_addr, offset, result_low, result_high, new_value_low,
new_value_high, store_result, expected_low, expected_high); new_value_high, store_result, expected_low, expected_high);
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{ __ ParallelRegisterMove(
{LiftoffRegister::ForPair(new_value_low, new_value_high), new_value, {{LiftoffRegister::ForPair(new_value_low, new_value_high), new_value,
kWasmI64}, kWasmI64},
{LiftoffRegister::ForPair(expected_low, expected_high), expected, {LiftoffRegister::ForPair(expected_low, expected_high), expected,
kWasmI64}, kWasmI64},
{LiftoffRegister(dst_addr), LiftoffRegister(dst_addr_reg), kWasmI32}, {dst_addr, dst_addr_reg, kWasmI32},
{LiftoffRegister(offset), {offset, offset_reg != no_reg ? offset_reg : offset, kWasmI32}});
LiftoffRegister(offset_reg != no_reg ? offset_reg : offset), kWasmI32}};
__ ParallelRegisterMove(ArrayVector(reg_moves));
{ {
UseScratchRegisterScope temps(lasm); UseScratchRegisterScope temps(lasm);
...@@ -1106,9 +1103,8 @@ inline void AtomicI64CompareExchange(LiftoffAssembler* lasm, ...@@ -1106,9 +1103,8 @@ inline void AtomicI64CompareExchange(LiftoffAssembler* lasm,
__ dmb(ISH); __ dmb(ISH);
__ bind(&done); __ bind(&done);
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves_result[]{ __ ParallelRegisterMove(
{result, LiftoffRegister::ForPair(result_low, result_high), kWasmI64}}; {{result, LiftoffRegister::ForPair(result_low, result_high), kWasmI64}});
__ ParallelRegisterMove(ArrayVector(reg_moves_result));
} }
#undef __ #undef __
} // namespace liftoff } // namespace liftoff
......
...@@ -707,12 +707,9 @@ inline void AtomicBinop64(LiftoffAssembler* lasm, Binop op, Register dst_addr, ...@@ -707,12 +707,9 @@ inline void AtomicBinop64(LiftoffAssembler* lasm, Binop op, Register dst_addr,
} }
// Spill all these registers if they are still holding other values. // Spill all these registers if they are still holding other values.
liftoff::SpillRegisters(lasm, old_hi, old_lo, new_hi, base, offset); liftoff::SpillRegisters(lasm, old_hi, old_lo, new_hi, base, offset);
{ __ ParallelRegisterMove(
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{ {{LiftoffRegister::ForPair(base, offset),
{LiftoffRegister::ForPair(base, offset), LiftoffRegister::ForPair(dst_addr, offset_reg), kWasmI64}});
LiftoffRegister::ForPair(dst_addr, offset_reg), kWasmI64}};
__ ParallelRegisterMove(ArrayVector(reg_moves));
}
Operand dst_op_lo = Operand(base, offset, times_1, offset_imm); Operand dst_op_lo = Operand(base, offset, times_1, offset_imm);
Operand dst_op_hi = Operand(base, offset, times_1, offset_imm + 4); Operand dst_op_hi = Operand(base, offset, times_1, offset_imm + 4);
...@@ -759,12 +756,9 @@ inline void AtomicBinop64(LiftoffAssembler* lasm, Binop op, Register dst_addr, ...@@ -759,12 +756,9 @@ inline void AtomicBinop64(LiftoffAssembler* lasm, Binop op, Register dst_addr,
// Restore the root register, and we are done. // Restore the root register, and we are done.
__ pop(kRootRegister); __ pop(kRootRegister);
{ // Move the result into the correct registers.
// Move the result into the correct registers. __ ParallelRegisterMove(
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{ {{result, LiftoffRegister::ForPair(old_lo, old_hi), kWasmI64}});
{result, LiftoffRegister::ForPair(old_lo, old_hi), kWasmI64}};
__ ParallelRegisterMove(ArrayVector(reg_moves));
}
} }
#undef __ #undef __
...@@ -1346,10 +1340,9 @@ void LiftoffAssembler::emit_i64_mul(LiftoffRegister dst, LiftoffRegister lhs, ...@@ -1346,10 +1340,9 @@ void LiftoffAssembler::emit_i64_mul(LiftoffRegister dst, LiftoffRegister lhs,
liftoff::SpillRegisters(this, dst_hi, dst_lo, lhs_hi, rhs_lo); liftoff::SpillRegisters(this, dst_hi, dst_lo, lhs_hi, rhs_lo);
// Move lhs and rhs into the respective registers. // Move lhs and rhs into the respective registers.
ParallelRegisterMoveTuple reg_moves[]{ ParallelRegisterMove(
{LiftoffRegister::ForPair(lhs_lo, lhs_hi), lhs, kWasmI64}, {{LiftoffRegister::ForPair(lhs_lo, lhs_hi), lhs, kWasmI64},
{LiftoffRegister::ForPair(rhs_lo, rhs_hi), rhs, kWasmI64}}; {LiftoffRegister::ForPair(rhs_lo, rhs_hi), rhs, kWasmI64}});
ParallelRegisterMove(ArrayVector(reg_moves));
// First mul: lhs_hi' = lhs_hi * rhs_lo. // First mul: lhs_hi' = lhs_hi * rhs_lo.
imul(lhs_hi, rhs_lo); imul(lhs_hi, rhs_lo);
......
...@@ -867,7 +867,7 @@ void LiftoffAssembler::Move(LiftoffRegister dst, LiftoffRegister src, ...@@ -867,7 +867,7 @@ void LiftoffAssembler::Move(LiftoffRegister dst, LiftoffRegister src,
} }
void LiftoffAssembler::ParallelRegisterMove( void LiftoffAssembler::ParallelRegisterMove(
Vector<ParallelRegisterMoveTuple> tuples) { Vector<const ParallelRegisterMoveTuple> tuples) {
StackTransferRecipe stack_transfers(this); StackTransferRecipe stack_transfers(this);
for (auto tuple : tuples) { for (auto tuple : tuples) {
if (tuple.dst == tuple.src) continue; if (tuple.dst == tuple.src) continue;
......
...@@ -452,7 +452,13 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -452,7 +452,13 @@ class LiftoffAssembler : public TurboAssembler {
ParallelRegisterMoveTuple(Dst dst, Src src, ValueType type) ParallelRegisterMoveTuple(Dst dst, Src src, ValueType type)
: dst(dst), src(src), type(type) {} : dst(dst), src(src), type(type) {}
}; };
void ParallelRegisterMove(Vector<ParallelRegisterMoveTuple>);
void ParallelRegisterMove(Vector<const ParallelRegisterMoveTuple>);
void ParallelRegisterMove(
std::initializer_list<ParallelRegisterMoveTuple> moves) {
ParallelRegisterMove(VectorOf(moves));
}
void MoveToReturnLocations(const FunctionSig*, void MoveToReturnLocations(const FunctionSig*,
compiler::CallDescriptor* descriptor); compiler::CallDescriptor* descriptor);
......
...@@ -3216,11 +3216,9 @@ class LiftoffCompiler { ...@@ -3216,11 +3216,9 @@ class LiftoffCompiler {
WasmAtomicNotifyDescriptor descriptor; WasmAtomicNotifyDescriptor descriptor;
DCHECK_EQ(0, descriptor.GetStackParameterCount()); DCHECK_EQ(0, descriptor.GetStackParameterCount());
DCHECK_EQ(2, descriptor.GetRegisterParameterCount()); DCHECK_EQ(2, descriptor.GetRegisterParameterCount());
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{ __ ParallelRegisterMove(
{LiftoffRegister(descriptor.GetRegisterParameter(0)), {{descriptor.GetRegisterParameter(0), index, kWasmI32},
LiftoffRegister(index), kWasmI32}, {descriptor.GetRegisterParameter(1), count, kWasmI32}});
{LiftoffRegister(descriptor.GetRegisterParameter(1)), count, kWasmI32}};
__ ParallelRegisterMove(ArrayVector(reg_moves));
__ CallRuntimeStub(WasmCode::kWasmAtomicNotify); __ CallRuntimeStub(WasmCode::kWasmAtomicNotify);
RegisterDebugSideTableEntry(DebugSideTableBuilder::kDidSpill); RegisterDebugSideTableEntry(DebugSideTableBuilder::kDidSpill);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment