Commit 219b0edb authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[liftoff] Shorten names of value types

Import the most commonly used ValueType kinds as constants into
{LiftoffCompiler}, so that we don't need the fully-qualified accessor on
{ValueType}.
This makes many template instantiations much shorter and hence easier to
read.

Drive-by: Replace break after function by return. This often saves
  another line, making macros and switch statements much shorter.

R=zhin@chromium.org

Bug: v8:10364
Change-Id: If78352c2fa6b854989fa82718d0b3478b4d73aad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2129634
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66943}
parent 91a60a4f
...@@ -253,6 +253,12 @@ class LiftoffCompiler { ...@@ -253,6 +253,12 @@ class LiftoffCompiler {
using Value = ValueBase; using Value = ValueBase;
static constexpr auto kI32 = ValueType::kI32;
static constexpr auto kI64 = ValueType::kI64;
static constexpr auto kF32 = ValueType::kF32;
static constexpr auto kF64 = ValueType::kF64;
static constexpr auto kS128 = ValueType::kS128;
struct ElseState { struct ElseState {
MovableLabel label; MovableLabel label;
LiftoffAssembler::CacheState state; LiftoffAssembler::CacheState state;
...@@ -974,28 +980,21 @@ class LiftoffCompiler { ...@@ -974,28 +980,21 @@ class LiftoffCompiler {
Value* result) { Value* result) {
#define CASE_I32_UNOP(opcode, fn) \ #define CASE_I32_UNOP(opcode, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
EmitUnOp<ValueType::kI32, ValueType::kI32>(&LiftoffAssembler::emit_##fn); \ return EmitUnOp<kI32, kI32>(&LiftoffAssembler::emit_##fn);
break;
#define CASE_I64_UNOP(opcode, fn) \ #define CASE_I64_UNOP(opcode, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
EmitUnOp<ValueType::kI64, ValueType::kI64>(&LiftoffAssembler::emit_##fn); \ return EmitUnOp<kI64, kI64>(&LiftoffAssembler::emit_##fn);
break;
#define CASE_FLOAT_UNOP(opcode, type, fn) \ #define CASE_FLOAT_UNOP(opcode, type, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
EmitUnOp<ValueType::k##type, ValueType::k##type>( \ return EmitUnOp<k##type, k##type>(&LiftoffAssembler::emit_##fn);
&LiftoffAssembler::emit_##fn); \
break;
#define CASE_FLOAT_UNOP_WITH_CFALLBACK(opcode, type, fn) \ #define CASE_FLOAT_UNOP_WITH_CFALLBACK(opcode, type, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
EmitFloatUnOpWithCFallback<ValueType::k##type>( \ return EmitFloatUnOpWithCFallback<k##type>(&LiftoffAssembler::emit_##fn, \
&LiftoffAssembler::emit_##fn, &ExternalReference::wasm_##fn); \ &ExternalReference::wasm_##fn);
break;
#define CASE_TYPE_CONVERSION(opcode, dst_type, src_type, ext_ref, can_trap) \ #define CASE_TYPE_CONVERSION(opcode, dst_type, src_type, ext_ref, can_trap) \
case kExpr##opcode: \ case kExpr##opcode: \
EmitTypeConversion<ValueType::k##dst_type, ValueType::k##src_type, \ return EmitTypeConversion<k##dst_type, k##src_type, can_trap>( \
can_trap>(kExpr##opcode, ext_ref, \ kExpr##opcode, ext_ref, can_trap ? decoder->position() : 0);
can_trap ? decoder->position() : 0); \
break;
switch (opcode) { switch (opcode) {
CASE_I32_UNOP(I32Clz, i32_clz) CASE_I32_UNOP(I32Clz, i32_clz)
CASE_I32_UNOP(I32Ctz, i32_ctz) CASE_I32_UNOP(I32Ctz, i32_ctz)
...@@ -1060,15 +1059,11 @@ class LiftoffCompiler { ...@@ -1060,15 +1059,11 @@ class LiftoffCompiler {
outstanding_op_ = kExprI32Eqz; outstanding_op_ = kExprI32Eqz;
break; break;
} }
EmitUnOp<ValueType::kI32, ValueType::kI32>( return EmitUnOp<kI32, kI32>(&LiftoffAssembler::emit_i32_eqz);
&LiftoffAssembler::emit_i32_eqz);
break;
case kExprI64Eqz: case kExprI64Eqz:
EmitUnOp<ValueType::kI64, ValueType::kI32>( return EmitUnOp<kI64, kI32>(&LiftoffAssembler::emit_i64_eqz);
&LiftoffAssembler::emit_i64_eqz);
break;
case kExprI32Popcnt: case kExprI32Popcnt:
EmitUnOp<ValueType::kI32, ValueType::kI32>( return EmitUnOp<kI32, kI32>(
[=](LiftoffRegister dst, LiftoffRegister src) { [=](LiftoffRegister dst, LiftoffRegister src) {
if (__ emit_i32_popcnt(dst.gp(), src.gp())) return; if (__ emit_i32_popcnt(dst.gp(), src.gp())) return;
ValueType sig_i_i_reps[] = {kWasmI32, kWasmI32}; ValueType sig_i_i_reps[] = {kWasmI32, kWasmI32};
...@@ -1076,9 +1071,8 @@ class LiftoffCompiler { ...@@ -1076,9 +1071,8 @@ class LiftoffCompiler {
GenerateCCall(&dst, &sig_i_i, kWasmStmt, &src, GenerateCCall(&dst, &sig_i_i, kWasmStmt, &src,
ExternalReference::wasm_word32_popcnt()); ExternalReference::wasm_word32_popcnt());
}); });
break;
case kExprI64Popcnt: case kExprI64Popcnt:
EmitUnOp<ValueType::kI64, ValueType::kI64>( return EmitUnOp<kI64, kI64>(
[=](LiftoffRegister dst, LiftoffRegister src) { [=](LiftoffRegister dst, LiftoffRegister src) {
if (__ emit_i64_popcnt(dst, src)) return; if (__ emit_i64_popcnt(dst, src)) return;
// The c function returns i32. We will zero-extend later. // The c function returns i32. We will zero-extend later.
...@@ -1091,7 +1085,6 @@ class LiftoffCompiler { ...@@ -1091,7 +1085,6 @@ class LiftoffCompiler {
__ emit_type_conversion(kExprI64UConvertI32, dst, c_call_dst, __ emit_type_conversion(kExprI64UConvertI32, dst, c_call_dst,
nullptr); nullptr);
}); });
break;
case kExprI32SConvertSatF32: case kExprI32SConvertSatF32:
case kExprI32UConvertSatF32: case kExprI32UConvertSatF32:
case kExprI32SConvertSatF64: case kExprI32SConvertSatF64:
...@@ -1179,24 +1172,21 @@ class LiftoffCompiler { ...@@ -1179,24 +1172,21 @@ class LiftoffCompiler {
const Value& rhs, Value* result) { const Value& rhs, Value* result) {
#define CASE_I32_BINOP(opcode, fn) \ #define CASE_I32_BINOP(opcode, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOp<ValueType::kI32, ValueType::kI32>( \ return EmitBinOp<kI32, kI32>(&LiftoffAssembler::emit_##fn);
&LiftoffAssembler::emit_##fn);
#define CASE_I32_BINOPI(opcode, fn) \ #define CASE_I32_BINOPI(opcode, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOpImm<ValueType::kI32, ValueType::kI32>( \ return EmitBinOpImm<kI32, kI32>(&LiftoffAssembler::emit_##fn, \
&LiftoffAssembler::emit_##fn, &LiftoffAssembler::emit_##fn##i); &LiftoffAssembler::emit_##fn##i);
#define CASE_I64_BINOP(opcode, fn) \ #define CASE_I64_BINOP(opcode, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOp<ValueType::kI64, ValueType::kI64>( \ return EmitBinOp<kI64, kI64>(&LiftoffAssembler::emit_##fn);
&LiftoffAssembler::emit_##fn);
#define CASE_I64_BINOPI(opcode, fn) \ #define CASE_I64_BINOPI(opcode, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOpImm<ValueType::kI64, ValueType::kI64>( \ return EmitBinOpImm<kI64, kI64>(&LiftoffAssembler::emit_##fn, \
&LiftoffAssembler::emit_##fn, &LiftoffAssembler::emit_##fn##i); &LiftoffAssembler::emit_##fn##i);
#define CASE_FLOAT_BINOP(opcode, type, fn) \ #define CASE_FLOAT_BINOP(opcode, type, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOp<ValueType::k##type, ValueType::k##type>( \ return EmitBinOp<k##type, k##type>(&LiftoffAssembler::emit_##fn);
&LiftoffAssembler::emit_##fn);
#define CASE_I32_CMPOP(opcode) \ #define CASE_I32_CMPOP(opcode) \
case kExpr##opcode: \ case kExpr##opcode: \
DCHECK(decoder->lookahead(0, kExpr##opcode)); \ DCHECK(decoder->lookahead(0, kExpr##opcode)); \
...@@ -1205,32 +1195,32 @@ class LiftoffCompiler { ...@@ -1205,32 +1195,32 @@ class LiftoffCompiler {
outstanding_op_ = kExpr##opcode; \ outstanding_op_ = kExpr##opcode; \
break; \ break; \
} \ } \
return EmitBinOp<ValueType::kI32, ValueType::kI32>( \ return EmitBinOp<kI32, kI32>( \
[=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ [=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \
constexpr Condition cond = GetCompareCondition(kExpr##opcode); \ constexpr Condition cond = GetCompareCondition(kExpr##opcode); \
__ emit_i32_set_cond(cond, dst.gp(), lhs.gp(), rhs.gp()); \ __ emit_i32_set_cond(cond, dst.gp(), lhs.gp(), rhs.gp()); \
}); });
#define CASE_I64_CMPOP(opcode, cond) \ #define CASE_I64_CMPOP(opcode, cond) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOp<ValueType::kI64, ValueType::kI32>( \ return EmitBinOp<kI64, kI32>( \
[=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ [=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \
__ emit_i64_set_cond(cond, dst.gp(), lhs, rhs); \ __ emit_i64_set_cond(cond, dst.gp(), lhs, rhs); \
}); });
#define CASE_F32_CMPOP(opcode, cond) \ #define CASE_F32_CMPOP(opcode, cond) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOp<ValueType::kF32, ValueType::kI32>( \ return EmitBinOp<kF32, kI32>( \
[=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ [=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \
__ emit_f32_set_cond(cond, dst.gp(), lhs.fp(), rhs.fp()); \ __ emit_f32_set_cond(cond, dst.gp(), lhs.fp(), rhs.fp()); \
}); });
#define CASE_F64_CMPOP(opcode, cond) \ #define CASE_F64_CMPOP(opcode, cond) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOp<ValueType::kF64, ValueType::kI32>( \ return EmitBinOp<kF64, kI32>( \
[=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ [=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \
__ emit_f64_set_cond(cond, dst.gp(), lhs.fp(), rhs.fp()); \ __ emit_f64_set_cond(cond, dst.gp(), lhs.fp(), rhs.fp()); \
}); });
#define CASE_I64_SHIFTOP(opcode, fn) \ #define CASE_I64_SHIFTOP(opcode, fn) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOpImm<ValueType::kI64, ValueType::kI64>( \ return EmitBinOpImm<kI64, kI64>( \
[=](LiftoffRegister dst, LiftoffRegister src, \ [=](LiftoffRegister dst, LiftoffRegister src, \
LiftoffRegister amount) { \ LiftoffRegister amount) { \
__ emit_##fn(dst, src, \ __ emit_##fn(dst, src, \
...@@ -1239,7 +1229,7 @@ class LiftoffCompiler { ...@@ -1239,7 +1229,7 @@ class LiftoffCompiler {
&LiftoffAssembler::emit_##fn##i); &LiftoffAssembler::emit_##fn##i);
#define CASE_CCALL_BINOP(opcode, type, ext_ref_fn) \ #define CASE_CCALL_BINOP(opcode, type, ext_ref_fn) \
case kExpr##opcode: \ case kExpr##opcode: \
return EmitBinOp<ValueType::k##type, ValueType::k##type>( \ return EmitBinOp<k##type, k##type>( \
[=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ [=](LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \
LiftoffRegister args[] = {lhs, rhs}; \ LiftoffRegister args[] = {lhs, rhs}; \
auto ext_ref = ExternalReference::ext_ref_fn(); \ auto ext_ref = ExternalReference::ext_ref_fn(); \
...@@ -1319,8 +1309,7 @@ class LiftoffCompiler { ...@@ -1319,8 +1309,7 @@ class LiftoffCompiler {
CASE_FLOAT_BINOP(F64Max, F64, f64_max) CASE_FLOAT_BINOP(F64Max, F64, f64_max)
CASE_FLOAT_BINOP(F64CopySign, F64, f64_copysign) CASE_FLOAT_BINOP(F64CopySign, F64, f64_copysign)
case kExprI32DivS: case kExprI32DivS:
EmitBinOp<ValueType::kI32, ValueType::kI32>([this, decoder]( return EmitBinOp<kI32, kI32>([this, decoder](LiftoffRegister dst,
LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
WasmCodePosition position = decoder->position(); WasmCodePosition position = decoder->position();
...@@ -1334,37 +1323,32 @@ class LiftoffCompiler { ...@@ -1334,37 +1323,32 @@ class LiftoffCompiler {
__ emit_i32_divs(dst.gp(), lhs.gp(), rhs.gp(), div_by_zero, __ emit_i32_divs(dst.gp(), lhs.gp(), rhs.gp(), div_by_zero,
div_unrepresentable); div_unrepresentable);
}); });
break;
case kExprI32DivU: case kExprI32DivU:
EmitBinOp<ValueType::kI32, ValueType::kI32>( return EmitBinOp<kI32, kI32>(
[this, decoder](LiftoffRegister dst, LiftoffRegister lhs, [this, decoder](LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Label* div_by_zero = AddOutOfLineTrap( Label* div_by_zero = AddOutOfLineTrap(
decoder->position(), WasmCode::kThrowWasmTrapDivByZero); decoder->position(), WasmCode::kThrowWasmTrapDivByZero);
__ emit_i32_divu(dst.gp(), lhs.gp(), rhs.gp(), div_by_zero); __ emit_i32_divu(dst.gp(), lhs.gp(), rhs.gp(), div_by_zero);
}); });
break;
case kExprI32RemS: case kExprI32RemS:
EmitBinOp<ValueType::kI32, ValueType::kI32>( return EmitBinOp<kI32, kI32>(
[this, decoder](LiftoffRegister dst, LiftoffRegister lhs, [this, decoder](LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Label* rem_by_zero = AddOutOfLineTrap( Label* rem_by_zero = AddOutOfLineTrap(
decoder->position(), WasmCode::kThrowWasmTrapRemByZero); decoder->position(), WasmCode::kThrowWasmTrapRemByZero);
__ emit_i32_rems(dst.gp(), lhs.gp(), rhs.gp(), rem_by_zero); __ emit_i32_rems(dst.gp(), lhs.gp(), rhs.gp(), rem_by_zero);
}); });
break;
case kExprI32RemU: case kExprI32RemU:
EmitBinOp<ValueType::kI32, ValueType::kI32>( return EmitBinOp<kI32, kI32>(
[this, decoder](LiftoffRegister dst, LiftoffRegister lhs, [this, decoder](LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Label* rem_by_zero = AddOutOfLineTrap( Label* rem_by_zero = AddOutOfLineTrap(
decoder->position(), WasmCode::kThrowWasmTrapRemByZero); decoder->position(), WasmCode::kThrowWasmTrapRemByZero);
__ emit_i32_remu(dst.gp(), lhs.gp(), rhs.gp(), rem_by_zero); __ emit_i32_remu(dst.gp(), lhs.gp(), rhs.gp(), rem_by_zero);
}); });
break;
case kExprI64DivS: case kExprI64DivS:
EmitBinOp<ValueType::kI64, ValueType::kI64>([this, decoder]( return EmitBinOp<kI64, kI64>([this, decoder](LiftoffRegister dst,
LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
WasmCodePosition position = decoder->position(); WasmCodePosition position = decoder->position();
...@@ -1382,10 +1366,8 @@ class LiftoffCompiler { ...@@ -1382,10 +1366,8 @@ class LiftoffCompiler {
div_unrepresentable); div_unrepresentable);
} }
}); });
break;
case kExprI64DivU: case kExprI64DivU:
EmitBinOp<ValueType::kI64, ValueType::kI64>([this, decoder]( return EmitBinOp<kI64, kI64>([this, decoder](LiftoffRegister dst,
LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Label* div_by_zero = AddOutOfLineTrap( Label* div_by_zero = AddOutOfLineTrap(
...@@ -1395,9 +1377,8 @@ class LiftoffCompiler { ...@@ -1395,9 +1377,8 @@ class LiftoffCompiler {
EmitDivOrRem64CCall(dst, lhs, rhs, ext_ref, div_by_zero); EmitDivOrRem64CCall(dst, lhs, rhs, ext_ref, div_by_zero);
} }
}); });
break;
case kExprI64RemS: case kExprI64RemS:
EmitBinOp<ValueType::kI64, ValueType::kI64>( return EmitBinOp<kI64, kI64>(
[this, decoder](LiftoffRegister dst, LiftoffRegister lhs, [this, decoder](LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Label* rem_by_zero = AddOutOfLineTrap( Label* rem_by_zero = AddOutOfLineTrap(
...@@ -1407,10 +1388,8 @@ class LiftoffCompiler { ...@@ -1407,10 +1388,8 @@ class LiftoffCompiler {
EmitDivOrRem64CCall(dst, lhs, rhs, ext_ref, rem_by_zero); EmitDivOrRem64CCall(dst, lhs, rhs, ext_ref, rem_by_zero);
} }
}); });
break;
case kExprI64RemU: case kExprI64RemU:
EmitBinOp<ValueType::kI64, ValueType::kI64>([this, decoder]( return EmitBinOp<kI64, kI64>([this, decoder](LiftoffRegister dst,
LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs) { LiftoffRegister rhs) {
Label* rem_by_zero = AddOutOfLineTrap( Label* rem_by_zero = AddOutOfLineTrap(
...@@ -1420,7 +1399,6 @@ class LiftoffCompiler { ...@@ -1420,7 +1399,6 @@ class LiftoffCompiler {
EmitDivOrRem64CCall(dst, lhs, rhs, ext_ref, rem_by_zero); EmitDivOrRem64CCall(dst, lhs, rhs, ext_ref, rem_by_zero);
} }
}); });
break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
...@@ -2289,101 +2267,53 @@ class LiftoffCompiler { ...@@ -2289,101 +2267,53 @@ class LiftoffCompiler {
} }
switch (opcode) { switch (opcode) {
case wasm::kExprF64x2Splat: case wasm::kExprF64x2Splat:
EmitUnOp<ValueType::kF64, ValueType::kS128>( return EmitUnOp<kF64, kS128>(&LiftoffAssembler::emit_f64x2_splat);
&LiftoffAssembler::emit_f64x2_splat);
break;
case wasm::kExprF64x2Add: case wasm::kExprF64x2Add:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f64x2_add);
&LiftoffAssembler::emit_f64x2_add);
break;
case wasm::kExprF64x2Sub: case wasm::kExprF64x2Sub:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f64x2_sub);
&LiftoffAssembler::emit_f64x2_sub);
break;
case wasm::kExprF64x2Mul: case wasm::kExprF64x2Mul:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f64x2_mul);
&LiftoffAssembler::emit_f64x2_mul);
break;
case wasm::kExprF32x4Splat: case wasm::kExprF32x4Splat:
EmitUnOp<ValueType::kF32, ValueType::kS128>( return EmitUnOp<kF32, kS128>(&LiftoffAssembler::emit_f32x4_splat);
&LiftoffAssembler::emit_f32x4_splat);
break;
case wasm::kExprF32x4Add: case wasm::kExprF32x4Add:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_add);
&LiftoffAssembler::emit_f32x4_add);
break;
case wasm::kExprF32x4Sub: case wasm::kExprF32x4Sub:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_sub);
&LiftoffAssembler::emit_f32x4_sub);
break;
case wasm::kExprF32x4Mul: case wasm::kExprF32x4Mul:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_f32x4_mul);
&LiftoffAssembler::emit_f32x4_mul);
break;
case wasm::kExprI64x2Splat: case wasm::kExprI64x2Splat:
EmitUnOp<ValueType::kI64, ValueType::kS128>( return EmitUnOp<kI64, kS128>(&LiftoffAssembler::emit_i64x2_splat);
&LiftoffAssembler::emit_i64x2_splat);
break;
case wasm::kExprI64x2Add: case wasm::kExprI64x2Add:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_add);
&LiftoffAssembler::emit_i64x2_add);
break;
case wasm::kExprI64x2Sub: case wasm::kExprI64x2Sub:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_sub);
&LiftoffAssembler::emit_i64x2_sub);
break;
case wasm::kExprI64x2Mul: case wasm::kExprI64x2Mul:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i64x2_mul);
&LiftoffAssembler::emit_i64x2_mul);
break;
case wasm::kExprI32x4Splat: case wasm::kExprI32x4Splat:
EmitUnOp<ValueType::kI32, ValueType::kS128>( return EmitUnOp<kI32, kS128>(&LiftoffAssembler::emit_i32x4_splat);
&LiftoffAssembler::emit_i32x4_splat);
break;
case wasm::kExprI32x4Add: case wasm::kExprI32x4Add:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_add);
&LiftoffAssembler::emit_i32x4_add);
break;
case wasm::kExprI32x4Sub: case wasm::kExprI32x4Sub:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_sub);
&LiftoffAssembler::emit_i32x4_sub);
break;
case wasm::kExprI32x4Mul: case wasm::kExprI32x4Mul:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_mul);
&LiftoffAssembler::emit_i32x4_mul);
break;
case wasm::kExprI16x8Splat: case wasm::kExprI16x8Splat:
EmitUnOp<ValueType::kI32, ValueType::kS128>( return EmitUnOp<kI32, kS128>(&LiftoffAssembler::emit_i16x8_splat);
&LiftoffAssembler::emit_i16x8_splat);
break;
case wasm::kExprI16x8Add: case wasm::kExprI16x8Add:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_add);
&LiftoffAssembler::emit_i16x8_add);
break;
case wasm::kExprI16x8Sub: case wasm::kExprI16x8Sub:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_sub);
&LiftoffAssembler::emit_i16x8_sub);
break;
case wasm::kExprI16x8Mul: case wasm::kExprI16x8Mul:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i16x8_mul);
&LiftoffAssembler::emit_i16x8_mul);
break;
case wasm::kExprI8x16Splat: case wasm::kExprI8x16Splat:
EmitUnOp<ValueType::kI32, ValueType::kS128>( return EmitUnOp<kI32, kS128>(&LiftoffAssembler::emit_i8x16_splat);
&LiftoffAssembler::emit_i8x16_splat);
break;
case wasm::kExprI8x16Add: case wasm::kExprI8x16Add:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_add);
&LiftoffAssembler::emit_i8x16_add);
break;
case wasm::kExprI8x16Sub: case wasm::kExprI8x16Sub:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_sub);
&LiftoffAssembler::emit_i8x16_sub);
break;
case wasm::kExprI8x16Mul: case wasm::kExprI8x16Mul:
EmitBinOp<ValueType::kS128, ValueType::kS128>( return EmitBinOp<kS128, kS128>(&LiftoffAssembler::emit_i8x16_mul);
&LiftoffAssembler::emit_i8x16_mul);
break;
default: default:
unsupported(decoder, kSimd, "simd"); unsupported(decoder, kSimd, "simd");
} }
...@@ -2406,9 +2336,9 @@ class LiftoffCompiler { ...@@ -2406,9 +2336,9 @@ class LiftoffCompiler {
template <ValueType::Kind src2_type, typename EmitFn> template <ValueType::Kind src2_type, typename EmitFn>
void EmitSimdReplaceLaneOp(EmitFn fn, void EmitSimdReplaceLaneOp(EmitFn fn,
const SimdLaneImmediate<validate>& imm) { const SimdLaneImmediate<validate>& imm) {
static constexpr RegClass src1_rc = reg_class_for(ValueType::kS128); static constexpr RegClass src1_rc = reg_class_for(kS128);
static constexpr RegClass src2_rc = reg_class_for(src2_type); static constexpr RegClass src2_rc = reg_class_for(src2_type);
static constexpr RegClass result_rc = reg_class_for(ValueType::kS128); static constexpr RegClass result_rc = reg_class_for(kS128);
// On backends which need fp pair, src1_rc and result_rc end up being // On backends which need fp pair, src1_rc and result_rc end up being
// kFpRegPair, which is != kFpReg, but we still want to pin src2 when it is // kFpRegPair, which is != kFpReg, but we still want to pin src2 when it is
// kFpReg, since it can overlap with those pairs. // kFpReg, since it can overlap with those pairs.
...@@ -2438,7 +2368,7 @@ class LiftoffCompiler { ...@@ -2438,7 +2368,7 @@ class LiftoffCompiler {
switch (opcode) { switch (opcode) {
#define CASE_SIMD_EXTRACT_LANE_OP(opcode, type, fn) \ #define CASE_SIMD_EXTRACT_LANE_OP(opcode, type, fn) \
case wasm::kExpr##opcode: \ case wasm::kExpr##opcode: \
EmitSimdExtractLaneOp<ValueType::kS128, ValueType::k##type>( \ EmitSimdExtractLaneOp<kS128, k##type>( \
[=](LiftoffRegister dst, LiftoffRegister lhs, uint8_t imm_lane_idx) { \ [=](LiftoffRegister dst, LiftoffRegister lhs, uint8_t imm_lane_idx) { \
__ emit_##fn(dst, lhs, imm_lane_idx); \ __ emit_##fn(dst, lhs, imm_lane_idx); \
}, \ }, \
...@@ -2455,7 +2385,7 @@ class LiftoffCompiler { ...@@ -2455,7 +2385,7 @@ class LiftoffCompiler {
#undef CASE_SIMD_EXTRACT_LANE_OP #undef CASE_SIMD_EXTRACT_LANE_OP
#define CASE_SIMD_REPLACE_LANE_OP(opcode, type, fn) \ #define CASE_SIMD_REPLACE_LANE_OP(opcode, type, fn) \
case wasm::kExpr##opcode: \ case wasm::kExpr##opcode: \
EmitSimdReplaceLaneOp<ValueType::k##type>( \ EmitSimdReplaceLaneOp<k##type>( \
[=](LiftoffRegister dst, LiftoffRegister src1, LiftoffRegister src2, \ [=](LiftoffRegister dst, LiftoffRegister src1, LiftoffRegister src2, \
uint8_t imm_lane_idx) { \ uint8_t imm_lane_idx) { \
__ emit_##fn(dst, src1, src2, imm_lane_idx); \ __ emit_##fn(dst, src1, src2, imm_lane_idx); \
......
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