Chromium Code Reviews| Index: src/compiler/simd-lowering.cc |
| diff --git a/src/compiler/simd-lowering.cc b/src/compiler/simd-lowering.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5c80b127cecb7a000b44219bdf9d4ba43b9c9436 |
| --- /dev/null |
| +++ b/src/compiler/simd-lowering.cc |
| @@ -0,0 +1,103 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "src/compiler/simd-lowering.h" |
| + |
| +namespace v8 { |
| +namespace internal { |
| +namespace compiler { |
| + |
| +SimdLowering::~SimdLowering() {} |
| + |
| +Reduction SimdLowering::Reduce(Node* node) { |
| + // For now lower everything to runtime calls. |
| + typedef Signature<Conversion> ConversionSignature; |
| + const int kReturnCount = 1; |
| + const int kSimd32x4 = 4; |
| + const int kSimd16x8 = 8; |
| + const int kSimd8x16 = 16; |
| + |
| + switch (node->opcode()) { |
| + case IrOpcode::kCreateInt32x4: { |
| + 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
|
| + for (int i = 0; i < kSimd32x4; i++) { |
| + conversions.AddParam(Conversion::kInt32); |
| + } |
| + conversions.AddReturn(Conversion::kOpaque); |
| + return Replace(builder_->ChangeToRuntimeCall( |
| + node, Runtime::kCreateInt32x4, conversions.Build())); |
| + } |
| + case IrOpcode::kCreateInt16x8: { |
| + ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd16x8); |
| + for (int i = 0; i < kSimd16x8; i++) { |
| + conversions.AddParam(Conversion::kInt32); |
| + } |
| + conversions.AddReturn(Conversion::kOpaque); |
| + return Replace(builder_->ChangeToRuntimeCall( |
| + node, Runtime::kCreateInt16x8, conversions.Build())); |
| + } |
| + case IrOpcode::kCreateInt8x16: { |
| + ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd8x16); |
| + for (int i = 0; i < kSimd8x16; i++) { |
| + conversions.AddParam(Conversion::kInt32); |
| + } |
| + conversions.AddReturn(Conversion::kOpaque); |
| + return Replace(builder_->ChangeToRuntimeCall( |
| + node, Runtime::kCreateInt8x16, conversions.Build())); |
| + } |
| + case IrOpcode::kCreateFloat32x4: { |
| + ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd32x4); |
| + for (int i = 0; i < kSimd32x4; i++) { |
| + conversions.AddParam(Conversion::kFloat32); |
| + } |
| + conversions.AddReturn(Conversion::kOpaque); |
| + return Replace(builder_->ChangeToRuntimeCall( |
| + node, Runtime::kCreateFloat32x4, conversions.Build())); |
| + } |
| + case IrOpcode::kInt8x16ExtractLane: |
| + case IrOpcode::kInt16x8ExtractLane: |
| + case IrOpcode::kInt32x4ExtractLane: { |
| + ConversionSignature::Builder conversions(zone_, 1, 2); |
| + conversions.AddParam(Conversion::kOpaque); |
| + conversions.AddParam(Conversion::kInt32); |
| + conversions.AddReturn(Conversion::kInt32); |
| + return Replace(builder_->ChangeToRuntimeCall( |
| + node, Runtime::kInt32x4ExtractLane, conversions.Build())); |
| + } |
| + case IrOpcode::kFloat32x4ExtractLane: { |
| + ConversionSignature::Builder conversions(zone_, 1, 2); |
| + conversions.AddParam(Conversion::kOpaque); |
| + conversions.AddParam(Conversion::kFloat32); |
| + conversions.AddReturn(Conversion::kFloat32); |
| + return Replace(builder_->ChangeToRuntimeCall( |
| + node, Runtime::kFloat32x4ExtractLane, conversions.Build())); |
| + } |
| + default: { break; } |
| + } |
| + |
| + // TODO(gdeepti): Implement and test. |
| + // Assume the others are all just simd in and out. |
| + ConversionSignature::Builder conversions(zone_, kReturnCount, kSimd8x16); |
| + for (int i = 0; i < kSimd8x16; i++) { |
| + conversions.AddParam(Conversion::kNone); |
| + } |
| + conversions.AddReturn(Conversion::kNone); |
| + switch (node->opcode()) { |
| +#define F(Opcode) \ |
| + case IrOpcode::k##Opcode: { \ |
| + return Replace(builder_->ChangeToRuntimeCall(node, Runtime::k##Opcode, \ |
| + conversions.Build())); \ |
| + } |
| + MACHINE_SIMD_RETURN_SIMD_OP_LIST(F) |
| + MACHINE_SIMD_RETURN_BOOL_OP_LIST(F) |
| +#undef F |
| + default: { return NoChange(); } |
| + } |
| + UNREACHABLE(); |
| + return NoChange(); |
| +} |
| + |
| +} // namespace compiler |
| +} // namespace internal |
| +} // namespace v8 |