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

Side by Side Diff: test/cctest/compiler/test-run-calls-to-external-references.cc

Issue 1738623003: [wasm] Int64Lowering of FXXXConvertI64 instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase. Created 4 years, 9 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/cctest.gyp ('k') | test/cctest/compiler/test-run-machops.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 2014 the V8 project authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 #include "test/cctest/cctest.h"
6 #include "test/cctest/compiler/codegen-tester.h"
7 #include "test/cctest/compiler/value-helper.h"
8
9 namespace v8 {
10 namespace internal {
11 namespace compiler {
12
13 template <typename T>
14 void TestExternalReferenceRoundingFunction(
15 BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref,
16 T (*comparison)(T)) {
17 T parameter;
18
19 Node* function = m->ExternalConstant(ref);
20 m->CallCFunction1(MachineType::Pointer(), MachineType::Pointer(), function,
21 m->PointerConstant(&parameter));
22 m->Return(m->Int32Constant(4356));
23 FOR_FLOAT64_INPUTS(i) {
24 parameter = *i;
25 m->Call();
26 CheckDoubleEq(comparison(*i), parameter);
27 }
28 }
29
30 TEST(RunCallF32Trunc) {
31 BufferedRawMachineAssemblerTester<int32_t> m;
32 ExternalReference ref = ExternalReference::wasm_f32_trunc(m.isolate());
33 TestExternalReferenceRoundingFunction<float>(&m, ref, truncf);
34 }
35
36 TEST(RunCallF32Floor) {
37 BufferedRawMachineAssemblerTester<int32_t> m;
38 ExternalReference ref = ExternalReference::wasm_f32_floor(m.isolate());
39 TestExternalReferenceRoundingFunction<float>(&m, ref, floorf);
40 }
41
42 TEST(RunCallF32Ceil) {
43 BufferedRawMachineAssemblerTester<int32_t> m;
44 ExternalReference ref = ExternalReference::wasm_f32_ceil(m.isolate());
45 TestExternalReferenceRoundingFunction<float>(&m, ref, ceilf);
46 }
47
48 TEST(RunCallF32RoundTiesEven) {
49 BufferedRawMachineAssemblerTester<int32_t> m;
50 ExternalReference ref = ExternalReference::wasm_f32_nearest_int(m.isolate());
51 TestExternalReferenceRoundingFunction<float>(&m, ref, nearbyintf);
52 }
53
54 TEST(RunCallF64Trunc) {
55 BufferedRawMachineAssemblerTester<int32_t> m;
56 ExternalReference ref = ExternalReference::wasm_f64_trunc(m.isolate());
57 TestExternalReferenceRoundingFunction<double>(&m, ref, trunc);
58 }
59
60 TEST(RunCallF64Floor) {
61 BufferedRawMachineAssemblerTester<int32_t> m;
62 ExternalReference ref = ExternalReference::wasm_f64_floor(m.isolate());
63 TestExternalReferenceRoundingFunction<double>(&m, ref, floor);
64 }
65
66 TEST(RunCallF64Ceil) {
67 BufferedRawMachineAssemblerTester<int32_t> m;
68 ExternalReference ref = ExternalReference::wasm_f64_ceil(m.isolate());
69 TestExternalReferenceRoundingFunction<double>(&m, ref, ceil);
70 }
71
72 TEST(RunCallF64RoundTiesEven) {
73 BufferedRawMachineAssemblerTester<int32_t> m;
74 ExternalReference ref = ExternalReference::wasm_f64_nearest_int(m.isolate());
75 TestExternalReferenceRoundingFunction<double>(&m, ref, nearbyint);
76 }
77
78 TEST(RunCallInt64ToFloat32) {
79 BufferedRawMachineAssemblerTester<int32_t> m;
80 ExternalReference ref = ExternalReference::wasm_int64_to_float32(m.isolate());
81
82 int64_t input;
83 float output;
84
85 Node* function = m.ExternalConstant(ref);
86 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
87 MachineType::Pointer(), function, m.PointerConstant(&input),
88 m.PointerConstant(&output));
89 m.Return(m.Int32Constant(4356));
90 FOR_INT64_INPUTS(i) {
91 input = *i;
92 m.Call();
93 CheckFloatEq(static_cast<float>(*i), output);
94 }
95 }
96
97 TEST(RunCallUint64ToFloat32) {
98 struct {
99 uint64_t input;
100 uint32_t expected;
101 } values[] = {{0x0, 0x0},
102 {0x1, 0x3f800000},
103 {0xffffffff, 0x4f800000},
104 {0x1b09788b, 0x4dd84bc4},
105 {0x4c5fce8, 0x4c98bf9d},
106 {0xcc0de5bf, 0x4f4c0de6},
107 {0x2, 0x40000000},
108 {0x3, 0x40400000},
109 {0x4, 0x40800000},
110 {0x5, 0x40a00000},
111 {0x8, 0x41000000},
112 {0x9, 0x41100000},
113 {0xffffffffffffffff, 0x5f800000},
114 {0xfffffffffffffffe, 0x5f800000},
115 {0xfffffffffffffffd, 0x5f800000},
116 {0x0, 0x0},
117 {0x100000000, 0x4f800000},
118 {0xffffffff00000000, 0x5f800000},
119 {0x1b09788b00000000, 0x5dd84bc4},
120 {0x4c5fce800000000, 0x5c98bf9d},
121 {0xcc0de5bf00000000, 0x5f4c0de6},
122 {0x200000000, 0x50000000},
123 {0x300000000, 0x50400000},
124 {0x400000000, 0x50800000},
125 {0x500000000, 0x50a00000},
126 {0x800000000, 0x51000000},
127 {0x900000000, 0x51100000},
128 {0x273a798e187937a3, 0x5e1ce9e6},
129 {0xece3af835495a16b, 0x5f6ce3b0},
130 {0xb668ecc11223344, 0x5d3668ed},
131 {0x9e, 0x431e0000},
132 {0x43, 0x42860000},
133 {0xaf73, 0x472f7300},
134 {0x116b, 0x458b5800},
135 {0x658ecc, 0x4acb1d98},
136 {0x2b3b4c, 0x4a2ced30},
137 {0x88776655, 0x4f087766},
138 {0x70000000, 0x4ee00000},
139 {0x7200000, 0x4ce40000},
140 {0x7fffffff, 0x4f000000},
141 {0x56123761, 0x4eac246f},
142 {0x7fffff00, 0x4efffffe},
143 {0x761c4761eeeeeeee, 0x5eec388f},
144 {0x80000000eeeeeeee, 0x5f000000},
145 {0x88888888dddddddd, 0x5f088889},
146 {0xa0000000dddddddd, 0x5f200000},
147 {0xddddddddaaaaaaaa, 0x5f5dddde},
148 {0xe0000000aaaaaaaa, 0x5f600000},
149 {0xeeeeeeeeeeeeeeee, 0x5f6eeeef},
150 {0xfffffffdeeeeeeee, 0x5f800000},
151 {0xf0000000dddddddd, 0x5f700000},
152 {0x7fffffdddddddd, 0x5b000000},
153 {0x3fffffaaaaaaaa, 0x5a7fffff},
154 {0x1fffffaaaaaaaa, 0x59fffffd},
155 {0xfffff, 0x497ffff0},
156 {0x7ffff, 0x48ffffe0},
157 {0x3ffff, 0x487fffc0},
158 {0x1ffff, 0x47ffff80},
159 {0xffff, 0x477fff00},
160 {0x7fff, 0x46fffe00},
161 {0x3fff, 0x467ffc00},
162 {0x1fff, 0x45fff800},
163 {0xfff, 0x457ff000},
164 {0x7ff, 0x44ffe000},
165 {0x3ff, 0x447fc000},
166 {0x1ff, 0x43ff8000},
167 {0x3fffffffffff, 0x56800000},
168 {0x1fffffffffff, 0x56000000},
169 {0xfffffffffff, 0x55800000},
170 {0x7ffffffffff, 0x55000000},
171 {0x3ffffffffff, 0x54800000},
172 {0x1ffffffffff, 0x54000000},
173 {0x8000008000000000, 0x5f000000},
174 {0x8000008000000001, 0x5f000001},
175 {0x8000008000000002, 0x5f000001},
176 {0x8000008000000004, 0x5f000001},
177 {0x8000008000000008, 0x5f000001},
178 {0x8000008000000010, 0x5f000001},
179 {0x8000008000000020, 0x5f000001},
180 {0x8000009000000000, 0x5f000001},
181 {0x800000a000000000, 0x5f000001},
182 {0x8000008000100000, 0x5f000001},
183 {0x8000000000000400, 0x5f000000},
184 {0x8000000000000401, 0x5f000000}};
185
186 BufferedRawMachineAssemblerTester<int32_t> m;
187 ExternalReference ref =
188 ExternalReference::wasm_uint64_to_float32(m.isolate());
189
190 uint64_t input;
191 float output;
192
193 Node* function = m.ExternalConstant(ref);
194 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
195 MachineType::Pointer(), function, m.PointerConstant(&input),
196 m.PointerConstant(&output));
197 m.Return(m.Int32Constant(4356));
198
199 for (size_t i = 0; i < arraysize(values); i++) {
200 input = values[i].input;
201 m.Call();
202 CHECK_EQ(values[i].expected, bit_cast<uint32_t>(output));
203 }
204 }
205
206 TEST(RunCallInt64ToFloat64) {
207 BufferedRawMachineAssemblerTester<int32_t> m;
208 ExternalReference ref = ExternalReference::wasm_int64_to_float64(m.isolate());
209
210 int64_t input;
211 double output;
212
213 Node* function = m.ExternalConstant(ref);
214 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
215 MachineType::Pointer(), function, m.PointerConstant(&input),
216 m.PointerConstant(&output));
217 m.Return(m.Int32Constant(4356));
218 FOR_INT64_INPUTS(i) {
219 input = *i;
220 m.Call();
221 CheckDoubleEq(static_cast<double>(*i), output);
222 }
223 }
224
225 TEST(RunCallUint64ToFloat64) {
226 struct {
227 uint64_t input;
228 uint64_t expected;
229 } values[] = {{0x0, 0x0},
230 {0x1, 0x3ff0000000000000},
231 {0xffffffff, 0x41efffffffe00000},
232 {0x1b09788b, 0x41bb09788b000000},
233 {0x4c5fce8, 0x419317f3a0000000},
234 {0xcc0de5bf, 0x41e981bcb7e00000},
235 {0x2, 0x4000000000000000},
236 {0x3, 0x4008000000000000},
237 {0x4, 0x4010000000000000},
238 {0x5, 0x4014000000000000},
239 {0x8, 0x4020000000000000},
240 {0x9, 0x4022000000000000},
241 {0xffffffffffffffff, 0x43f0000000000000},
242 {0xfffffffffffffffe, 0x43f0000000000000},
243 {0xfffffffffffffffd, 0x43f0000000000000},
244 {0x100000000, 0x41f0000000000000},
245 {0xffffffff00000000, 0x43efffffffe00000},
246 {0x1b09788b00000000, 0x43bb09788b000000},
247 {0x4c5fce800000000, 0x439317f3a0000000},
248 {0xcc0de5bf00000000, 0x43e981bcb7e00000},
249 {0x200000000, 0x4200000000000000},
250 {0x300000000, 0x4208000000000000},
251 {0x400000000, 0x4210000000000000},
252 {0x500000000, 0x4214000000000000},
253 {0x800000000, 0x4220000000000000},
254 {0x900000000, 0x4222000000000000},
255 {0x273a798e187937a3, 0x43c39d3cc70c3c9c},
256 {0xece3af835495a16b, 0x43ed9c75f06a92b4},
257 {0xb668ecc11223344, 0x43a6cd1d98224467},
258 {0x9e, 0x4063c00000000000},
259 {0x43, 0x4050c00000000000},
260 {0xaf73, 0x40e5ee6000000000},
261 {0x116b, 0x40b16b0000000000},
262 {0x658ecc, 0x415963b300000000},
263 {0x2b3b4c, 0x41459da600000000},
264 {0x88776655, 0x41e10eeccaa00000},
265 {0x70000000, 0x41dc000000000000},
266 {0x7200000, 0x419c800000000000},
267 {0x7fffffff, 0x41dfffffffc00000},
268 {0x56123761, 0x41d5848dd8400000},
269 {0x7fffff00, 0x41dfffffc0000000},
270 {0x761c4761eeeeeeee, 0x43dd8711d87bbbbc},
271 {0x80000000eeeeeeee, 0x43e00000001dddde},
272 {0x88888888dddddddd, 0x43e11111111bbbbc},
273 {0xa0000000dddddddd, 0x43e40000001bbbbc},
274 {0xddddddddaaaaaaaa, 0x43ebbbbbbbb55555},
275 {0xe0000000aaaaaaaa, 0x43ec000000155555},
276 {0xeeeeeeeeeeeeeeee, 0x43edddddddddddde},
277 {0xfffffffdeeeeeeee, 0x43efffffffbdddde},
278 {0xf0000000dddddddd, 0x43ee0000001bbbbc},
279 {0x7fffffdddddddd, 0x435ffffff7777777},
280 {0x3fffffaaaaaaaa, 0x434fffffd5555555},
281 {0x1fffffaaaaaaaa, 0x433fffffaaaaaaaa},
282 {0xfffff, 0x412ffffe00000000},
283 {0x7ffff, 0x411ffffc00000000},
284 {0x3ffff, 0x410ffff800000000},
285 {0x1ffff, 0x40fffff000000000},
286 {0xffff, 0x40efffe000000000},
287 {0x7fff, 0x40dfffc000000000},
288 {0x3fff, 0x40cfff8000000000},
289 {0x1fff, 0x40bfff0000000000},
290 {0xfff, 0x40affe0000000000},
291 {0x7ff, 0x409ffc0000000000},
292 {0x3ff, 0x408ff80000000000},
293 {0x1ff, 0x407ff00000000000},
294 {0x3fffffffffff, 0x42cfffffffffff80},
295 {0x1fffffffffff, 0x42bfffffffffff00},
296 {0xfffffffffff, 0x42affffffffffe00},
297 {0x7ffffffffff, 0x429ffffffffffc00},
298 {0x3ffffffffff, 0x428ffffffffff800},
299 {0x1ffffffffff, 0x427ffffffffff000},
300 {0x8000008000000000, 0x43e0000010000000},
301 {0x8000008000000001, 0x43e0000010000000},
302 {0x8000000000000400, 0x43e0000000000000},
303 {0x8000000000000401, 0x43e0000000000001},
304 {0x8000000000000402, 0x43e0000000000001},
305 {0x8000000000000404, 0x43e0000000000001},
306 {0x8000000000000408, 0x43e0000000000001},
307 {0x8000000000000410, 0x43e0000000000001},
308 {0x8000000000000420, 0x43e0000000000001},
309 {0x8000000000000440, 0x43e0000000000001},
310 {0x8000000000000480, 0x43e0000000000001},
311 {0x8000000000000500, 0x43e0000000000001},
312 {0x8000000000000600, 0x43e0000000000001}};
313
314 BufferedRawMachineAssemblerTester<int32_t> m;
315 ExternalReference ref =
316 ExternalReference::wasm_uint64_to_float64(m.isolate());
317
318 uint64_t input;
319 double output;
320
321 Node* function = m.ExternalConstant(ref);
322 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
323 MachineType::Pointer(), function, m.PointerConstant(&input),
324 m.PointerConstant(&output));
325 m.Return(m.Int32Constant(4356));
326
327 for (size_t i = 0; i < arraysize(values); i++) {
328 input = values[i].input;
329 m.Call();
330 CHECK_EQ(values[i].expected, bit_cast<uint64_t>(output));
331 }
332 }
333
334 } // namespace compiler
335 } // namespace internal
336 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/compiler/test-run-machops.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698