Commit a8d5d176 authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] Added I64Xor to the Int64Lowering.

R=titzer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34241}
parent 51089074
......@@ -274,6 +274,20 @@ void Int64Lowering::LowerNode(Node* node) {
}
// kExprI64Xor:
case IrOpcode::kWord64Xor: {
DCHECK(node->InputCount() == 2);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
Node* low_node =
graph()->NewNode(machine()->Word32Xor(), GetReplacementLow(left),
GetReplacementLow(right));
Node* high_node =
graph()->NewNode(machine()->Word32Xor(), GetReplacementHigh(left),
GetReplacementHigh(right));
ReplaceNode(node, low_node, high_node);
break;
}
// kExprI64Shl:
// kExprI64ShrU:
// kExprI64ShrS:
......
......@@ -500,6 +500,9 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left,
op = m->Word64Or();
break;
// kExprI64Xor:
case wasm::kExprI64Xor:
op = m->Word64Xor();
break;
// kExprI64Shl:
// kExprI64ShrU:
// kExprI64ShrS:
......@@ -583,9 +586,6 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left,
op = m->Uint64Mod();
return graph()->NewNode(op, left, right,
trap_->ZeroCheck64(kTrapRemByZero, right));
case wasm::kExprI64Xor:
op = m->Word64Xor();
break;
case wasm::kExprI64Shl:
op = m->Word64Shl();
break;
......
......@@ -43,6 +43,13 @@ TEST(Run_WasmI64Ior) {
}
}
// kExprI64Xor:
TEST(Run_WasmI64Xor) {
WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
FOR_INT64_INPUTS(i) {
FOR_INT64_INPUTS(j) { CHECK_EQ((*i) ^ (*j), r.Call(*i, *j)); }
}
}
// kExprI64Shl:
// kExprI64ShrU:
// kExprI64ShrS:
......
......@@ -320,6 +320,19 @@ TEST_F(Int64LoweringTest, Int64Ior) {
}
// kExprI64Xor:
TEST_F(Int64LoweringTest, Int64Xor) {
if (4 != kPointerSize) return;
LowerGraph(graph()->NewNode(machine()->Word64Xor(), Int64Constant(value(0)),
Int64Constant(value(1))),
MachineRepresentation::kWord64);
EXPECT_THAT(graph()->end()->InputAt(1),
IsReturn2(IsWord32Xor(IsInt32Constant(low_word_value(0)),
IsInt32Constant(low_word_value(1))),
IsWord32Xor(IsInt32Constant(high_word_value(0)),
IsInt32Constant(high_word_value(1))),
start(), start()));
}
// kExprI64Shl:
// kExprI64ShrU:
// kExprI64ShrS:
......
......@@ -2085,6 +2085,7 @@ IS_BINOP_MATCHER(NumberShiftRight)
IS_BINOP_MATCHER(NumberShiftRightLogical)
IS_BINOP_MATCHER(Word32And)
IS_BINOP_MATCHER(Word32Or)
IS_BINOP_MATCHER(Word32Xor)
IS_BINOP_MATCHER(Word32Sar)
IS_BINOP_MATCHER(Word32Shl)
IS_BINOP_MATCHER(Word32Shr)
......
......@@ -265,6 +265,8 @@ Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord32Or(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord32Xor(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsWord32Shl(const Matcher<Node*>& lhs_matcher,
......
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