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

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

Issue 2838943002: [wasm] Implement 128-bit endian swap for simd type (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | test/cctest/wasm/test-run-wasm-simd.cc » ('J')
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 158c70fc5c03d9e1489ace784e16d2aac5e48dc8..6150e731242dac9c7cf6a7d6a09f8df110fbe88a 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -1069,6 +1069,8 @@ static bool ReverseBytesSupported(MachineOperatorBuilder* m,
return m->Word32ReverseBytes().IsSupported();
case 8:
return m->Word64ReverseBytes().IsSupported();
+ case 16:
Clemens Hammacher 2017/04/26 18:40:05 You can merge this with the case for 4.
+ return m->Word32ReverseBytes().IsSupported();
default:
break;
}
@@ -1102,6 +1104,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, 4));
Clemens Hammacher 2017/04/26 18:40:05 You meant 16, not 4. You can also use valueSizeInB
+ break;
default:
UNREACHABLE();
break;
@@ -1124,6 +1129,21 @@ Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype,
case 8:
result = graph()->NewNode(m->Word64ReverseBytes().op(), value);
break;
+ case 16: {
+ Node* byte_reversed_lanes[4];
+ result = value;
+ for (int lane = 0; lane < 4; lane++)
bbudge 2017/04/26 20:14:12 use braces for this loop body and below
+ byte_reversed_lanes[lane] = graph()->NewNode(
+ m->Word32ReverseBytes().op(),
+ graph()->NewNode(jsgraph()->machine()->I32x4ExtractLane(lane),
+ value));
+ for (int lane = 0; lane < 4; lane++)
+ result =
+ graph()->NewNode(jsgraph()->machine()->I32x4ReplaceLane(lane),
+ result, byte_reversed_lanes[3 - lane]);
+
+ break;
+ }
default:
UNREACHABLE();
}
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | test/cctest/wasm/test-run-wasm-simd.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698