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/assembler-inl.h" | 5 #include "src/assembler-inl.h" |
6 #include "src/wasm/wasm-macro-gen.h" | 6 #include "src/wasm/wasm-macro-gen.h" |
7 #include "test/cctest/cctest.h" | 7 #include "test/cctest/cctest.h" |
8 #include "test/cctest/compiler/value-helper.h" | 8 #include "test/cctest/compiler/value-helper.h" |
9 #include "test/cctest/wasm/wasm-run-utils.h" | 9 #include "test/cctest/wasm/wasm-run-utils.h" |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 T Minimum(T a, T b) { | 68 T Minimum(T a, T b) { |
69 return a <= b ? a : b; | 69 return a <= b ? a : b; |
70 } | 70 } |
71 | 71 |
72 template <typename T> | 72 template <typename T> |
73 T Maximum(T a, T b) { | 73 T Maximum(T a, T b) { |
74 return a >= b ? a : b; | 74 return a >= b ? a : b; |
75 } | 75 } |
76 | 76 |
77 // For float operands, Min and Max must return NaN if either operand is NaN. | 77 // For float operands, Min and Max must return NaN if either operand is NaN. |
78 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 78 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 79 V8_TARGET_ARCH_MIPS64 |
79 template <> | 80 template <> |
80 float Minimum(float a, float b) { | 81 float Minimum(float a, float b) { |
81 if (std::isnan(a) || std::isnan(b)) | 82 if (std::isnan(a) || std::isnan(b)) |
82 return std::numeric_limits<float>::quiet_NaN(); | 83 return std::numeric_limits<float>::quiet_NaN(); |
83 return a <= b ? a : b; | 84 return a <= b ? a : b; |
84 } | 85 } |
85 | 86 |
86 template <> | 87 template <> |
87 float Maximum(float a, float b) { | 88 float Maximum(float a, float b) { |
88 if (std::isnan(a) || std::isnan(b)) | 89 if (std::isnan(a) || std::isnan(b)) |
89 return std::numeric_limits<float>::quiet_NaN(); | 90 return std::numeric_limits<float>::quiet_NaN(); |
90 return a >= b ? a : b; | 91 return a >= b ? a : b; |
91 } | 92 } |
92 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 93 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || |
| 94 // V8_TARGET_ARCH_MIPS64 |
93 | 95 |
94 template <typename T> | 96 template <typename T> |
95 T UnsignedMinimum(T a, T b) { | 97 T UnsignedMinimum(T a, T b) { |
96 using UnsignedT = typename std::make_unsigned<T>::type; | 98 using UnsignedT = typename std::make_unsigned<T>::type; |
97 return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? a : b; | 99 return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? a : b; |
98 } | 100 } |
99 | 101 |
100 template <typename T> | 102 template <typename T> |
101 T UnsignedMaximum(T a, T b) { | 103 T UnsignedMaximum(T a, T b) { |
102 using UnsignedT = typename std::make_unsigned<T>::type; | 104 using UnsignedT = typename std::make_unsigned<T>::type; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 WASM_RETURN1(WASM_ONE)); | 480 WASM_RETURN1(WASM_ONE)); |
479 | 481 |
480 FOR_INT32_INPUTS(i) { | 482 FOR_INT32_INPUTS(i) { |
481 CHECK_EQ(1, r.Call(*i, static_cast<float>(*i), | 483 CHECK_EQ(1, r.Call(*i, static_cast<float>(*i), |
482 static_cast<float>(static_cast<uint32_t>(*i)))); | 484 static_cast<float>(static_cast<uint32_t>(*i)))); |
483 } | 485 } |
484 } | 486 } |
485 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || | 487 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || |
486 // V8_TARGET_ARCH_MIPS64 | 488 // V8_TARGET_ARCH_MIPS64 |
487 | 489 |
488 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 490 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 491 V8_TARGET_ARCH_MIPS64 |
489 void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op, | 492 void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op, |
490 float error = 0.0f) { | 493 float error = 0.0f) { |
491 FLAG_wasm_simd_prototype = true; | 494 FLAG_wasm_simd_prototype = true; |
492 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); | 495 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); |
493 byte a = 0; | 496 byte a = 0; |
494 byte low = 1; | 497 byte low = 1; |
495 byte high = 2; | 498 byte high = 2; |
496 byte simd = r.AllocateLocal(kWasmS128); | 499 byte simd = r.AllocateLocal(kWasmS128); |
497 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 500 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
498 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 501 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
499 WASM_SIMD_CHECK_SPLAT_F32x4_ESTIMATE(simd, low, high), | 502 WASM_SIMD_CHECK_SPLAT_F32x4_ESTIMATE(simd, low, high), |
500 WASM_RETURN1(WASM_ONE)); | 503 WASM_RETURN1(WASM_ONE)); |
501 | 504 |
502 FOR_FLOAT32_INPUTS(i) { | 505 FOR_FLOAT32_INPUTS(i) { |
503 if (SkipFPValue(*i)) continue; | 506 if (SkipFPValue(*i)) continue; |
504 float expected = expected_op(*i); | 507 float expected = expected_op(*i); |
505 if (SkipFPExpectedValue(expected)) continue; | 508 if (SkipFPExpectedValue(expected)) continue; |
506 float abs_error = std::abs(expected) * error; | 509 float abs_error = std::abs(expected) * error; |
507 CHECK_EQ(1, r.Call(*i, expected - abs_error, expected + abs_error)); | 510 CHECK_EQ(1, r.Call(*i, expected - abs_error, expected + abs_error)); |
508 } | 511 } |
509 } | 512 } |
510 | 513 |
511 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } | 514 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } |
512 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } | 515 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } |
513 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 516 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || |
| 517 // V8_TARGET_ARCH_MIPS64 |
514 | 518 |
515 #if SIMD_LOWERING_TARGET | 519 #if SIMD_LOWERING_TARGET |
516 WASM_EXEC_COMPILED_TEST(F32x4Sqrt) { RunF32x4UnOpTest(kExprF32x4Sqrt, Sqrt); } | 520 WASM_EXEC_COMPILED_TEST(F32x4Sqrt) { RunF32x4UnOpTest(kExprF32x4Sqrt, Sqrt); } |
517 #endif // SIMD_LOWERING_TARGET | 521 #endif // SIMD_LOWERING_TARGET |
518 | 522 |
519 #if V8_TARGET_ARCH_ARM | 523 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
520 static const float kApproxError = 0.01f; | 524 static const float kApproxError = 0.01f; |
521 | 525 |
522 WASM_EXEC_COMPILED_TEST(F32x4RecipApprox) { | 526 WASM_EXEC_COMPILED_TEST(F32x4RecipApprox) { |
523 RunF32x4UnOpTest(kExprF32x4RecipApprox, Recip, kApproxError); | 527 RunF32x4UnOpTest(kExprF32x4RecipApprox, Recip, kApproxError); |
524 } | 528 } |
525 | 529 |
526 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtApprox) { | 530 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtApprox) { |
527 RunF32x4UnOpTest(kExprF32x4RecipSqrtApprox, RecipSqrt, kApproxError); | 531 RunF32x4UnOpTest(kExprF32x4RecipSqrtApprox, RecipSqrt, kApproxError); |
528 } | 532 } |
529 #endif // V8_TARGET_ARCH_ARM | 533 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
530 | 534 |
531 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 535 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 536 V8_TARGET_ARCH_MIPS64 |
532 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { | 537 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { |
533 FLAG_wasm_simd_prototype = true; | 538 FLAG_wasm_simd_prototype = true; |
534 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); | 539 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); |
535 byte a = 0; | 540 byte a = 0; |
536 byte b = 1; | 541 byte b = 1; |
537 byte expected = 2; | 542 byte expected = 2; |
538 byte simd0 = r.AllocateLocal(kWasmS128); | 543 byte simd0 = r.AllocateLocal(kWasmS128); |
539 byte simd1 = r.AllocateLocal(kWasmS128); | 544 byte simd1 = r.AllocateLocal(kWasmS128); |
540 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 545 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
541 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), | 546 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), |
(...skipping 14 matching lines...) Expand all Loading... |
556 | 561 |
557 WASM_EXEC_COMPILED_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } | 562 WASM_EXEC_COMPILED_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } |
558 WASM_EXEC_COMPILED_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } | 563 WASM_EXEC_COMPILED_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } |
559 WASM_EXEC_COMPILED_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); } | 564 WASM_EXEC_COMPILED_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); } |
560 WASM_EXEC_COMPILED_TEST(F32x4_Min) { | 565 WASM_EXEC_COMPILED_TEST(F32x4_Min) { |
561 RunF32x4BinOpTest(kExprF32x4Min, Minimum); | 566 RunF32x4BinOpTest(kExprF32x4Min, Minimum); |
562 } | 567 } |
563 WASM_EXEC_COMPILED_TEST(F32x4_Max) { | 568 WASM_EXEC_COMPILED_TEST(F32x4_Max) { |
564 RunF32x4BinOpTest(kExprF32x4Max, Maximum); | 569 RunF32x4BinOpTest(kExprF32x4Max, Maximum); |
565 } | 570 } |
566 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 571 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || |
| 572 // V8_TARGET_ARCH_MIPS64 |
567 | 573 |
568 #if SIMD_LOWERING_TARGET | 574 #if SIMD_LOWERING_TARGET |
569 WASM_EXEC_COMPILED_TEST(F32x4Div) { RunF32x4BinOpTest(kExprF32x4Div, Div); } | 575 WASM_EXEC_COMPILED_TEST(F32x4Div) { RunF32x4BinOpTest(kExprF32x4Div, Div); } |
570 #endif // SIMD_LOWERING_TARGET | 576 #endif // SIMD_LOWERING_TARGET |
571 | 577 |
572 #if V8_TARGET_ARCH_ARM | 578 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
573 WASM_EXEC_COMPILED_TEST(F32x4RecipRefine) { | 579 WASM_EXEC_COMPILED_TEST(F32x4RecipRefine) { |
574 RunF32x4BinOpTest(kExprF32x4RecipRefine, RecipRefine); | 580 RunF32x4BinOpTest(kExprF32x4RecipRefine, RecipRefine); |
575 } | 581 } |
576 | 582 |
577 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtRefine) { | 583 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtRefine) { |
578 RunF32x4BinOpTest(kExprF32x4RecipSqrtRefine, RecipSqrtRefine); | 584 RunF32x4BinOpTest(kExprF32x4RecipSqrtRefine, RecipSqrtRefine); |
579 } | 585 } |
580 #endif // V8_TARGET_ARCH_ARM | 586 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
581 | 587 |
582 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 588 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 589 V8_TARGET_ARCH_MIPS64 |
583 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { | 590 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { |
584 FLAG_wasm_simd_prototype = true; | 591 FLAG_wasm_simd_prototype = true; |
585 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); | 592 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); |
586 byte a = 0; | 593 byte a = 0; |
587 byte b = 1; | 594 byte b = 1; |
588 byte expected = 2; | 595 byte expected = 2; |
589 byte simd0 = r.AllocateLocal(kWasmS128); | 596 byte simd0 = r.AllocateLocal(kWasmS128); |
590 byte simd1 = r.AllocateLocal(kWasmS128); | 597 byte simd1 = r.AllocateLocal(kWasmS128); |
591 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), | 598 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), |
592 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), | 599 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), |
(...skipping 26 matching lines...) Expand all Loading... |
619 | 626 |
620 WASM_EXEC_COMPILED_TEST(F32x4Ge) { | 627 WASM_EXEC_COMPILED_TEST(F32x4Ge) { |
621 RunF32x4CompareOpTest(kExprF32x4Ge, GreaterEqual); | 628 RunF32x4CompareOpTest(kExprF32x4Ge, GreaterEqual); |
622 } | 629 } |
623 | 630 |
624 WASM_EXEC_COMPILED_TEST(F32x4Lt) { RunF32x4CompareOpTest(kExprF32x4Lt, Less); } | 631 WASM_EXEC_COMPILED_TEST(F32x4Lt) { RunF32x4CompareOpTest(kExprF32x4Lt, Less); } |
625 | 632 |
626 WASM_EXEC_COMPILED_TEST(F32x4Le) { | 633 WASM_EXEC_COMPILED_TEST(F32x4Le) { |
627 RunF32x4CompareOpTest(kExprF32x4Le, LessEqual); | 634 RunF32x4CompareOpTest(kExprF32x4Le, LessEqual); |
628 } | 635 } |
629 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 636 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || |
| 637 // V8_TARGET_ARCH_MIPS64 |
630 | 638 |
631 WASM_EXEC_COMPILED_TEST(I32x4Splat) { | 639 WASM_EXEC_COMPILED_TEST(I32x4Splat) { |
632 FLAG_wasm_simd_prototype = true; | 640 FLAG_wasm_simd_prototype = true; |
633 | 641 |
634 // Store SIMD value in a local variable, use extract lane to check lane values | 642 // Store SIMD value in a local variable, use extract lane to check lane values |
635 // This test is not a test for ExtractLane as Splat does not create | 643 // This test is not a test for ExtractLane as Splat does not create |
636 // interesting SIMD values. | 644 // interesting SIMD values. |
637 // | 645 // |
638 // SetLocal(1, I32x4Splat(Local(0))); | 646 // SetLocal(1, I32x4Splat(Local(0))); |
639 // For each lane index | 647 // For each lane index |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 new_val, new_val, new_val, new_val, new_val, old_val), | 863 new_val, new_val, new_val, new_val, new_val, old_val), |
856 WASM_SET_LOCAL(simd, | 864 WASM_SET_LOCAL(simd, |
857 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), | 865 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), |
858 WASM_GET_LOCAL(new_val))), | 866 WASM_GET_LOCAL(new_val))), |
859 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); | 867 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); |
860 | 868 |
861 CHECK_EQ(1, r.Call(1, 2)); | 869 CHECK_EQ(1, r.Call(1, 2)); |
862 } | 870 } |
863 #endif // V8_TARGET_ARCH_ARM | 871 #endif // V8_TARGET_ARCH_ARM |
864 | 872 |
865 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 873 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 874 V8_TARGET_ARCH_MIPS64 |
866 // Determines if conversion from float to int will be valid. | 875 // Determines if conversion from float to int will be valid. |
867 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { | 876 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { |
868 const double max_uint = static_cast<double>(0xffffffffu); | 877 const double max_uint = static_cast<double>(0xffffffffu); |
869 const double max_int = static_cast<double>(kMaxInt); | 878 const double max_int = static_cast<double>(kMaxInt); |
870 const double min_int = static_cast<double>(kMinInt); | 879 const double min_int = static_cast<double>(kMinInt); |
871 | 880 |
872 // Check for NaN. | 881 // Check for NaN. |
873 if (val != val) { | 882 if (val != val) { |
874 return false; | 883 return false; |
875 } | 884 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 WASM_GET_LOCAL(simd0))), | 930 WASM_GET_LOCAL(simd0))), |
922 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE); | 931 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE); |
923 | 932 |
924 FOR_FLOAT32_INPUTS(i) { | 933 FOR_FLOAT32_INPUTS(i) { |
925 if (SkipFPValue(*i)) continue; | 934 if (SkipFPValue(*i)) continue; |
926 int32_t signed_value = ConvertToInt(*i, false); | 935 int32_t signed_value = ConvertToInt(*i, false); |
927 int32_t unsigned_value = ConvertToInt(*i, true); | 936 int32_t unsigned_value = ConvertToInt(*i, true); |
928 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); | 937 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); |
929 } | 938 } |
930 } | 939 } |
| 940 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || |
| 941 // V8_TARGET_ARCH_MIPS64 |
931 | 942 |
932 #if V8_TARGET_ARCH_ARM | 943 #if V8_TARGET_ARCH_ARM |
933 // Tests both signed and unsigned conversion from I16x8 (unpacking). | 944 // Tests both signed and unsigned conversion from I16x8 (unpacking). |
934 WASM_EXEC_COMPILED_TEST(I32x4ConvertI16x8) { | 945 WASM_EXEC_COMPILED_TEST(I32x4ConvertI16x8) { |
935 FLAG_wasm_simd_prototype = true; | 946 FLAG_wasm_simd_prototype = true; |
936 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 947 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
937 byte a = 0; | 948 byte a = 0; |
938 byte unpacked_signed = 1; | 949 byte unpacked_signed = 1; |
939 byte unpacked_unsigned = 2; | 950 byte unpacked_unsigned = 2; |
940 byte simd0 = r.AllocateLocal(kWasmS128); | 951 byte simd0 = r.AllocateLocal(kWasmS128); |
941 byte simd1 = r.AllocateLocal(kWasmS128); | 952 byte simd1 = r.AllocateLocal(kWasmS128); |
942 byte simd2 = r.AllocateLocal(kWasmS128); | 953 byte simd2 = r.AllocateLocal(kWasmS128); |
943 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), | 954 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), |
944 WASM_SET_LOCAL(simd1, WASM_SIMD_UNOP(kExprI32x4SConvertI16x8Low, | 955 WASM_SET_LOCAL(simd1, WASM_SIMD_UNOP(kExprI32x4SConvertI16x8Low, |
945 WASM_GET_LOCAL(simd0))), | 956 WASM_GET_LOCAL(simd0))), |
946 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, unpacked_signed), | 957 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, unpacked_signed), |
947 WASM_SET_LOCAL(simd2, WASM_SIMD_UNOP(kExprI32x4UConvertI16x8High, | 958 WASM_SET_LOCAL(simd2, WASM_SIMD_UNOP(kExprI32x4UConvertI16x8High, |
948 WASM_GET_LOCAL(simd0))), | 959 WASM_GET_LOCAL(simd0))), |
949 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, unpacked_unsigned), WASM_ONE); | 960 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, unpacked_unsigned), WASM_ONE); |
950 | 961 |
951 FOR_INT16_INPUTS(i) { | 962 FOR_INT16_INPUTS(i) { |
952 int32_t unpacked_signed = Widen<int16_t>(*i); | 963 int32_t unpacked_signed = Widen<int16_t>(*i); |
953 int32_t unpacked_unsigned = UnsignedWiden<int16_t>(*i); | 964 int32_t unpacked_unsigned = UnsignedWiden<int16_t>(*i); |
954 CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned)); | 965 CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned)); |
955 } | 966 } |
956 } | 967 } |
957 #endif // V8_TARGET_ARCH_ARM | 968 #endif // V8_TARGET_ARCH_ARM |
958 | 969 |
| 970 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
959 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { | 971 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { |
960 FLAG_wasm_simd_prototype = true; | 972 FLAG_wasm_simd_prototype = true; |
961 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 973 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
962 byte a = 0; | 974 byte a = 0; |
963 byte expected = 1; | 975 byte expected = 1; |
964 byte simd = r.AllocateLocal(kWasmS128); | 976 byte simd = r.AllocateLocal(kWasmS128); |
965 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 977 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
966 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 978 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
967 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); | 979 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); |
968 | 980 |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 WASM_SIMD_I32x4_EXTRACT_LANE( | 1999 WASM_SIMD_I32x4_EXTRACT_LANE( |
1988 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); | 2000 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); |
1989 | 2001 |
1990 FOR_INT32_INPUTS(i) { | 2002 FOR_INT32_INPUTS(i) { |
1991 int32_t expected = *i; | 2003 int32_t expected = *i; |
1992 r.module().WriteMemory(&memory[0], expected); | 2004 r.module().WriteMemory(&memory[0], expected); |
1993 CHECK_EQ(expected, r.Call()); | 2005 CHECK_EQ(expected, r.Call()); |
1994 } | 2006 } |
1995 } | 2007 } |
1996 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 2008 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
OLD | NEW |