OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "src/wasm/wasm-macro-gen.h" | |
6 #include "src/wasm/wasm-module.h" | |
7 | |
8 #include "test/cctest/cctest.h" | |
9 #include "test/cctest/wasm/test-run-wasm-module-helper.h" | |
10 #include "test/cctest/wasm/test-signatures.h" | |
11 | |
12 using namespace v8::base; | |
13 using namespace v8::internal; | |
14 using namespace v8::internal::compiler; | |
15 using namespace v8::internal::wasm; | |
16 | |
17 namespace { | |
18 void SimpleTest(byte* code, uint32_t size, int32_t result) { | |
19 FLAG_wasm_simd_prototype = true; | |
20 TestSignatures sigs; | |
21 v8::base::AccountingAllocator allocator; | |
22 Zone zone(&allocator); | |
23 | |
24 WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone); | |
25 uint16_t f_index = builder->AddFunction(); | |
26 WasmFunctionBuilder* f = builder->FunctionAt(f_index); | |
27 f->SetSignature(sigs.i_v()); | |
28 TestRunWasmModuleHelper::ExportAsMain(f); | |
29 f->EmitCode(code, size); | |
30 TestRunWasmModuleHelper::TestModule(&zone, builder, result); | |
31 } | |
32 } // namespace | |
33 | |
34 TEST(Simd_I32x4_Splat) { | |
gdeepti
2016/08/30 17:16:06
WASM_EXEC_TEST here could work here too if you wan
aseemgarg
2016/10/10 17:35:17
Done.
| |
35 byte code[] = {WASM_SIMD_I32x4_EXTRACT_LANE( | |
36 WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)), WASM_I8(0))}; | |
37 SimpleTest(code, sizeof(code), 5); | |
38 } | |
39 | |
40 TEST(Simd_I32x4_Add) { | |
41 byte code[] = {WASM_SIMD_I32x4_EXTRACT_LANE( | |
42 WASM_SIMD_I32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(5)), | |
43 WASM_SIMD_I32x4_SPLAT(WASM_I32V(6))), | |
44 WASM_I8(0))}; | |
45 SimpleTest(code, sizeof(code), 11); | |
46 } | |
47 | |
48 TEST(Simd_F32x4_Splat) { | |
49 byte code[] = {WASM_IF_ELSE( | |
50 WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( | |
51 WASM_SIMD_F32x4_SPLAT(WASM_F32(9.5)), WASM_I32V(0)), | |
52 WASM_F32(9.5)), | |
53 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; | |
54 SimpleTest(code, sizeof(code), 1); | |
55 } | |
56 | |
57 TEST(Simd_F32x4_Add) { | |
58 byte code[] = {WASM_IF_ELSE( | |
59 WASM_F32_EQ( | |
60 WASM_SIMD_F32x4_EXTRACT_LANE( | |
61 WASM_SIMD_F32x4_ADD(WASM_SIMD_F32x4_SPLAT(WASM_F32(13.25)), | |
62 WASM_SIMD_F32x4_SPLAT(WASM_F32(6.25))), | |
63 WASM_I8(0)), | |
64 WASM_F32(19.5)), | |
65 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; | |
66 SimpleTest(code, sizeof(code), 1); | |
67 } | |
68 | |
69 TEST(Simd_I32x4_Extract_With_F32x4) { | |
70 byte code[] = {WASM_IF_ELSE( | |
71 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( | |
72 WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5)), WASM_I32V(0)), | |
73 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))), | |
74 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; | |
75 SimpleTest(code, sizeof(code), 1); | |
76 } | |
77 | |
78 TEST(Simd_F32x4_Extract_With_I32x4) { | |
79 byte code[] = {WASM_IF_ELSE( | |
80 WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( | |
81 WASM_SIMD_I32x4_SPLAT(WASM_I32V(15)), WASM_I32V(0)), | |
82 WASM_F32_REINTERPRET_I32(WASM_I32V(15))), | |
83 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; | |
84 SimpleTest(code, sizeof(code), 1); | |
85 } | |
86 | |
87 TEST(Simd_F32x4_Add_With_I32x4) { | |
88 byte code[] = {WASM_IF_ELSE( | |
89 WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( | |
90 WASM_SIMD_F32x4_ADD(WASM_SIMD_I32x4_SPLAT(WASM_I32V(32)), | |
91 WASM_SIMD_I32x4_SPLAT(WASM_I32V(19))), | |
92 WASM_I8(0)), | |
93 WASM_F32_ADD(WASM_F32_REINTERPRET_I32(WASM_I32V(32)), | |
94 WASM_F32_REINTERPRET_I32(WASM_I32V(19)))), | |
95 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; | |
96 SimpleTest(code, sizeof(code), 1); | |
97 } | |
98 | |
99 TEST(Simd_I32x4_Add_With_F32x4) { | |
100 byte code[] = {WASM_IF_ELSE( | |
101 WASM_I32_EQ( | |
102 WASM_SIMD_I32x4_EXTRACT_LANE( | |
103 WASM_SIMD_I32x4_ADD(WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25)), | |
104 WASM_SIMD_F32x4_SPLAT(WASM_F32(31.5))), | |
105 WASM_I8(0)), | |
106 WASM_I32_ADD(WASM_I32_REINTERPRET_F32(WASM_F32(21.25)), | |
107 WASM_I32_REINTERPRET_F32(WASM_F32(31.5)))), | |
108 WASM_RETURN1(WASM_I32V(1)), WASM_RETURN1(WASM_I32V(0)))}; | |
109 SimpleTest(code, sizeof(code), 1); | |
bradnelson
2016/08/31 22:42:08
I assume you'll want tests with loops + conditions
aseemgarg
2016/10/10 17:35:17
yes. Will do in next change.
| |
110 } | |
OLD | NEW |