[wasm] Infrastructure to support loop exits in wasm
Changes: - Add LoopExit and LoopExitValue functions in wasm-compiler. - Handle kLoopExitValue opcode in simd-scalar-lowering. Bug: v8:11298 Change-Id: I4d00402ed1913f927bec973b3d480ddc1990962b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2611251 Reviewed-by: Andreas Haas <ahaas@chromium.org> Reviewed-by: Zhi An Ng <zhin@chromium.org> Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Cr-Commit-Position: refs/heads/master@{#72030}
This commit is contained in:
parent
646bdbf843
commit
8361a59f89
@ -1577,6 +1577,19 @@ void SimdScalarLowering::LowerNode(Node* node) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kLoopExitValue: {
|
||||
if (!HasReplacement(0, node->InputAt(0))) break;
|
||||
Node* control = node->InputAt(NodeProperties::FirstControlIndex(node));
|
||||
Node** inputs = GetReplacementsWithType(node->InputAt(0), rep_type);
|
||||
Node** rep_nodes = zone()->NewArray<Node*>(num_lanes);
|
||||
for (int i = 0; i < num_lanes; i++) {
|
||||
auto op =
|
||||
common()->LoopExitValue(MachineTypeFrom(rep_type).representation());
|
||||
rep_nodes[i] = graph()->NewNode(op, inputs[i], control);
|
||||
}
|
||||
ReplaceNode(node, rep_nodes, num_lanes);
|
||||
break;
|
||||
}
|
||||
case IrOpcode::kI64x2Add: {
|
||||
LowerBinaryOp(node, rep_type, machine()->Int64Add());
|
||||
break;
|
||||
|
@ -403,6 +403,23 @@ Node* WasmGraphBuilder::TerminateLoop(Node* effect, Node* control) {
|
||||
return terminate;
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::LoopExit(Node* loop_node) {
|
||||
DCHECK(loop_node->opcode() == IrOpcode::kLoop);
|
||||
Node* loop_exit =
|
||||
graph()->NewNode(mcgraph()->common()->LoopExit(), control(), loop_node);
|
||||
Node* loop_exit_effect = graph()->NewNode(
|
||||
mcgraph()->common()->LoopExitEffect(), effect(), loop_exit);
|
||||
SetEffectControl(loop_exit_effect, loop_exit);
|
||||
return loop_exit;
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::LoopExitValue(Node* value,
|
||||
MachineRepresentation representation) {
|
||||
DCHECK(control()->opcode() == IrOpcode::kLoopExit);
|
||||
return graph()->NewNode(mcgraph()->common()->LoopExitValue(representation),
|
||||
value, control());
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::TerminateThrow(Node* effect, Node* control) {
|
||||
Node* terminate =
|
||||
graph()->NewNode(mcgraph()->common()->Throw(), effect, control);
|
||||
|
@ -196,6 +196,9 @@ class WasmGraphBuilder {
|
||||
Node* Param(unsigned index);
|
||||
Node* Loop(Node* entry);
|
||||
Node* TerminateLoop(Node* effect, Node* control);
|
||||
Node* LoopExit(Node* loop_node);
|
||||
// Assumes current control() is the corresponding loop exit.
|
||||
Node* LoopExitValue(Node* value, MachineRepresentation representation);
|
||||
Node* TerminateThrow(Node* effect, Node* control);
|
||||
Node* Merge(unsigned count, Node** controls);
|
||||
Node* Phi(wasm::ValueType type, unsigned count, Node** vals_and_control);
|
||||
|
Loading…
Reference in New Issue
Block a user