Commit 7f570150 authored by aseemgarg's avatar aseemgarg Committed by Commit bot

[wasm]implement simd lowering for F32x4 and I32x4 binops

BUG=v8:4124
R=bradnelson@chromium.org,bbudge@chromium.org,gdeepti@chromium.org

Review-Url: https://codereview.chromium.org/2713613005
Cr-Commit-Position: refs/heads/master@{#43465}
parent ef2a9e2d
...@@ -72,16 +72,26 @@ void SimdScalarLowering::LowerGraph() { ...@@ -72,16 +72,26 @@ void SimdScalarLowering::LowerGraph() {
} }
#define FOREACH_INT32X4_OPCODE(V) \ #define FOREACH_INT32X4_OPCODE(V) \
V(Int32x4Add) \
V(Int32x4ExtractLane) \
V(Int32x4Splat) \ V(Int32x4Splat) \
V(Int32x4ReplaceLane) V(Int32x4ExtractLane) \
V(Int32x4ReplaceLane) \
V(Int32x4Add) \
V(Int32x4Sub) \
V(Int32x4Mul) \
V(Simd128And) \
V(Simd128Or) \
V(Simd128Xor)
#define FOREACH_FLOAT32X4_OPCODE(V) \ #define FOREACH_FLOAT32X4_OPCODE(V) \
V(Float32x4Add) \
V(Float32x4ExtractLane) \
V(Float32x4Splat) \ V(Float32x4Splat) \
V(Float32x4ReplaceLane) V(Float32x4ExtractLane) \
V(Float32x4ReplaceLane) \
V(Float32x4Add) \
V(Float32x4Sub) \
V(Float32x4Mul) \
V(Float32x4Div) \
V(Float32x4Min) \
V(Float32x4Max)
void SimdScalarLowering::SetLoweredType(Node* node, Node* output) { void SimdScalarLowering::SetLoweredType(Node* node, Node* output) {
switch (node->opcode()) { switch (node->opcode()) {
...@@ -377,14 +387,30 @@ void SimdScalarLowering::LowerNode(Node* node) { ...@@ -377,14 +387,30 @@ void SimdScalarLowering::LowerNode(Node* node) {
} }
break; break;
} }
case IrOpcode::kInt32x4Add: { #define I32X4_BINOP_CASE(opcode, instruction) \
LowerBinaryOp(node, rep_type, machine()->Int32Add()); case IrOpcode::opcode: { \
break; LowerBinaryOp(node, rep_type, machine()->instruction()); \
} break; \
case IrOpcode::kFloat32x4Add: { }
LowerBinaryOp(node, rep_type, machine()->Float32Add()); I32X4_BINOP_CASE(kInt32x4Add, Int32Add)
break; I32X4_BINOP_CASE(kInt32x4Sub, Int32Sub)
} I32X4_BINOP_CASE(kInt32x4Mul, Int32Mul)
I32X4_BINOP_CASE(kSimd128And, Word32And)
I32X4_BINOP_CASE(kSimd128Or, Word32Or)
I32X4_BINOP_CASE(kSimd128Xor, Word32Xor)
#undef I32X4_BINOP_CASE
#define F32X4_BINOP_CASE(name) \
case IrOpcode::kFloat32x4##name: { \
LowerBinaryOp(node, rep_type, machine()->Float32##name()); \
break; \
}
F32X4_BINOP_CASE(Add)
F32X4_BINOP_CASE(Sub)
F32X4_BINOP_CASE(Mul)
F32X4_BINOP_CASE(Div)
F32X4_BINOP_CASE(Min)
F32X4_BINOP_CASE(Max)
#undef F32X4_BINOP_CASE
case IrOpcode::kInt32x4Splat: case IrOpcode::kInt32x4Splat:
case IrOpcode::kFloat32x4Splat: { case IrOpcode::kFloat32x4Splat: {
Node* rep_node[kMaxLanes]; Node* rep_node[kMaxLanes];
......
...@@ -3380,6 +3380,18 @@ Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, ...@@ -3380,6 +3380,18 @@ Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
case wasm::kExprF32x4Sub: case wasm::kExprF32x4Sub:
return graph()->NewNode(jsgraph()->machine()->Float32x4Sub(), inputs[0], return graph()->NewNode(jsgraph()->machine()->Float32x4Sub(), inputs[0],
inputs[1]); inputs[1]);
case wasm::kExprF32x4Mul:
return graph()->NewNode(jsgraph()->machine()->Float32x4Mul(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Div:
return graph()->NewNode(jsgraph()->machine()->Float32x4Div(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Min:
return graph()->NewNode(jsgraph()->machine()->Float32x4Min(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Max:
return graph()->NewNode(jsgraph()->machine()->Float32x4Max(), inputs[0],
inputs[1]);
case wasm::kExprF32x4Eq: case wasm::kExprF32x4Eq:
return graph()->NewNode(jsgraph()->machine()->Float32x4Equal(), inputs[0], return graph()->NewNode(jsgraph()->machine()->Float32x4Equal(), inputs[0],
inputs[1]); inputs[1]);
......
...@@ -619,36 +619,6 @@ class LocalDeclEncoder { ...@@ -619,36 +619,6 @@ class LocalDeclEncoder {
#define WASM_GROW_MEMORY(x) x, kExprGrowMemory, 0 #define WASM_GROW_MEMORY(x) x, kExprGrowMemory, 0
#define WASM_MEMORY_SIZE kExprMemorySize, 0 #define WASM_MEMORY_SIZE kExprMemorySize, 0
//------------------------------------------------------------------------------
// Simd Operations.
//------------------------------------------------------------------------------
// TODO(bbudge) Migrate these into tests.
#define WASM_SIMD_F32x4_SPLAT(x) \
x, kSimdPrefix, static_cast<byte>(kExprF32x4Splat)
#define WASM_SIMD_F32x4_EXTRACT_LANE(lane, x) \
x, kSimdPrefix, static_cast<byte>(kExprF32x4ExtractLane), \
static_cast<byte>(lane)
#define WASM_SIMD_F32x4_REPLACE_LANE(lane, x, y) \
x, y, kSimdPrefix, static_cast<byte>(kExprF32x4ReplaceLane), \
static_cast<byte>(lane)
#define WASM_SIMD_F32x4_ADD(x, y) \
x, y, kSimdPrefix, static_cast<byte>(kExprF32x4Add)
#define WASM_SIMD_F32x4_SUB(x, y) \
x, y, kSimdPrefix, static_cast<byte>(kExprF32x4Sub)
#define WASM_SIMD_I32x4_SPLAT(x) \
x, kSimdPrefix, static_cast<byte>(kExprI32x4Splat)
#define WASM_SIMD_I32x4_EXTRACT_LANE(lane, x) \
x, kSimdPrefix, static_cast<byte>(kExprI32x4ExtractLane), \
static_cast<byte>(lane)
#define WASM_SIMD_I32x4_REPLACE_LANE(lane, x, y) \
x, y, kSimdPrefix, static_cast<byte>(kExprI32x4ReplaceLane), \
static_cast<byte>(lane)
#define WASM_SIMD_I32x4_ADD(x, y) \
x, y, kSimdPrefix, static_cast<byte>(kExprI32x4Add)
#define WASM_SIMD_I32x4_SUB(x, y) \
x, y, kSimdPrefix, static_cast<byte>(kExprI32x4Sub)
#define SIG_ENTRY_v_v kWasmFunctionTypeForm, 0, 0 #define SIG_ENTRY_v_v kWasmFunctionTypeForm, 0, 0
#define SIZEOF_SIG_ENTRY_v_v 3 #define SIZEOF_SIG_ENTRY_v_v 3
......
...@@ -193,6 +193,7 @@ v8_executable("cctest") { ...@@ -193,6 +193,7 @@ v8_executable("cctest") {
"wasm/test-run-wasm-js.cc", "wasm/test-run-wasm-js.cc",
"wasm/test-run-wasm-module.cc", "wasm/test-run-wasm-module.cc",
"wasm/test-run-wasm-relocation.cc", "wasm/test-run-wasm-relocation.cc",
"wasm/test-run-wasm-simd.cc",
"wasm/test-run-wasm.cc", "wasm/test-run-wasm.cc",
"wasm/test-wasm-breakpoints.cc", "wasm/test-wasm-breakpoints.cc",
"wasm/test-wasm-interpreter-entry.cc", "wasm/test-wasm-interpreter-entry.cc",
...@@ -211,7 +212,6 @@ v8_executable("cctest") { ...@@ -211,7 +212,6 @@ v8_executable("cctest") {
"test-macro-assembler-arm.cc", "test-macro-assembler-arm.cc",
"test-run-wasm-relocation-arm.cc", "test-run-wasm-relocation-arm.cc",
"test-simulator-arm.cc", "test-simulator-arm.cc",
"wasm/test-run-wasm-simd.cc",
] ]
} else if (v8_current_cpu == "arm64") { } else if (v8_current_cpu == "arm64") {
sources += [ ### gcmole(arch:arm64) ### sources += [ ### gcmole(arch:arm64) ###
...@@ -226,7 +226,6 @@ v8_executable("cctest") { ...@@ -226,7 +226,6 @@ v8_executable("cctest") {
"test-run-wasm-relocation-arm64.cc", "test-run-wasm-relocation-arm64.cc",
"test-utils-arm64.cc", "test-utils-arm64.cc",
"test-utils-arm64.h", "test-utils-arm64.h",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} else if (v8_current_cpu == "x86") { } else if (v8_current_cpu == "x86") {
sources += [ ### gcmole(arch:ia32) ### sources += [ ### gcmole(arch:ia32) ###
...@@ -238,7 +237,6 @@ v8_executable("cctest") { ...@@ -238,7 +237,6 @@ v8_executable("cctest") {
"test-log-stack-tracer.cc", "test-log-stack-tracer.cc",
"test-macro-assembler-ia32.cc", "test-macro-assembler-ia32.cc",
"test-run-wasm-relocation-ia32.cc", "test-run-wasm-relocation-ia32.cc",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} else if (v8_current_cpu == "mips") { } else if (v8_current_cpu == "mips") {
sources += [ ### gcmole(arch:mips) ### sources += [ ### gcmole(arch:mips) ###
...@@ -248,7 +246,6 @@ v8_executable("cctest") { ...@@ -248,7 +246,6 @@ v8_executable("cctest") {
"test-code-stubs.h", "test-code-stubs.h",
"test-disasm-mips.cc", "test-disasm-mips.cc",
"test-macro-assembler-mips.cc", "test-macro-assembler-mips.cc",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} else if (v8_current_cpu == "mipsel") { } else if (v8_current_cpu == "mipsel") {
sources += [ ### gcmole(arch:mipsel) ### sources += [ ### gcmole(arch:mipsel) ###
...@@ -258,7 +255,6 @@ v8_executable("cctest") { ...@@ -258,7 +255,6 @@ v8_executable("cctest") {
"test-code-stubs.h", "test-code-stubs.h",
"test-disasm-mips.cc", "test-disasm-mips.cc",
"test-macro-assembler-mips.cc", "test-macro-assembler-mips.cc",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} else if (v8_current_cpu == "mips64") { } else if (v8_current_cpu == "mips64") {
sources += [ ### gcmole(arch:mips64) ### sources += [ ### gcmole(arch:mips64) ###
...@@ -268,7 +264,6 @@ v8_executable("cctest") { ...@@ -268,7 +264,6 @@ v8_executable("cctest") {
"test-code-stubs.h", "test-code-stubs.h",
"test-disasm-mips64.cc", "test-disasm-mips64.cc",
"test-macro-assembler-mips64.cc", "test-macro-assembler-mips64.cc",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} else if (v8_current_cpu == "mips64el") { } else if (v8_current_cpu == "mips64el") {
sources += [ ### gcmole(arch:mips64el) ### sources += [ ### gcmole(arch:mips64el) ###
...@@ -278,7 +273,6 @@ v8_executable("cctest") { ...@@ -278,7 +273,6 @@ v8_executable("cctest") {
"test-code-stubs.h", "test-code-stubs.h",
"test-disasm-mips64.cc", "test-disasm-mips64.cc",
"test-macro-assembler-mips64.cc", "test-macro-assembler-mips64.cc",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} else if (v8_current_cpu == "x64") { } else if (v8_current_cpu == "x64") {
sources += [ ### gcmole(arch:x64) ### sources += [ ### gcmole(arch:x64) ###
...@@ -290,7 +284,6 @@ v8_executable("cctest") { ...@@ -290,7 +284,6 @@ v8_executable("cctest") {
"test-log-stack-tracer.cc", "test-log-stack-tracer.cc",
"test-macro-assembler-x64.cc", "test-macro-assembler-x64.cc",
"test-run-wasm-relocation-x64.cc", "test-run-wasm-relocation-x64.cc",
"wasm/test-run-wasm-simd.cc",
] ]
} else if (v8_current_cpu == "x87") { } else if (v8_current_cpu == "x87") {
sources += [ ### gcmole(arch:x87) ### sources += [ ### gcmole(arch:x87) ###
...@@ -302,7 +295,6 @@ v8_executable("cctest") { ...@@ -302,7 +295,6 @@ v8_executable("cctest") {
"test-log-stack-tracer.cc", "test-log-stack-tracer.cc",
"test-macro-assembler-x87.cc", "test-macro-assembler-x87.cc",
"test-run-wasm-relocation-x87.cc", "test-run-wasm-relocation-x87.cc",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} else if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") { } else if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") {
sources += [ ### gcmole(arch:ppc) ### sources += [ ### gcmole(arch:ppc) ###
...@@ -310,7 +302,6 @@ v8_executable("cctest") { ...@@ -310,7 +302,6 @@ v8_executable("cctest") {
"test-code-stubs.cc", "test-code-stubs.cc",
"test-code-stubs.h", "test-code-stubs.h",
"test-disasm-ppc.cc", "test-disasm-ppc.cc",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") { } else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") {
sources += [ ### gcmole(arch:s390) ### sources += [ ### gcmole(arch:s390) ###
...@@ -318,7 +309,6 @@ v8_executable("cctest") { ...@@ -318,7 +309,6 @@ v8_executable("cctest") {
"test-code-stubs.cc", "test-code-stubs.cc",
"test-code-stubs.h", "test-code-stubs.h",
"test-disasm-s390.cc", "test-disasm-s390.cc",
"wasm/test-run-wasm-simd-lowering.cc",
] ]
} }
......
...@@ -215,6 +215,7 @@ ...@@ -215,6 +215,7 @@
'wasm/test-run-wasm-js.cc', 'wasm/test-run-wasm-js.cc',
'wasm/test-run-wasm-module.cc', 'wasm/test-run-wasm-module.cc',
'wasm/test-run-wasm-relocation.cc', 'wasm/test-run-wasm-relocation.cc',
'wasm/test-run-wasm-simd.cc',
'wasm/test-wasm-breakpoints.cc', 'wasm/test-wasm-breakpoints.cc',
'wasm/test-wasm-interpreter-entry.cc', 'wasm/test-wasm-interpreter-entry.cc',
'wasm/test-wasm-stack.cc', 'wasm/test-wasm-stack.cc',
...@@ -230,7 +231,6 @@ ...@@ -230,7 +231,6 @@
'test-macro-assembler-ia32.cc', 'test-macro-assembler-ia32.cc',
'test-log-stack-tracer.cc', 'test-log-stack-tracer.cc',
'test-run-wasm-relocation-ia32.cc', 'test-run-wasm-relocation-ia32.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_x64': [ ### gcmole(arch:x64) ### 'cctest_sources_x64': [ ### gcmole(arch:x64) ###
'test-assembler-x64.cc', 'test-assembler-x64.cc',
...@@ -241,7 +241,6 @@ ...@@ -241,7 +241,6 @@
'test-macro-assembler-x64.cc', 'test-macro-assembler-x64.cc',
'test-log-stack-tracer.cc', 'test-log-stack-tracer.cc',
'test-run-wasm-relocation-x64.cc', 'test-run-wasm-relocation-x64.cc',
'wasm/test-run-wasm-simd.cc',
], ],
'cctest_sources_arm': [ ### gcmole(arch:arm) ### 'cctest_sources_arm': [ ### gcmole(arch:arm) ###
'test-assembler-arm.cc', 'test-assembler-arm.cc',
...@@ -252,7 +251,6 @@ ...@@ -252,7 +251,6 @@
'test-macro-assembler-arm.cc', 'test-macro-assembler-arm.cc',
'test-run-wasm-relocation-arm.cc', 'test-run-wasm-relocation-arm.cc',
'test-simulator-arm.cc', 'test-simulator-arm.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_arm64': [ ### gcmole(arch:arm64) ### 'cctest_sources_arm64': [ ### gcmole(arch:arm64) ###
'test-utils-arm64.cc', 'test-utils-arm64.cc',
...@@ -266,21 +264,18 @@ ...@@ -266,21 +264,18 @@
'test-javascript-arm64.cc', 'test-javascript-arm64.cc',
'test-js-arm64-variables.cc', 'test-js-arm64-variables.cc',
'test-run-wasm-relocation-arm64.cc', 'test-run-wasm-relocation-arm64.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_s390': [ ### gcmole(arch:s390) ### 'cctest_sources_s390': [ ### gcmole(arch:s390) ###
'test-assembler-s390.cc', 'test-assembler-s390.cc',
'test-code-stubs.cc', 'test-code-stubs.cc',
'test-code-stubs.h', 'test-code-stubs.h',
'test-disasm-s390.cc', 'test-disasm-s390.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_ppc': [ ### gcmole(arch:ppc) ### 'cctest_sources_ppc': [ ### gcmole(arch:ppc) ###
'test-assembler-ppc.cc', 'test-assembler-ppc.cc',
'test-code-stubs.cc', 'test-code-stubs.cc',
'test-code-stubs.h', 'test-code-stubs.h',
'test-disasm-ppc.cc', 'test-disasm-ppc.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_mips': [ ### gcmole(arch:mips) ### 'cctest_sources_mips': [ ### gcmole(arch:mips) ###
'test-assembler-mips.cc', 'test-assembler-mips.cc',
...@@ -289,7 +284,6 @@ ...@@ -289,7 +284,6 @@
'test-code-stubs-mips.cc', 'test-code-stubs-mips.cc',
'test-disasm-mips.cc', 'test-disasm-mips.cc',
'test-macro-assembler-mips.cc', 'test-macro-assembler-mips.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_mipsel': [ ### gcmole(arch:mipsel) ### 'cctest_sources_mipsel': [ ### gcmole(arch:mipsel) ###
'test-assembler-mips.cc', 'test-assembler-mips.cc',
...@@ -298,7 +292,6 @@ ...@@ -298,7 +292,6 @@
'test-code-stubs-mips.cc', 'test-code-stubs-mips.cc',
'test-disasm-mips.cc', 'test-disasm-mips.cc',
'test-macro-assembler-mips.cc', 'test-macro-assembler-mips.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_mips64': [ ### gcmole(arch:mips64) ### 'cctest_sources_mips64': [ ### gcmole(arch:mips64) ###
'test-assembler-mips64.cc', 'test-assembler-mips64.cc',
...@@ -307,7 +300,6 @@ ...@@ -307,7 +300,6 @@
'test-code-stubs-mips64.cc', 'test-code-stubs-mips64.cc',
'test-disasm-mips64.cc', 'test-disasm-mips64.cc',
'test-macro-assembler-mips64.cc', 'test-macro-assembler-mips64.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_mips64el': [ ### gcmole(arch:mips64el) ### 'cctest_sources_mips64el': [ ### gcmole(arch:mips64el) ###
'test-assembler-mips64.cc', 'test-assembler-mips64.cc',
...@@ -316,7 +308,6 @@ ...@@ -316,7 +308,6 @@
'test-code-stubs-mips64.cc', 'test-code-stubs-mips64.cc',
'test-disasm-mips64.cc', 'test-disasm-mips64.cc',
'test-macro-assembler-mips64.cc', 'test-macro-assembler-mips64.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
'cctest_sources_x87': [ ### gcmole(arch:x87) ### 'cctest_sources_x87': [ ### gcmole(arch:x87) ###
'test-assembler-x87.cc', 'test-assembler-x87.cc',
...@@ -327,7 +318,6 @@ ...@@ -327,7 +318,6 @@
'test-macro-assembler-x87.cc', 'test-macro-assembler-x87.cc',
'test-log-stack-tracer.cc', 'test-log-stack-tracer.cc',
'test-run-wasm-relocation-x87.cc', 'test-run-wasm-relocation-x87.cc',
'wasm/test-run-wasm-simd-lowering.cc'
], ],
}, },
'includes': ['../../gypfiles/toolchain.gypi', '../../gypfiles/features.gypi'], 'includes': ['../../gypfiles/toolchain.gypi', '../../gypfiles/features.gypi'],
......
This diff is collapsed.
This diff is collapsed.
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