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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, | 754 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, new_val, new_val, new_val, |
755 new_val, new_val, new_val, new_val, new_val, new_val, | 755 new_val, new_val, new_val, new_val, new_val, new_val, |
756 new_val, new_val, new_val, new_val, new_val, old_val), | 756 new_val, new_val, new_val, new_val, new_val, old_val), |
757 WASM_SET_LOCAL(simd, | 757 WASM_SET_LOCAL(simd, |
758 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), | 758 WASM_SIMD_I8x16_REPLACE_LANE(15, WASM_GET_LOCAL(simd), |
759 WASM_GET_LOCAL(new_val))), | 759 WASM_GET_LOCAL(new_val))), |
760 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); | 760 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, new_val), WASM_ONE); |
761 | 761 |
762 CHECK_EQ(1, r.Call(1, 2)); | 762 CHECK_EQ(1, r.Call(1, 2)); |
763 } | 763 } |
| 764 #endif // V8_TARGET_ARCH_ARM |
764 | 765 |
| 766 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
765 // Determines if conversion from float to int will be valid. | 767 // Determines if conversion from float to int will be valid. |
766 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { | 768 bool CanRoundToZeroAndConvert(double val, bool unsigned_integer) { |
767 const double max_uint = static_cast<double>(0xffffffffu); | 769 const double max_uint = static_cast<double>(0xffffffffu); |
768 const double max_int = static_cast<double>(kMaxInt); | 770 const double max_int = static_cast<double>(kMaxInt); |
769 const double min_int = static_cast<double>(kMinInt); | 771 const double min_int = static_cast<double>(kMinInt); |
770 | 772 |
771 // Check for NaN. | 773 // Check for NaN. |
772 if (val != val) { | 774 if (val != val) { |
773 return false; | 775 return false; |
774 } | 776 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 WASM_SET_LOCAL(simd2, WASM_SIMD_U32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))), | 821 WASM_SET_LOCAL(simd2, WASM_SIMD_U32x4_FROM_F32x4(WASM_GET_LOCAL(simd0))), |
820 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE); | 822 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, expected_unsigned), WASM_ONE); |
821 | 823 |
822 FOR_FLOAT32_INPUTS(i) { | 824 FOR_FLOAT32_INPUTS(i) { |
823 if (SkipFPTestInput(*i)) continue; | 825 if (SkipFPTestInput(*i)) continue; |
824 int32_t signed_value = ConvertToInt(*i, false); | 826 int32_t signed_value = ConvertToInt(*i, false); |
825 int32_t unsigned_value = ConvertToInt(*i, true); | 827 int32_t unsigned_value = ConvertToInt(*i, true); |
826 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); | 828 CHECK_EQ(1, r.Call(*i, signed_value, unsigned_value)); |
827 } | 829 } |
828 } | 830 } |
829 #endif // V8_TARGET_ARCH_ARM | |
830 | 831 |
831 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | |
832 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { | 832 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { |
833 FLAG_wasm_simd_prototype = true; | 833 FLAG_wasm_simd_prototype = true; |
834 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 834 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
835 byte a = 0; | 835 byte a = 0; |
836 byte expected = 1; | 836 byte expected = 1; |
837 byte simd = r.AllocateLocal(kWasmS128); | 837 byte simd = r.AllocateLocal(kWasmS128); |
838 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 838 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
839 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 839 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
840 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); | 840 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); |
841 | 841 |
(...skipping 29 matching lines...) Expand all Loading... |
871 WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } | 871 WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } |
872 | 872 |
873 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 873 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
874 WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); } | 874 WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); } |
875 | 875 |
876 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } | 876 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } |
877 | 877 |
878 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } | 878 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } |
879 | 879 |
880 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } | 880 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } |
881 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | |
882 | 881 |
883 #if V8_TARGET_ARCH_ARM | |
884 WASM_EXEC_COMPILED_TEST(I32x4Min) { | 882 WASM_EXEC_COMPILED_TEST(I32x4Min) { |
885 RunI32x4BinOpTest(kExprI32x4MinS, Minimum); | 883 RunI32x4BinOpTest(kExprI32x4MinS, Minimum); |
886 } | 884 } |
887 | 885 |
888 WASM_EXEC_COMPILED_TEST(I32x4Max) { | 886 WASM_EXEC_COMPILED_TEST(I32x4Max) { |
889 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); | 887 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); |
890 } | 888 } |
891 | 889 |
892 WASM_EXEC_COMPILED_TEST(Ui32x4Min) { | 890 WASM_EXEC_COMPILED_TEST(Ui32x4Min) { |
893 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); | 891 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); |
894 } | 892 } |
895 | 893 |
896 WASM_EXEC_COMPILED_TEST(Ui32x4Max) { | 894 WASM_EXEC_COMPILED_TEST(Ui32x4Max) { |
897 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); | 895 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); |
898 } | 896 } |
| 897 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
899 | 898 |
900 | 899 #if V8_TARGET_ARCH_ARM |
901 | |
902 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { | 900 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { |
903 FLAG_wasm_simd_prototype = true; | 901 FLAG_wasm_simd_prototype = true; |
904 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 902 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
905 byte a = 0; | 903 byte a = 0; |
906 byte b = 1; | 904 byte b = 1; |
907 byte expected = 2; | 905 byte expected = 2; |
908 byte simd0 = r.AllocateLocal(kWasmS128); | 906 byte simd0 = r.AllocateLocal(kWasmS128); |
909 byte simd1 = r.AllocateLocal(kWasmS128); | 907 byte simd1 = r.AllocateLocal(kWasmS128); |
910 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 908 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
911 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), | 909 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); | 950 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); |
953 } | 951 } |
954 | 952 |
955 WASM_EXEC_COMPILED_TEST(Ui32x4Less) { | 953 WASM_EXEC_COMPILED_TEST(Ui32x4Less) { |
956 RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); | 954 RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); |
957 } | 955 } |
958 | 956 |
959 WASM_EXEC_COMPILED_TEST(Ui32x4LessEqual) { | 957 WASM_EXEC_COMPILED_TEST(Ui32x4LessEqual) { |
960 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); | 958 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); |
961 } | 959 } |
| 960 #endif // V8_TARGET_ARCH_ARM |
962 | 961 |
| 962 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
963 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, | 963 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, |
964 int shift) { | 964 int shift) { |
965 FLAG_wasm_simd_prototype = true; | 965 FLAG_wasm_simd_prototype = true; |
966 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 966 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
967 byte a = 0; | 967 byte a = 0; |
968 byte expected = 1; | 968 byte expected = 1; |
969 byte simd = r.AllocateLocal(kWasmS128); | 969 byte simd = r.AllocateLocal(kWasmS128); |
970 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 970 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
971 WASM_SET_LOCAL( | 971 WASM_SET_LOCAL( |
972 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), | 972 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), |
973 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); | 973 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); |
974 | 974 |
975 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } | 975 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } |
976 } | 976 } |
977 | 977 |
978 WASM_EXEC_COMPILED_TEST(I32x4Shl) { | 978 WASM_EXEC_COMPILED_TEST(I32x4Shl) { |
979 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); | 979 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); |
980 } | 980 } |
981 | 981 |
982 WASM_EXEC_COMPILED_TEST(I32x4ShrS) { | 982 WASM_EXEC_COMPILED_TEST(I32x4ShrS) { |
983 RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); | 983 RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); |
984 } | 984 } |
985 | 985 |
986 WASM_EXEC_COMPILED_TEST(I32x4ShrU) { | 986 WASM_EXEC_COMPILED_TEST(I32x4ShrU) { |
987 RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1); | 987 RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1); |
988 } | 988 } |
| 989 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| 990 |
| 991 #if V8_TARGET_ARCH_ARM |
989 | 992 |
990 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { | 993 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { |
991 FLAG_wasm_simd_prototype = true; | 994 FLAG_wasm_simd_prototype = true; |
992 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 995 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
993 byte a = 0; | 996 byte a = 0; |
994 byte expected = 1; | 997 byte expected = 1; |
995 byte simd = r.AllocateLocal(kWasmS128); | 998 byte simd = r.AllocateLocal(kWasmS128); |
996 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), | 999 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), |
997 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 1000 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
998 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); | 1001 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0), | 1752 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0), |
1750 WASM_F32(65.0))), | 1753 WASM_F32(65.0))), |
1751 WASM_I32V(1)); | 1754 WASM_I32V(1)); |
1752 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } | 1755 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); } |
1753 CHECK_EQ(*global, 13.5); | 1756 CHECK_EQ(*global, 13.5); |
1754 CHECK_EQ(*(global + 1), 45.5); | 1757 CHECK_EQ(*(global + 1), 45.5); |
1755 CHECK_EQ(*(global + 2), 32.25); | 1758 CHECK_EQ(*(global + 2), 32.25); |
1756 CHECK_EQ(*(global + 3), 65.0); | 1759 CHECK_EQ(*(global + 3), 65.0); |
1757 } | 1760 } |
1758 #endif // SIMD_LOWERING_TARGET | 1761 #endif // SIMD_LOWERING_TARGET |
OLD | NEW |