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

Side by Side Diff: test/cctest/wasm/test-signatures.h

Issue 2395743003: [wasm] Move test-signatures.h from test/cctest to test/common (Closed)
Patch Set: Delete old build file entries Created 4 years, 2 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 | « test/cctest/wasm/test-run-wasm-module.cc ('k') | test/cctest/wasm/test-wasm-stack.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 #ifndef TEST_SIGNATURES_H
6 #define TEST_SIGNATURES_H
7
8 #include "src/signature.h"
9 #include "src/wasm/wasm-opcodes.h"
10
11 namespace v8 {
12 namespace internal {
13 namespace wasm {
14
15 typedef Signature<LocalType> FunctionSig;
16
17 // A helper class with many useful signatures in order to simplify tests.
18 class TestSignatures {
19 public:
20 TestSignatures()
21 : sig_i_v(1, 0, kIntTypes4),
22 sig_i_i(1, 1, kIntTypes4),
23 sig_i_ii(1, 2, kIntTypes4),
24 sig_i_iii(1, 3, kIntTypes4),
25 sig_i_f(1, 1, kIntFloatTypes4),
26 sig_i_ff(1, 2, kIntFloatTypes4),
27 sig_i_d(1, 1, kIntDoubleTypes4),
28 sig_i_dd(1, 2, kIntDoubleTypes4),
29 sig_l_v(1, 0, kLongTypes4),
30 sig_l_l(1, 1, kLongTypes4),
31 sig_l_ll(1, 2, kLongTypes4),
32 sig_i_ll(1, 2, kIntLongTypes4),
33 sig_f_f(1, 1, kFloatTypes4),
34 sig_f_ff(1, 2, kFloatTypes4),
35 sig_d_d(1, 1, kDoubleTypes4),
36 sig_d_dd(1, 2, kDoubleTypes4),
37 sig_v_v(0, 0, kIntTypes4),
38 sig_v_i(0, 1, kIntTypes4),
39 sig_v_ii(0, 2, kIntTypes4),
40 sig_v_iii(0, 3, kIntTypes4),
41 sig_s_i(1, 1, kSimd128IntTypes4) {
42 // I used C++ and you won't believe what happened next....
43 for (int i = 0; i < 4; i++) kIntTypes4[i] = kAstI32;
44 for (int i = 0; i < 4; i++) kLongTypes4[i] = kAstI64;
45 for (int i = 0; i < 4; i++) kFloatTypes4[i] = kAstF32;
46 for (int i = 0; i < 4; i++) kDoubleTypes4[i] = kAstF64;
47 for (int i = 0; i < 4; i++) kIntLongTypes4[i] = kAstI64;
48 for (int i = 0; i < 4; i++) kIntFloatTypes4[i] = kAstF32;
49 for (int i = 0; i < 4; i++) kIntDoubleTypes4[i] = kAstF64;
50 for (int i = 0; i < 4; i++) kSimd128IntTypes4[i] = kAstS128;
51 kIntLongTypes4[0] = kAstI32;
52 kIntFloatTypes4[0] = kAstI32;
53 kIntDoubleTypes4[0] = kAstI32;
54 kSimd128IntTypes4[1] = kAstI32;
55 }
56
57 FunctionSig* i_v() { return &sig_i_v; }
58 FunctionSig* i_i() { return &sig_i_i; }
59 FunctionSig* i_ii() { return &sig_i_ii; }
60 FunctionSig* i_iii() { return &sig_i_iii; }
61
62 FunctionSig* i_f() { return &sig_i_f; }
63 FunctionSig* i_ff() { return &sig_i_ff; }
64 FunctionSig* i_d() { return &sig_i_d; }
65 FunctionSig* i_dd() { return &sig_i_dd; }
66
67 FunctionSig* l_v() { return &sig_l_v; }
68 FunctionSig* l_l() { return &sig_l_l; }
69 FunctionSig* l_ll() { return &sig_l_ll; }
70 FunctionSig* i_ll() { return &sig_i_ll; }
71
72 FunctionSig* f_f() { return &sig_f_f; }
73 FunctionSig* f_ff() { return &sig_f_ff; }
74 FunctionSig* d_d() { return &sig_d_d; }
75 FunctionSig* d_dd() { return &sig_d_dd; }
76
77 FunctionSig* v_v() { return &sig_v_v; }
78 FunctionSig* v_i() { return &sig_v_i; }
79 FunctionSig* v_ii() { return &sig_v_ii; }
80 FunctionSig* v_iii() { return &sig_v_iii; }
81 FunctionSig* s_i() { return &sig_s_i; }
82
83 FunctionSig* many(Zone* zone, LocalType ret, LocalType param, int count) {
84 FunctionSig::Builder builder(zone, ret == kAstStmt ? 0 : 1, count);
85 if (ret != kAstStmt) builder.AddReturn(ret);
86 for (int i = 0; i < count; i++) {
87 builder.AddParam(param);
88 }
89 return builder.Build();
90 }
91
92 private:
93 LocalType kIntTypes4[4];
94 LocalType kLongTypes4[4];
95 LocalType kFloatTypes4[4];
96 LocalType kDoubleTypes4[4];
97 LocalType kIntLongTypes4[4];
98 LocalType kIntFloatTypes4[4];
99 LocalType kIntDoubleTypes4[4];
100 LocalType kSimd128IntTypes4[4];
101
102 FunctionSig sig_i_v;
103 FunctionSig sig_i_i;
104 FunctionSig sig_i_ii;
105 FunctionSig sig_i_iii;
106
107 FunctionSig sig_i_f;
108 FunctionSig sig_i_ff;
109 FunctionSig sig_i_d;
110 FunctionSig sig_i_dd;
111
112 FunctionSig sig_l_v;
113 FunctionSig sig_l_l;
114 FunctionSig sig_l_ll;
115 FunctionSig sig_i_ll;
116
117 FunctionSig sig_f_f;
118 FunctionSig sig_f_ff;
119 FunctionSig sig_d_d;
120 FunctionSig sig_d_dd;
121
122 FunctionSig sig_v_v;
123 FunctionSig sig_v_i;
124 FunctionSig sig_v_ii;
125 FunctionSig sig_v_iii;
126 FunctionSig sig_s_i;
127 };
128 } // namespace wasm
129 } // namespace internal
130 } // namespace v8
131
132 #endif // TEST_SIGNATURES_H
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm-module.cc ('k') | test/cctest/wasm/test-wasm-stack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698