[wasm] Int64Lowering of F64ReinterpretI64.
The implementation is done by storing to and then loading from memory. R=titzer@chromium.org Review URL: https://codereview.chromium.org/1801013002 Cr-Commit-Position: refs/heads/master@{#34785}
This commit is contained in:
parent
b484cc12f3
commit
ccbf004293
@ -120,6 +120,8 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
}
|
||||
NodeProperties::ChangeOp(node, load_op);
|
||||
ReplaceNode(node, node, high_node);
|
||||
} else {
|
||||
DefaultLowering(node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -162,6 +164,8 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
node->ReplaceInput(2, GetReplacementLow(value));
|
||||
NodeProperties::ChangeOp(node, store_op);
|
||||
ReplaceNode(node, node, high_node);
|
||||
} else {
|
||||
DefaultLowering(node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -443,10 +447,41 @@ void Int64Lowering::LowerNode(Node* node) {
|
||||
break;
|
||||
}
|
||||
// kExprF64ReinterpretI64:
|
||||
case IrOpcode::kBitcastInt64ToFloat64: {
|
||||
DCHECK(node->InputCount() == 1);
|
||||
Node* input = node->InputAt(0);
|
||||
Node* stack_slot = graph()->NewNode(
|
||||
machine()->StackSlot(MachineRepresentation::kWord64));
|
||||
|
||||
Node* store_high_word = graph()->NewNode(
|
||||
machine()->Store(
|
||||
StoreRepresentation(MachineRepresentation::kWord32,
|
||||
WriteBarrierKind::kNoWriteBarrier)),
|
||||
stack_slot, graph()->NewNode(common()->Int32Constant(4)),
|
||||
GetReplacementHigh(input), graph()->start(), graph()->start());
|
||||
|
||||
Node* store_low_word = graph()->NewNode(
|
||||
machine()->Store(
|
||||
StoreRepresentation(MachineRepresentation::kWord32,
|
||||
WriteBarrierKind::kNoWriteBarrier)),
|
||||
stack_slot, graph()->NewNode(common()->Int32Constant(0)),
|
||||
GetReplacementLow(input), store_high_word, graph()->start());
|
||||
|
||||
Node* load =
|
||||
graph()->NewNode(machine()->Load(MachineType::Float64()), stack_slot,
|
||||
graph()->NewNode(common()->Int32Constant(0)),
|
||||
store_low_word, graph()->start());
|
||||
|
||||
ReplaceNode(node, load, nullptr);
|
||||
break;
|
||||
}
|
||||
// kExprI64ReinterpretF64:
|
||||
case IrOpcode::kBitcastFloat64ToInt64: {
|
||||
DCHECK(node->InputCount() == 1);
|
||||
Node* input = node->InputAt(0);
|
||||
if (HasReplacementLow(input)) {
|
||||
input = GetReplacementLow(input);
|
||||
}
|
||||
Node* stack_slot = graph()->NewNode(
|
||||
machine()->StackSlot(MachineRepresentation::kWord64));
|
||||
Node* store = graph()->NewNode(
|
||||
|
@ -830,6 +830,9 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) {
|
||||
op = m->ChangeUint32ToUint64();
|
||||
break;
|
||||
// kExprF64ReinterpretI64:
|
||||
case wasm::kExprF64ReinterpretI64:
|
||||
op = m->BitcastInt64ToFloat64();
|
||||
break;
|
||||
// kExprI64ReinterpretF64:
|
||||
case wasm::kExprI64ReinterpretF64:
|
||||
op = m->BitcastFloat64ToInt64();
|
||||
@ -897,9 +900,6 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) {
|
||||
#if WASM_64
|
||||
// Opcodes only supported on 64-bit platforms.
|
||||
// TODO(titzer): query the machine operator builder here instead of #ifdef.
|
||||
case wasm::kExprF64ReinterpretI64:
|
||||
op = m->BitcastInt64ToFloat64();
|
||||
break;
|
||||
case wasm::kExprI64Clz:
|
||||
op = m->Word64Clz();
|
||||
break;
|
||||
|
@ -82,7 +82,7 @@
|
||||
V(F32UConvertI64, true) \
|
||||
V(F64SConvertI64, true) \
|
||||
V(F64UConvertI64, true) \
|
||||
V(F64ReinterpretI64, false) \
|
||||
V(F64ReinterpretI64, true) \
|
||||
V(I64ReinterpretF64, true) \
|
||||
V(I64Ror, false) \
|
||||
V(I64Rol, false)
|
||||
|
@ -491,6 +491,36 @@ TEST_F(Int64LoweringTest, I64UConvertI32_2) {
|
||||
start(), start()));
|
||||
}
|
||||
// kExprF64ReinterpretI64:
|
||||
TEST_F(Int64LoweringTest, F64ReinterpretI64) {
|
||||
LowerGraph(graph()->NewNode(machine()->BitcastInt64ToFloat64(),
|
||||
Int64Constant(value(0))),
|
||||
MachineRepresentation::kFloat64);
|
||||
|
||||
Capture<Node*> stack_slot_capture;
|
||||
Matcher<Node*> stack_slot_matcher =
|
||||
IsStackSlot(MachineRepresentation::kWord64);
|
||||
|
||||
Capture<Node*> store_capture;
|
||||
Matcher<Node*> store_matcher =
|
||||
IsStore(StoreRepresentation(MachineRepresentation::kWord32,
|
||||
WriteBarrierKind::kNoWriteBarrier),
|
||||
AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher),
|
||||
IsInt32Constant(0), IsInt32Constant(low_word_value(0)),
|
||||
IsStore(StoreRepresentation(MachineRepresentation::kWord32,
|
||||
WriteBarrierKind::kNoWriteBarrier),
|
||||
AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher),
|
||||
IsInt32Constant(4), IsInt32Constant(high_word_value(0)),
|
||||
start(), start()),
|
||||
start());
|
||||
|
||||
EXPECT_THAT(
|
||||
graph()->end()->InputAt(1),
|
||||
IsReturn(IsLoad(MachineType::Float64(),
|
||||
AllOf(CaptureEq(&stack_slot_capture), stack_slot_matcher),
|
||||
IsInt32Constant(0),
|
||||
AllOf(CaptureEq(&store_capture), store_matcher), start()),
|
||||
start(), start()));
|
||||
}
|
||||
// kExprI64ReinterpretF64:
|
||||
TEST_F(Int64LoweringTest, I64ReinterpretF64) {
|
||||
LowerGraph(graph()->NewNode(machine()->BitcastFloat64ToInt64(),
|
||||
|
@ -375,6 +375,8 @@ Matcher<Node*> IsWord32PairSar(const Matcher<Node*>& lhs_matcher,
|
||||
const Matcher<Node*>& mid_matcher,
|
||||
const Matcher<Node*>& rhs_matcher);
|
||||
|
||||
Matcher<Node*> IsStackSlot();
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
Loading…
Reference in New Issue
Block a user