Commit ad91d1c6 authored by titzer's avatar titzer Committed by Commit bot

[wasm] Add I64Eqz operator.

R=ahaas@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1798863004

Cr-Commit-Position: refs/heads/master@{#34757}
parent ace6f136
...@@ -865,6 +865,9 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) { ...@@ -865,6 +865,9 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) {
// kExprI64Ctz: // kExprI64Ctz:
// kExprI64Popcnt: // kExprI64Popcnt:
// kExprF32SConvertI64: // kExprF32SConvertI64:
case wasm::kExprI64Eqz:
op = m->Word64Equal();
return graph()->NewNode(op, input, jsgraph()->Int64Constant(0));
case wasm::kExprF32SConvertI64: case wasm::kExprF32SConvertI64:
if (m->Is32()) { if (m->Is32()) {
return BuildF32SConvertI64(input); return BuildF32SConvertI64(input);
......
...@@ -399,6 +399,7 @@ class LocalDeclEncoder { ...@@ -399,6 +399,7 @@ class LocalDeclEncoder {
#define WASM_I32_CLZ(x) kExprI32Clz, x #define WASM_I32_CLZ(x) kExprI32Clz, x
#define WASM_I32_CTZ(x) kExprI32Ctz, x #define WASM_I32_CTZ(x) kExprI32Ctz, x
#define WASM_I32_POPCNT(x) kExprI32Popcnt, x #define WASM_I32_POPCNT(x) kExprI32Popcnt, x
#define WASM_I32_EQZ(x) kExprI32Eqz, x
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Int64 operations // Int64 operations
...@@ -431,6 +432,7 @@ class LocalDeclEncoder { ...@@ -431,6 +432,7 @@ class LocalDeclEncoder {
#define WASM_I64_CLZ(x) kExprI64Clz, x #define WASM_I64_CLZ(x) kExprI64Clz, x
#define WASM_I64_CTZ(x) kExprI64Ctz, x #define WASM_I64_CTZ(x) kExprI64Ctz, x
#define WASM_I64_POPCNT(x) kExprI64Popcnt, x #define WASM_I64_POPCNT(x) kExprI64Popcnt, x
#define WASM_I64_EQZ(x) kExprI64Eqz, x
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Float32 operations // Float32 operations
......
...@@ -175,6 +175,7 @@ struct WasmName { ...@@ -175,6 +175,7 @@ struct WasmName {
V(I64Clz, 0x72, l_l) \ V(I64Clz, 0x72, l_l) \
V(I64Ctz, 0x73, l_l) \ V(I64Ctz, 0x73, l_l) \
V(I64Popcnt, 0x74, l_l) \ V(I64Popcnt, 0x74, l_l) \
V(I64Eqz, 0xba, i_l) \
V(F32Add, 0x75, f_ff) \ V(F32Add, 0x75, f_ff) \
V(F32Sub, 0x76, f_ff) \ V(F32Sub, 0x76, f_ff) \
V(F32Mul, 0x77, f_ff) \ V(F32Mul, 0x77, f_ff) \
......
...@@ -1209,3 +1209,15 @@ TEST(Run_Wasm_I64Global) { ...@@ -1209,3 +1209,15 @@ TEST(Run_Wasm_I64Global) {
CHECK_EQ(expected, *global); CHECK_EQ(expected, *global);
} }
} }
TEST(Run_WasmI64Eqz) {
REQUIRE(I64Eq);
WasmRunner<int32_t> r(MachineType::Int64());
BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0)));
FOR_INT64_INPUTS(i) {
int32_t result = *i == 0 ? 1 : 0;
CHECK_EQ(result, r.Call(*i));
}
}
...@@ -185,6 +185,8 @@ TEST_F(WasmMacroGenTest, Int32Ops) { ...@@ -185,6 +185,8 @@ TEST_F(WasmMacroGenTest, Int32Ops) {
EXPECT_SIZE(3, WASM_I32_CLZ(WASM_ZERO)); EXPECT_SIZE(3, WASM_I32_CLZ(WASM_ZERO));
EXPECT_SIZE(3, WASM_I32_CTZ(WASM_ZERO)); EXPECT_SIZE(3, WASM_I32_CTZ(WASM_ZERO));
EXPECT_SIZE(3, WASM_I32_POPCNT(WASM_ZERO)); EXPECT_SIZE(3, WASM_I32_POPCNT(WASM_ZERO));
EXPECT_SIZE(3, WASM_I32_EQZ(WASM_ZERO));
} }
...@@ -219,6 +221,8 @@ TEST_F(WasmMacroGenTest, Int64Ops) { ...@@ -219,6 +221,8 @@ TEST_F(WasmMacroGenTest, Int64Ops) {
EXPECT_SIZE(3, WASM_I64_CLZ(WASM_ZERO)); EXPECT_SIZE(3, WASM_I64_CLZ(WASM_ZERO));
EXPECT_SIZE(3, WASM_I64_CTZ(WASM_ZERO)); EXPECT_SIZE(3, WASM_I64_CTZ(WASM_ZERO));
EXPECT_SIZE(3, WASM_I64_POPCNT(WASM_ZERO)); EXPECT_SIZE(3, WASM_I64_POPCNT(WASM_ZERO));
EXPECT_SIZE(3, WASM_I64_EQZ(WASM_ZERO));
} }
......
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