Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Unified Diff: src/compiler/wasm-compiler.cc

Issue 2838943002: [wasm] Implement 128-bit endian swap for simd type (Closed)
Patch Set: address comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/simd-scalar-lowering.cc ('k') | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index f5cb58085e3bafd4a137a1ea5a14bddb91e1e754..14f9b6f344093036465047ab03f1688cbac6ca5f 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -1066,6 +1066,7 @@ static bool ReverseBytesSupported(MachineOperatorBuilder* m,
size_t size_in_bytes) {
switch (size_in_bytes) {
case 4:
+ case 16:
return m->Word32ReverseBytes().IsSupported();
case 8:
return m->Word64ReverseBytes().IsSupported();
@@ -1102,6 +1103,9 @@ Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype,
// No need to change endianness for byte size, return original node
return node;
break;
+ case MachineRepresentation::kSimd128:
+ DCHECK(ReverseBytesSupported(m, valueSizeInBytes));
+ break;
default:
UNREACHABLE();
break;
@@ -1124,6 +1128,27 @@ Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype,
case 8:
result = graph()->NewNode(m->Word64ReverseBytes().op(), value);
break;
+ case 16: {
+ Node* byte_reversed_lanes[4];
+ for (int lane = 0; lane < 4; lane++) {
+ byte_reversed_lanes[lane] = graph()->NewNode(
+ m->Word32ReverseBytes().op(),
+ graph()->NewNode(jsgraph()->machine()->I32x4ExtractLane(lane),
+ value));
+ }
+
+ // This is making a copy of the value.
+ result =
+ graph()->NewNode(jsgraph()->machine()->S128And(), value, value);
+
+ for (int lane = 0; lane < 4; lane++) {
+ result =
+ graph()->NewNode(jsgraph()->machine()->I32x4ReplaceLane(3 - lane),
+ result, byte_reversed_lanes[lane]);
+ }
+
+ break;
+ }
default:
UNREACHABLE();
}
« no previous file with comments | « src/compiler/simd-scalar-lowering.cc ('k') | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698