Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(986)

Side by Side Diff: test/cctest/wasm/test-run-wasm-simd.cc

Issue 2780713003: MIPS[64]: Support for some SIMD operations (3) (Closed)
Patch Set: rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/mips64/instruction-selector-mips64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 954
955 FOR_INT32_INPUTS(i) { 955 FOR_INT32_INPUTS(i) {
956 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } 956 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); }
957 } 957 }
958 } 958 }
959 959
960 WASM_EXEC_COMPILED_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } 960 WASM_EXEC_COMPILED_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); }
961 961
962 WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } 962 WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); }
963 963
964 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET 964 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \
965 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
965 WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); } 966 WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); }
966 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET 967 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
968 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
967 969
968 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 970 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
969 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } 971 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); }
970 972
971 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } 973 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); }
972 974
973 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } 975 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); }
974 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 976 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
975 977
976 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET 978 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \
979 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
977 WASM_EXEC_COMPILED_TEST(I32x4Min) { 980 WASM_EXEC_COMPILED_TEST(I32x4Min) {
978 RunI32x4BinOpTest(kExprI32x4MinS, Minimum); 981 RunI32x4BinOpTest(kExprI32x4MinS, Minimum);
979 } 982 }
980 983
981 WASM_EXEC_COMPILED_TEST(I32x4MaxS) { 984 WASM_EXEC_COMPILED_TEST(I32x4MaxS) {
982 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); 985 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum);
983 } 986 }
984 987
985 WASM_EXEC_COMPILED_TEST(I32x4MinU) { 988 WASM_EXEC_COMPILED_TEST(I32x4MinU) {
986 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); 989 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum);
(...skipping 22 matching lines...) Expand all
1009 FOR_INT32_INPUTS(i) { 1012 FOR_INT32_INPUTS(i) {
1010 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } 1013 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); }
1011 } 1014 }
1012 } 1015 }
1013 1016
1014 WASM_EXEC_COMPILED_TEST(I32x4Eq) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); } 1017 WASM_EXEC_COMPILED_TEST(I32x4Eq) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); }
1015 1018
1016 WASM_EXEC_COMPILED_TEST(I32x4Ne) { 1019 WASM_EXEC_COMPILED_TEST(I32x4Ne) {
1017 RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); 1020 RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual);
1018 } 1021 }
1019 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET 1022 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
1023 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
1020 1024
1021 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 1025 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
1022 WASM_EXEC_COMPILED_TEST(I32x4LtS) { 1026 WASM_EXEC_COMPILED_TEST(I32x4LtS) {
1023 RunI32x4CompareOpTest(kExprI32x4LtS, Less); 1027 RunI32x4CompareOpTest(kExprI32x4LtS, Less);
1024 } 1028 }
1025 1029
1026 WASM_EXEC_COMPILED_TEST(I32x4LeS) { 1030 WASM_EXEC_COMPILED_TEST(I32x4LeS) {
1027 RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); 1031 RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual);
1028 } 1032 }
1029 1033
(...skipping 15 matching lines...) Expand all
1045 1049
1046 WASM_EXEC_COMPILED_TEST(I32x4GtU) { 1050 WASM_EXEC_COMPILED_TEST(I32x4GtU) {
1047 RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater); 1051 RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater);
1048 } 1052 }
1049 1053
1050 WASM_EXEC_COMPILED_TEST(I32x4GeU) { 1054 WASM_EXEC_COMPILED_TEST(I32x4GeU) {
1051 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); 1055 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual);
1052 } 1056 }
1053 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 1057 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
1054 1058
1055 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET 1059 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET || \
1060 V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
1056 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, 1061 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op,
1057 int shift) { 1062 int shift) {
1058 FLAG_wasm_simd_prototype = true; 1063 FLAG_wasm_simd_prototype = true;
1059 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 1064 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
1060 byte a = 0; 1065 byte a = 0;
1061 byte expected = 1; 1066 byte expected = 1;
1062 byte simd = r.AllocateLocal(kWasmS128); 1067 byte simd = r.AllocateLocal(kWasmS128);
1063 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 1068 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
1064 WASM_SET_LOCAL( 1069 WASM_SET_LOCAL(
1065 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), 1070 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
1066 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); 1071 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
1067 1072
1068 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } 1073 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
1069 } 1074 }
1070 1075
1071 WASM_EXEC_COMPILED_TEST(I32x4Shl) { 1076 WASM_EXEC_COMPILED_TEST(I32x4Shl) {
1072 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); 1077 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1);
1073 } 1078 }
1074 1079
1075 WASM_EXEC_COMPILED_TEST(I32x4ShrS) { 1080 WASM_EXEC_COMPILED_TEST(I32x4ShrS) {
1076 RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); 1081 RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1);
1077 } 1082 }
1078 1083
1079 WASM_EXEC_COMPILED_TEST(I32x4ShrU) { 1084 WASM_EXEC_COMPILED_TEST(I32x4ShrU) {
1080 RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1); 1085 RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1);
1081 } 1086 }
1082 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET 1087 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || SIMD_LOWERING_TARGET ||
1088 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
1083 1089
1084 #if V8_TARGET_ARCH_ARM 1090 #if V8_TARGET_ARCH_ARM
1085 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { 1091 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) {
1086 FLAG_wasm_simd_prototype = true; 1092 FLAG_wasm_simd_prototype = true;
1087 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 1093 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
1088 byte a = 0; 1094 byte a = 0;
1089 byte expected = 1; 1095 byte expected = 1;
1090 byte simd = r.AllocateLocal(kWasmS128); 1096 byte simd = r.AllocateLocal(kWasmS128);
1091 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), 1097 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
1092 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 1098 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 1398
1393 WASM_EXEC_COMPILED_TEST(I8x16ShrS) { 1399 WASM_EXEC_COMPILED_TEST(I8x16ShrS) {
1394 RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1); 1400 RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1);
1395 } 1401 }
1396 1402
1397 WASM_EXEC_COMPILED_TEST(I8x16ShrU) { 1403 WASM_EXEC_COMPILED_TEST(I8x16ShrU) {
1398 RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1); 1404 RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1);
1399 } 1405 }
1400 #endif // V8_TARGET_ARCH_ARM 1406 #endif // V8_TARGET_ARCH_ARM
1401 1407
1402 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 1408 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || \
1409 V8_TARGET_ARCH_MIPS64
1403 // Test Select by making a mask where the first two lanes are true and the rest 1410 // Test Select by making a mask where the first two lanes are true and the rest
1404 // false, and comparing for non-equality with zero to materialize a bool vector. 1411 // false, and comparing for non-equality with zero to materialize a bool vector.
1405 #define WASM_SIMD_SELECT_TEST(format) \ 1412 #define WASM_SIMD_SELECT_TEST(format) \
1406 WASM_EXEC_COMPILED_TEST(S##format##Select) { \ 1413 WASM_EXEC_COMPILED_TEST(S##format##Select) { \
1407 FLAG_wasm_simd_prototype = true; \ 1414 FLAG_wasm_simd_prototype = true; \
1408 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \ 1415 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \
1409 byte val1 = 0; \ 1416 byte val1 = 0; \
1410 byte val2 = 1; \ 1417 byte val2 = 1; \
1411 byte src1 = r.AllocateLocal(kWasmS128); \ 1418 byte src1 = r.AllocateLocal(kWasmS128); \
1412 byte src2 = r.AllocateLocal(kWasmS128); \ 1419 byte src2 = r.AllocateLocal(kWasmS128); \
(...skipping 16 matching lines...) Expand all
1429 WASM_GET_LOCAL(src1), WASM_GET_LOCAL(src2))), \ 1436 WASM_GET_LOCAL(src1), WASM_GET_LOCAL(src2))), \
1430 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 0), \ 1437 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 0), \
1431 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 1), \ 1438 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 1), \
1432 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 2), \ 1439 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 2), \
1433 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 3), WASM_ONE); \ 1440 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 3), WASM_ONE); \
1434 \ 1441 \
1435 CHECK_EQ(1, r.Call(0x12, 0x34)); \ 1442 CHECK_EQ(1, r.Call(0x12, 0x34)); \
1436 } 1443 }
1437 1444
1438 WASM_SIMD_SELECT_TEST(32x4) 1445 WASM_SIMD_SELECT_TEST(32x4)
1439 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 1446 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS ||
1447 // V8_TARGET_ARCH_MIPS64
1440 1448
1441 #if V8_TARGET_ARCH_ARM 1449 #if V8_TARGET_ARCH_ARM
1442 WASM_SIMD_SELECT_TEST(16x8) 1450 WASM_SIMD_SELECT_TEST(16x8)
1443 WASM_SIMD_SELECT_TEST(8x16) 1451 WASM_SIMD_SELECT_TEST(8x16)
1444 1452
1445 // Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer 1453 // Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer
1446 // result. Use relational ops on numeric vectors to create the boolean vector 1454 // result. Use relational ops on numeric vectors to create the boolean vector
1447 // test inputs. Test inputs with all true, all false, one true, and one false. 1455 // test inputs. Test inputs with all true, all false, one true, and one false.
1448 #define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \ 1456 #define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \
1449 WASM_EXEC_TEST(ReductionTest##lanes) { \ 1457 WASM_EXEC_TEST(ReductionTest##lanes) { \
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 WASM_SIMD_I32x4_EXTRACT_LANE( 1868 WASM_SIMD_I32x4_EXTRACT_LANE(
1861 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); 1869 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO)));
1862 1870
1863 FOR_INT32_INPUTS(i) { 1871 FOR_INT32_INPUTS(i) {
1864 int32_t expected = *i; 1872 int32_t expected = *i;
1865 r.module().WriteMemory(&memory[0], expected); 1873 r.module().WriteMemory(&memory[0], expected);
1866 CHECK_EQ(expected, r.Call()); 1874 CHECK_EQ(expected, r.Call());
1867 } 1875 }
1868 } 1876 }
1869 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 1877 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
OLDNEW
« no previous file with comments | « src/compiler/mips64/instruction-selector-mips64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698