OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/simd-scalar-lowering.h" | 5 #include "src/compiler/simd-scalar-lowering.h" |
6 #include "src/compiler/diamond.h" | 6 #include "src/compiler/diamond.h" |
7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } else { | 65 } else { |
66 stack_.push_back({input, 0}); | 66 stack_.push_back({input, 0}); |
67 } | 67 } |
68 state_.Set(input, State::kOnStack); | 68 state_.Set(input, State::kOnStack); |
69 } | 69 } |
70 } | 70 } |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 #define FOREACH_INT32X4_OPCODE(V) \ | 74 #define FOREACH_INT32X4_OPCODE(V) \ |
| 75 V(Int32x4Splat) \ |
| 76 V(Int32x4ExtractLane) \ |
| 77 V(Int32x4ReplaceLane) \ |
75 V(Int32x4Add) \ | 78 V(Int32x4Add) \ |
76 V(Int32x4ExtractLane) \ | 79 V(Int32x4Sub) \ |
77 V(Int32x4Splat) \ | 80 V(Int32x4Mul) \ |
78 V(Int32x4ReplaceLane) | 81 V(Simd128And) \ |
| 82 V(Simd128Or) \ |
| 83 V(Simd128Xor) |
79 | 84 |
80 #define FOREACH_FLOAT32X4_OPCODE(V) \ | 85 #define FOREACH_FLOAT32X4_OPCODE(V) \ |
| 86 V(Float32x4Splat) \ |
| 87 V(Float32x4ExtractLane) \ |
| 88 V(Float32x4ReplaceLane) \ |
81 V(Float32x4Add) \ | 89 V(Float32x4Add) \ |
82 V(Float32x4ExtractLane) \ | 90 V(Float32x4Sub) \ |
83 V(Float32x4Splat) \ | 91 V(Float32x4Mul) \ |
84 V(Float32x4ReplaceLane) | 92 V(Float32x4Div) \ |
| 93 V(Float32x4Min) \ |
| 94 V(Float32x4Max) |
85 | 95 |
86 void SimdScalarLowering::SetLoweredType(Node* node, Node* output) { | 96 void SimdScalarLowering::SetLoweredType(Node* node, Node* output) { |
87 switch (node->opcode()) { | 97 switch (node->opcode()) { |
88 #define CASE_STMT(name) case IrOpcode::k##name: | 98 #define CASE_STMT(name) case IrOpcode::k##name: |
89 FOREACH_INT32X4_OPCODE(CASE_STMT) | 99 FOREACH_INT32X4_OPCODE(CASE_STMT) |
90 case IrOpcode::kReturn: | 100 case IrOpcode::kReturn: |
91 case IrOpcode::kParameter: | 101 case IrOpcode::kParameter: |
92 case IrOpcode::kCall: { | 102 case IrOpcode::kCall: { |
93 replacements_[node->id()].type = SimdType::kInt32; | 103 replacements_[node->id()].type = SimdType::kInt32; |
94 break; | 104 break; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 GetReplacementsWithType(node->InputAt(i), rep_type); | 380 GetReplacementsWithType(node->InputAt(i), rep_type); |
371 for (int j = 0; j < kMaxLanes; j++) { | 381 for (int j = 0; j < kMaxLanes; j++) { |
372 rep_node[j]->ReplaceInput(i, rep_input[j]); | 382 rep_node[j]->ReplaceInput(i, rep_input[j]); |
373 } | 383 } |
374 } | 384 } |
375 } else { | 385 } else { |
376 DefaultLowering(node); | 386 DefaultLowering(node); |
377 } | 387 } |
378 break; | 388 break; |
379 } | 389 } |
380 case IrOpcode::kInt32x4Add: { | 390 #define I32X4_BINOP_CASE(opcode, instruction) \ |
381 LowerBinaryOp(node, rep_type, machine()->Int32Add()); | 391 case IrOpcode::opcode: { \ |
382 break; | 392 LowerBinaryOp(node, rep_type, machine()->instruction()); \ |
383 } | 393 break; \ |
384 case IrOpcode::kFloat32x4Add: { | 394 } |
385 LowerBinaryOp(node, rep_type, machine()->Float32Add()); | 395 I32X4_BINOP_CASE(kInt32x4Add, Int32Add) |
386 break; | 396 I32X4_BINOP_CASE(kInt32x4Sub, Int32Sub) |
387 } | 397 I32X4_BINOP_CASE(kInt32x4Mul, Int32Mul) |
| 398 I32X4_BINOP_CASE(kSimd128And, Word32And) |
| 399 I32X4_BINOP_CASE(kSimd128Or, Word32Or) |
| 400 I32X4_BINOP_CASE(kSimd128Xor, Word32Xor) |
| 401 #undef I32X4_BINOP_CASE |
| 402 #define F32X4_BINOP_CASE(name) \ |
| 403 case IrOpcode::kFloat32x4##name: { \ |
| 404 LowerBinaryOp(node, rep_type, machine()->Float32##name()); \ |
| 405 break; \ |
| 406 } |
| 407 F32X4_BINOP_CASE(Add) |
| 408 F32X4_BINOP_CASE(Sub) |
| 409 F32X4_BINOP_CASE(Mul) |
| 410 F32X4_BINOP_CASE(Div) |
| 411 F32X4_BINOP_CASE(Min) |
| 412 F32X4_BINOP_CASE(Max) |
| 413 #undef F32X4_BINOP_CASE |
388 case IrOpcode::kInt32x4Splat: | 414 case IrOpcode::kInt32x4Splat: |
389 case IrOpcode::kFloat32x4Splat: { | 415 case IrOpcode::kFloat32x4Splat: { |
390 Node* rep_node[kMaxLanes]; | 416 Node* rep_node[kMaxLanes]; |
391 for (int i = 0; i < kMaxLanes; ++i) { | 417 for (int i = 0; i < kMaxLanes; ++i) { |
392 if (HasReplacement(0, node->InputAt(0))) { | 418 if (HasReplacement(0, node->InputAt(0))) { |
393 rep_node[i] = GetReplacements(node->InputAt(0))[0]; | 419 rep_node[i] = GetReplacements(node->InputAt(0))[0]; |
394 } else { | 420 } else { |
395 rep_node[i] = node->InputAt(0); | 421 rep_node[i] = node->InputAt(0); |
396 } | 422 } |
397 } | 423 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } else { | 554 } else { |
529 UNREACHABLE(); | 555 UNREACHABLE(); |
530 } | 556 } |
531 } | 557 } |
532 ReplaceNode(phi, rep_nodes); | 558 ReplaceNode(phi, rep_nodes); |
533 } | 559 } |
534 } | 560 } |
535 } // namespace compiler | 561 } // namespace compiler |
536 } // namespace internal | 562 } // namespace internal |
537 } // namespace v8 | 563 } // namespace v8 |
OLD | NEW |