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 "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 #include "test/cctest/compiler/value-helper.h" | 7 #include "test/cctest/compiler/value-helper.h" |
8 #include "test/cctest/wasm/wasm-run-utils.h" | 8 #include "test/cctest/wasm/wasm-run-utils.h" |
9 #include "test/common/wasm/wasm-macro-gen.h" | 9 #include "test/common/wasm/wasm-macro-gen.h" |
10 | 10 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 WASM_GET_LOCAL(new_val))), | 653 WASM_GET_LOCAL(new_val))), |
654 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, new_val, new_val, old_val), | 654 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, new_val, new_val, old_val), |
655 WASM_SET_LOCAL(simd, | 655 WASM_SET_LOCAL(simd, |
656 WASM_SIMD_I32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), | 656 WASM_SIMD_I32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), |
657 WASM_GET_LOCAL(new_val))), | 657 WASM_GET_LOCAL(new_val))), |
658 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, new_val), WASM_ONE); | 658 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, new_val), WASM_ONE); |
659 | 659 |
660 CHECK_EQ(1, r.Call(1, 2)); | 660 CHECK_EQ(1, r.Call(1, 2)); |
661 } | 661 } |
662 | 662 |
663 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET | 663 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \ |
| 664 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
664 WASM_EXEC_COMPILED_TEST(I16x8Splat) { | 665 WASM_EXEC_COMPILED_TEST(I16x8Splat) { |
665 FLAG_wasm_simd_prototype = true; | 666 FLAG_wasm_simd_prototype = true; |
666 | 667 |
667 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 668 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
668 byte lane_val = 0; | 669 byte lane_val = 0; |
669 byte simd = r.AllocateLocal(kWasmS128); | 670 byte simd = r.AllocateLocal(kWasmS128); |
670 BUILD(r, | 671 BUILD(r, |
671 WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))), | 672 WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))), |
672 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE); | 673 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE); |
673 | 674 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 WASM_GET_LOCAL(new_val))), | 717 WASM_GET_LOCAL(new_val))), |
717 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, | 718 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, |
718 new_val, new_val, new_val, old_val), | 719 new_val, new_val, new_val, old_val), |
719 WASM_SET_LOCAL(simd, | 720 WASM_SET_LOCAL(simd, |
720 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), | 721 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), |
721 WASM_GET_LOCAL(new_val))), | 722 WASM_GET_LOCAL(new_val))), |
722 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); | 723 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); |
723 | 724 |
724 CHECK_EQ(1, r.Call(1, 2)); | 725 CHECK_EQ(1, r.Call(1, 2)); |
725 } | 726 } |
726 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET | 727 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || |
| 728 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
727 | 729 |
728 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 730 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
729 WASM_EXEC_COMPILED_TEST(I8x16Splat) { | 731 WASM_EXEC_COMPILED_TEST(I8x16Splat) { |
730 FLAG_wasm_simd_prototype = true; | 732 FLAG_wasm_simd_prototype = true; |
731 | 733 |
732 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); | 734 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); |
733 byte lane_val = 0; | 735 byte lane_val = 0; |
734 byte simd = r.AllocateLocal(kWasmS128); | 736 byte simd = r.AllocateLocal(kWasmS128); |
735 BUILD(r, | 737 BUILD(r, |
736 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), | 738 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, unpacked_unsigned), WASM_ONE); | 937 WASM_SIMD_CHECK_SPLAT4(I32x4, simd2, I32, unpacked_unsigned), WASM_ONE); |
936 | 938 |
937 FOR_INT16_INPUTS(i) { | 939 FOR_INT16_INPUTS(i) { |
938 int32_t unpacked_signed = Widen<int16_t>(*i); | 940 int32_t unpacked_signed = Widen<int16_t>(*i); |
939 int32_t unpacked_unsigned = UnsignedWiden<int16_t>(*i); | 941 int32_t unpacked_unsigned = UnsignedWiden<int16_t>(*i); |
940 CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned)); | 942 CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned)); |
941 } | 943 } |
942 } | 944 } |
943 #endif // V8_TARGET_ARCH_ARM | 945 #endif // V8_TARGET_ARCH_ARM |
944 | 946 |
945 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 947 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 948 V8_TARGET_ARCH_MIPS64 |
946 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { | 949 void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) { |
947 FLAG_wasm_simd_prototype = true; | 950 FLAG_wasm_simd_prototype = true; |
948 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 951 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
949 byte a = 0; | 952 byte a = 0; |
950 byte expected = 1; | 953 byte expected = 1; |
951 byte simd = r.AllocateLocal(kWasmS128); | 954 byte simd = r.AllocateLocal(kWasmS128); |
952 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), | 955 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), |
953 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 956 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
954 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); | 957 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); |
955 | 958 |
956 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } | 959 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } |
957 } | 960 } |
958 | 961 |
959 WASM_EXEC_COMPILED_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); } | 962 WASM_EXEC_COMPILED_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); } |
| 963 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || |
| 964 // V8_TARGET_ARCH_MIPS64 |
960 | 965 |
| 966 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
961 WASM_EXEC_COMPILED_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); } | 967 WASM_EXEC_COMPILED_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); } |
962 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 968 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
963 | 969 |
964 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { | 970 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { |
965 FLAG_wasm_simd_prototype = true; | 971 FLAG_wasm_simd_prototype = true; |
966 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 972 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
967 byte a = 0; | 973 byte a = 0; |
968 byte b = 1; | 974 byte b = 1; |
969 byte expected = 2; | 975 byte expected = 2; |
970 byte simd0 = r.AllocateLocal(kWasmS128); | 976 byte simd0 = r.AllocateLocal(kWasmS128); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 1044 } |
1039 | 1045 |
1040 WASM_EXEC_COMPILED_TEST(I32x4Eq) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); } | 1046 WASM_EXEC_COMPILED_TEST(I32x4Eq) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); } |
1041 | 1047 |
1042 WASM_EXEC_COMPILED_TEST(I32x4Ne) { | 1048 WASM_EXEC_COMPILED_TEST(I32x4Ne) { |
1043 RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); | 1049 RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); |
1044 } | 1050 } |
1045 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || | 1051 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || |
1046 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 1052 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1047 | 1053 |
1048 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 1054 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ |
| 1055 V8_TARGET_ARCH_MIPS64 |
1049 WASM_EXEC_COMPILED_TEST(I32x4LtS) { | 1056 WASM_EXEC_COMPILED_TEST(I32x4LtS) { |
1050 RunI32x4CompareOpTest(kExprI32x4LtS, Less); | 1057 RunI32x4CompareOpTest(kExprI32x4LtS, Less); |
1051 } | 1058 } |
1052 | 1059 |
1053 WASM_EXEC_COMPILED_TEST(I32x4LeS) { | 1060 WASM_EXEC_COMPILED_TEST(I32x4LeS) { |
1054 RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); | 1061 RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); |
1055 } | 1062 } |
1056 | 1063 |
1057 WASM_EXEC_COMPILED_TEST(I32x4GtS) { | 1064 WASM_EXEC_COMPILED_TEST(I32x4GtS) { |
1058 RunI32x4CompareOpTest(kExprI32x4GtS, Greater); | 1065 RunI32x4CompareOpTest(kExprI32x4GtS, Greater); |
(...skipping 11 matching lines...) Expand all Loading... |
1070 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); | 1077 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); |
1071 } | 1078 } |
1072 | 1079 |
1073 WASM_EXEC_COMPILED_TEST(I32x4GtU) { | 1080 WASM_EXEC_COMPILED_TEST(I32x4GtU) { |
1074 RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater); | 1081 RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater); |
1075 } | 1082 } |
1076 | 1083 |
1077 WASM_EXEC_COMPILED_TEST(I32x4GeU) { | 1084 WASM_EXEC_COMPILED_TEST(I32x4GeU) { |
1078 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); | 1085 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); |
1079 } | 1086 } |
1080 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 1087 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || |
| 1088 // V8_TARGET_ARCH_MIPS64 |
1081 | 1089 |
1082 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \ | 1090 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \ |
1083 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 1091 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1084 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, | 1092 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, |
1085 int shift) { | 1093 int shift) { |
1086 FLAG_wasm_simd_prototype = true; | 1094 FLAG_wasm_simd_prototype = true; |
1087 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1095 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1088 byte a = 0; | 1096 byte a = 0; |
1089 byte expected = 1; | 1097 byte expected = 1; |
1090 byte simd = r.AllocateLocal(kWasmS128); | 1098 byte simd = r.AllocateLocal(kWasmS128); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 WASM_SET_LOCAL(simd2, WASM_SIMD_UNOP(kExprI16x8UConvertI8x16High, | 1136 WASM_SET_LOCAL(simd2, WASM_SIMD_UNOP(kExprI16x8UConvertI8x16High, |
1129 WASM_GET_LOCAL(simd0))), | 1137 WASM_GET_LOCAL(simd0))), |
1130 WASM_SIMD_CHECK_SPLAT8(I16x8, simd2, I32, unpacked_unsigned), WASM_ONE); | 1138 WASM_SIMD_CHECK_SPLAT8(I16x8, simd2, I32, unpacked_unsigned), WASM_ONE); |
1131 | 1139 |
1132 FOR_INT8_INPUTS(i) { | 1140 FOR_INT8_INPUTS(i) { |
1133 int32_t unpacked_signed = Widen<int8_t>(*i); | 1141 int32_t unpacked_signed = Widen<int8_t>(*i); |
1134 int32_t unpacked_unsigned = UnsignedWiden<int8_t>(*i); | 1142 int32_t unpacked_unsigned = UnsignedWiden<int8_t>(*i); |
1135 CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned)); | 1143 CHECK_EQ(1, r.Call(*i, unpacked_signed, unpacked_unsigned)); |
1136 } | 1144 } |
1137 } | 1145 } |
| 1146 #endif // V8_TARGET_ARCH_ARM |
1138 | 1147 |
| 1148 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1139 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { | 1149 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { |
1140 FLAG_wasm_simd_prototype = true; | 1150 FLAG_wasm_simd_prototype = true; |
1141 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1151 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1142 byte a = 0; | 1152 byte a = 0; |
1143 byte expected = 1; | 1153 byte expected = 1; |
1144 byte simd = r.AllocateLocal(kWasmS128); | 1154 byte simd = r.AllocateLocal(kWasmS128); |
1145 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), | 1155 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), |
1146 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 1156 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
1147 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); | 1157 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); |
1148 | 1158 |
1149 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } | 1159 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } |
1150 } | 1160 } |
1151 | 1161 |
1152 WASM_EXEC_COMPILED_TEST(I16x8Neg) { RunI16x8UnOpTest(kExprI16x8Neg, Negate); } | 1162 WASM_EXEC_COMPILED_TEST(I16x8Neg) { RunI16x8UnOpTest(kExprI16x8Neg, Negate); } |
| 1163 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1153 | 1164 |
| 1165 #if V8_TARGET_ARCH_ARM |
1154 // Tests both signed and unsigned conversion from I32x4 (packing). | 1166 // Tests both signed and unsigned conversion from I32x4 (packing). |
1155 WASM_EXEC_COMPILED_TEST(I16x8ConvertI32x4) { | 1167 WASM_EXEC_COMPILED_TEST(I16x8ConvertI32x4) { |
1156 FLAG_wasm_simd_prototype = true; | 1168 FLAG_wasm_simd_prototype = true; |
1157 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1169 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1158 byte a = 0; | 1170 byte a = 0; |
1159 byte packed_signed = 1; | 1171 byte packed_signed = 1; |
1160 byte packed_unsigned = 2; | 1172 byte packed_unsigned = 2; |
1161 byte simd0 = r.AllocateLocal(kWasmS128); | 1173 byte simd0 = r.AllocateLocal(kWasmS128); |
1162 byte simd1 = r.AllocateLocal(kWasmS128); | 1174 byte simd1 = r.AllocateLocal(kWasmS128); |
1163 byte simd2 = r.AllocateLocal(kWasmS128); | 1175 byte simd2 = r.AllocateLocal(kWasmS128); |
(...skipping 10 matching lines...) Expand all Loading... |
1174 FOR_INT32_INPUTS(i) { | 1186 FOR_INT32_INPUTS(i) { |
1175 int32_t packed_signed = Narrow<int16_t>(*i); | 1187 int32_t packed_signed = Narrow<int16_t>(*i); |
1176 int32_t packed_unsigned = UnsignedNarrow<int16_t>(*i); | 1188 int32_t packed_unsigned = UnsignedNarrow<int16_t>(*i); |
1177 // Sign-extend here, since ExtractLane sign extends. | 1189 // Sign-extend here, since ExtractLane sign extends. |
1178 if (packed_unsigned & 0x8000) packed_unsigned |= 0xffff0000; | 1190 if (packed_unsigned & 0x8000) packed_unsigned |= 0xffff0000; |
1179 CHECK_EQ(1, r.Call(*i, packed_signed, packed_unsigned)); | 1191 CHECK_EQ(1, r.Call(*i, packed_signed, packed_unsigned)); |
1180 } | 1192 } |
1181 } | 1193 } |
1182 #endif // V8_TARGET_ARCH_ARM | 1194 #endif // V8_TARGET_ARCH_ARM |
1183 | 1195 |
1184 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET | 1196 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \ |
| 1197 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1185 void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { | 1198 void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { |
1186 FLAG_wasm_simd_prototype = true; | 1199 FLAG_wasm_simd_prototype = true; |
1187 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1200 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1188 byte a = 0; | 1201 byte a = 0; |
1189 byte b = 1; | 1202 byte b = 1; |
1190 byte expected = 2; | 1203 byte expected = 2; |
1191 byte simd0 = r.AllocateLocal(kWasmS128); | 1204 byte simd0 = r.AllocateLocal(kWasmS128); |
1192 byte simd1 = r.AllocateLocal(kWasmS128); | 1205 byte simd1 = r.AllocateLocal(kWasmS128); |
1193 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), | 1206 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), |
1194 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), | 1207 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), |
(...skipping 10 matching lines...) Expand all Loading... |
1205 | 1218 |
1206 WASM_EXEC_COMPILED_TEST(I16x8AddSaturateS) { | 1219 WASM_EXEC_COMPILED_TEST(I16x8AddSaturateS) { |
1207 RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate); | 1220 RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate); |
1208 } | 1221 } |
1209 | 1222 |
1210 WASM_EXEC_COMPILED_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); } | 1223 WASM_EXEC_COMPILED_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); } |
1211 | 1224 |
1212 WASM_EXEC_COMPILED_TEST(I16x8SubSaturateS) { | 1225 WASM_EXEC_COMPILED_TEST(I16x8SubSaturateS) { |
1213 RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate); | 1226 RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate); |
1214 } | 1227 } |
| 1228 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || |
| 1229 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1215 | 1230 |
| 1231 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET |
1216 WASM_EXEC_COMPILED_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); } | 1232 WASM_EXEC_COMPILED_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); } |
1217 | 1233 |
1218 WASM_EXEC_COMPILED_TEST(I16x8MinS) { | 1234 WASM_EXEC_COMPILED_TEST(I16x8MinS) { |
1219 RunI16x8BinOpTest(kExprI16x8MinS, Minimum); | 1235 RunI16x8BinOpTest(kExprI16x8MinS, Minimum); |
1220 } | 1236 } |
1221 | 1237 |
1222 WASM_EXEC_COMPILED_TEST(I16x8MaxS) { | 1238 WASM_EXEC_COMPILED_TEST(I16x8MaxS) { |
1223 RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); | 1239 RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); |
1224 } | 1240 } |
1225 | 1241 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 | 1310 |
1295 WASM_EXEC_COMPILED_TEST(I16x8LtU) { | 1311 WASM_EXEC_COMPILED_TEST(I16x8LtU) { |
1296 RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); | 1312 RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); |
1297 } | 1313 } |
1298 | 1314 |
1299 WASM_EXEC_COMPILED_TEST(I16x8LeU) { | 1315 WASM_EXEC_COMPILED_TEST(I16x8LeU) { |
1300 RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); | 1316 RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); |
1301 } | 1317 } |
1302 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET | 1318 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
1303 | 1319 |
1304 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET | 1320 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \ |
| 1321 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1305 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, | 1322 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, |
1306 int shift) { | 1323 int shift) { |
1307 FLAG_wasm_simd_prototype = true; | 1324 FLAG_wasm_simd_prototype = true; |
1308 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1325 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1309 byte a = 0; | 1326 byte a = 0; |
1310 byte expected = 1; | 1327 byte expected = 1; |
1311 byte simd = r.AllocateLocal(kWasmS128); | 1328 byte simd = r.AllocateLocal(kWasmS128); |
1312 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), | 1329 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), |
1313 WASM_SET_LOCAL( | 1330 WASM_SET_LOCAL( |
1314 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), | 1331 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), |
1315 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); | 1332 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); |
1316 | 1333 |
1317 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } | 1334 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } |
1318 } | 1335 } |
1319 | 1336 |
1320 WASM_EXEC_COMPILED_TEST(I16x8Shl) { | 1337 WASM_EXEC_COMPILED_TEST(I16x8Shl) { |
1321 RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1); | 1338 RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1); |
1322 } | 1339 } |
1323 | 1340 |
1324 WASM_EXEC_COMPILED_TEST(I16x8ShrS) { | 1341 WASM_EXEC_COMPILED_TEST(I16x8ShrS) { |
1325 RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); | 1342 RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); |
1326 } | 1343 } |
1327 | 1344 |
1328 WASM_EXEC_COMPILED_TEST(I16x8ShrU) { | 1345 WASM_EXEC_COMPILED_TEST(I16x8ShrU) { |
1329 RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); | 1346 RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); |
1330 } | 1347 } |
1331 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET | 1348 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || |
| 1349 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1332 | 1350 |
1333 #if V8_TARGET_ARCH_ARM | 1351 #if V8_TARGET_ARCH_ARM |
1334 void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { | 1352 void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { |
1335 FLAG_wasm_simd_prototype = true; | 1353 FLAG_wasm_simd_prototype = true; |
1336 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); | 1354 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); |
1337 byte a = 0; | 1355 byte a = 0; |
1338 byte expected = 1; | 1356 byte expected = 1; |
1339 byte simd = r.AllocateLocal(kWasmS128); | 1357 byte simd = r.AllocateLocal(kWasmS128); |
1340 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), | 1358 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), |
1341 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), | 1359 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 WASM_SIMD_I32x4_EXTRACT_LANE( | 2241 WASM_SIMD_I32x4_EXTRACT_LANE( |
2224 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); | 2242 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); |
2225 | 2243 |
2226 FOR_INT32_INPUTS(i) { | 2244 FOR_INT32_INPUTS(i) { |
2227 int32_t expected = *i; | 2245 int32_t expected = *i; |
2228 r.module().WriteMemory(&memory[0], expected); | 2246 r.module().WriteMemory(&memory[0], expected); |
2229 CHECK_EQ(expected, r.Call()); | 2247 CHECK_EQ(expected, r.Call()); |
2230 } | 2248 } |
2231 } | 2249 } |
2232 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64 | 2250 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64 |
OLD | NEW |