Commit f9b0df1d authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[compiler] [cleanup] Replace 12 instantiations by one template

Variadic template FTW!

R=mstarzinger@chromium.org
BUG=v8:6474

Change-Id: I0585e25e861e8a2fcd29501872edd6b0dd494302
Reviewed-on: https://chromium-review.googlesource.com/529188Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45836}
parent f850b32d
......@@ -5,6 +5,8 @@
#ifndef V8_COMPILER_GRAPH_H_
#define V8_COMPILER_GRAPH_H_
#include <array>
#include "src/base/compiler-specific.h"
#include "src/globals.h"
#include "src/zone/zone-containers.h"
......@@ -62,58 +64,11 @@ class V8_EXPORT_PRIVATE Graph final : public NON_EXPORTED_BASE(ZoneObject) {
Node* NewNode(const Operator* op, int input_count, Node* const* inputs,
bool incomplete = false);
// Factories for nodes with static input counts.
Node* NewNode(const Operator* op) {
return NewNode(op, 0, static_cast<Node* const*>(nullptr));
}
Node* NewNode(const Operator* op, Node* n1) { return NewNode(op, 1, &n1); }
Node* NewNode(const Operator* op, Node* n1, Node* n2) {
Node* nodes[] = {n1, n2};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) {
Node* nodes[] = {n1, n2, n3};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) {
Node* nodes[] = {n1, n2, n3, n4};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5) {
Node* nodes[] = {n1, n2, n3, n4, n5};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5, Node* n6) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5, Node* n6, Node* n7) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5, Node* n6, Node* n7, Node* n8) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7, n8};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5, Node* n6, Node* n7, Node* n8, Node* n9) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7, n8, n9};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5, Node* n6, Node* n7, Node* n8, Node* n9, Node* n10) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5, Node* n6, Node* n7, Node* n8, Node* n9, Node* n10,
Node* n11) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11};
return NewNode(op, arraysize(nodes), nodes);
// Factory template for nodes with static input counts.
template <typename... Nodes>
Node* NewNode(const Operator* op, Nodes*... nodes) {
std::array<Node*, sizeof...(nodes)> nodes_arr{{nodes...}};
return NewNode(op, nodes_arr.size(), nodes_arr.data());
}
// Clone the {node}, and assign a new node id to the copy.
......
......@@ -3501,7 +3501,7 @@ Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
case wasm::kExprS1x16AllTrue:
return graph()->NewNode(jsgraph()->machine()->S1x16AllTrue(), inputs[0]);
default:
return graph()->NewNode(UnsupportedOpcode(opcode), nullptr);
return graph()->NewNode(UnsupportedOpcode(opcode));
}
}
......@@ -3534,7 +3534,7 @@ Node* WasmGraphBuilder::SimdLaneOp(wasm::WasmOpcode opcode, uint8_t lane,
return graph()->NewNode(jsgraph()->machine()->I8x16ReplaceLane(lane),
inputs[0], inputs[1]);
default:
return graph()->NewNode(UnsupportedOpcode(opcode), nullptr);
return graph()->NewNode(UnsupportedOpcode(opcode));
}
}
......@@ -3567,7 +3567,7 @@ Node* WasmGraphBuilder::SimdShiftOp(wasm::WasmOpcode opcode, uint8_t shift,
return graph()->NewNode(jsgraph()->machine()->I8x16ShrU(shift),
inputs[0]);
default:
return graph()->NewNode(UnsupportedOpcode(opcode), nullptr);
return graph()->NewNode(UnsupportedOpcode(opcode));
}
}
......
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