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

Side by Side Diff: src/compiler/simd-lowering.cc

Issue 1991143002: Convert SIMD wasm ops to runtime function calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/compiler/simd-lowering.h"
6
7 namespace v8 {
8 namespace internal {
9 namespace compiler {
10
11 SimdLowering::~SimdLowering() {}
12
13 Reduction SimdLowering::Reduce(Node* node) {
14 // For now lower everything to runtime calls.
15 typedef Signature<Conversion> ConversionSignature;
16 const int kReturnCount = 1;
17 const int kSimd32x4 = 4;
18 const int kSimd16x8 = 8;
19 const int kSimd8x16 = 16;
20
21 switch (node->opcode()) {
22 case IrOpcode::kCreateInt32x4: {
23 ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd32x4);
titzer 2016/07/13 19:45:09 Is it possible to cache these signatures? You coul
gdeepti 2016/07/15 08:26:40 Added signatures as static variables, signatures a
24 for (int i = 0; i < kSimd32x4; i++) {
25 conversions.AddParam(Conversion::kInt32);
26 }
27 conversions.AddReturn(Conversion::kOpaque);
28 return Replace(builder_->ChangeToRuntimeCall(
29 node, Runtime::kCreateInt32x4, conversions.Build()));
30 }
31 case IrOpcode::kCreateInt16x8: {
32 ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd16x8);
33 for (int i = 0; i < kSimd16x8; i++) {
34 conversions.AddParam(Conversion::kInt32);
35 }
36 conversions.AddReturn(Conversion::kOpaque);
37 return Replace(builder_->ChangeToRuntimeCall(
38 node, Runtime::kCreateInt16x8, conversions.Build()));
39 }
40 case IrOpcode::kCreateInt8x16: {
41 ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd8x16);
42 for (int i = 0; i < kSimd8x16; i++) {
43 conversions.AddParam(Conversion::kInt32);
44 }
45 conversions.AddReturn(Conversion::kOpaque);
46 return Replace(builder_->ChangeToRuntimeCall(
47 node, Runtime::kCreateInt8x16, conversions.Build()));
48 }
49 case IrOpcode::kCreateFloat32x4: {
50 ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd32x4);
51 for (int i = 0; i < kSimd32x4; i++) {
52 conversions.AddParam(Conversion::kFloat32);
53 }
54 conversions.AddReturn(Conversion::kOpaque);
55 return Replace(builder_->ChangeToRuntimeCall(
56 node, Runtime::kCreateFloat32x4, conversions.Build()));
57 }
58 case IrOpcode::kInt8x16ExtractLane:
59 case IrOpcode::kInt16x8ExtractLane:
60 case IrOpcode::kInt32x4ExtractLane: {
61 ConversionSignature::Builder conversions(zone_, 1, 2);
62 conversions.AddParam(Conversion::kOpaque);
63 conversions.AddParam(Conversion::kInt32);
64 conversions.AddReturn(Conversion::kInt32);
65 return Replace(builder_->ChangeToRuntimeCall(
66 node, Runtime::kInt32x4ExtractLane, conversions.Build()));
67 }
68 case IrOpcode::kFloat32x4ExtractLane: {
69 ConversionSignature::Builder conversions(zone_, 1, 2);
70 conversions.AddParam(Conversion::kOpaque);
71 conversions.AddParam(Conversion::kFloat32);
72 conversions.AddReturn(Conversion::kFloat32);
73 return Replace(builder_->ChangeToRuntimeCall(
74 node, Runtime::kFloat32x4ExtractLane, conversions.Build()));
75 }
76 default: { break; }
77 }
78
79 // TODO(gdeepti): Implement and test.
80 // Assume the others are all just simd in and out.
81 ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd8x16);
82 for (int i = 0; i < kSimd8x16; i++) {
83 conversions.AddParam(Conversion::kNone);
84 }
85 conversions.AddReturn(Conversion::kNone);
86 switch (node->opcode()) {
87 #define F(Opcode) \
88 case IrOpcode::k##Opcode: { \
89 return Replace(builder_->ChangeToRuntimeCall(node, Runtime::k##Opcode, \
90 conversions.Build())); \
91 }
92 MACHINE_SIMD_RETURN_SIMD_OP_LIST(F)
93 MACHINE_SIMD_RETURN_BOOL_OP_LIST(F)
94 #undef F
95 default: { return NoChange(); }
96 }
97 UNREACHABLE();
98 return NoChange();
99 }
100
101 } // namespace compiler
102 } // namespace internal
103 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698