OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.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 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 AddressingMode addressing_mode = kMode_Offset_RR; | 2279 AddressingMode addressing_mode = kMode_Offset_RR; |
2280 InstructionOperand inputs[4]; | 2280 InstructionOperand inputs[4]; |
2281 size_t input_count = 0; | 2281 size_t input_count = 0; |
2282 inputs[input_count++] = g.UseUniqueRegister(base); | 2282 inputs[input_count++] = g.UseUniqueRegister(base); |
2283 inputs[input_count++] = g.UseUniqueRegister(index); | 2283 inputs[input_count++] = g.UseUniqueRegister(index); |
2284 inputs[input_count++] = g.UseUniqueRegister(value); | 2284 inputs[input_count++] = g.UseUniqueRegister(value); |
2285 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); | 2285 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); |
2286 Emit(code, 0, nullptr, input_count, inputs); | 2286 Emit(code, 0, nullptr, input_count, inputs); |
2287 } | 2287 } |
2288 | 2288 |
| 2289 // TODO(bbudge) Macro-ize SIMD methods. |
2289 void InstructionSelector::VisitCreateFloat32x4(Node* node) { | 2290 void InstructionSelector::VisitCreateFloat32x4(Node* node) { |
2290 ArmOperandGenerator g(this); | 2291 ArmOperandGenerator g(this); |
2291 Emit(kArmFloat32x4Splat, g.DefineAsRegister(node), g.Use(node->InputAt(0))); | 2292 Emit(kArmFloat32x4Splat, g.DefineAsRegister(node), g.Use(node->InputAt(0))); |
2292 } | 2293 } |
2293 | 2294 |
2294 void InstructionSelector::VisitFloat32x4ExtractLane(Node* node) { | 2295 void InstructionSelector::VisitFloat32x4ExtractLane(Node* node) { |
2295 ArmOperandGenerator g(this); | 2296 ArmOperandGenerator g(this); |
2296 int32_t lane = OpParameter<int32_t>(node); | 2297 int32_t lane = OpParameter<int32_t>(node); |
2297 Emit(kArmFloat32x4ExtractLane, g.DefineAsRegister(node), | 2298 Emit(kArmFloat32x4ExtractLane, g.DefineAsRegister(node), |
2298 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); | 2299 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 Emit(kArmInt32x4FromFloat32x4, g.DefineAsRegister(node), | 2380 Emit(kArmInt32x4FromFloat32x4, g.DefineAsRegister(node), |
2380 g.UseRegister(node->InputAt(0))); | 2381 g.UseRegister(node->InputAt(0))); |
2381 } | 2382 } |
2382 | 2383 |
2383 void InstructionSelector::VisitUint32x4FromFloat32x4(Node* node) { | 2384 void InstructionSelector::VisitUint32x4FromFloat32x4(Node* node) { |
2384 ArmOperandGenerator g(this); | 2385 ArmOperandGenerator g(this); |
2385 Emit(kArmUint32x4FromFloat32x4, g.DefineAsRegister(node), | 2386 Emit(kArmUint32x4FromFloat32x4, g.DefineAsRegister(node), |
2386 g.UseRegister(node->InputAt(0))); | 2387 g.UseRegister(node->InputAt(0))); |
2387 } | 2388 } |
2388 | 2389 |
| 2390 void InstructionSelector::VisitInt32x4Neg(Node* node) { |
| 2391 ArmOperandGenerator g(this); |
| 2392 Emit(kArmInt32x4Neg, g.DefineAsRegister(node), |
| 2393 g.UseRegister(node->InputAt(0))); |
| 2394 } |
| 2395 |
2389 void InstructionSelector::VisitInt32x4Add(Node* node) { | 2396 void InstructionSelector::VisitInt32x4Add(Node* node) { |
2390 ArmOperandGenerator g(this); | 2397 ArmOperandGenerator g(this); |
2391 Emit(kArmInt32x4Add, g.DefineAsRegister(node), | 2398 Emit(kArmInt32x4Add, g.DefineAsRegister(node), |
2392 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); | 2399 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
2393 } | 2400 } |
2394 | 2401 |
2395 void InstructionSelector::VisitInt32x4Sub(Node* node) { | 2402 void InstructionSelector::VisitInt32x4Sub(Node* node) { |
2396 ArmOperandGenerator g(this); | 2403 ArmOperandGenerator g(this); |
2397 Emit(kArmInt32x4Sub, g.DefineAsRegister(node), | 2404 Emit(kArmInt32x4Sub, g.DefineAsRegister(node), |
2398 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); | 2405 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
2399 } | 2406 } |
2400 | 2407 |
| 2408 void InstructionSelector::VisitInt32x4Mul(Node* node) { |
| 2409 ArmOperandGenerator g(this); |
| 2410 Emit(kArmInt32x4Mul, g.DefineAsRegister(node), |
| 2411 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2412 } |
| 2413 |
| 2414 void InstructionSelector::VisitInt32x4Min(Node* node) { |
| 2415 ArmOperandGenerator g(this); |
| 2416 Emit(kArmInt32x4Min, g.DefineAsRegister(node), |
| 2417 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2418 } |
| 2419 |
| 2420 void InstructionSelector::VisitInt32x4Max(Node* node) { |
| 2421 ArmOperandGenerator g(this); |
| 2422 Emit(kArmInt32x4Max, g.DefineAsRegister(node), |
| 2423 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2424 } |
| 2425 |
2401 void InstructionSelector::VisitInt32x4Equal(Node* node) { | 2426 void InstructionSelector::VisitInt32x4Equal(Node* node) { |
2402 ArmOperandGenerator g(this); | 2427 ArmOperandGenerator g(this); |
2403 Emit(kArmInt32x4Eq, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), | 2428 Emit(kArmInt32x4Eq, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
2404 g.UseRegister(node->InputAt(1))); | 2429 g.UseRegister(node->InputAt(1))); |
2405 } | 2430 } |
2406 | 2431 |
2407 void InstructionSelector::VisitInt32x4NotEqual(Node* node) { | 2432 void InstructionSelector::VisitInt32x4NotEqual(Node* node) { |
2408 ArmOperandGenerator g(this); | 2433 ArmOperandGenerator g(this); |
2409 Emit(kArmInt32x4Ne, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), | 2434 Emit(kArmInt32x4Ne, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
2410 g.UseRegister(node->InputAt(1))); | 2435 g.UseRegister(node->InputAt(1))); |
2411 } | 2436 } |
2412 | 2437 |
| 2438 void InstructionSelector::VisitInt32x4GreaterThan(Node* node) { |
| 2439 ArmOperandGenerator g(this); |
| 2440 Emit(kArmInt32x4Gt, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2441 g.UseRegister(node->InputAt(1))); |
| 2442 } |
| 2443 |
| 2444 void InstructionSelector::VisitInt32x4GreaterThanOrEqual(Node* node) { |
| 2445 ArmOperandGenerator g(this); |
| 2446 Emit(kArmInt32x4Ge, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2447 g.UseRegister(node->InputAt(1))); |
| 2448 } |
| 2449 |
| 2450 void InstructionSelector::VisitUint32x4GreaterThan(Node* node) { |
| 2451 ArmOperandGenerator g(this); |
| 2452 Emit(kArmUint32x4Gt, g.DefineAsRegister(node), |
| 2453 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2454 } |
| 2455 |
| 2456 void InstructionSelector::VisitUint32x4GreaterThanOrEqual(Node* node) { |
| 2457 ArmOperandGenerator g(this); |
| 2458 Emit(kArmUint32x4Ge, g.DefineAsRegister(node), |
| 2459 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2460 } |
| 2461 |
2413 void InstructionSelector::VisitSimd32x4Select(Node* node) { | 2462 void InstructionSelector::VisitSimd32x4Select(Node* node) { |
2414 ArmOperandGenerator g(this); | 2463 ArmOperandGenerator g(this); |
2415 Emit(kArmSimd32x4Select, g.DefineAsRegister(node), | 2464 Emit(kArmSimd32x4Select, g.DefineAsRegister(node), |
2416 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1)), | 2465 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1)), |
2417 g.UseRegister(node->InputAt(2))); | 2466 g.UseRegister(node->InputAt(2))); |
2418 } | 2467 } |
2419 | 2468 |
| 2469 void InstructionSelector::VisitCreateInt16x8(Node* node) { |
| 2470 ArmOperandGenerator g(this); |
| 2471 Emit(kArmInt16x8Splat, g.DefineAsRegister(node), g.Use(node->InputAt(0))); |
| 2472 } |
| 2473 |
| 2474 void InstructionSelector::VisitInt16x8ExtractLane(Node* node) { |
| 2475 ArmOperandGenerator g(this); |
| 2476 int32_t lane = OpParameter<int32_t>(node); |
| 2477 Emit(kArmInt16x8ExtractLane, g.DefineAsRegister(node), |
| 2478 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); |
| 2479 } |
| 2480 |
| 2481 void InstructionSelector::VisitInt16x8ReplaceLane(Node* node) { |
| 2482 ArmOperandGenerator g(this); |
| 2483 int32_t lane = OpParameter<int32_t>(node); |
| 2484 Emit(kArmInt16x8ReplaceLane, g.DefineAsRegister(node), |
| 2485 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane), |
| 2486 g.Use(node->InputAt(1))); |
| 2487 } |
| 2488 |
| 2489 void InstructionSelector::VisitInt16x8Neg(Node* node) { |
| 2490 ArmOperandGenerator g(this); |
| 2491 Emit(kArmInt16x8Neg, g.DefineAsRegister(node), |
| 2492 g.UseRegister(node->InputAt(0))); |
| 2493 } |
| 2494 |
| 2495 void InstructionSelector::VisitInt16x8Add(Node* node) { |
| 2496 ArmOperandGenerator g(this); |
| 2497 Emit(kArmInt16x8Add, g.DefineAsRegister(node), |
| 2498 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2499 } |
| 2500 |
| 2501 void InstructionSelector::VisitInt16x8Sub(Node* node) { |
| 2502 ArmOperandGenerator g(this); |
| 2503 Emit(kArmInt16x8Sub, g.DefineAsRegister(node), |
| 2504 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2505 } |
| 2506 |
| 2507 void InstructionSelector::VisitInt16x8Mul(Node* node) { |
| 2508 ArmOperandGenerator g(this); |
| 2509 Emit(kArmInt16x8Mul, g.DefineAsRegister(node), |
| 2510 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2511 } |
| 2512 |
| 2513 void InstructionSelector::VisitInt16x8Min(Node* node) { |
| 2514 ArmOperandGenerator g(this); |
| 2515 Emit(kArmInt16x8Min, g.DefineAsRegister(node), |
| 2516 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2517 } |
| 2518 |
| 2519 void InstructionSelector::VisitInt16x8Max(Node* node) { |
| 2520 ArmOperandGenerator g(this); |
| 2521 Emit(kArmInt16x8Max, g.DefineAsRegister(node), |
| 2522 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2523 } |
| 2524 |
| 2525 void InstructionSelector::VisitInt16x8Equal(Node* node) { |
| 2526 ArmOperandGenerator g(this); |
| 2527 Emit(kArmInt16x8Eq, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2528 g.UseRegister(node->InputAt(1))); |
| 2529 } |
| 2530 |
| 2531 void InstructionSelector::VisitInt16x8NotEqual(Node* node) { |
| 2532 ArmOperandGenerator g(this); |
| 2533 Emit(kArmInt16x8Ne, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2534 g.UseRegister(node->InputAt(1))); |
| 2535 } |
| 2536 |
| 2537 void InstructionSelector::VisitInt16x8GreaterThan(Node* node) { |
| 2538 ArmOperandGenerator g(this); |
| 2539 Emit(kArmInt16x8Gt, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2540 g.UseRegister(node->InputAt(1))); |
| 2541 } |
| 2542 |
| 2543 void InstructionSelector::VisitInt16x8GreaterThanOrEqual(Node* node) { |
| 2544 ArmOperandGenerator g(this); |
| 2545 Emit(kArmInt16x8Ge, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2546 g.UseRegister(node->InputAt(1))); |
| 2547 } |
| 2548 |
| 2549 void InstructionSelector::VisitUint16x8GreaterThan(Node* node) { |
| 2550 ArmOperandGenerator g(this); |
| 2551 Emit(kArmUint16x8Gt, g.DefineAsRegister(node), |
| 2552 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2553 } |
| 2554 |
| 2555 void InstructionSelector::VisitUint16x8GreaterThanOrEqual(Node* node) { |
| 2556 ArmOperandGenerator g(this); |
| 2557 Emit(kArmUint16x8Ge, g.DefineAsRegister(node), |
| 2558 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2559 } |
| 2560 |
| 2561 void InstructionSelector::VisitCreateInt8x16(Node* node) { |
| 2562 ArmOperandGenerator g(this); |
| 2563 Emit(kArmInt8x16Splat, g.DefineAsRegister(node), g.Use(node->InputAt(0))); |
| 2564 } |
| 2565 |
| 2566 void InstructionSelector::VisitInt8x16ExtractLane(Node* node) { |
| 2567 ArmOperandGenerator g(this); |
| 2568 int32_t lane = OpParameter<int32_t>(node); |
| 2569 Emit(kArmInt8x16ExtractLane, g.DefineAsRegister(node), |
| 2570 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); |
| 2571 } |
| 2572 |
| 2573 void InstructionSelector::VisitInt8x16ReplaceLane(Node* node) { |
| 2574 ArmOperandGenerator g(this); |
| 2575 int32_t lane = OpParameter<int32_t>(node); |
| 2576 Emit(kArmInt8x16ReplaceLane, g.DefineAsRegister(node), |
| 2577 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane), |
| 2578 g.Use(node->InputAt(1))); |
| 2579 } |
| 2580 |
| 2581 void InstructionSelector::VisitInt8x16Neg(Node* node) { |
| 2582 ArmOperandGenerator g(this); |
| 2583 Emit(kArmInt8x16Neg, g.DefineAsRegister(node), |
| 2584 g.UseRegister(node->InputAt(0))); |
| 2585 } |
| 2586 |
| 2587 void InstructionSelector::VisitInt8x16Add(Node* node) { |
| 2588 ArmOperandGenerator g(this); |
| 2589 Emit(kArmInt8x16Add, g.DefineAsRegister(node), |
| 2590 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2591 } |
| 2592 |
| 2593 void InstructionSelector::VisitInt8x16Sub(Node* node) { |
| 2594 ArmOperandGenerator g(this); |
| 2595 Emit(kArmInt8x16Sub, g.DefineAsRegister(node), |
| 2596 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2597 } |
| 2598 |
| 2599 void InstructionSelector::VisitInt8x16Mul(Node* node) { |
| 2600 ArmOperandGenerator g(this); |
| 2601 Emit(kArmInt8x16Mul, g.DefineAsRegister(node), |
| 2602 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2603 } |
| 2604 |
| 2605 void InstructionSelector::VisitInt8x16Min(Node* node) { |
| 2606 ArmOperandGenerator g(this); |
| 2607 Emit(kArmInt8x16Min, g.DefineAsRegister(node), |
| 2608 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2609 } |
| 2610 |
| 2611 void InstructionSelector::VisitInt8x16Max(Node* node) { |
| 2612 ArmOperandGenerator g(this); |
| 2613 Emit(kArmInt8x16Max, g.DefineAsRegister(node), |
| 2614 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2615 } |
| 2616 |
| 2617 void InstructionSelector::VisitInt8x16Equal(Node* node) { |
| 2618 ArmOperandGenerator g(this); |
| 2619 Emit(kArmInt8x16Eq, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2620 g.UseRegister(node->InputAt(1))); |
| 2621 } |
| 2622 |
| 2623 void InstructionSelector::VisitInt8x16NotEqual(Node* node) { |
| 2624 ArmOperandGenerator g(this); |
| 2625 Emit(kArmInt8x16Ne, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2626 g.UseRegister(node->InputAt(1))); |
| 2627 } |
| 2628 |
| 2629 void InstructionSelector::VisitInt8x16GreaterThan(Node* node) { |
| 2630 ArmOperandGenerator g(this); |
| 2631 Emit(kArmInt8x16Gt, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2632 g.UseRegister(node->InputAt(1))); |
| 2633 } |
| 2634 |
| 2635 void InstructionSelector::VisitInt8x16GreaterThanOrEqual(Node* node) { |
| 2636 ArmOperandGenerator g(this); |
| 2637 Emit(kArmInt8x16Ge, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), |
| 2638 g.UseRegister(node->InputAt(1))); |
| 2639 } |
| 2640 |
| 2641 void InstructionSelector::VisitUint8x16GreaterThan(Node* node) { |
| 2642 ArmOperandGenerator g(this); |
| 2643 Emit(kArmUint8x16Gt, g.DefineAsRegister(node), |
| 2644 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2645 } |
| 2646 |
| 2647 void InstructionSelector::VisitUint8x16GreaterThanOrEqual(Node* node) { |
| 2648 ArmOperandGenerator g(this); |
| 2649 Emit(kArmUint8x16Ge, g.DefineAsRegister(node), |
| 2650 g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); |
| 2651 } |
| 2652 |
2420 // static | 2653 // static |
2421 MachineOperatorBuilder::Flags | 2654 MachineOperatorBuilder::Flags |
2422 InstructionSelector::SupportedMachineOperatorFlags() { | 2655 InstructionSelector::SupportedMachineOperatorFlags() { |
2423 MachineOperatorBuilder::Flags flags; | 2656 MachineOperatorBuilder::Flags flags; |
2424 if (CpuFeatures::IsSupported(SUDIV)) { | 2657 if (CpuFeatures::IsSupported(SUDIV)) { |
2425 // The sdiv and udiv instructions correctly return 0 if the divisor is 0, | 2658 // The sdiv and udiv instructions correctly return 0 if the divisor is 0, |
2426 // but the fall-back implementation does not. | 2659 // but the fall-back implementation does not. |
2427 flags |= MachineOperatorBuilder::kInt32DivIsSafe | | 2660 flags |= MachineOperatorBuilder::kInt32DivIsSafe | |
2428 MachineOperatorBuilder::kUint32DivIsSafe; | 2661 MachineOperatorBuilder::kUint32DivIsSafe; |
2429 } | 2662 } |
(...skipping 20 matching lines...) Expand all Loading... |
2450 Vector<MachineType> req_aligned = Vector<MachineType>::New(2); | 2683 Vector<MachineType> req_aligned = Vector<MachineType>::New(2); |
2451 req_aligned[0] = MachineType::Float32(); | 2684 req_aligned[0] = MachineType::Float32(); |
2452 req_aligned[1] = MachineType::Float64(); | 2685 req_aligned[1] = MachineType::Float64(); |
2453 return MachineOperatorBuilder::AlignmentRequirements:: | 2686 return MachineOperatorBuilder::AlignmentRequirements:: |
2454 SomeUnalignedAccessUnsupported(req_aligned, req_aligned); | 2687 SomeUnalignedAccessUnsupported(req_aligned, req_aligned); |
2455 } | 2688 } |
2456 | 2689 |
2457 } // namespace compiler | 2690 } // namespace compiler |
2458 } // namespace internal | 2691 } // namespace internal |
2459 } // namespace v8 | 2692 } // namespace v8 |
OLD | NEW |