Commit ea96bd76 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Make LiftoffRegList::ForRegs a constructor

The 'ForRegs' method is not needed for clarity of the code, it's pretty
clear what to construct a register list from. Hence turn the static
{LiftoffRegList::ForRegs} method into a constructor. This makes the code
more concise.

Also, turn the for loop into a C++17 folding expression, which might
generate better code because the loop will automatically be unrolled.

R=thibaudm@chromium.org

Bug: v8:12425
Change-Id: Ic4446f23022db5f17420303d45b9c15fa5daff60
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3572041Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79815}
parent 5cd917d5
......@@ -155,9 +155,9 @@ inline void I64Binop(LiftoffAssembler* assm, LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister rhs) {
Register dst_low = dst.low_gp();
if (dst_low == lhs.high_gp() || dst_low == rhs.high_gp()) {
dst_low = assm->GetUnusedRegister(
kGpReg, LiftoffRegList::ForRegs(lhs, rhs, dst.high_gp()))
.gp();
dst_low =
assm->GetUnusedRegister(kGpReg, LiftoffRegList{lhs, rhs, dst.high_gp()})
.gp();
}
(assm->*op)(dst_low, lhs.low_gp(), rhs.low_gp(), SetCC, al);
(assm->*op_with_carry)(dst.high_gp(), lhs.high_gp(), Operand(rhs.high_gp()),
......@@ -193,7 +193,7 @@ inline void I64Shiftop(LiftoffAssembler* assm, LiftoffRegister dst,
// Left shift writes {dst_high} then {dst_low}, right shifts write {dst_low}
// then {dst_high}.
Register clobbered_dst_reg = is_left_shift ? dst_high : dst_low;
LiftoffRegList pinned = LiftoffRegList::ForRegs(clobbered_dst_reg, src);
LiftoffRegList pinned = {clobbered_dst_reg, src};
Register amount_capped =
pinned.set(assm->GetUnusedRegister(kGpReg, pinned)).gp();
assm->and_(amount_capped, amount, Operand(0x3F));
......@@ -950,8 +950,7 @@ inline void AtomicBinop32(LiftoffAssembler* lasm, Register dst_addr,
StoreType type,
void (*op)(LiftoffAssembler*, Register, Register,
Register)) {
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, value, result);
LiftoffRegList pinned = {dst_addr, offset_reg, value, result};
switch (type.value()) {
case StoreType::kI64Store8:
__ LoadConstant(result.high(), WasmValue(0));
......@@ -1002,16 +1001,14 @@ inline void AtomicOp64(LiftoffAssembler* lasm, Register dst_addr,
// Make sure {dst_low} and {dst_high} are not occupied by any other value.
Register value_low = value.low_gp();
Register value_high = value.high_gp();
LiftoffRegList pinned = LiftoffRegList::ForRegs(
dst_addr, offset_reg, value_low, value_high, dst_low, dst_high);
LiftoffRegList pinned = {dst_addr, offset_reg, value_low,
value_high, dst_low, dst_high};
__ ClearRegister(dst_low, {&dst_addr, &offset_reg, &value_low, &value_high},
pinned);
pinned = pinned |
LiftoffRegList::ForRegs(dst_addr, offset_reg, value_low, value_high);
pinned = pinned | LiftoffRegList{dst_addr, offset_reg, value_low, value_high};
__ ClearRegister(dst_high, {&dst_addr, &offset_reg, &value_low, &value_high},
pinned);
pinned = pinned |
LiftoffRegList::ForRegs(dst_addr, offset_reg, value_low, value_high);
pinned = pinned | LiftoffRegList{dst_addr, offset_reg, value_low, value_high};
// Make sure that {result}, if it exists, also does not overlap with
// {dst_low} and {dst_high}. We don't have to transfer the value stored in
......@@ -1275,7 +1272,7 @@ void LiftoffAssembler::AtomicCompareExchange(
void (Assembler::*load)(Register, Register, Condition) = nullptr;
void (Assembler::*store)(Register, Register, Register, Condition) = nullptr;
LiftoffRegList pinned = LiftoffRegList::ForRegs(dst_addr, offset_reg);
LiftoffRegList pinned = {dst_addr, offset_reg};
// We need to remember the high word of {result}, so we can set it to zero in
// the end if necessary.
Register result_high = no_reg;
......@@ -1614,7 +1611,7 @@ inline void GeneratePopCnt(Assembler* assm, Register dst, Register src,
} // namespace liftoff
bool LiftoffAssembler::emit_i32_popcnt(Register dst, Register src) {
LiftoffRegList pinned = LiftoffRegList::ForRegs(dst);
LiftoffRegList pinned = {dst};
Register scratch1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register scratch2 = GetUnusedRegister(kGpReg, pinned).gp();
liftoff::GeneratePopCnt(this, dst, src, scratch1, scratch2);
......@@ -1855,7 +1852,7 @@ bool LiftoffAssembler::emit_i64_popcnt(LiftoffRegister dst,
// overwrite the second src register before using it.
Register src1 = src.high_gp() == dst.low_gp() ? src.high_gp() : src.low_gp();
Register src2 = src.high_gp() == dst.low_gp() ? src.low_gp() : src.high_gp();
LiftoffRegList pinned = LiftoffRegList::ForRegs(dst, src2);
LiftoffRegList pinned = {dst, src2};
Register scratch1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register scratch2 = GetUnusedRegister(kGpReg, pinned).gp();
liftoff::GeneratePopCnt(this, dst.low_gp(), src1, scratch1, scratch2);
......@@ -2924,12 +2921,12 @@ void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs,
QwNeonRegister tmp2 = right;
LiftoffRegList used_plus_dst =
cache_state()->used_registers | LiftoffRegList::ForRegs(dst);
cache_state()->used_registers | LiftoffRegList{dst};
if (used_plus_dst.has(lhs) && used_plus_dst.has(rhs)) {
tmp1 = temps.AcquireQ();
// We only have 1 scratch Q register, so acquire another ourselves.
LiftoffRegList pinned = LiftoffRegList::ForRegs(dst);
LiftoffRegList pinned = {dst};
LiftoffRegister unused_pair = GetUnusedRegister(kFpRegPair, pinned);
tmp2 = liftoff::GetSimd128Register(unused_pair);
} else if (used_plus_dst.has(lhs)) {
......@@ -3055,7 +3052,7 @@ void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst,
if (cache_state()->is_used(src)) {
// We only have 1 scratch Q register, so try and reuse src.
LiftoffRegList pinned = LiftoffRegList::ForRegs(src);
LiftoffRegList pinned = {src};
LiftoffRegister unused_pair = GetUnusedRegister(kFpRegPair, pinned);
mask = liftoff::GetSimd128Register(unused_pair);
}
......@@ -3240,7 +3237,7 @@ void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst,
if (cache_state()->is_used(src)) {
// We only have 1 scratch Q register, so try and reuse src.
LiftoffRegList pinned = LiftoffRegList::ForRegs(src);
LiftoffRegList pinned = {src};
LiftoffRegister unused_pair = GetUnusedRegister(kFpRegPair, pinned);
mask = liftoff::GetSimd128Register(unused_pair);
}
......@@ -3555,7 +3552,7 @@ void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst,
if (cache_state()->is_used(src)) {
// We only have 1 scratch Q register, so try and reuse src.
LiftoffRegList pinned = LiftoffRegList::ForRegs(src);
LiftoffRegList pinned = {src};
LiftoffRegister unused_pair = GetUnusedRegister(kFpRegPair, pinned);
mask = liftoff::GetSimd128Register(unused_pair);
}
......
......@@ -636,8 +636,7 @@ inline void AtomicBinop(LiftoffAssembler* lasm, Register dst_addr,
Register offset_reg, uintptr_t offset_imm,
LiftoffRegister value, LiftoffRegister result,
StoreType type, Binop op) {
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, value, result);
LiftoffRegList pinned = {dst_addr, offset_reg, value, result};
Register store_result = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
// {LiftoffCompiler::AtomicBinop} ensures that {result} is unique.
......@@ -823,8 +822,7 @@ void LiftoffAssembler::AtomicCompareExchange(
Register dst_addr, Register offset_reg, uintptr_t offset_imm,
LiftoffRegister expected, LiftoffRegister new_value, LiftoffRegister result,
StoreType type) {
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, expected, new_value);
LiftoffRegList pinned = {dst_addr, offset_reg, expected, new_value};
Register result_reg = result.gp();
if (pinned.has(result)) {
......@@ -2511,7 +2509,7 @@ void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst,
VRegister temp = dst.fp();
if (dst == lhs || dst == rhs) {
// dst overlaps with lhs or rhs, so we need a temporary.
temp = GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(lhs, rhs)).fp();
temp = GetUnusedRegister(kFpReg, LiftoffRegList{lhs, rhs}).fp();
}
UseScratchRegisterScope scope(this);
......
......@@ -1591,8 +1591,7 @@ void EmitI64IndependentHalfOperation(LiftoffAssembler* assm,
return;
}
// Otherwise, we need a temporary register.
Register tmp =
assm->GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp();
Register tmp = assm->GetUnusedRegister(kGpReg, LiftoffRegList{lhs, rhs}).gp();
(assm->*op)(tmp, lhs.low_gp(), rhs.low_gp());
(assm->*op)(dst.high_gp(), lhs.high_gp(), rhs.high_gp());
assm->Move(dst.low_gp(), tmp, kI32);
......@@ -1619,8 +1618,7 @@ void EmitI64IndependentHalfOperationImm(LiftoffAssembler* assm,
return;
}
// Otherwise, we need a temporary register.
Register tmp =
assm->GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs)).gp();
Register tmp = assm->GetUnusedRegister(kGpReg, LiftoffRegList{lhs}).gp();
(assm->*op)(tmp, lhs.low_gp(), low_word);
(assm->*op)(dst.high_gp(), lhs.high_gp(), high_word);
assm->Move(dst.low_gp(), tmp, kI32);
......
This diff is collapsed.
......@@ -347,6 +347,17 @@ class LiftoffRegList {
constexpr LiftoffRegList() = default;
// Allow to construct LiftoffRegList from a number of
// {Register|DoubleRegister|LiftoffRegister}.
template <
typename... Regs,
typename = std::enable_if_t<std::conjunction_v<std::disjunction<
std::is_same<Register, Regs>, std::is_same<DoubleRegister, Regs>,
std::is_same<LiftoffRegister, Regs>>...>>>
constexpr LiftoffRegList(Regs... regs) {
(..., set(regs));
}
constexpr Register set(Register reg) {
return set(LiftoffRegister(reg)).gp();
}
......@@ -461,13 +472,6 @@ class LiftoffRegList {
return LiftoffRegList(bits);
}
template <typename... Regs>
static LiftoffRegList ForRegs(Regs... regs) {
LiftoffRegList list;
for (LiftoffRegister reg : {LiftoffRegister(regs)...}) list.set(reg);
return list;
}
private:
// Unchecked constructor. Only use for valid bits.
explicit constexpr LiftoffRegList(storage_t bits) : regs_(bits) {}
......
......@@ -599,8 +599,7 @@ void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg,
void LiftoffAssembler::Atomic##name( \
Register dst_addr, Register offset_reg, uintptr_t offset_imm, \
LiftoffRegister value, LiftoffRegister result, StoreType type) { \
LiftoffRegList pinned = \
LiftoffRegList::ForRegs(dst_addr, offset_reg, value, result); \
LiftoffRegList pinned = {dst_addr, offset_reg, value, result}; \
Register temp0 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp(); \
Register temp1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp(); \
Register temp2 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp(); \
......@@ -655,8 +654,7 @@ ATOMIC_BINOP_CASE(Xor, Xor, Xor, xor)
void LiftoffAssembler::AtomicSub(Register dst_addr, Register offset_reg,
uintptr_t offset_imm, LiftoffRegister value,
LiftoffRegister result, StoreType type) {
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, value, result);
LiftoffRegList pinned = {dst_addr, offset_reg, value, result};
Register temp0 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp2 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
......@@ -714,8 +712,7 @@ void LiftoffAssembler::AtomicExchange(Register dst_addr, Register offset_reg,
uintptr_t offset_imm,
LiftoffRegister value,
LiftoffRegister result, StoreType type) {
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, value, result);
LiftoffRegList pinned = {dst_addr, offset_reg, value, result};
Register temp0 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp2 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
......@@ -790,8 +787,7 @@ void LiftoffAssembler::AtomicCompareExchange(
Register dst_addr, Register offset_reg, uintptr_t offset_imm,
LiftoffRegister expected, LiftoffRegister new_value, LiftoffRegister result,
StoreType type) {
LiftoffRegList pinned = LiftoffRegList::ForRegs(dst_addr, offset_reg,
expected, new_value, result);
LiftoffRegList pinned = {dst_addr, offset_reg, expected, new_value, result};
Register temp0 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp2 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
......@@ -1320,10 +1316,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::bstrpick_w(dst.gp(), src.gp(), 31, 0);
return true;
case kExprI32SConvertF32: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_s(rounded.fp(), src.fp());
......@@ -1343,10 +1338,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI32UConvertF32: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_s(rounded.fp(), src.fp());
......@@ -1364,10 +1358,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI32SConvertF64: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_d(rounded.fp(), src.fp());
......@@ -1381,10 +1374,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI32UConvertF64: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_d(rounded.fp(), src.fp());
......@@ -1406,10 +1398,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::bstrpick_d(dst.gp(), src.gp(), 31, 0);
return true;
case kExprI64SConvertF32: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_s(rounded.fp(), src.fp());
......@@ -1438,10 +1429,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI64SConvertF64: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_d(rounded.fp(), src.fp());
......@@ -1473,8 +1463,7 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
movfr2gr_d(dst.gp(), src.fp());
return true;
case kExprF32SConvertI32: {
LiftoffRegister scratch =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kFpReg, LiftoffRegList{dst});
movgr2fr_w(scratch.fp(), src.gp());
ffint_s_w(dst.fp(), scratch.fp());
return true;
......@@ -1489,8 +1478,7 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::FmoveLow(dst.fp(), src.gp());
return true;
case kExprF64SConvertI32: {
LiftoffRegister scratch =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kFpReg, LiftoffRegList{dst});
movgr2fr_w(scratch.fp(), src.gp());
ffint_d_w(dst.fp(), scratch.fp());
return true;
......@@ -1635,7 +1623,7 @@ void LiftoffAssembler::emit_i32_set_cond(LiftoffCondition liftoff_cond,
Condition cond = liftoff::ToCondition(liftoff_cond);
Register tmp = dst;
if (dst == lhs || dst == rhs) {
tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp();
tmp = GetUnusedRegister(kGpReg, LiftoffRegList{lhs, rhs}).gp();
}
// Write 1 as result.
TurboAssembler::li(tmp, 1);
......@@ -1658,7 +1646,7 @@ void LiftoffAssembler::emit_i64_set_cond(LiftoffCondition liftoff_cond,
Condition cond = liftoff::ToCondition(liftoff_cond);
Register tmp = dst;
if (dst == lhs.gp() || dst == rhs.gp()) {
tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp();
tmp = GetUnusedRegister(kGpReg, LiftoffRegList{lhs, rhs}).gp();
}
// Write 1 as result.
TurboAssembler::li(tmp, 1);
......
......@@ -658,7 +658,7 @@ void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
#if defined(V8_TARGET_BIG_ENDIAN)
if (is_store_mem) {
pinned = pinned | LiftoffRegList::ForRegs(dst_op.rm(), src);
pinned = pinned | LiftoffRegList{dst_op.rm(), src};
LiftoffRegister tmp = GetUnusedRegister(src.reg_class(), pinned);
// Save original value.
Move(tmp, src, type.value_type());
......@@ -1022,8 +1022,7 @@ I32_SHIFTOP_I(shr, srl)
void LiftoffAssembler::emit_i64_addi(LiftoffRegister dst, LiftoffRegister lhs,
int64_t imm) {
LiftoffRegister imm_reg =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst, lhs));
LiftoffRegister imm_reg = GetUnusedRegister(kFpReg, LiftoffRegList{dst, lhs});
int32_t imm_low_word = static_cast<int32_t>(imm);
int32_t imm_high_word = static_cast<int32_t>(imm >> 32);
TurboAssembler::li(imm_reg.low_gp(), imm_low_word);
......@@ -1092,7 +1091,7 @@ inline void Emit64BitShiftOperation(
void (TurboAssembler::*emit_shift)(Register, Register, Register, Register,
Register, Register, Register)) {
Label move, done;
LiftoffRegList pinned = LiftoffRegList::ForRegs(dst, src, amount);
LiftoffRegList pinned = {dst, src, amount};
// If some of destination registers are in use, get another, unused pair.
// That way we prevent overwriting some input registers while shifting.
......@@ -1377,10 +1376,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::Move(dst.gp(), src.low_gp());
return true;
case kExprI32SConvertF32: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_s_s(rounded.fp(), src.fp());
......@@ -1400,10 +1398,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI32UConvertF32: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_s_s(rounded.fp(), src.fp());
......@@ -1422,8 +1419,7 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI32SConvertF64: {
LiftoffRegister scratch =
GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kGpReg, LiftoffRegList{dst});
// Try a conversion to a signed integer.
trunc_w_d(kScratchDoubleReg, src.fp());
......@@ -1442,9 +1438,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
IsFp64Mode()) {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_d_d(rounded.fp(), src.fp());
......@@ -1501,15 +1497,13 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::Mfhc1(dst.high_gp(), src.fp());
return true;
case kExprF32SConvertI32: {
LiftoffRegister scratch =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kFpReg, LiftoffRegList{dst});
mtc1(src.gp(), scratch.fp());
cvt_s_w(dst.fp(), scratch.fp());
return true;
}
case kExprF32UConvertI32: {
LiftoffRegister scratch =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kFpReg, LiftoffRegList{dst});
TurboAssembler::Cvt_d_uw(dst.fp(), src.gp(), scratch.fp());
cvt_s_d(dst.fp(), dst.fp());
return true;
......@@ -1521,15 +1515,13 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::FmoveLow(dst.fp(), src.gp());
return true;
case kExprF64SConvertI32: {
LiftoffRegister scratch =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kFpReg, LiftoffRegList{dst});
mtc1(src.gp(), scratch.fp());
cvt_d_w(dst.fp(), scratch.fp());
return true;
}
case kExprF64UConvertI32: {
LiftoffRegister scratch =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kFpReg, LiftoffRegList{dst});
TurboAssembler::Cvt_d_uw(dst.fp(), src.gp(), scratch.fp());
return true;
}
......@@ -1614,7 +1606,7 @@ void LiftoffAssembler::emit_i32_set_cond(LiftoffCondition liftoff_cond,
Condition cond = liftoff::ToCondition(liftoff_cond);
Register tmp = dst;
if (dst == lhs || dst == rhs) {
tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp();
tmp = GetUnusedRegister(kGpReg, LiftoffRegList{lhs, rhs}).gp();
}
// Write 1 as result.
TurboAssembler::li(tmp, 1);
......@@ -1628,8 +1620,7 @@ void LiftoffAssembler::emit_i32_set_cond(LiftoffCondition liftoff_cond,
}
void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) {
Register tmp =
GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(src, dst)).gp();
Register tmp = GetUnusedRegister(kGpReg, LiftoffRegList{src, dst}).gp();
sltiu(tmp, src.low_gp(), 1);
sltiu(dst, src.high_gp(), 1);
and_(dst, dst, tmp);
......@@ -1666,8 +1657,7 @@ void LiftoffAssembler::emit_i64_set_cond(LiftoffCondition liftoff_cond,
Register tmp = dst;
if (liftoff::IsRegInRegPair(lhs, dst) || liftoff::IsRegInRegPair(rhs, dst)) {
tmp =
GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(dst, lhs, rhs)).gp();
tmp = GetUnusedRegister(kGpReg, LiftoffRegList{dst, lhs, rhs}).gp();
}
// Write 1 initially in tmp register.
......
......@@ -738,8 +738,7 @@ void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg,
void LiftoffAssembler::Atomic##name( \
Register dst_addr, Register offset_reg, uintptr_t offset_imm, \
LiftoffRegister value, LiftoffRegister result, StoreType type) { \
LiftoffRegList pinned = \
LiftoffRegList::ForRegs(dst_addr, offset_reg, value, result); \
LiftoffRegList pinned = {dst_addr, offset_reg, value, result}; \
Register temp0 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp(); \
Register temp1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp(); \
Register temp2 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp(); \
......@@ -816,8 +815,7 @@ void LiftoffAssembler::AtomicExchange(Register dst_addr, Register offset_reg,
uintptr_t offset_imm,
LiftoffRegister value,
LiftoffRegister result, StoreType type) {
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, value, result);
LiftoffRegList pinned = {dst_addr, offset_reg, value, result};
Register temp0 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp2 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
......@@ -893,8 +891,7 @@ void LiftoffAssembler::AtomicCompareExchange(
Register dst_addr, Register offset_reg, uintptr_t offset_imm,
LiftoffRegister expected, LiftoffRegister new_value, LiftoffRegister result,
StoreType type) {
LiftoffRegList pinned = LiftoffRegList::ForRegs(dst_addr, offset_reg,
expected, new_value, result);
LiftoffRegList pinned = {dst_addr, offset_reg, expected, new_value, result};
Register temp0 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp1 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
Register temp2 = pinned.set(GetUnusedRegister(kGpReg, pinned)).gp();
......@@ -1463,10 +1460,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::Ext(dst.gp(), src.gp(), 0, 32);
return true;
case kExprI32SConvertF32: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_s_s(rounded.fp(), src.fp());
......@@ -1486,10 +1482,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI32UConvertF32: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_s_s(rounded.fp(), src.fp());
......@@ -1507,10 +1502,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI32SConvertF64: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_d_d(rounded.fp(), src.fp());
......@@ -1524,10 +1518,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI32UConvertF64: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_d_d(rounded.fp(), src.fp());
......@@ -1549,10 +1542,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::Dext(dst.gp(), src.gp(), 0, 32);
return true;
case kExprI64SConvertF32: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_s_s(rounded.fp(), src.fp());
......@@ -1581,10 +1573,9 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
return true;
}
case kExprI64SConvertF64: {
LiftoffRegister rounded =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src));
LiftoffRegister rounded = GetUnusedRegister(kFpReg, LiftoffRegList{src});
LiftoffRegister converted_back =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded));
GetUnusedRegister(kFpReg, LiftoffRegList{src, rounded});
// Real conversion.
TurboAssembler::Trunc_d_d(rounded.fp(), src.fp());
......@@ -1616,8 +1607,7 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
dmfc1(dst.gp(), src.fp());
return true;
case kExprF32SConvertI32: {
LiftoffRegister scratch =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kFpReg, LiftoffRegList{dst});
mtc1(src.gp(), scratch.fp());
cvt_s_w(dst.fp(), scratch.fp());
return true;
......@@ -1632,8 +1622,7 @@ bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode,
TurboAssembler::FmoveLow(dst.fp(), src.gp());
return true;
case kExprF64SConvertI32: {
LiftoffRegister scratch =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst));
LiftoffRegister scratch = GetUnusedRegister(kFpReg, LiftoffRegList{dst});
mtc1(src.gp(), scratch.fp());
cvt_d_w(dst.fp(), scratch.fp());
return true;
......@@ -1847,7 +1836,7 @@ void LiftoffAssembler::emit_i32_set_cond(LiftoffCondition liftoff_cond,
Condition cond = liftoff::ToCondition(liftoff_cond);
Register tmp = dst;
if (dst == lhs || dst == rhs) {
tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp();
tmp = GetUnusedRegister(kGpReg, LiftoffRegList{lhs, rhs}).gp();
}
// Write 1 as result.
TurboAssembler::li(tmp, 1);
......@@ -1870,7 +1859,7 @@ void LiftoffAssembler::emit_i64_set_cond(LiftoffCondition liftoff_cond,
Condition cond = liftoff::ToCondition(liftoff_cond);
Register tmp = dst;
if (dst == lhs.gp() || dst == rhs.gp()) {
tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp();
tmp = GetUnusedRegister(kGpReg, LiftoffRegList{lhs, rhs}).gp();
}
// Write 1 as result.
TurboAssembler::li(tmp, 1);
......
......@@ -657,8 +657,7 @@ inline void AtomicBinop(LiftoffAssembler* lasm, Register dst_addr,
Register offset_reg, uintptr_t offset_imm,
LiftoffRegister value, LiftoffRegister result,
StoreType type, Binop op) {
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, value, result);
LiftoffRegList pinned = {dst_addr, offset_reg, value, result};
Register store_result = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
// Make sure that {result} is unique.
......@@ -869,8 +868,7 @@ void LiftoffAssembler::AtomicCompareExchange(
Register dst_addr, Register offset_reg, uintptr_t offset_imm,
LiftoffRegister expected, LiftoffRegister new_value, LiftoffRegister result,
StoreType type) {
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, expected, new_value);
LiftoffRegList pinned = {dst_addr, offset_reg, expected, new_value};
Register result_reg = result.gp();
if (pinned.has(result)) {
......@@ -1866,7 +1864,7 @@ void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst,
VU.set(kScratchReg, E8, m1);
VRegister temp =
GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(lhs, rhs)).fp().toV();
GetUnusedRegister(kFpReg, LiftoffRegList{lhs, rhs}).fp().toV();
if (dst_v == lhs_v) {
vmv_vv(temp, lhs_v);
lhs_v = temp;
......
......@@ -598,8 +598,8 @@ void LiftoffAssembler::AtomicAdd(Register dst_addr, Register offset_reg,
void LiftoffAssembler::AtomicSub(Register dst_addr, Register offset_reg,
uintptr_t offset_imm, LiftoffRegister value,
LiftoffRegister result, StoreType type) {
LiftoffRegList dont_overwrite = cache_state()->used_registers |
LiftoffRegList::ForRegs(dst_addr, offset_reg);
LiftoffRegList dont_overwrite =
cache_state()->used_registers | LiftoffRegList{dst_addr, offset_reg};
DCHECK(!dont_overwrite.has(result));
if (dont_overwrite.has(value)) {
// We cannot overwrite {value}, but the {value} register is changed in the
......@@ -660,8 +660,7 @@ inline void AtomicBinop(LiftoffAssembler* lasm,
// The cmpxchg instruction uses rax to store the old value of the
// compare-exchange primitive. Therefore we have to spill the register and
// move any use to another register.
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, value_reg);
LiftoffRegList pinned = LiftoffRegList{dst_addr, offset_reg, value_reg};
__ ClearRegister(rax, {&dst_addr, &offset_reg, &value_reg}, pinned);
Operand dst_op = liftoff::GetMemOp(lasm, dst_addr, offset_reg, offset_imm);
......@@ -798,7 +797,7 @@ void LiftoffAssembler::AtomicCompareExchange(
// compare-exchange primitive. Therefore we have to spill the register and
// move any use to another register.
LiftoffRegList pinned =
LiftoffRegList::ForRegs(dst_addr, offset_reg, expected, value_reg);
LiftoffRegList{dst_addr, offset_reg, expected, value_reg};
ClearRegister(rax, {&dst_addr, &offset_reg, &value_reg}, pinned);
if (expected.gp() != rax) {
movq(rax, expected.gp());
......@@ -3429,9 +3428,9 @@ void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) {
static constexpr RegClass tmp_rc = reg_class_for(kS128);
LiftoffRegister tmp1 =
GetUnusedRegister(tmp_rc, LiftoffRegList::ForRegs(dst, lhs, rhs));
GetUnusedRegister(tmp_rc, LiftoffRegList{dst, lhs, rhs});
LiftoffRegister tmp2 =
GetUnusedRegister(tmp_rc, LiftoffRegList::ForRegs(dst, lhs, rhs, tmp1));
GetUnusedRegister(tmp_rc, LiftoffRegList{dst, lhs, rhs, tmp1});
I64x2Mul(dst.fp(), lhs.fp(), rhs.fp(), tmp1.fp(), tmp2.fp());
}
......
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