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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 case IrOpcode::kCall: { | 209 case IrOpcode::kCall: { |
210 replacements_[node->id()].type = SimdType::kInt32x4; | 210 replacements_[node->id()].type = SimdType::kInt32x4; |
211 break; | 211 break; |
212 } | 212 } |
213 FOREACH_FLOAT32X4_OPCODE(CASE_STMT) { | 213 FOREACH_FLOAT32X4_OPCODE(CASE_STMT) { |
214 replacements_[node->id()].type = SimdType::kFloat32x4; | 214 replacements_[node->id()].type = SimdType::kFloat32x4; |
215 break; | 215 break; |
216 } | 216 } |
217 FOREACH_FLOAT32X4_TO_SIMD1X4OPCODE(CASE_STMT) | 217 FOREACH_FLOAT32X4_TO_SIMD1X4OPCODE(CASE_STMT) |
218 FOREACH_INT32X4_TO_SIMD1X4OPCODE(CASE_STMT) { | 218 FOREACH_INT32X4_TO_SIMD1X4OPCODE(CASE_STMT) { |
219 replacements_[node->id()].type = SimdType::kSimd1x4; | 219 replacements_[node->id()].type = SimdType::kInt32x4; |
220 break; | 220 break; |
221 } | 221 } |
222 FOREACH_INT16X8_OPCODE(CASE_STMT) { | 222 FOREACH_INT16X8_OPCODE(CASE_STMT) { |
223 replacements_[node->id()].type = SimdType::kInt16x8; | 223 replacements_[node->id()].type = SimdType::kInt16x8; |
224 break; | 224 break; |
225 } | 225 } |
226 FOREACH_INT16X8_TO_SIMD1X8OPCODE(CASE_STMT) { | 226 FOREACH_INT16X8_TO_SIMD1X8OPCODE(CASE_STMT) { |
227 replacements_[node->id()].type = SimdType::kSimd1x8; | 227 replacements_[node->id()].type = SimdType::kInt16x8; |
228 break; | 228 break; |
229 } | 229 } |
230 FOREACH_INT8X16_OPCODE(CASE_STMT) { | 230 FOREACH_INT8X16_OPCODE(CASE_STMT) { |
231 replacements_[node->id()].type = SimdType::kInt8x16; | 231 replacements_[node->id()].type = SimdType::kInt8x16; |
232 break; | 232 break; |
233 } | 233 } |
234 FOREACH_INT8X16_TO_SIMD1X16OPCODE(CASE_STMT) { | 234 FOREACH_INT8X16_TO_SIMD1X16OPCODE(CASE_STMT) { |
235 replacements_[node->id()].type = SimdType::kSimd1x16; | 235 replacements_[node->id()].type = SimdType::kInt8x16; |
236 break; | 236 break; |
237 } | 237 } |
238 default: { | 238 default: { |
239 switch (output->opcode()) { | 239 switch (output->opcode()) { |
240 FOREACH_FLOAT32X4_TO_SIMD1X4OPCODE(CASE_STMT) | 240 FOREACH_FLOAT32X4_TO_SIMD1X4OPCODE(CASE_STMT) |
241 case IrOpcode::kF32x4SConvertI32x4: | 241 case IrOpcode::kF32x4SConvertI32x4: |
242 case IrOpcode::kF32x4UConvertI32x4: { | 242 case IrOpcode::kF32x4UConvertI32x4: { |
243 replacements_[node->id()].type = SimdType::kInt32x4; | 243 replacements_[node->id()].type = SimdType::kInt32x4; |
244 break; | 244 break; |
245 } | 245 } |
246 FOREACH_INT32X4_TO_SIMD1X4OPCODE(CASE_STMT) | 246 FOREACH_INT32X4_TO_SIMD1X4OPCODE(CASE_STMT) |
247 case IrOpcode::kI32x4SConvertF32x4: | 247 case IrOpcode::kI32x4SConvertF32x4: |
248 case IrOpcode::kI32x4UConvertF32x4: { | 248 case IrOpcode::kI32x4UConvertF32x4: { |
249 replacements_[node->id()].type = SimdType::kFloat32x4; | 249 replacements_[node->id()].type = SimdType::kFloat32x4; |
250 break; | 250 break; |
251 } | 251 } |
252 case IrOpcode::kS32x4Select: { | 252 case IrOpcode::kS128Select: { |
253 replacements_[node->id()].type = SimdType::kSimd1x4; | 253 replacements_[node->id()].type = SimdType::kInt32x4; |
254 break; | 254 break; |
255 } | 255 } |
256 FOREACH_INT16X8_TO_SIMD1X8OPCODE(CASE_STMT) { | 256 FOREACH_INT16X8_TO_SIMD1X8OPCODE(CASE_STMT) { |
257 replacements_[node->id()].type = SimdType::kInt16x8; | 257 replacements_[node->id()].type = SimdType::kInt16x8; |
258 break; | 258 break; |
259 } | 259 } |
260 FOREACH_INT8X16_TO_SIMD1X16OPCODE(CASE_STMT) { | 260 FOREACH_INT8X16_TO_SIMD1X16OPCODE(CASE_STMT) { |
261 replacements_[node->id()].type = SimdType::kInt8x16; | 261 replacements_[node->id()].type = SimdType::kInt8x16; |
262 break; | 262 break; |
263 } | 263 } |
264 case IrOpcode::kS16x8Select: { | |
265 replacements_[node->id()].type = SimdType::kSimd1x8; | |
266 break; | |
267 } | |
268 default: { | 264 default: { |
269 replacements_[node->id()].type = replacements_[output->id()].type; | 265 replacements_[node->id()].type = replacements_[output->id()].type; |
270 } | 266 } |
271 } | 267 } |
272 } | 268 } |
273 #undef CASE_STMT | 269 #undef CASE_STMT |
274 } | 270 } |
275 } | 271 } |
276 | 272 |
277 static int GetParameterIndexAfterLowering( | 273 static int GetParameterIndexAfterLowering( |
(...skipping 25 matching lines...) Expand all Loading... |
303 for (int i = 0; i < static_cast<int>(signature->return_count()); ++i) { | 299 for (int i = 0; i < static_cast<int>(signature->return_count()); ++i) { |
304 if (signature->GetReturn(i) == MachineRepresentation::kSimd128) { | 300 if (signature->GetReturn(i) == MachineRepresentation::kSimd128) { |
305 result += 3; | 301 result += 3; |
306 } | 302 } |
307 } | 303 } |
308 return result; | 304 return result; |
309 } | 305 } |
310 | 306 |
311 int SimdScalarLowering::NumLanes(SimdType type) { | 307 int SimdScalarLowering::NumLanes(SimdType type) { |
312 int num_lanes = 0; | 308 int num_lanes = 0; |
313 if (type == SimdType::kFloat32x4 || type == SimdType::kInt32x4 || | 309 if (type == SimdType::kFloat32x4 || type == SimdType::kInt32x4) { |
314 type == SimdType::kSimd1x4) { | |
315 num_lanes = kNumLanes32; | 310 num_lanes = kNumLanes32; |
316 } else if (type == SimdType::kInt16x8 || type == SimdType::kSimd1x8) { | 311 } else if (type == SimdType::kInt16x8) { |
317 num_lanes = kNumLanes16; | 312 num_lanes = kNumLanes16; |
318 } else if (type == SimdType::kInt8x16 || type == SimdType::kSimd1x16) { | 313 } else if (type == SimdType::kInt8x16) { |
319 num_lanes = kNumLanes8; | 314 num_lanes = kNumLanes8; |
320 } else { | 315 } else { |
321 UNREACHABLE(); | 316 UNREACHABLE(); |
322 } | 317 } |
323 return num_lanes; | 318 return num_lanes; |
324 } | 319 } |
325 | 320 |
326 constexpr int SimdScalarLowering::kLaneOffsets[]; | 321 constexpr int SimdScalarLowering::kLaneOffsets[]; |
327 | 322 |
328 void SimdScalarLowering::GetIndexNodes(Node* index, Node** new_indices, | 323 void SimdScalarLowering::GetIndexNodes(Node* index, Node** new_indices, |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 break; | 1092 break; |
1098 } | 1093 } |
1099 case IrOpcode::kI16x8Ne: { | 1094 case IrOpcode::kI16x8Ne: { |
1100 LowerNotEqual(node, SimdType::kInt16x8, machine()->Word32Equal()); | 1095 LowerNotEqual(node, SimdType::kInt16x8, machine()->Word32Equal()); |
1101 break; | 1096 break; |
1102 } | 1097 } |
1103 case IrOpcode::kI8x16Ne: { | 1098 case IrOpcode::kI8x16Ne: { |
1104 LowerNotEqual(node, SimdType::kInt8x16, machine()->Word32Equal()); | 1099 LowerNotEqual(node, SimdType::kInt8x16, machine()->Word32Equal()); |
1105 break; | 1100 break; |
1106 } | 1101 } |
1107 case IrOpcode::kS32x4Select: | 1102 case IrOpcode::kS128Select: { |
1108 case IrOpcode::kS16x8Select: | |
1109 case IrOpcode::kS8x16Select: { | |
1110 DCHECK(node->InputCount() == 3); | 1103 DCHECK(node->InputCount() == 3); |
1111 DCHECK(ReplacementType(node->InputAt(0)) == SimdType::kSimd1x4 || | 1104 DCHECK(ReplacementType(node->InputAt(0)) == SimdType::kInt32x4 || |
1112 ReplacementType(node->InputAt(0)) == SimdType::kSimd1x8 || | 1105 ReplacementType(node->InputAt(0)) == SimdType::kInt16x8 || |
1113 ReplacementType(node->InputAt(0)) == SimdType::kSimd1x16); | 1106 ReplacementType(node->InputAt(0)) == SimdType::kInt8x16); |
1114 Node** boolean_input = GetReplacements(node->InputAt(0)); | 1107 Node** boolean_input = GetReplacements(node->InputAt(0)); |
1115 Node** rep_left = GetReplacementsWithType(node->InputAt(1), rep_type); | 1108 Node** rep_left = GetReplacementsWithType(node->InputAt(1), rep_type); |
1116 Node** rep_right = GetReplacementsWithType(node->InputAt(2), rep_type); | 1109 Node** rep_right = GetReplacementsWithType(node->InputAt(2), rep_type); |
1117 Node** rep_node = zone()->NewArray<Node*>(num_lanes); | 1110 Node** rep_node = zone()->NewArray<Node*>(num_lanes); |
1118 for (int i = 0; i < num_lanes; ++i) { | 1111 for (int i = 0; i < num_lanes; ++i) { |
1119 Diamond d(graph(), common(), | 1112 Diamond d(graph(), common(), |
1120 graph()->NewNode(machine()->Word32Equal(), boolean_input[i], | 1113 graph()->NewNode(machine()->Word32Equal(), boolean_input[i], |
1121 jsgraph_->Int32Constant(0))); | 1114 jsgraph_->Int32Constant(0))); |
1122 #define SELECT_CASE(sType, mType) \ | 1115 #define SELECT_CASE(sType, mType) \ |
1123 case SimdType::k##sType: \ | 1116 case SimdType::k##sType: \ |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 UNREACHABLE(); | 1270 UNREACHABLE(); |
1278 } | 1271 } |
1279 #undef PHI_CASE | 1272 #undef PHI_CASE |
1280 } | 1273 } |
1281 ReplaceNode(phi, rep_nodes, num_lanes); | 1274 ReplaceNode(phi, rep_nodes, num_lanes); |
1282 } | 1275 } |
1283 } | 1276 } |
1284 } // namespace compiler | 1277 } // namespace compiler |
1285 } // namespace internal | 1278 } // namespace internal |
1286 } // namespace v8 | 1279 } // namespace v8 |
OLD | NEW |