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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 1513543003: [turbofan] Make MachineType a pair of enums. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moar rebase Created 5 years 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this 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 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 12 matching lines...) Expand all
23 23
24 TEST(RunInt32Add) { 24 TEST(RunInt32Add) {
25 RawMachineAssemblerTester<int32_t> m; 25 RawMachineAssemblerTester<int32_t> m;
26 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); 26 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1));
27 m.Return(add); 27 m.Return(add);
28 CHECK_EQ(1, m.Call()); 28 CHECK_EQ(1, m.Call());
29 } 29 }
30 30
31 31
32 TEST(RunWord32Ctz) { 32 TEST(RunWord32Ctz) {
33 BufferedRawMachineAssemblerTester<int32_t> m(kMachUint32); 33 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
34 if (!m.machine()->Word32Ctz().IsSupported()) { 34 if (!m.machine()->Word32Ctz().IsSupported()) {
35 // We can only test the operator if it exists on the testing platform. 35 // We can only test the operator if it exists on the testing platform.
36 return; 36 return;
37 } 37 }
38 m.Return(m.AddNode(m.machine()->Word32Ctz().op(), m.Parameter(0))); 38 m.Return(m.AddNode(m.machine()->Word32Ctz().op(), m.Parameter(0)));
39 39
40 CHECK_EQ(32, m.Call(uint32_t(0x00000000))); 40 CHECK_EQ(32, m.Call(uint32_t(0x00000000)));
41 CHECK_EQ(31, m.Call(uint32_t(0x80000000))); 41 CHECK_EQ(31, m.Call(uint32_t(0x80000000)));
42 CHECK_EQ(30, m.Call(uint32_t(0x40000000))); 42 CHECK_EQ(30, m.Call(uint32_t(0x40000000)));
43 CHECK_EQ(29, m.Call(uint32_t(0x20000000))); 43 CHECK_EQ(29, m.Call(uint32_t(0x20000000)));
(...skipping 23 matching lines...) Expand all
67 CHECK_EQ(5, m.Call(uint32_t(0xde3bcb20))); 67 CHECK_EQ(5, m.Call(uint32_t(0xde3bcb20)));
68 CHECK_EQ(4, m.Call(uint32_t(0xd7e8a610))); 68 CHECK_EQ(4, m.Call(uint32_t(0xd7e8a610)));
69 CHECK_EQ(3, m.Call(uint32_t(0x9afdbc88))); 69 CHECK_EQ(3, m.Call(uint32_t(0x9afdbc88)));
70 CHECK_EQ(2, m.Call(uint32_t(0x9afdbc84))); 70 CHECK_EQ(2, m.Call(uint32_t(0x9afdbc84)));
71 CHECK_EQ(1, m.Call(uint32_t(0x9afdbc82))); 71 CHECK_EQ(1, m.Call(uint32_t(0x9afdbc82)));
72 CHECK_EQ(0, m.Call(uint32_t(0x9afdbc81))); 72 CHECK_EQ(0, m.Call(uint32_t(0x9afdbc81)));
73 } 73 }
74 74
75 75
76 TEST(RunWord32Clz) { 76 TEST(RunWord32Clz) {
77 BufferedRawMachineAssemblerTester<int32_t> m(kMachUint32); 77 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
78 m.Return(m.Word32Clz(m.Parameter(0))); 78 m.Return(m.Word32Clz(m.Parameter(0)));
79 79
80 CHECK_EQ(0, m.Call(uint32_t(0x80001000))); 80 CHECK_EQ(0, m.Call(uint32_t(0x80001000)));
81 CHECK_EQ(1, m.Call(uint32_t(0x40000500))); 81 CHECK_EQ(1, m.Call(uint32_t(0x40000500)));
82 CHECK_EQ(2, m.Call(uint32_t(0x20000300))); 82 CHECK_EQ(2, m.Call(uint32_t(0x20000300)));
83 CHECK_EQ(3, m.Call(uint32_t(0x10000003))); 83 CHECK_EQ(3, m.Call(uint32_t(0x10000003)));
84 CHECK_EQ(4, m.Call(uint32_t(0x08050000))); 84 CHECK_EQ(4, m.Call(uint32_t(0x08050000)));
85 CHECK_EQ(5, m.Call(uint32_t(0x04006000))); 85 CHECK_EQ(5, m.Call(uint32_t(0x04006000)));
86 CHECK_EQ(6, m.Call(uint32_t(0x02000000))); 86 CHECK_EQ(6, m.Call(uint32_t(0x02000000)));
87 CHECK_EQ(7, m.Call(uint32_t(0x010000a0))); 87 CHECK_EQ(7, m.Call(uint32_t(0x010000a0)));
(...skipping 19 matching lines...) Expand all
107 CHECK_EQ(27, m.Call(uint32_t(0x00000013))); 107 CHECK_EQ(27, m.Call(uint32_t(0x00000013)));
108 CHECK_EQ(28, m.Call(uint32_t(0x00000008))); 108 CHECK_EQ(28, m.Call(uint32_t(0x00000008)));
109 CHECK_EQ(29, m.Call(uint32_t(0x00000004))); 109 CHECK_EQ(29, m.Call(uint32_t(0x00000004)));
110 CHECK_EQ(30, m.Call(uint32_t(0x00000002))); 110 CHECK_EQ(30, m.Call(uint32_t(0x00000002)));
111 CHECK_EQ(31, m.Call(uint32_t(0x00000001))); 111 CHECK_EQ(31, m.Call(uint32_t(0x00000001)));
112 CHECK_EQ(32, m.Call(uint32_t(0x00000000))); 112 CHECK_EQ(32, m.Call(uint32_t(0x00000000)));
113 } 113 }
114 114
115 115
116 TEST(RunWord32Popcnt) { 116 TEST(RunWord32Popcnt) {
117 BufferedRawMachineAssemblerTester<int32_t> m(kMachUint32); 117 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
118 if (!m.machine()->Word32Popcnt().IsSupported()) { 118 if (!m.machine()->Word32Popcnt().IsSupported()) {
119 // We can only test the operator if it exists on the testing platform. 119 // We can only test the operator if it exists on the testing platform.
120 return; 120 return;
121 } 121 }
122 m.Return(m.AddNode(m.machine()->Word32Popcnt().op(), m.Parameter(0))); 122 m.Return(m.AddNode(m.machine()->Word32Popcnt().op(), m.Parameter(0)));
123 123
124 CHECK_EQ(0, m.Call(uint32_t(0x00000000))); 124 CHECK_EQ(0, m.Call(uint32_t(0x00000000)));
125 CHECK_EQ(1, m.Call(uint32_t(0x00000001))); 125 CHECK_EQ(1, m.Call(uint32_t(0x00000001)));
126 CHECK_EQ(1, m.Call(uint32_t(0x80000000))); 126 CHECK_EQ(1, m.Call(uint32_t(0x80000000)));
127 CHECK_EQ(32, m.Call(uint32_t(0xffffffff))); 127 CHECK_EQ(32, m.Call(uint32_t(0xffffffff)));
128 CHECK_EQ(6, m.Call(uint32_t(0x000dc100))); 128 CHECK_EQ(6, m.Call(uint32_t(0x000dc100)));
129 CHECK_EQ(9, m.Call(uint32_t(0xe00dc100))); 129 CHECK_EQ(9, m.Call(uint32_t(0xe00dc100)));
130 CHECK_EQ(11, m.Call(uint32_t(0xe00dc103))); 130 CHECK_EQ(11, m.Call(uint32_t(0xe00dc103)));
131 CHECK_EQ(9, m.Call(uint32_t(0x000dc107))); 131 CHECK_EQ(9, m.Call(uint32_t(0x000dc107)));
132 } 132 }
133 133
134 134
135 #if V8_TARGET_ARCH_64_BIT 135 #if V8_TARGET_ARCH_64_BIT
136 TEST(RunWord64Clz) { 136 TEST(RunWord64Clz) {
137 BufferedRawMachineAssemblerTester<int32_t> m(kMachUint64); 137 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint64());
138 m.Return(m.Word64Clz(m.Parameter(0))); 138 m.Return(m.Word64Clz(m.Parameter(0)));
139 139
140 CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000))); 140 CHECK_EQ(0, m.Call(uint64_t(0x8000100000000000)));
141 CHECK_EQ(1, m.Call(uint64_t(0x4000050000000000))); 141 CHECK_EQ(1, m.Call(uint64_t(0x4000050000000000)));
142 CHECK_EQ(2, m.Call(uint64_t(0x2000030000000000))); 142 CHECK_EQ(2, m.Call(uint64_t(0x2000030000000000)));
143 CHECK_EQ(3, m.Call(uint64_t(0x1000000300000000))); 143 CHECK_EQ(3, m.Call(uint64_t(0x1000000300000000)));
144 CHECK_EQ(4, m.Call(uint64_t(0x0805000000000000))); 144 CHECK_EQ(4, m.Call(uint64_t(0x0805000000000000)));
145 CHECK_EQ(5, m.Call(uint64_t(0x0400600000000000))); 145 CHECK_EQ(5, m.Call(uint64_t(0x0400600000000000)));
146 CHECK_EQ(6, m.Call(uint64_t(0x0200000000000000))); 146 CHECK_EQ(6, m.Call(uint64_t(0x0200000000000000)));
147 CHECK_EQ(7, m.Call(uint64_t(0x010000a000000000))); 147 CHECK_EQ(7, m.Call(uint64_t(0x010000a000000000)));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 CHECK_EQ(59, m.Call(uint64_t(0x0000000000000013))); 199 CHECK_EQ(59, m.Call(uint64_t(0x0000000000000013)));
200 CHECK_EQ(60, m.Call(uint64_t(0x0000000000000008))); 200 CHECK_EQ(60, m.Call(uint64_t(0x0000000000000008)));
201 CHECK_EQ(61, m.Call(uint64_t(0x0000000000000004))); 201 CHECK_EQ(61, m.Call(uint64_t(0x0000000000000004)));
202 CHECK_EQ(62, m.Call(uint64_t(0x0000000000000002))); 202 CHECK_EQ(62, m.Call(uint64_t(0x0000000000000002)));
203 CHECK_EQ(63, m.Call(uint64_t(0x0000000000000001))); 203 CHECK_EQ(63, m.Call(uint64_t(0x0000000000000001)));
204 CHECK_EQ(64, m.Call(uint64_t(0x0000000000000000))); 204 CHECK_EQ(64, m.Call(uint64_t(0x0000000000000000)));
205 } 205 }
206 206
207 207
208 TEST(RunWord64Ctz) { 208 TEST(RunWord64Ctz) {
209 RawMachineAssemblerTester<int32_t> m(kMachUint64); 209 RawMachineAssemblerTester<int32_t> m(MachineType::Uint64());
210 if (!m.machine()->Word64Ctz().IsSupported()) { 210 if (!m.machine()->Word64Ctz().IsSupported()) {
211 return; 211 return;
212 } 212 }
213 213
214 m.Return(m.AddNode(m.machine()->Word64Ctz().op(), m.Parameter(0))); 214 m.Return(m.AddNode(m.machine()->Word64Ctz().op(), m.Parameter(0)));
215 215
216 CHECK_EQ(64, m.Call(uint64_t(0x0000000000000000))); 216 CHECK_EQ(64, m.Call(uint64_t(0x0000000000000000)));
217 CHECK_EQ(63, m.Call(uint64_t(0x8000000000000000))); 217 CHECK_EQ(63, m.Call(uint64_t(0x8000000000000000)));
218 CHECK_EQ(62, m.Call(uint64_t(0x4000000000000000))); 218 CHECK_EQ(62, m.Call(uint64_t(0x4000000000000000)));
219 CHECK_EQ(61, m.Call(uint64_t(0x2000000000000000))); 219 CHECK_EQ(61, m.Call(uint64_t(0x2000000000000000)));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 CHECK_EQ(5, m.Call(uint64_t(0x00000000de3bcb20))); 275 CHECK_EQ(5, m.Call(uint64_t(0x00000000de3bcb20)));
276 CHECK_EQ(4, m.Call(uint64_t(0x00000000d7e8a610))); 276 CHECK_EQ(4, m.Call(uint64_t(0x00000000d7e8a610)));
277 CHECK_EQ(3, m.Call(uint64_t(0x000000009afdbc88))); 277 CHECK_EQ(3, m.Call(uint64_t(0x000000009afdbc88)));
278 CHECK_EQ(2, m.Call(uint64_t(0x000000009afdbc84))); 278 CHECK_EQ(2, m.Call(uint64_t(0x000000009afdbc84)));
279 CHECK_EQ(1, m.Call(uint64_t(0x000000009afdbc82))); 279 CHECK_EQ(1, m.Call(uint64_t(0x000000009afdbc82)));
280 CHECK_EQ(0, m.Call(uint64_t(0x000000009afdbc81))); 280 CHECK_EQ(0, m.Call(uint64_t(0x000000009afdbc81)));
281 } 281 }
282 282
283 283
284 TEST(RunWord64Popcnt) { 284 TEST(RunWord64Popcnt) {
285 BufferedRawMachineAssemblerTester<int32_t> m(kMachUint64); 285 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint64());
286 if (!m.machine()->Word64Popcnt().IsSupported()) { 286 if (!m.machine()->Word64Popcnt().IsSupported()) {
287 return; 287 return;
288 } 288 }
289 289
290 m.Return(m.AddNode(m.machine()->Word64Popcnt().op(), m.Parameter(0))); 290 m.Return(m.AddNode(m.machine()->Word64Popcnt().op(), m.Parameter(0)));
291 291
292 CHECK_EQ(0, m.Call(uint64_t(0x0000000000000000))); 292 CHECK_EQ(0, m.Call(uint64_t(0x0000000000000000)));
293 CHECK_EQ(1, m.Call(uint64_t(0x0000000000000001))); 293 CHECK_EQ(1, m.Call(uint64_t(0x0000000000000001)));
294 CHECK_EQ(1, m.Call(uint64_t(0x8000000000000000))); 294 CHECK_EQ(1, m.Call(uint64_t(0x8000000000000000)));
295 CHECK_EQ(64, m.Call(uint64_t(0xffffffffffffffff))); 295 CHECK_EQ(64, m.Call(uint64_t(0xffffffffffffffff)));
(...skipping 15 matching lines...) Expand all
311 return m->Int32Constant(0); 311 return m->Int32Constant(0);
312 case 3: 312 case 3:
313 return m->Int32Constant(1); 313 return m->Int32Constant(1);
314 case 4: 314 case 4:
315 return m->Int32Constant(-1); 315 return m->Int32Constant(-1);
316 case 5: 316 case 5:
317 return m->Int32Constant(0xff); 317 return m->Int32Constant(0xff);
318 case 6: 318 case 6:
319 return m->Int32Constant(0x01234567); 319 return m->Int32Constant(0x01234567);
320 case 7: 320 case 7:
321 return m->Load(kMachInt32, m->PointerConstant(NULL)); 321 return m->Load(MachineType::Int32(), m->PointerConstant(NULL));
322 default: 322 default:
323 return NULL; 323 return NULL;
324 } 324 }
325 } 325 }
326 326
327 327
328 TEST(CodeGenInt32Binop) { 328 TEST(CodeGenInt32Binop) {
329 RawMachineAssemblerTester<void> m; 329 RawMachineAssemblerTester<void> m;
330 330
331 const Operator* kOps[] = { 331 const Operator* kOps[] = {
332 m.machine()->Word32And(), m.machine()->Word32Or(), 332 m.machine()->Word32And(), m.machine()->Word32Or(),
333 m.machine()->Word32Xor(), m.machine()->Word32Shl(), 333 m.machine()->Word32Xor(), m.machine()->Word32Shl(),
334 m.machine()->Word32Shr(), m.machine()->Word32Sar(), 334 m.machine()->Word32Shr(), m.machine()->Word32Sar(),
335 m.machine()->Word32Equal(), m.machine()->Int32Add(), 335 m.machine()->Word32Equal(), m.machine()->Int32Add(),
336 m.machine()->Int32Sub(), m.machine()->Int32Mul(), 336 m.machine()->Int32Sub(), m.machine()->Int32Mul(),
337 m.machine()->Int32MulHigh(), m.machine()->Int32Div(), 337 m.machine()->Int32MulHigh(), m.machine()->Int32Div(),
338 m.machine()->Uint32Div(), m.machine()->Int32Mod(), 338 m.machine()->Uint32Div(), m.machine()->Int32Mod(),
339 m.machine()->Uint32Mod(), m.machine()->Uint32MulHigh(), 339 m.machine()->Uint32Mod(), m.machine()->Uint32MulHigh(),
340 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), 340 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(),
341 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual()}; 341 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual()};
342 342
343 for (size_t i = 0; i < arraysize(kOps); ++i) { 343 for (size_t i = 0; i < arraysize(kOps); ++i) {
344 for (int j = 0; j < 8; j++) { 344 for (int j = 0; j < 8; j++) {
345 for (int k = 0; k < 8; k++) { 345 for (int k = 0; k < 8; k++) {
346 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 346 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
347 MachineType::Int32());
347 Node* a = Int32Input(&m, j); 348 Node* a = Int32Input(&m, j);
348 Node* b = Int32Input(&m, k); 349 Node* b = Int32Input(&m, k);
349 m.Return(m.AddNode(kOps[i], a, b)); 350 m.Return(m.AddNode(kOps[i], a, b));
350 m.GenerateCode(); 351 m.GenerateCode();
351 } 352 }
352 } 353 }
353 } 354 }
354 } 355 }
355 356
356 357
(...skipping 15 matching lines...) Expand all
372 return m->Int64Constant(0); 373 return m->Int64Constant(0);
373 case 3: 374 case 3:
374 return m->Int64Constant(1); 375 return m->Int64Constant(1);
375 case 4: 376 case 4:
376 return m->Int64Constant(-1); 377 return m->Int64Constant(-1);
377 case 5: 378 case 5:
378 return m->Int64Constant(0xff); 379 return m->Int64Constant(0xff);
379 case 6: 380 case 6:
380 return m->Int64Constant(0x0123456789abcdefLL); 381 return m->Int64Constant(0x0123456789abcdefLL);
381 case 7: 382 case 7:
382 return m->Load(kMachInt64, m->PointerConstant(NULL)); 383 return m->Load(MachineType::Int64(), m->PointerConstant(NULL));
383 default: 384 default:
384 return NULL; 385 return NULL;
385 } 386 }
386 } 387 }
387 388
388 389
389 TEST(CodeGenInt64Binop) { 390 TEST(CodeGenInt64Binop) {
390 RawMachineAssemblerTester<void> m; 391 RawMachineAssemblerTester<void> m;
391 392
392 const Operator* kOps[] = { 393 const Operator* kOps[] = {
393 m.machine()->Word64And(), m.machine()->Word64Or(), 394 m.machine()->Word64And(), m.machine()->Word64Or(),
394 m.machine()->Word64Xor(), m.machine()->Word64Shl(), 395 m.machine()->Word64Xor(), m.machine()->Word64Shl(),
395 m.machine()->Word64Shr(), m.machine()->Word64Sar(), 396 m.machine()->Word64Shr(), m.machine()->Word64Sar(),
396 m.machine()->Word64Equal(), m.machine()->Int64Add(), 397 m.machine()->Word64Equal(), m.machine()->Int64Add(),
397 m.machine()->Int64Sub(), m.machine()->Int64Mul(), m.machine()->Int64Div(), 398 m.machine()->Int64Sub(), m.machine()->Int64Mul(), m.machine()->Int64Div(),
398 m.machine()->Uint64Div(), m.machine()->Int64Mod(), 399 m.machine()->Uint64Div(), m.machine()->Int64Mod(),
399 m.machine()->Uint64Mod(), m.machine()->Int64LessThan(), 400 m.machine()->Uint64Mod(), m.machine()->Int64LessThan(),
400 m.machine()->Int64LessThanOrEqual(), m.machine()->Uint64LessThan(), 401 m.machine()->Int64LessThanOrEqual(), m.machine()->Uint64LessThan(),
401 m.machine()->Uint64LessThanOrEqual()}; 402 m.machine()->Uint64LessThanOrEqual()};
402 403
403 for (size_t i = 0; i < arraysize(kOps); ++i) { 404 for (size_t i = 0; i < arraysize(kOps); ++i) {
404 for (int j = 0; j < 8; j++) { 405 for (int j = 0; j < 8; j++) {
405 for (int k = 0; k < 8; k++) { 406 for (int k = 0; k < 8; k++) {
406 RawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64); 407 RawMachineAssemblerTester<int64_t> m(MachineType::Int64(),
408 MachineType::Int64());
407 Node* a = Int64Input(&m, j); 409 Node* a = Int64Input(&m, j);
408 Node* b = Int64Input(&m, k); 410 Node* b = Int64Input(&m, k);
409 m.Return(m.AddNode(kOps[i], a, b)); 411 m.Return(m.AddNode(kOps[i], a, b));
410 m.GenerateCode(); 412 m.GenerateCode();
411 } 413 }
412 } 414 }
413 } 415 }
414 } 416 }
415 417
416 418
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 m.Goto(&header); 493 m.Goto(&header);
492 m.Bind(&exit); 494 m.Bind(&exit);
493 m.Return(m.Int32Constant(constant)); 495 m.Return(m.Int32Constant(constant));
494 496
495 CHECK_EQ(constant, m.Call()); 497 CHECK_EQ(constant, m.Call());
496 } 498 }
497 499
498 500
499 template <typename R> 501 template <typename R>
500 static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, 502 static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node,
501 MachineType type, Node* true_node, 503 MachineRepresentation rep, Node* true_node,
502 Node* false_node) { 504 Node* false_node) {
503 RawMachineLabel blocka, blockb, end; 505 RawMachineLabel blocka, blockb, end;
504 m->Branch(cond_node, &blocka, &blockb); 506 m->Branch(cond_node, &blocka, &blockb);
505 m->Bind(&blocka); 507 m->Bind(&blocka);
506 m->Goto(&end); 508 m->Goto(&end);
507 m->Bind(&blockb); 509 m->Bind(&blockb);
508 m->Goto(&end); 510 m->Goto(&end);
509 511
510 m->Bind(&end); 512 m->Bind(&end);
511 Node* phi = m->Phi(type, true_node, false_node); 513 Node* phi = m->Phi(rep, true_node, false_node);
512 m->Return(phi); 514 m->Return(phi);
513 } 515 }
514 516
515 517
516 TEST(RunDiamondPhiConst) { 518 TEST(RunDiamondPhiConst) {
517 RawMachineAssemblerTester<int32_t> m(kMachInt32); 519 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
518 int false_val = 0xFF666; 520 int false_val = 0xFF666;
519 int true_val = 0x00DDD; 521 int true_val = 0x00DDD;
520 Node* true_node = m.Int32Constant(true_val); 522 Node* true_node = m.Int32Constant(true_val);
521 Node* false_node = m.Int32Constant(false_val); 523 Node* false_node = m.Int32Constant(false_val);
522 BuildDiamondPhi(&m, m.Parameter(0), kMachInt32, true_node, false_node); 524 BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kWord32, true_node,
525 false_node);
523 CHECK_EQ(false_val, m.Call(0)); 526 CHECK_EQ(false_val, m.Call(0));
524 CHECK_EQ(true_val, m.Call(1)); 527 CHECK_EQ(true_val, m.Call(1));
525 } 528 }
526 529
527 530
528 TEST(RunDiamondPhiNumber) { 531 TEST(RunDiamondPhiNumber) {
529 RawMachineAssemblerTester<Object*> m(kMachInt32); 532 RawMachineAssemblerTester<Object*> m(MachineType::Int32());
530 double false_val = -11.1; 533 double false_val = -11.1;
531 double true_val = 200.1; 534 double true_val = 200.1;
532 Node* true_node = m.NumberConstant(true_val); 535 Node* true_node = m.NumberConstant(true_val);
533 Node* false_node = m.NumberConstant(false_val); 536 Node* false_node = m.NumberConstant(false_val);
534 BuildDiamondPhi(&m, m.Parameter(0), kMachAnyTagged, true_node, false_node); 537 BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kTagged, true_node,
538 false_node);
535 m.CheckNumber(false_val, m.Call(0)); 539 m.CheckNumber(false_val, m.Call(0));
536 m.CheckNumber(true_val, m.Call(1)); 540 m.CheckNumber(true_val, m.Call(1));
537 } 541 }
538 542
539 543
540 TEST(RunDiamondPhiString) { 544 TEST(RunDiamondPhiString) {
541 RawMachineAssemblerTester<Object*> m(kMachInt32); 545 RawMachineAssemblerTester<Object*> m(MachineType::Int32());
542 const char* false_val = "false"; 546 const char* false_val = "false";
543 const char* true_val = "true"; 547 const char* true_val = "true";
544 Node* true_node = m.StringConstant(true_val); 548 Node* true_node = m.StringConstant(true_val);
545 Node* false_node = m.StringConstant(false_val); 549 Node* false_node = m.StringConstant(false_val);
546 BuildDiamondPhi(&m, m.Parameter(0), kMachAnyTagged, true_node, false_node); 550 BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kTagged, true_node,
551 false_node);
547 m.CheckString(false_val, m.Call(0)); 552 m.CheckString(false_val, m.Call(0));
548 m.CheckString(true_val, m.Call(1)); 553 m.CheckString(true_val, m.Call(1));
549 } 554 }
550 555
551 556
552 TEST(RunDiamondPhiParam) { 557 TEST(RunDiamondPhiParam) {
553 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); 558 RawMachineAssemblerTester<int32_t> m(
554 BuildDiamondPhi(&m, m.Parameter(0), kMachInt32, m.Parameter(1), 559 MachineType::Int32(), MachineType::Int32(), MachineType::Int32());
555 m.Parameter(2)); 560 BuildDiamondPhi(&m, m.Parameter(0), MachineRepresentation::kWord32,
561 m.Parameter(1), m.Parameter(2));
556 int32_t c1 = 0x260cb75a; 562 int32_t c1 = 0x260cb75a;
557 int32_t c2 = 0xcd3e9c8b; 563 int32_t c2 = 0xcd3e9c8b;
558 int result = m.Call(0, c1, c2); 564 int result = m.Call(0, c1, c2);
559 CHECK_EQ(c2, result); 565 CHECK_EQ(c2, result);
560 result = m.Call(1, c1, c2); 566 result = m.Call(1, c1, c2);
561 CHECK_EQ(c1, result); 567 CHECK_EQ(c1, result);
562 } 568 }
563 569
564 570
565 TEST(RunLoopPhiConst) { 571 TEST(RunLoopPhiConst) {
566 RawMachineAssemblerTester<int32_t> m; 572 RawMachineAssemblerTester<int32_t> m;
567 int true_val = 0x44000; 573 int true_val = 0x44000;
568 int false_val = 0x00888; 574 int false_val = 0x00888;
569 575
570 Node* cond_node = m.Int32Constant(0); 576 Node* cond_node = m.Int32Constant(0);
571 Node* true_node = m.Int32Constant(true_val); 577 Node* true_node = m.Int32Constant(true_val);
572 Node* false_node = m.Int32Constant(false_val); 578 Node* false_node = m.Int32Constant(false_val);
573 579
574 // x = false_val; while(false) { x = true_val; } return x; 580 // x = false_val; while(false) { x = true_val; } return x;
575 RawMachineLabel body, header, end; 581 RawMachineLabel body, header, end;
576 582
577 m.Goto(&header); 583 m.Goto(&header);
578 m.Bind(&header); 584 m.Bind(&header);
579 Node* phi = m.Phi(kMachInt32, false_node, true_node); 585 Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, true_node);
580 m.Branch(cond_node, &body, &end); 586 m.Branch(cond_node, &body, &end);
581 m.Bind(&body); 587 m.Bind(&body);
582 m.Goto(&header); 588 m.Goto(&header);
583 m.Bind(&end); 589 m.Bind(&end);
584 m.Return(phi); 590 m.Return(phi);
585 591
586 CHECK_EQ(false_val, m.Call()); 592 CHECK_EQ(false_val, m.Call());
587 } 593 }
588 594
589 595
590 TEST(RunLoopPhiParam) { 596 TEST(RunLoopPhiParam) {
591 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); 597 RawMachineAssemblerTester<int32_t> m(
598 MachineType::Int32(), MachineType::Int32(), MachineType::Int32());
592 599
593 RawMachineLabel blocka, blockb, end; 600 RawMachineLabel blocka, blockb, end;
594 601
595 m.Goto(&blocka); 602 m.Goto(&blocka);
596 603
597 m.Bind(&blocka); 604 m.Bind(&blocka);
598 Node* phi = m.Phi(kMachInt32, m.Parameter(1), m.Parameter(2)); 605 Node* phi =
599 Node* cond = m.Phi(kMachInt32, m.Parameter(0), m.Int32Constant(0)); 606 m.Phi(MachineRepresentation::kWord32, m.Parameter(1), m.Parameter(2));
607 Node* cond =
608 m.Phi(MachineRepresentation::kWord32, m.Parameter(0), m.Int32Constant(0));
600 m.Branch(cond, &blockb, &end); 609 m.Branch(cond, &blockb, &end);
601 610
602 m.Bind(&blockb); 611 m.Bind(&blockb);
603 m.Goto(&blocka); 612 m.Goto(&blocka);
604 613
605 m.Bind(&end); 614 m.Bind(&end);
606 m.Return(phi); 615 m.Return(phi);
607 616
608 int32_t c1 = 0xa81903b4; 617 int32_t c1 = 0xa81903b4;
609 int32_t c2 = 0x5a1207da; 618 int32_t c2 = 0x5a1207da;
610 int result = m.Call(0, c1, c2); 619 int result = m.Call(0, c1, c2);
611 CHECK_EQ(c1, result); 620 CHECK_EQ(c1, result);
612 result = m.Call(1, c1, c2); 621 result = m.Call(1, c1, c2);
613 CHECK_EQ(c2, result); 622 CHECK_EQ(c2, result);
614 } 623 }
615 624
616 625
617 TEST(RunLoopPhiInduction) { 626 TEST(RunLoopPhiInduction) {
618 RawMachineAssemblerTester<int32_t> m; 627 RawMachineAssemblerTester<int32_t> m;
619 628
620 int false_val = 0x10777; 629 int false_val = 0x10777;
621 630
622 // x = false_val; while(false) { x++; } return x; 631 // x = false_val; while(false) { x++; } return x;
623 RawMachineLabel header, body, end; 632 RawMachineLabel header, body, end;
624 Node* false_node = m.Int32Constant(false_val); 633 Node* false_node = m.Int32Constant(false_val);
625 634
626 m.Goto(&header); 635 m.Goto(&header);
627 636
628 m.Bind(&header); 637 m.Bind(&header);
629 Node* phi = m.Phi(kMachInt32, false_node, false_node); 638 Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, false_node);
630 m.Branch(m.Int32Constant(0), &body, &end); 639 m.Branch(m.Int32Constant(0), &body, &end);
631 640
632 m.Bind(&body); 641 m.Bind(&body);
633 Node* add = m.Int32Add(phi, m.Int32Constant(1)); 642 Node* add = m.Int32Add(phi, m.Int32Constant(1));
634 phi->ReplaceInput(1, add); 643 phi->ReplaceInput(1, add);
635 m.Goto(&header); 644 m.Goto(&header);
636 645
637 m.Bind(&end); 646 m.Bind(&end);
638 m.Return(phi); 647 m.Return(phi);
639 648
640 CHECK_EQ(false_val, m.Call()); 649 CHECK_EQ(false_val, m.Call());
641 } 650 }
642 651
643 652
644 TEST(RunLoopIncrement) { 653 TEST(RunLoopIncrement) {
645 RawMachineAssemblerTester<int32_t> m; 654 RawMachineAssemblerTester<int32_t> m;
646 Int32BinopTester bt(&m); 655 Int32BinopTester bt(&m);
647 656
648 // x = 0; while(x ^ param) { x++; } return x; 657 // x = 0; while(x ^ param) { x++; } return x;
649 RawMachineLabel header, body, end; 658 RawMachineLabel header, body, end;
650 Node* zero = m.Int32Constant(0); 659 Node* zero = m.Int32Constant(0);
651 660
652 m.Goto(&header); 661 m.Goto(&header);
653 662
654 m.Bind(&header); 663 m.Bind(&header);
655 Node* phi = m.Phi(kMachInt32, zero, zero); 664 Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero);
656 m.Branch(m.WordXor(phi, bt.param0), &body, &end); 665 m.Branch(m.WordXor(phi, bt.param0), &body, &end);
657 666
658 m.Bind(&body); 667 m.Bind(&body);
659 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); 668 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1)));
660 m.Goto(&header); 669 m.Goto(&header);
661 670
662 m.Bind(&end); 671 m.Bind(&end);
663 bt.AddReturn(phi); 672 bt.AddReturn(phi);
664 673
665 CHECK_EQ(11, bt.call(11, 0)); 674 CHECK_EQ(11, bt.call(11, 0));
666 CHECK_EQ(110, bt.call(110, 0)); 675 CHECK_EQ(110, bt.call(110, 0));
667 CHECK_EQ(176, bt.call(176, 0)); 676 CHECK_EQ(176, bt.call(176, 0));
668 } 677 }
669 678
670 679
671 TEST(RunLoopIncrement2) { 680 TEST(RunLoopIncrement2) {
672 RawMachineAssemblerTester<int32_t> m; 681 RawMachineAssemblerTester<int32_t> m;
673 Int32BinopTester bt(&m); 682 Int32BinopTester bt(&m);
674 683
675 // x = 0; while(x < param) { x++; } return x; 684 // x = 0; while(x < param) { x++; } return x;
676 RawMachineLabel header, body, end; 685 RawMachineLabel header, body, end;
677 Node* zero = m.Int32Constant(0); 686 Node* zero = m.Int32Constant(0);
678 687
679 m.Goto(&header); 688 m.Goto(&header);
680 689
681 m.Bind(&header); 690 m.Bind(&header);
682 Node* phi = m.Phi(kMachInt32, zero, zero); 691 Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero);
683 m.Branch(m.Int32LessThan(phi, bt.param0), &body, &end); 692 m.Branch(m.Int32LessThan(phi, bt.param0), &body, &end);
684 693
685 m.Bind(&body); 694 m.Bind(&body);
686 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); 695 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1)));
687 m.Goto(&header); 696 m.Goto(&header);
688 697
689 m.Bind(&end); 698 m.Bind(&end);
690 bt.AddReturn(phi); 699 bt.AddReturn(phi);
691 700
692 CHECK_EQ(11, bt.call(11, 0)); 701 CHECK_EQ(11, bt.call(11, 0));
693 CHECK_EQ(110, bt.call(110, 0)); 702 CHECK_EQ(110, bt.call(110, 0));
694 CHECK_EQ(176, bt.call(176, 0)); 703 CHECK_EQ(176, bt.call(176, 0));
695 CHECK_EQ(0, bt.call(-200, 0)); 704 CHECK_EQ(0, bt.call(-200, 0));
696 } 705 }
697 706
698 707
699 TEST(RunLoopIncrement3) { 708 TEST(RunLoopIncrement3) {
700 RawMachineAssemblerTester<int32_t> m; 709 RawMachineAssemblerTester<int32_t> m;
701 Int32BinopTester bt(&m); 710 Int32BinopTester bt(&m);
702 711
703 // x = 0; while(x < param) { x++; } return x; 712 // x = 0; while(x < param) { x++; } return x;
704 RawMachineLabel header, body, end; 713 RawMachineLabel header, body, end;
705 Node* zero = m.Int32Constant(0); 714 Node* zero = m.Int32Constant(0);
706 715
707 m.Goto(&header); 716 m.Goto(&header);
708 717
709 m.Bind(&header); 718 m.Bind(&header);
710 Node* phi = m.Phi(kMachInt32, zero, zero); 719 Node* phi = m.Phi(MachineRepresentation::kWord32, zero, zero);
711 m.Branch(m.Uint32LessThan(phi, bt.param0), &body, &end); 720 m.Branch(m.Uint32LessThan(phi, bt.param0), &body, &end);
712 721
713 m.Bind(&body); 722 m.Bind(&body);
714 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); 723 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1)));
715 m.Goto(&header); 724 m.Goto(&header);
716 725
717 m.Bind(&end); 726 m.Bind(&end);
718 bt.AddReturn(phi); 727 bt.AddReturn(phi);
719 728
720 CHECK_EQ(11, bt.call(11, 0)); 729 CHECK_EQ(11, bt.call(11, 0));
721 CHECK_EQ(110, bt.call(110, 0)); 730 CHECK_EQ(110, bt.call(110, 0));
722 CHECK_EQ(176, bt.call(176, 0)); 731 CHECK_EQ(176, bt.call(176, 0));
723 CHECK_EQ(200, bt.call(200, 0)); 732 CHECK_EQ(200, bt.call(200, 0));
724 } 733 }
725 734
726 735
727 TEST(RunLoopDecrement) { 736 TEST(RunLoopDecrement) {
728 RawMachineAssemblerTester<int32_t> m; 737 RawMachineAssemblerTester<int32_t> m;
729 Int32BinopTester bt(&m); 738 Int32BinopTester bt(&m);
730 739
731 // x = param; while(x) { x--; } return x; 740 // x = param; while(x) { x--; } return x;
732 RawMachineLabel header, body, end; 741 RawMachineLabel header, body, end;
733 742
734 m.Goto(&header); 743 m.Goto(&header);
735 744
736 m.Bind(&header); 745 m.Bind(&header);
737 Node* phi = m.Phi(kMachInt32, bt.param0, m.Int32Constant(0)); 746 Node* phi =
747 m.Phi(MachineRepresentation::kWord32, bt.param0, m.Int32Constant(0));
738 m.Branch(phi, &body, &end); 748 m.Branch(phi, &body, &end);
739 749
740 m.Bind(&body); 750 m.Bind(&body);
741 phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1))); 751 phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1)));
742 m.Goto(&header); 752 m.Goto(&header);
743 753
744 m.Bind(&end); 754 m.Bind(&end);
745 bt.AddReturn(phi); 755 bt.AddReturn(phi);
746 756
747 CHECK_EQ(0, bt.call(11, 0)); 757 CHECK_EQ(0, bt.call(11, 0));
748 CHECK_EQ(0, bt.call(110, 0)); 758 CHECK_EQ(0, bt.call(110, 0));
749 CHECK_EQ(0, bt.call(197, 0)); 759 CHECK_EQ(0, bt.call(197, 0));
750 } 760 }
751 761
752 762
753 TEST(RunLoopIncrementFloat32) { 763 TEST(RunLoopIncrementFloat32) {
754 RawMachineAssemblerTester<int32_t> m; 764 RawMachineAssemblerTester<int32_t> m;
755 765
756 // x = -3.0f; while(x < 10f) { x = x + 0.5f; } return (int) (double) x; 766 // x = -3.0f; while(x < 10f) { x = x + 0.5f; } return (int) (double) x;
757 RawMachineLabel header, body, end; 767 RawMachineLabel header, body, end;
758 Node* minus_3 = m.Float32Constant(-3.0f); 768 Node* minus_3 = m.Float32Constant(-3.0f);
759 Node* ten = m.Float32Constant(10.0f); 769 Node* ten = m.Float32Constant(10.0f);
760 770
761 m.Goto(&header); 771 m.Goto(&header);
762 772
763 m.Bind(&header); 773 m.Bind(&header);
764 Node* phi = m.Phi(kMachFloat32, minus_3, ten); 774 Node* phi = m.Phi(MachineRepresentation::kFloat32, minus_3, ten);
765 m.Branch(m.Float32LessThan(phi, ten), &body, &end); 775 m.Branch(m.Float32LessThan(phi, ten), &body, &end);
766 776
767 m.Bind(&body); 777 m.Bind(&body);
768 phi->ReplaceInput(1, m.Float32Add(phi, m.Float32Constant(0.5f))); 778 phi->ReplaceInput(1, m.Float32Add(phi, m.Float32Constant(0.5f)));
769 m.Goto(&header); 779 m.Goto(&header);
770 780
771 m.Bind(&end); 781 m.Bind(&end);
772 m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(phi))); 782 m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(phi)));
773 783
774 CHECK_EQ(10, m.Call()); 784 CHECK_EQ(10, m.Call());
775 } 785 }
776 786
777 787
778 TEST(RunLoopIncrementFloat64) { 788 TEST(RunLoopIncrementFloat64) {
779 RawMachineAssemblerTester<int32_t> m; 789 RawMachineAssemblerTester<int32_t> m;
780 790
781 // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x; 791 // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x;
782 RawMachineLabel header, body, end; 792 RawMachineLabel header, body, end;
783 Node* minus_3 = m.Float64Constant(-3.0); 793 Node* minus_3 = m.Float64Constant(-3.0);
784 Node* ten = m.Float64Constant(10.0); 794 Node* ten = m.Float64Constant(10.0);
785 795
786 m.Goto(&header); 796 m.Goto(&header);
787 797
788 m.Bind(&header); 798 m.Bind(&header);
789 Node* phi = m.Phi(kMachFloat64, minus_3, ten); 799 Node* phi = m.Phi(MachineRepresentation::kFloat64, minus_3, ten);
790 m.Branch(m.Float64LessThan(phi, ten), &body, &end); 800 m.Branch(m.Float64LessThan(phi, ten), &body, &end);
791 801
792 m.Bind(&body); 802 m.Bind(&body);
793 phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5))); 803 phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5)));
794 m.Goto(&header); 804 m.Goto(&header);
795 805
796 m.Bind(&end); 806 m.Bind(&end);
797 m.Return(m.ChangeFloat64ToInt32(phi)); 807 m.Return(m.ChangeFloat64ToInt32(phi));
798 808
799 CHECK_EQ(10, m.Call()); 809 CHECK_EQ(10, m.Call());
(...skipping 17 matching lines...) Expand all
817 m.Bind(&def); 827 m.Bind(&def);
818 m.Goto(&end); 828 m.Goto(&end);
819 m.Bind(&end); 829 m.Bind(&end);
820 m.Return(m.Int32Constant(constant)); 830 m.Return(m.Int32Constant(constant));
821 831
822 CHECK_EQ(constant, m.Call()); 832 CHECK_EQ(constant, m.Call());
823 } 833 }
824 834
825 835
826 TEST(RunSwitch2) { 836 TEST(RunSwitch2) {
827 RawMachineAssemblerTester<int32_t> m(kMachInt32); 837 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
828 838
829 RawMachineLabel blocka, blockb, blockc; 839 RawMachineLabel blocka, blockb, blockc;
830 RawMachineLabel* case_labels[] = {&blocka, &blockb}; 840 RawMachineLabel* case_labels[] = {&blocka, &blockb};
831 int32_t case_values[] = {std::numeric_limits<int32_t>::min(), 841 int32_t case_values[] = {std::numeric_limits<int32_t>::min(),
832 std::numeric_limits<int32_t>::max()}; 842 std::numeric_limits<int32_t>::max()};
833 m.Switch(m.Parameter(0), &blockc, case_values, case_labels, 843 m.Switch(m.Parameter(0), &blockc, case_values, case_labels,
834 arraysize(case_labels)); 844 arraysize(case_labels));
835 m.Bind(&blocka); 845 m.Bind(&blocka);
836 m.Return(m.Int32Constant(-1)); 846 m.Return(m.Int32Constant(-1));
837 m.Bind(&blockb); 847 m.Bind(&blockb);
838 m.Return(m.Int32Constant(1)); 848 m.Return(m.Int32Constant(1));
839 m.Bind(&blockc); 849 m.Bind(&blockc);
840 m.Return(m.Int32Constant(0)); 850 m.Return(m.Int32Constant(0));
841 851
842 CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::max())); 852 CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::max()));
843 CHECK_EQ(-1, m.Call(std::numeric_limits<int32_t>::min())); 853 CHECK_EQ(-1, m.Call(std::numeric_limits<int32_t>::min()));
844 for (int i = -100; i < 100; i += 25) { 854 for (int i = -100; i < 100; i += 25) {
845 CHECK_EQ(0, m.Call(i)); 855 CHECK_EQ(0, m.Call(i));
846 } 856 }
847 } 857 }
848 858
849 859
850 TEST(RunSwitch3) { 860 TEST(RunSwitch3) {
851 RawMachineAssemblerTester<int32_t> m(kMachInt32); 861 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
852 862
853 RawMachineLabel blocka, blockb, blockc; 863 RawMachineLabel blocka, blockb, blockc;
854 RawMachineLabel* case_labels[] = {&blocka, &blockb}; 864 RawMachineLabel* case_labels[] = {&blocka, &blockb};
855 int32_t case_values[] = {std::numeric_limits<int32_t>::min() + 0, 865 int32_t case_values[] = {std::numeric_limits<int32_t>::min() + 0,
856 std::numeric_limits<int32_t>::min() + 1}; 866 std::numeric_limits<int32_t>::min() + 1};
857 m.Switch(m.Parameter(0), &blockc, case_values, case_labels, 867 m.Switch(m.Parameter(0), &blockc, case_values, case_labels,
858 arraysize(case_labels)); 868 arraysize(case_labels));
859 m.Bind(&blocka); 869 m.Bind(&blocka);
860 m.Return(m.Int32Constant(0)); 870 m.Return(m.Int32Constant(0));
861 m.Bind(&blockb); 871 m.Bind(&blockb);
862 m.Return(m.Int32Constant(1)); 872 m.Return(m.Int32Constant(1));
863 m.Bind(&blockc); 873 m.Bind(&blockc);
864 m.Return(m.Int32Constant(2)); 874 m.Return(m.Int32Constant(2));
865 875
866 CHECK_EQ(0, m.Call(std::numeric_limits<int32_t>::min() + 0)); 876 CHECK_EQ(0, m.Call(std::numeric_limits<int32_t>::min() + 0));
867 CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::min() + 1)); 877 CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::min() + 1));
868 for (int i = -100; i < 100; i += 25) { 878 for (int i = -100; i < 100; i += 25) {
869 CHECK_EQ(2, m.Call(i)); 879 CHECK_EQ(2, m.Call(i));
870 } 880 }
871 } 881 }
872 882
873 883
874 TEST(RunSwitch4) { 884 TEST(RunSwitch4) {
875 RawMachineAssemblerTester<int32_t> m(kMachInt32); 885 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
876 886
877 const size_t kNumCases = 512; 887 const size_t kNumCases = 512;
878 const size_t kNumValues = kNumCases + 1; 888 const size_t kNumValues = kNumCases + 1;
879 int32_t values[kNumValues]; 889 int32_t values[kNumValues];
880 m.main_isolate()->random_number_generator()->NextBytes(values, 890 m.main_isolate()->random_number_generator()->NextBytes(values,
881 sizeof(values)); 891 sizeof(values));
882 RawMachineLabel end, def; 892 RawMachineLabel end, def;
883 int32_t case_values[kNumCases]; 893 int32_t case_values[kNumCases];
884 RawMachineLabel* case_labels[kNumCases]; 894 RawMachineLabel* case_labels[kNumCases];
885 Node* results[kNumValues]; 895 Node* results[kNumValues];
886 for (size_t i = 0; i < kNumCases; ++i) { 896 for (size_t i = 0; i < kNumCases; ++i) {
887 case_values[i] = static_cast<int32_t>(i); 897 case_values[i] = static_cast<int32_t>(i);
888 case_labels[i] = 898 case_labels[i] =
889 new (m.main_zone()->New(sizeof(RawMachineLabel))) RawMachineLabel; 899 new (m.main_zone()->New(sizeof(RawMachineLabel))) RawMachineLabel;
890 } 900 }
891 m.Switch(m.Parameter(0), &def, case_values, case_labels, 901 m.Switch(m.Parameter(0), &def, case_values, case_labels,
892 arraysize(case_labels)); 902 arraysize(case_labels));
893 for (size_t i = 0; i < kNumCases; ++i) { 903 for (size_t i = 0; i < kNumCases; ++i) {
894 m.Bind(case_labels[i]); 904 m.Bind(case_labels[i]);
895 results[i] = m.Int32Constant(values[i]); 905 results[i] = m.Int32Constant(values[i]);
896 m.Goto(&end); 906 m.Goto(&end);
897 } 907 }
898 m.Bind(&def); 908 m.Bind(&def);
899 results[kNumCases] = m.Int32Constant(values[kNumCases]); 909 results[kNumCases] = m.Int32Constant(values[kNumCases]);
900 m.Goto(&end); 910 m.Goto(&end);
901 m.Bind(&end); 911 m.Bind(&end);
902 const int num_results = static_cast<int>(arraysize(results)); 912 const int num_results = static_cast<int>(arraysize(results));
903 Node* phi = 913 Node* phi =
904 m.AddNode(m.common()->Phi(kMachInt32, num_results), num_results, results); 914 m.AddNode(m.common()->Phi(MachineRepresentation::kWord32, num_results),
915 num_results, results);
905 m.Return(phi); 916 m.Return(phi);
906 917
907 for (size_t i = 0; i < kNumValues; ++i) { 918 for (size_t i = 0; i < kNumValues; ++i) {
908 CHECK_EQ(values[i], m.Call(static_cast<int>(i))); 919 CHECK_EQ(values[i], m.Call(static_cast<int>(i)));
909 } 920 }
910 } 921 }
911 922
912 923
913 TEST(RunLoadInt32) { 924 TEST(RunLoadInt32) {
914 RawMachineAssemblerTester<int32_t> m; 925 RawMachineAssemblerTester<int32_t> m;
915 926
916 int32_t p1 = 0; // loads directly from this location. 927 int32_t p1 = 0; // loads directly from this location.
917 m.Return(m.LoadFromPointer(&p1, kMachInt32)); 928 m.Return(m.LoadFromPointer(&p1, MachineType::Int32()));
918 929
919 FOR_INT32_INPUTS(i) { 930 FOR_INT32_INPUTS(i) {
920 p1 = *i; 931 p1 = *i;
921 CHECK_EQ(p1, m.Call()); 932 CHECK_EQ(p1, m.Call());
922 } 933 }
923 } 934 }
924 935
925 936
926 TEST(RunLoadInt32Offset) { 937 TEST(RunLoadInt32Offset) {
927 int32_t p1 = 0; // loads directly from this location. 938 int32_t p1 = 0; // loads directly from this location.
928 939
929 int32_t offsets[] = {-2000000, -100, -101, 1, 3, 940 int32_t offsets[] = {-2000000, -100, -101, 1, 3,
930 7, 120, 2000, 2000000000, 0xff}; 941 7, 120, 2000, 2000000000, 0xff};
931 942
932 for (size_t i = 0; i < arraysize(offsets); i++) { 943 for (size_t i = 0; i < arraysize(offsets); i++) {
933 RawMachineAssemblerTester<int32_t> m; 944 RawMachineAssemblerTester<int32_t> m;
934 int32_t offset = offsets[i]; 945 int32_t offset = offsets[i];
935 byte* pointer = reinterpret_cast<byte*>(&p1) - offset; 946 byte* pointer = reinterpret_cast<byte*>(&p1) - offset;
936 // generate load [#base + #index] 947 // generate load [#base + #index]
937 m.Return(m.LoadFromPointer(pointer, kMachInt32, offset)); 948 m.Return(m.LoadFromPointer(pointer, MachineType::Int32(), offset));
938 949
939 FOR_INT32_INPUTS(j) { 950 FOR_INT32_INPUTS(j) {
940 p1 = *j; 951 p1 = *j;
941 CHECK_EQ(p1, m.Call()); 952 CHECK_EQ(p1, m.Call());
942 } 953 }
943 } 954 }
944 } 955 }
945 956
946 957
947 TEST(RunLoadStoreFloat32Offset) { 958 TEST(RunLoadStoreFloat32Offset) {
948 float p1 = 0.0f; // loads directly from this location. 959 float p1 = 0.0f; // loads directly from this location.
949 float p2 = 0.0f; // and stores directly into this location. 960 float p2 = 0.0f; // and stores directly into this location.
950 961
951 FOR_INT32_INPUTS(i) { 962 FOR_INT32_INPUTS(i) {
952 int32_t magic = 0x2342aabb + *i * 3; 963 int32_t magic = 0x2342aabb + *i * 3;
953 RawMachineAssemblerTester<int32_t> m; 964 RawMachineAssemblerTester<int32_t> m;
954 int32_t offset = *i; 965 int32_t offset = *i;
955 byte* from = reinterpret_cast<byte*>(&p1) - offset; 966 byte* from = reinterpret_cast<byte*>(&p1) - offset;
956 byte* to = reinterpret_cast<byte*>(&p2) - offset; 967 byte* to = reinterpret_cast<byte*>(&p2) - offset;
957 // generate load [#base + #index] 968 // generate load [#base + #index]
958 Node* load = 969 Node* load = m.Load(MachineType::Float32(), m.PointerConstant(from),
959 m.Load(kMachFloat32, m.PointerConstant(from), m.IntPtrConstant(offset)); 970 m.IntPtrConstant(offset));
960 m.Store(kMachFloat32, m.PointerConstant(to), m.IntPtrConstant(offset), load, 971 m.Store(MachineType::Float32(), m.PointerConstant(to),
961 kNoWriteBarrier); 972 m.IntPtrConstant(offset), load, kNoWriteBarrier);
962 m.Return(m.Int32Constant(magic)); 973 m.Return(m.Int32Constant(magic));
963 974
964 FOR_FLOAT32_INPUTS(j) { 975 FOR_FLOAT32_INPUTS(j) {
965 p1 = *j; 976 p1 = *j;
966 p2 = *j - 5; 977 p2 = *j - 5;
967 CHECK_EQ(magic, m.Call()); 978 CHECK_EQ(magic, m.Call());
968 CheckDoubleEq(p1, p2); 979 CheckDoubleEq(p1, p2);
969 } 980 }
970 } 981 }
971 } 982 }
972 983
973 984
974 TEST(RunLoadStoreFloat64Offset) { 985 TEST(RunLoadStoreFloat64Offset) {
975 double p1 = 0; // loads directly from this location. 986 double p1 = 0; // loads directly from this location.
976 double p2 = 0; // and stores directly into this location. 987 double p2 = 0; // and stores directly into this location.
977 988
978 FOR_INT32_INPUTS(i) { 989 FOR_INT32_INPUTS(i) {
979 int32_t magic = 0x2342aabb + *i * 3; 990 int32_t magic = 0x2342aabb + *i * 3;
980 RawMachineAssemblerTester<int32_t> m; 991 RawMachineAssemblerTester<int32_t> m;
981 int32_t offset = *i; 992 int32_t offset = *i;
982 byte* from = reinterpret_cast<byte*>(&p1) - offset; 993 byte* from = reinterpret_cast<byte*>(&p1) - offset;
983 byte* to = reinterpret_cast<byte*>(&p2) - offset; 994 byte* to = reinterpret_cast<byte*>(&p2) - offset;
984 // generate load [#base + #index] 995 // generate load [#base + #index]
985 Node* load = 996 Node* load = m.Load(MachineType::Float64(), m.PointerConstant(from),
986 m.Load(kMachFloat64, m.PointerConstant(from), m.IntPtrConstant(offset)); 997 m.IntPtrConstant(offset));
987 m.Store(kMachFloat64, m.PointerConstant(to), m.IntPtrConstant(offset), load, 998 m.Store(MachineType::Float64(), m.PointerConstant(to),
988 kNoWriteBarrier); 999 m.IntPtrConstant(offset), load, kNoWriteBarrier);
989 m.Return(m.Int32Constant(magic)); 1000 m.Return(m.Int32Constant(magic));
990 1001
991 FOR_FLOAT64_INPUTS(j) { 1002 FOR_FLOAT64_INPUTS(j) {
992 p1 = *j; 1003 p1 = *j;
993 p2 = *j - 5; 1004 p2 = *j - 5;
994 CHECK_EQ(magic, m.Call()); 1005 CHECK_EQ(magic, m.Call());
995 CheckDoubleEq(p1, p2); 1006 CheckDoubleEq(p1, p2);
996 } 1007 }
997 } 1008 }
998 } 1009 }
(...skipping 10 matching lines...) Expand all
1009 // Use uint32_t because signed overflow is UB in C. 1020 // Use uint32_t because signed overflow is UB in C.
1010 int expected = static_cast<int32_t>(*i + *j); 1021 int expected = static_cast<int32_t>(*i + *j);
1011 CHECK_EQ(expected, bt.call(*i, *j)); 1022 CHECK_EQ(expected, bt.call(*i, *j));
1012 } 1023 }
1013 } 1024 }
1014 } 1025 }
1015 1026
1016 1027
1017 TEST(RunInt32AddAndWord32EqualP) { 1028 TEST(RunInt32AddAndWord32EqualP) {
1018 { 1029 {
1019 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); 1030 RawMachineAssemblerTester<int32_t> m(
1031 MachineType::Int32(), MachineType::Int32(), MachineType::Int32());
1020 m.Return(m.Int32Add(m.Parameter(0), 1032 m.Return(m.Int32Add(m.Parameter(0),
1021 m.Word32Equal(m.Parameter(1), m.Parameter(2)))); 1033 m.Word32Equal(m.Parameter(1), m.Parameter(2))));
1022 FOR_INT32_INPUTS(i) { 1034 FOR_INT32_INPUTS(i) {
1023 FOR_INT32_INPUTS(j) { 1035 FOR_INT32_INPUTS(j) {
1024 FOR_INT32_INPUTS(k) { 1036 FOR_INT32_INPUTS(k) {
1025 // Use uint32_t because signed overflow is UB in C. 1037 // Use uint32_t because signed overflow is UB in C.
1026 int32_t const expected = 1038 int32_t const expected =
1027 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j == *k)); 1039 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j == *k));
1028 CHECK_EQ(expected, m.Call(*i, *j, *k)); 1040 CHECK_EQ(expected, m.Call(*i, *j, *k));
1029 } 1041 }
1030 } 1042 }
1031 } 1043 }
1032 } 1044 }
1033 { 1045 {
1034 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); 1046 RawMachineAssemblerTester<int32_t> m(
1047 MachineType::Int32(), MachineType::Int32(), MachineType::Int32());
1035 m.Return(m.Int32Add(m.Word32Equal(m.Parameter(0), m.Parameter(1)), 1048 m.Return(m.Int32Add(m.Word32Equal(m.Parameter(0), m.Parameter(1)),
1036 m.Parameter(2))); 1049 m.Parameter(2)));
1037 FOR_INT32_INPUTS(i) { 1050 FOR_INT32_INPUTS(i) {
1038 FOR_INT32_INPUTS(j) { 1051 FOR_INT32_INPUTS(j) {
1039 FOR_INT32_INPUTS(k) { 1052 FOR_INT32_INPUTS(k) {
1040 // Use uint32_t because signed overflow is UB in C. 1053 // Use uint32_t because signed overflow is UB in C.
1041 int32_t const expected = 1054 int32_t const expected =
1042 bit_cast<int32_t>((*i == *j) + bit_cast<uint32_t>(*k)); 1055 bit_cast<int32_t>((*i == *j) + bit_cast<uint32_t>(*k));
1043 CHECK_EQ(expected, m.Call(*i, *j, *k)); 1056 CHECK_EQ(expected, m.Call(*i, *j, *k));
1044 } 1057 }
1045 } 1058 }
1046 } 1059 }
1047 } 1060 }
1048 } 1061 }
1049 1062
1050 1063
1051 TEST(RunInt32AddAndWord32EqualImm) { 1064 TEST(RunInt32AddAndWord32EqualImm) {
1052 { 1065 {
1053 FOR_INT32_INPUTS(i) { 1066 FOR_INT32_INPUTS(i) {
1054 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 1067 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
1068 MachineType::Int32());
1055 m.Return(m.Int32Add(m.Int32Constant(*i), 1069 m.Return(m.Int32Add(m.Int32Constant(*i),
1056 m.Word32Equal(m.Parameter(0), m.Parameter(1)))); 1070 m.Word32Equal(m.Parameter(0), m.Parameter(1))));
1057 FOR_INT32_INPUTS(j) { 1071 FOR_INT32_INPUTS(j) {
1058 FOR_INT32_INPUTS(k) { 1072 FOR_INT32_INPUTS(k) {
1059 // Use uint32_t because signed overflow is UB in C. 1073 // Use uint32_t because signed overflow is UB in C.
1060 int32_t const expected = 1074 int32_t const expected =
1061 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j == *k)); 1075 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j == *k));
1062 CHECK_EQ(expected, m.Call(*j, *k)); 1076 CHECK_EQ(expected, m.Call(*j, *k));
1063 } 1077 }
1064 } 1078 }
1065 } 1079 }
1066 } 1080 }
1067 { 1081 {
1068 FOR_INT32_INPUTS(i) { 1082 FOR_INT32_INPUTS(i) {
1069 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 1083 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
1084 MachineType::Int32());
1070 m.Return(m.Int32Add(m.Word32Equal(m.Int32Constant(*i), m.Parameter(0)), 1085 m.Return(m.Int32Add(m.Word32Equal(m.Int32Constant(*i), m.Parameter(0)),
1071 m.Parameter(1))); 1086 m.Parameter(1)));
1072 FOR_INT32_INPUTS(j) { 1087 FOR_INT32_INPUTS(j) {
1073 FOR_INT32_INPUTS(k) { 1088 FOR_INT32_INPUTS(k) {
1074 // Use uint32_t because signed overflow is UB in C. 1089 // Use uint32_t because signed overflow is UB in C.
1075 int32_t const expected = 1090 int32_t const expected =
1076 bit_cast<int32_t>((*i == *j) + bit_cast<uint32_t>(*k)); 1091 bit_cast<int32_t>((*i == *j) + bit_cast<uint32_t>(*k));
1077 CHECK_EQ(expected, m.Call(*j, *k)); 1092 CHECK_EQ(expected, m.Call(*j, *k));
1078 } 1093 }
1079 } 1094 }
1080 } 1095 }
1081 } 1096 }
1082 } 1097 }
1083 1098
1084 1099
1085 TEST(RunInt32AddAndWord32NotEqualP) { 1100 TEST(RunInt32AddAndWord32NotEqualP) {
1086 { 1101 {
1087 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); 1102 RawMachineAssemblerTester<int32_t> m(
1103 MachineType::Int32(), MachineType::Int32(), MachineType::Int32());
1088 m.Return(m.Int32Add(m.Parameter(0), 1104 m.Return(m.Int32Add(m.Parameter(0),
1089 m.Word32NotEqual(m.Parameter(1), m.Parameter(2)))); 1105 m.Word32NotEqual(m.Parameter(1), m.Parameter(2))));
1090 FOR_INT32_INPUTS(i) { 1106 FOR_INT32_INPUTS(i) {
1091 FOR_INT32_INPUTS(j) { 1107 FOR_INT32_INPUTS(j) {
1092 FOR_INT32_INPUTS(k) { 1108 FOR_INT32_INPUTS(k) {
1093 // Use uint32_t because signed overflow is UB in C. 1109 // Use uint32_t because signed overflow is UB in C.
1094 int32_t const expected = 1110 int32_t const expected =
1095 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j != *k)); 1111 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j != *k));
1096 CHECK_EQ(expected, m.Call(*i, *j, *k)); 1112 CHECK_EQ(expected, m.Call(*i, *j, *k));
1097 } 1113 }
1098 } 1114 }
1099 } 1115 }
1100 } 1116 }
1101 { 1117 {
1102 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); 1118 RawMachineAssemblerTester<int32_t> m(
1119 MachineType::Int32(), MachineType::Int32(), MachineType::Int32());
1103 m.Return(m.Int32Add(m.Word32NotEqual(m.Parameter(0), m.Parameter(1)), 1120 m.Return(m.Int32Add(m.Word32NotEqual(m.Parameter(0), m.Parameter(1)),
1104 m.Parameter(2))); 1121 m.Parameter(2)));
1105 FOR_INT32_INPUTS(i) { 1122 FOR_INT32_INPUTS(i) {
1106 FOR_INT32_INPUTS(j) { 1123 FOR_INT32_INPUTS(j) {
1107 FOR_INT32_INPUTS(k) { 1124 FOR_INT32_INPUTS(k) {
1108 // Use uint32_t because signed overflow is UB in C. 1125 // Use uint32_t because signed overflow is UB in C.
1109 int32_t const expected = 1126 int32_t const expected =
1110 bit_cast<int32_t>((*i != *j) + bit_cast<uint32_t>(*k)); 1127 bit_cast<int32_t>((*i != *j) + bit_cast<uint32_t>(*k));
1111 CHECK_EQ(expected, m.Call(*i, *j, *k)); 1128 CHECK_EQ(expected, m.Call(*i, *j, *k));
1112 } 1129 }
1113 } 1130 }
1114 } 1131 }
1115 } 1132 }
1116 } 1133 }
1117 1134
1118 1135
1119 TEST(RunInt32AddAndWord32NotEqualImm) { 1136 TEST(RunInt32AddAndWord32NotEqualImm) {
1120 { 1137 {
1121 FOR_INT32_INPUTS(i) { 1138 FOR_INT32_INPUTS(i) {
1122 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 1139 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
1140 MachineType::Int32());
1123 m.Return(m.Int32Add(m.Int32Constant(*i), 1141 m.Return(m.Int32Add(m.Int32Constant(*i),
1124 m.Word32NotEqual(m.Parameter(0), m.Parameter(1)))); 1142 m.Word32NotEqual(m.Parameter(0), m.Parameter(1))));
1125 FOR_INT32_INPUTS(j) { 1143 FOR_INT32_INPUTS(j) {
1126 FOR_INT32_INPUTS(k) { 1144 FOR_INT32_INPUTS(k) {
1127 // Use uint32_t because signed overflow is UB in C. 1145 // Use uint32_t because signed overflow is UB in C.
1128 int32_t const expected = 1146 int32_t const expected =
1129 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j != *k)); 1147 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j != *k));
1130 CHECK_EQ(expected, m.Call(*j, *k)); 1148 CHECK_EQ(expected, m.Call(*j, *k));
1131 } 1149 }
1132 } 1150 }
1133 } 1151 }
1134 } 1152 }
1135 { 1153 {
1136 FOR_INT32_INPUTS(i) { 1154 FOR_INT32_INPUTS(i) {
1137 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 1155 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
1156 MachineType::Int32());
1138 m.Return(m.Int32Add(m.Word32NotEqual(m.Int32Constant(*i), m.Parameter(0)), 1157 m.Return(m.Int32Add(m.Word32NotEqual(m.Int32Constant(*i), m.Parameter(0)),
1139 m.Parameter(1))); 1158 m.Parameter(1)));
1140 FOR_INT32_INPUTS(j) { 1159 FOR_INT32_INPUTS(j) {
1141 FOR_INT32_INPUTS(k) { 1160 FOR_INT32_INPUTS(k) {
1142 // Use uint32_t because signed overflow is UB in C. 1161 // Use uint32_t because signed overflow is UB in C.
1143 int32_t const expected = 1162 int32_t const expected =
1144 bit_cast<int32_t>((*i != *j) + bit_cast<uint32_t>(*k)); 1163 bit_cast<int32_t>((*i != *j) + bit_cast<uint32_t>(*k));
1145 CHECK_EQ(expected, m.Call(*j, *k)); 1164 CHECK_EQ(expected, m.Call(*j, *k));
1146 } 1165 }
1147 } 1166 }
1148 } 1167 }
1149 } 1168 }
1150 } 1169 }
1151 1170
1152 1171
1153 TEST(RunInt32AddAndWord32SarP) { 1172 TEST(RunInt32AddAndWord32SarP) {
1154 { 1173 {
1155 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); 1174 RawMachineAssemblerTester<int32_t> m(
1175 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
1156 m.Return(m.Int32Add(m.Parameter(0), 1176 m.Return(m.Int32Add(m.Parameter(0),
1157 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 1177 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
1158 FOR_UINT32_INPUTS(i) { 1178 FOR_UINT32_INPUTS(i) {
1159 FOR_INT32_INPUTS(j) { 1179 FOR_INT32_INPUTS(j) {
1160 FOR_UINT32_SHIFTS(shift) { 1180 FOR_UINT32_SHIFTS(shift) {
1161 // Use uint32_t because signed overflow is UB in C. 1181 // Use uint32_t because signed overflow is UB in C.
1162 int32_t expected = *i + (*j >> shift); 1182 int32_t expected = *i + (*j >> shift);
1163 CHECK_EQ(expected, m.Call(*i, *j, shift)); 1183 CHECK_EQ(expected, m.Call(*i, *j, shift));
1164 } 1184 }
1165 } 1185 }
1166 } 1186 }
1167 } 1187 }
1168 { 1188 {
1169 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachUint32); 1189 RawMachineAssemblerTester<int32_t> m(
1190 MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32());
1170 m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 1191 m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
1171 m.Parameter(2))); 1192 m.Parameter(2)));
1172 FOR_INT32_INPUTS(i) { 1193 FOR_INT32_INPUTS(i) {
1173 FOR_UINT32_SHIFTS(shift) { 1194 FOR_UINT32_SHIFTS(shift) {
1174 FOR_UINT32_INPUTS(k) { 1195 FOR_UINT32_INPUTS(k) {
1175 // Use uint32_t because signed overflow is UB in C. 1196 // Use uint32_t because signed overflow is UB in C.
1176 int32_t expected = (*i >> shift) + *k; 1197 int32_t expected = (*i >> shift) + *k;
1177 CHECK_EQ(expected, m.Call(*i, shift, *k)); 1198 CHECK_EQ(expected, m.Call(*i, shift, *k));
1178 } 1199 }
1179 } 1200 }
1180 } 1201 }
1181 } 1202 }
1182 } 1203 }
1183 1204
1184 1205
1185 TEST(RunInt32AddAndWord32ShlP) { 1206 TEST(RunInt32AddAndWord32ShlP) {
1186 { 1207 {
1187 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); 1208 RawMachineAssemblerTester<int32_t> m(
1209 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
1188 m.Return(m.Int32Add(m.Parameter(0), 1210 m.Return(m.Int32Add(m.Parameter(0),
1189 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 1211 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
1190 FOR_UINT32_INPUTS(i) { 1212 FOR_UINT32_INPUTS(i) {
1191 FOR_INT32_INPUTS(j) { 1213 FOR_INT32_INPUTS(j) {
1192 FOR_UINT32_SHIFTS(shift) { 1214 FOR_UINT32_SHIFTS(shift) {
1193 // Use uint32_t because signed overflow is UB in C. 1215 // Use uint32_t because signed overflow is UB in C.
1194 int32_t expected = *i + (*j << shift); 1216 int32_t expected = *i + (*j << shift);
1195 CHECK_EQ(expected, m.Call(*i, *j, shift)); 1217 CHECK_EQ(expected, m.Call(*i, *j, shift));
1196 } 1218 }
1197 } 1219 }
1198 } 1220 }
1199 } 1221 }
1200 { 1222 {
1201 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachUint32); 1223 RawMachineAssemblerTester<int32_t> m(
1224 MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32());
1202 m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 1225 m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
1203 m.Parameter(2))); 1226 m.Parameter(2)));
1204 FOR_INT32_INPUTS(i) { 1227 FOR_INT32_INPUTS(i) {
1205 FOR_UINT32_SHIFTS(shift) { 1228 FOR_UINT32_SHIFTS(shift) {
1206 FOR_UINT32_INPUTS(k) { 1229 FOR_UINT32_INPUTS(k) {
1207 // Use uint32_t because signed overflow is UB in C. 1230 // Use uint32_t because signed overflow is UB in C.
1208 int32_t expected = (*i << shift) + *k; 1231 int32_t expected = (*i << shift) + *k;
1209 CHECK_EQ(expected, m.Call(*i, shift, *k)); 1232 CHECK_EQ(expected, m.Call(*i, shift, *k));
1210 } 1233 }
1211 } 1234 }
1212 } 1235 }
1213 } 1236 }
1214 } 1237 }
1215 1238
1216 1239
1217 TEST(RunInt32AddAndWord32ShrP) { 1240 TEST(RunInt32AddAndWord32ShrP) {
1218 { 1241 {
1219 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); 1242 RawMachineAssemblerTester<int32_t> m(
1243 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
1220 m.Return(m.Int32Add(m.Parameter(0), 1244 m.Return(m.Int32Add(m.Parameter(0),
1221 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 1245 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
1222 FOR_UINT32_INPUTS(i) { 1246 FOR_UINT32_INPUTS(i) {
1223 FOR_UINT32_INPUTS(j) { 1247 FOR_UINT32_INPUTS(j) {
1224 FOR_UINT32_SHIFTS(shift) { 1248 FOR_UINT32_SHIFTS(shift) {
1225 // Use uint32_t because signed overflow is UB in C. 1249 // Use uint32_t because signed overflow is UB in C.
1226 int32_t expected = *i + (*j >> shift); 1250 int32_t expected = *i + (*j >> shift);
1227 CHECK_EQ(expected, m.Call(*i, *j, shift)); 1251 CHECK_EQ(expected, m.Call(*i, *j, shift));
1228 } 1252 }
1229 } 1253 }
1230 } 1254 }
1231 } 1255 }
1232 { 1256 {
1233 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); 1257 RawMachineAssemblerTester<int32_t> m(
1258 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
1234 m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 1259 m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
1235 m.Parameter(2))); 1260 m.Parameter(2)));
1236 FOR_UINT32_INPUTS(i) { 1261 FOR_UINT32_INPUTS(i) {
1237 FOR_UINT32_SHIFTS(shift) { 1262 FOR_UINT32_SHIFTS(shift) {
1238 FOR_UINT32_INPUTS(k) { 1263 FOR_UINT32_INPUTS(k) {
1239 // Use uint32_t because signed overflow is UB in C. 1264 // Use uint32_t because signed overflow is UB in C.
1240 int32_t expected = (*i >> shift) + *k; 1265 int32_t expected = (*i >> shift) + *k;
1241 CHECK_EQ(expected, m.Call(*i, shift, *k)); 1266 CHECK_EQ(expected, m.Call(*i, shift, *k));
1242 } 1267 }
1243 } 1268 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 bt.AddReturn(m.Int32Constant(0 - constant)); 1304 bt.AddReturn(m.Int32Constant(0 - constant));
1280 FOR_UINT32_INPUTS(i) { 1305 FOR_UINT32_INPUTS(i) {
1281 FOR_UINT32_INPUTS(j) { 1306 FOR_UINT32_INPUTS(j) {
1282 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; 1307 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant;
1283 CHECK_EQ(expected, bt.call(*i, *j)); 1308 CHECK_EQ(expected, bt.call(*i, *j));
1284 } 1309 }
1285 } 1310 }
1286 } 1311 }
1287 { 1312 {
1288 FOR_UINT32_INPUTS(i) { 1313 FOR_UINT32_INPUTS(i) {
1289 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1314 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1290 RawMachineLabel blocka, blockb; 1315 RawMachineLabel blocka, blockb;
1291 m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), 1316 m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)),
1292 m.Int32Constant(0)), 1317 m.Int32Constant(0)),
1293 &blocka, &blockb); 1318 &blocka, &blockb);
1294 m.Bind(&blocka); 1319 m.Bind(&blocka);
1295 m.Return(m.Int32Constant(constant)); 1320 m.Return(m.Int32Constant(constant));
1296 m.Bind(&blockb); 1321 m.Bind(&blockb);
1297 m.Return(m.Int32Constant(0 - constant)); 1322 m.Return(m.Int32Constant(0 - constant));
1298 FOR_UINT32_INPUTS(j) { 1323 FOR_UINT32_INPUTS(j) {
1299 uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant; 1324 uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant;
1300 CHECK_EQ(expected, m.Call(*j)); 1325 CHECK_EQ(expected, m.Call(*j));
1301 } 1326 }
1302 } 1327 }
1303 } 1328 }
1304 { 1329 {
1305 FOR_UINT32_INPUTS(i) { 1330 FOR_UINT32_INPUTS(i) {
1306 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1331 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1307 RawMachineLabel blocka, blockb; 1332 RawMachineLabel blocka, blockb;
1308 m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), 1333 m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)),
1309 m.Int32Constant(0)), 1334 m.Int32Constant(0)),
1310 &blocka, &blockb); 1335 &blocka, &blockb);
1311 m.Bind(&blocka); 1336 m.Bind(&blocka);
1312 m.Return(m.Int32Constant(constant)); 1337 m.Return(m.Int32Constant(constant));
1313 m.Bind(&blockb); 1338 m.Bind(&blockb);
1314 m.Return(m.Int32Constant(0 - constant)); 1339 m.Return(m.Int32Constant(0 - constant));
1315 FOR_UINT32_INPUTS(j) { 1340 FOR_UINT32_INPUTS(j) {
1316 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; 1341 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant;
1317 CHECK_EQ(expected, m.Call(*j)); 1342 CHECK_EQ(expected, m.Call(*j));
1318 } 1343 }
1319 } 1344 }
1320 } 1345 }
1321 { 1346 {
1322 RawMachineAssemblerTester<void> m; 1347 RawMachineAssemblerTester<void> m;
1323 const Operator* shops[] = {m.machine()->Word32Sar(), 1348 const Operator* shops[] = {m.machine()->Word32Sar(),
1324 m.machine()->Word32Shl(), 1349 m.machine()->Word32Shl(),
1325 m.machine()->Word32Shr()}; 1350 m.machine()->Word32Shr()};
1326 for (size_t n = 0; n < arraysize(shops); n++) { 1351 for (size_t n = 0; n < arraysize(shops); n++) {
1327 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, 1352 RawMachineAssemblerTester<int32_t> m(
1328 kMachUint32); 1353 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
1329 RawMachineLabel blocka, blockb; 1354 RawMachineLabel blocka, blockb;
1330 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), 1355 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0),
1331 m.AddNode(shops[n], m.Parameter(1), 1356 m.AddNode(shops[n], m.Parameter(1),
1332 m.Parameter(2))), 1357 m.Parameter(2))),
1333 m.Int32Constant(0)), 1358 m.Int32Constant(0)),
1334 &blocka, &blockb); 1359 &blocka, &blockb);
1335 m.Bind(&blocka); 1360 m.Bind(&blocka);
1336 m.Return(m.Int32Constant(constant)); 1361 m.Return(m.Int32Constant(constant));
1337 m.Bind(&blockb); 1362 m.Bind(&blockb);
1338 m.Return(m.Int32Constant(0 - constant)); 1363 m.Return(m.Int32Constant(0 - constant));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 m.Word32Equal(m.Int32Constant(0), m.Int32Add(bt.param0, bt.param1))); 1408 m.Word32Equal(m.Int32Constant(0), m.Int32Add(bt.param0, bt.param1)));
1384 FOR_UINT32_INPUTS(i) { 1409 FOR_UINT32_INPUTS(i) {
1385 FOR_UINT32_INPUTS(j) { 1410 FOR_UINT32_INPUTS(j) {
1386 uint32_t expected = (*i + *j) == 0; 1411 uint32_t expected = (*i + *j) == 0;
1387 CHECK_EQ(expected, bt.call(*i, *j)); 1412 CHECK_EQ(expected, bt.call(*i, *j));
1388 } 1413 }
1389 } 1414 }
1390 } 1415 }
1391 { 1416 {
1392 FOR_UINT32_INPUTS(i) { 1417 FOR_UINT32_INPUTS(i) {
1393 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1418 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1394 m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), 1419 m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)),
1395 m.Int32Constant(0))); 1420 m.Int32Constant(0)));
1396 FOR_UINT32_INPUTS(j) { 1421 FOR_UINT32_INPUTS(j) {
1397 uint32_t expected = (*i + *j) == 0; 1422 uint32_t expected = (*i + *j) == 0;
1398 CHECK_EQ(expected, m.Call(*j)); 1423 CHECK_EQ(expected, m.Call(*j));
1399 } 1424 }
1400 } 1425 }
1401 } 1426 }
1402 { 1427 {
1403 FOR_UINT32_INPUTS(i) { 1428 FOR_UINT32_INPUTS(i) {
1404 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1429 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1405 m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), 1430 m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)),
1406 m.Int32Constant(0))); 1431 m.Int32Constant(0)));
1407 FOR_UINT32_INPUTS(j) { 1432 FOR_UINT32_INPUTS(j) {
1408 uint32_t expected = (*j + *i) == 0; 1433 uint32_t expected = (*j + *i) == 0;
1409 CHECK_EQ(expected, m.Call(*j)); 1434 CHECK_EQ(expected, m.Call(*j));
1410 } 1435 }
1411 } 1436 }
1412 } 1437 }
1413 { 1438 {
1414 RawMachineAssemblerTester<void> m; 1439 RawMachineAssemblerTester<void> m;
1415 const Operator* shops[] = {m.machine()->Word32Sar(), 1440 const Operator* shops[] = {m.machine()->Word32Sar(),
1416 m.machine()->Word32Shl(), 1441 m.machine()->Word32Shl(),
1417 m.machine()->Word32Shr()}; 1442 m.machine()->Word32Shr()};
1418 for (size_t n = 0; n < arraysize(shops); n++) { 1443 for (size_t n = 0; n < arraysize(shops); n++) {
1419 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, 1444 RawMachineAssemblerTester<int32_t> m(
1420 kMachUint32); 1445 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
1421 m.Return(m.Word32Equal( 1446 m.Return(m.Word32Equal(
1422 m.Int32Add(m.Parameter(0), 1447 m.Int32Add(m.Parameter(0),
1423 m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), 1448 m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))),
1424 m.Int32Constant(0))); 1449 m.Int32Constant(0)));
1425 FOR_UINT32_INPUTS(i) { 1450 FOR_UINT32_INPUTS(i) {
1426 FOR_INT32_INPUTS(j) { 1451 FOR_INT32_INPUTS(j) {
1427 FOR_UINT32_SHIFTS(shift) { 1452 FOR_UINT32_SHIFTS(shift) {
1428 int32_t right; 1453 int32_t right;
1429 switch (shops[n]->opcode()) { 1454 switch (shops[n]->opcode()) {
1430 default: 1455 default:
(...skipping 29 matching lines...) Expand all
1460 uint32_t expected = static_cast<int32_t>(*i - *j); 1485 uint32_t expected = static_cast<int32_t>(*i - *j);
1461 CHECK_EQ(expected, bt.call(*i, *j)); 1486 CHECK_EQ(expected, bt.call(*i, *j));
1462 } 1487 }
1463 } 1488 }
1464 } 1489 }
1465 1490
1466 1491
1467 TEST(RunInt32SubImm) { 1492 TEST(RunInt32SubImm) {
1468 { 1493 {
1469 FOR_UINT32_INPUTS(i) { 1494 FOR_UINT32_INPUTS(i) {
1470 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1495 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1471 m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0))); 1496 m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)));
1472 FOR_UINT32_INPUTS(j) { 1497 FOR_UINT32_INPUTS(j) {
1473 uint32_t expected = *i - *j; 1498 uint32_t expected = *i - *j;
1474 CHECK_EQ(expected, m.Call(*j)); 1499 CHECK_EQ(expected, m.Call(*j));
1475 } 1500 }
1476 } 1501 }
1477 } 1502 }
1478 { 1503 {
1479 FOR_UINT32_INPUTS(i) { 1504 FOR_UINT32_INPUTS(i) {
1480 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1505 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1481 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i))); 1506 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)));
1482 FOR_UINT32_INPUTS(j) { 1507 FOR_UINT32_INPUTS(j) {
1483 uint32_t expected = *j - *i; 1508 uint32_t expected = *j - *i;
1484 CHECK_EQ(expected, m.Call(*j)); 1509 CHECK_EQ(expected, m.Call(*j));
1485 } 1510 }
1486 } 1511 }
1487 } 1512 }
1488 } 1513 }
1489 1514
1490 1515
1491 TEST(RunInt32SubAndWord32SarP) { 1516 TEST(RunInt32SubAndWord32SarP) {
1492 { 1517 {
1493 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); 1518 RawMachineAssemblerTester<int32_t> m(
1519 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
1494 m.Return(m.Int32Sub(m.Parameter(0), 1520 m.Return(m.Int32Sub(m.Parameter(0),
1495 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 1521 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
1496 FOR_UINT32_INPUTS(i) { 1522 FOR_UINT32_INPUTS(i) {
1497 FOR_INT32_INPUTS(j) { 1523 FOR_INT32_INPUTS(j) {
1498 FOR_UINT32_SHIFTS(shift) { 1524 FOR_UINT32_SHIFTS(shift) {
1499 int32_t expected = *i - (*j >> shift); 1525 int32_t expected = *i - (*j >> shift);
1500 CHECK_EQ(expected, m.Call(*i, *j, shift)); 1526 CHECK_EQ(expected, m.Call(*i, *j, shift));
1501 } 1527 }
1502 } 1528 }
1503 } 1529 }
1504 } 1530 }
1505 { 1531 {
1506 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachUint32); 1532 RawMachineAssemblerTester<int32_t> m(
1533 MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32());
1507 m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 1534 m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
1508 m.Parameter(2))); 1535 m.Parameter(2)));
1509 FOR_INT32_INPUTS(i) { 1536 FOR_INT32_INPUTS(i) {
1510 FOR_UINT32_SHIFTS(shift) { 1537 FOR_UINT32_SHIFTS(shift) {
1511 FOR_UINT32_INPUTS(k) { 1538 FOR_UINT32_INPUTS(k) {
1512 int32_t expected = (*i >> shift) - *k; 1539 int32_t expected = (*i >> shift) - *k;
1513 CHECK_EQ(expected, m.Call(*i, shift, *k)); 1540 CHECK_EQ(expected, m.Call(*i, shift, *k));
1514 } 1541 }
1515 } 1542 }
1516 } 1543 }
1517 } 1544 }
1518 } 1545 }
1519 1546
1520 1547
1521 TEST(RunInt32SubAndWord32ShlP) { 1548 TEST(RunInt32SubAndWord32ShlP) {
1522 { 1549 {
1523 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); 1550 RawMachineAssemblerTester<int32_t> m(
1551 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
1524 m.Return(m.Int32Sub(m.Parameter(0), 1552 m.Return(m.Int32Sub(m.Parameter(0),
1525 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 1553 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
1526 FOR_UINT32_INPUTS(i) { 1554 FOR_UINT32_INPUTS(i) {
1527 FOR_INT32_INPUTS(j) { 1555 FOR_INT32_INPUTS(j) {
1528 FOR_UINT32_SHIFTS(shift) { 1556 FOR_UINT32_SHIFTS(shift) {
1529 int32_t expected = *i - (*j << shift); 1557 int32_t expected = *i - (*j << shift);
1530 CHECK_EQ(expected, m.Call(*i, *j, shift)); 1558 CHECK_EQ(expected, m.Call(*i, *j, shift));
1531 } 1559 }
1532 } 1560 }
1533 } 1561 }
1534 } 1562 }
1535 { 1563 {
1536 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachUint32); 1564 RawMachineAssemblerTester<int32_t> m(
1565 MachineType::Int32(), MachineType::Uint32(), MachineType::Uint32());
1537 m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 1566 m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
1538 m.Parameter(2))); 1567 m.Parameter(2)));
1539 FOR_INT32_INPUTS(i) { 1568 FOR_INT32_INPUTS(i) {
1540 FOR_UINT32_SHIFTS(shift) { 1569 FOR_UINT32_SHIFTS(shift) {
1541 FOR_UINT32_INPUTS(k) { 1570 FOR_UINT32_INPUTS(k) {
1542 // Use uint32_t because signed overflow is UB in C. 1571 // Use uint32_t because signed overflow is UB in C.
1543 int32_t expected = (*i << shift) - *k; 1572 int32_t expected = (*i << shift) - *k;
1544 CHECK_EQ(expected, m.Call(*i, shift, *k)); 1573 CHECK_EQ(expected, m.Call(*i, shift, *k));
1545 } 1574 }
1546 } 1575 }
1547 } 1576 }
1548 } 1577 }
1549 } 1578 }
1550 1579
1551 1580
1552 TEST(RunInt32SubAndWord32ShrP) { 1581 TEST(RunInt32SubAndWord32ShrP) {
1553 { 1582 {
1554 RawMachineAssemblerTester<uint32_t> m(kMachUint32, kMachUint32, 1583 RawMachineAssemblerTester<uint32_t> m(
1555 kMachUint32); 1584 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
1556 m.Return(m.Int32Sub(m.Parameter(0), 1585 m.Return(m.Int32Sub(m.Parameter(0),
1557 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 1586 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
1558 FOR_UINT32_INPUTS(i) { 1587 FOR_UINT32_INPUTS(i) {
1559 FOR_UINT32_INPUTS(j) { 1588 FOR_UINT32_INPUTS(j) {
1560 FOR_UINT32_SHIFTS(shift) { 1589 FOR_UINT32_SHIFTS(shift) {
1561 // Use uint32_t because signed overflow is UB in C. 1590 // Use uint32_t because signed overflow is UB in C.
1562 uint32_t expected = *i - (*j >> shift); 1591 uint32_t expected = *i - (*j >> shift);
1563 CHECK_EQ(expected, m.Call(*i, *j, shift)); 1592 CHECK_EQ(expected, m.Call(*i, *j, shift));
1564 } 1593 }
1565 } 1594 }
1566 } 1595 }
1567 } 1596 }
1568 { 1597 {
1569 RawMachineAssemblerTester<uint32_t> m(kMachUint32, kMachUint32, 1598 RawMachineAssemblerTester<uint32_t> m(
1570 kMachUint32); 1599 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
1571 m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 1600 m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
1572 m.Parameter(2))); 1601 m.Parameter(2)));
1573 FOR_UINT32_INPUTS(i) { 1602 FOR_UINT32_INPUTS(i) {
1574 FOR_UINT32_SHIFTS(shift) { 1603 FOR_UINT32_SHIFTS(shift) {
1575 FOR_UINT32_INPUTS(k) { 1604 FOR_UINT32_INPUTS(k) {
1576 // Use uint32_t because signed overflow is UB in C. 1605 // Use uint32_t because signed overflow is UB in C.
1577 uint32_t expected = (*i >> shift) - *k; 1606 uint32_t expected = (*i >> shift) - *k;
1578 CHECK_EQ(expected, m.Call(*i, shift, *k)); 1607 CHECK_EQ(expected, m.Call(*i, shift, *k));
1579 } 1608 }
1580 } 1609 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 bt.AddReturn(m.Int32Constant(0 - constant)); 1645 bt.AddReturn(m.Int32Constant(0 - constant));
1617 FOR_UINT32_INPUTS(i) { 1646 FOR_UINT32_INPUTS(i) {
1618 FOR_UINT32_INPUTS(j) { 1647 FOR_UINT32_INPUTS(j) {
1619 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; 1648 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant;
1620 CHECK_EQ(expected, bt.call(*i, *j)); 1649 CHECK_EQ(expected, bt.call(*i, *j));
1621 } 1650 }
1622 } 1651 }
1623 } 1652 }
1624 { 1653 {
1625 FOR_UINT32_INPUTS(i) { 1654 FOR_UINT32_INPUTS(i) {
1626 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1655 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1627 RawMachineLabel blocka, blockb; 1656 RawMachineLabel blocka, blockb;
1628 m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), 1657 m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)),
1629 m.Int32Constant(0)), 1658 m.Int32Constant(0)),
1630 &blocka, &blockb); 1659 &blocka, &blockb);
1631 m.Bind(&blocka); 1660 m.Bind(&blocka);
1632 m.Return(m.Int32Constant(constant)); 1661 m.Return(m.Int32Constant(constant));
1633 m.Bind(&blockb); 1662 m.Bind(&blockb);
1634 m.Return(m.Int32Constant(0 - constant)); 1663 m.Return(m.Int32Constant(0 - constant));
1635 FOR_UINT32_INPUTS(j) { 1664 FOR_UINT32_INPUTS(j) {
1636 uint32_t expected = (*i - *j) == 0 ? constant : 0 - constant; 1665 uint32_t expected = (*i - *j) == 0 ? constant : 0 - constant;
1637 CHECK_EQ(expected, m.Call(*j)); 1666 CHECK_EQ(expected, m.Call(*j));
1638 } 1667 }
1639 } 1668 }
1640 } 1669 }
1641 { 1670 {
1642 FOR_UINT32_INPUTS(i) { 1671 FOR_UINT32_INPUTS(i) {
1643 RawMachineAssemblerTester<int32_t> m(kMachUint32); 1672 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
1644 RawMachineLabel blocka, blockb; 1673 RawMachineLabel blocka, blockb;
1645 m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), 1674 m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)),
1646 m.Int32Constant(0)), 1675 m.Int32Constant(0)),
1647 &blocka, &blockb); 1676 &blocka, &blockb);
1648 m.Bind(&blocka); 1677 m.Bind(&blocka);
1649 m.Return(m.Int32Constant(constant)); 1678 m.Return(m.Int32Constant(constant));
1650 m.Bind(&blockb); 1679 m.Bind(&blockb);
1651 m.Return(m.Int32Constant(0 - constant)); 1680 m.Return(m.Int32Constant(0 - constant));
1652 FOR_UINT32_INPUTS(j) { 1681 FOR_UINT32_INPUTS(j) {
1653 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; 1682 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant;
1654 CHECK_EQ(expected, m.Call(*j)); 1683 CHECK_EQ(expected, m.Call(*j));
1655 } 1684 }
1656 } 1685 }
1657 } 1686 }
1658 { 1687 {
1659 RawMachineAssemblerTester<void> m; 1688 RawMachineAssemblerTester<void> m;
1660 const Operator* shops[] = {m.machine()->Word32Sar(), 1689 const Operator* shops[] = {m.machine()->Word32Sar(),
1661 m.machine()->Word32Shl(), 1690 m.machine()->Word32Shl(),
1662 m.machine()->Word32Shr()}; 1691 m.machine()->Word32Shr()};
1663 for (size_t n = 0; n < arraysize(shops); n++) { 1692 for (size_t n = 0; n < arraysize(shops); n++) {
1664 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, 1693 RawMachineAssemblerTester<int32_t> m(
1665 kMachUint32); 1694 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
1666 RawMachineLabel blocka, blockb; 1695 RawMachineLabel blocka, blockb;
1667 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), 1696 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0),
1668 m.AddNode(shops[n], m.Parameter(1), 1697 m.AddNode(shops[n], m.Parameter(1),
1669 m.Parameter(2))), 1698 m.Parameter(2))),
1670 m.Int32Constant(0)), 1699 m.Int32Constant(0)),
1671 &blocka, &blockb); 1700 &blocka, &blockb);
1672 m.Bind(&blocka); 1701 m.Bind(&blocka);
1673 m.Return(m.Int32Constant(constant)); 1702 m.Return(m.Int32Constant(constant));
1674 m.Bind(&blockb); 1703 m.Bind(&blockb);
1675 m.Return(m.Int32Constant(0 - constant)); 1704 m.Return(m.Int32Constant(0 - constant));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 m.Word32Equal(m.Int32Constant(0), m.Int32Sub(bt.param0, bt.param1))); 1749 m.Word32Equal(m.Int32Constant(0), m.Int32Sub(bt.param0, bt.param1)));
1721 FOR_UINT32_INPUTS(i) { 1750 FOR_UINT32_INPUTS(i) {
1722 FOR_UINT32_INPUTS(j) { 1751 FOR_UINT32_INPUTS(j) {
1723 uint32_t expected = (*i - *j) == 0; 1752 uint32_t expected = (*i - *j) == 0;
1724 CHECK_EQ(expected, bt.call(*i, *j)); 1753 CHECK_EQ(expected, bt.call(*i, *j));
1725 } 1754 }
1726 } 1755 }
1727 } 1756 }
1728 { 1757 {
1729 FOR_UINT32_INPUTS(i) { 1758 FOR_UINT32_INPUTS(i) {
1730 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1759 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1731 m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), 1760 m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)),
1732 m.Int32Constant(0))); 1761 m.Int32Constant(0)));
1733 FOR_UINT32_INPUTS(j) { 1762 FOR_UINT32_INPUTS(j) {
1734 uint32_t expected = (*i - *j) == 0; 1763 uint32_t expected = (*i - *j) == 0;
1735 CHECK_EQ(expected, m.Call(*j)); 1764 CHECK_EQ(expected, m.Call(*j));
1736 } 1765 }
1737 } 1766 }
1738 } 1767 }
1739 { 1768 {
1740 FOR_UINT32_INPUTS(i) { 1769 FOR_UINT32_INPUTS(i) {
1741 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1770 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1742 m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), 1771 m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)),
1743 m.Int32Constant(0))); 1772 m.Int32Constant(0)));
1744 FOR_UINT32_INPUTS(j) { 1773 FOR_UINT32_INPUTS(j) {
1745 uint32_t expected = (*j - *i) == 0; 1774 uint32_t expected = (*j - *i) == 0;
1746 CHECK_EQ(expected, m.Call(*j)); 1775 CHECK_EQ(expected, m.Call(*j));
1747 } 1776 }
1748 } 1777 }
1749 } 1778 }
1750 { 1779 {
1751 RawMachineAssemblerTester<void> m; 1780 RawMachineAssemblerTester<void> m;
1752 const Operator* shops[] = {m.machine()->Word32Sar(), 1781 const Operator* shops[] = {m.machine()->Word32Sar(),
1753 m.machine()->Word32Shl(), 1782 m.machine()->Word32Shl(),
1754 m.machine()->Word32Shr()}; 1783 m.machine()->Word32Shr()};
1755 for (size_t n = 0; n < arraysize(shops); n++) { 1784 for (size_t n = 0; n < arraysize(shops); n++) {
1756 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, 1785 RawMachineAssemblerTester<int32_t> m(
1757 kMachUint32); 1786 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
1758 m.Return(m.Word32Equal( 1787 m.Return(m.Word32Equal(
1759 m.Int32Sub(m.Parameter(0), 1788 m.Int32Sub(m.Parameter(0),
1760 m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), 1789 m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))),
1761 m.Int32Constant(0))); 1790 m.Int32Constant(0)));
1762 FOR_UINT32_INPUTS(i) { 1791 FOR_UINT32_INPUTS(i) {
1763 FOR_INT32_INPUTS(j) { 1792 FOR_INT32_INPUTS(j) {
1764 FOR_UINT32_SHIFTS(shift) { 1793 FOR_UINT32_SHIFTS(shift) {
1765 int32_t right; 1794 int32_t right;
1766 switch (shops[n]->opcode()) { 1795 switch (shops[n]->opcode()) {
1767 default: 1796 default:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 (static_cast<int64_t>(*i) * static_cast<int64_t>(*j)) >> 32); 1851 (static_cast<int64_t>(*i) * static_cast<int64_t>(*j)) >> 32);
1823 CHECK_EQ(expected, bt.call(*i, *j)); 1852 CHECK_EQ(expected, bt.call(*i, *j));
1824 } 1853 }
1825 } 1854 }
1826 } 1855 }
1827 1856
1828 1857
1829 TEST(RunInt32MulImm) { 1858 TEST(RunInt32MulImm) {
1830 { 1859 {
1831 FOR_UINT32_INPUTS(i) { 1860 FOR_UINT32_INPUTS(i) {
1832 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1861 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1833 m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0))); 1862 m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0)));
1834 FOR_UINT32_INPUTS(j) { 1863 FOR_UINT32_INPUTS(j) {
1835 uint32_t expected = *i * *j; 1864 uint32_t expected = *i * *j;
1836 CHECK_EQ(expected, m.Call(*j)); 1865 CHECK_EQ(expected, m.Call(*j));
1837 } 1866 }
1838 } 1867 }
1839 } 1868 }
1840 { 1869 {
1841 FOR_UINT32_INPUTS(i) { 1870 FOR_UINT32_INPUTS(i) {
1842 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 1871 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
1843 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i))); 1872 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i)));
1844 FOR_UINT32_INPUTS(j) { 1873 FOR_UINT32_INPUTS(j) {
1845 uint32_t expected = *j * *i; 1874 uint32_t expected = *j * *i;
1846 CHECK_EQ(expected, m.Call(*j)); 1875 CHECK_EQ(expected, m.Call(*j));
1847 } 1876 }
1848 } 1877 }
1849 } 1878 }
1850 } 1879 }
1851 1880
1852 1881
1853 TEST(RunInt32MulAndInt32AddP) { 1882 TEST(RunInt32MulAndInt32AddP) {
1854 { 1883 {
1855 FOR_INT32_INPUTS(i) { 1884 FOR_INT32_INPUTS(i) {
1856 FOR_INT32_INPUTS(j) { 1885 FOR_INT32_INPUTS(j) {
1857 RawMachineAssemblerTester<int32_t> m(kMachInt32); 1886 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
1858 int32_t p0 = *i; 1887 int32_t p0 = *i;
1859 int32_t p1 = *j; 1888 int32_t p1 = *j;
1860 m.Return(m.Int32Add(m.Int32Constant(p0), 1889 m.Return(m.Int32Add(m.Int32Constant(p0),
1861 m.Int32Mul(m.Parameter(0), m.Int32Constant(p1)))); 1890 m.Int32Mul(m.Parameter(0), m.Int32Constant(p1))));
1862 FOR_INT32_INPUTS(k) { 1891 FOR_INT32_INPUTS(k) {
1863 int32_t p2 = *k; 1892 int32_t p2 = *k;
1864 int expected = p0 + static_cast<int32_t>(p1 * p2); 1893 int expected = p0 + static_cast<int32_t>(p1 * p2);
1865 CHECK_EQ(expected, m.Call(p2)); 1894 CHECK_EQ(expected, m.Call(p2));
1866 } 1895 }
1867 } 1896 }
1868 } 1897 }
1869 } 1898 }
1870 { 1899 {
1871 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); 1900 RawMachineAssemblerTester<int32_t> m(
1901 MachineType::Int32(), MachineType::Int32(), MachineType::Int32());
1872 m.Return( 1902 m.Return(
1873 m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); 1903 m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2))));
1874 FOR_INT32_INPUTS(i) { 1904 FOR_INT32_INPUTS(i) {
1875 FOR_INT32_INPUTS(j) { 1905 FOR_INT32_INPUTS(j) {
1876 FOR_INT32_INPUTS(k) { 1906 FOR_INT32_INPUTS(k) {
1877 int32_t p0 = *i; 1907 int32_t p0 = *i;
1878 int32_t p1 = *j; 1908 int32_t p1 = *j;
1879 int32_t p2 = *k; 1909 int32_t p2 = *k;
1880 int expected = p0 + static_cast<int32_t>(p1 * p2); 1910 int expected = p0 + static_cast<int32_t>(p1 * p2);
1881 CHECK_EQ(expected, m.Call(p0, p1, p2)); 1911 CHECK_EQ(expected, m.Call(p0, p1, p2));
1882 } 1912 }
1883 } 1913 }
1884 } 1914 }
1885 } 1915 }
1886 { 1916 {
1887 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); 1917 RawMachineAssemblerTester<int32_t> m(
1918 MachineType::Int32(), MachineType::Int32(), MachineType::Int32());
1888 m.Return( 1919 m.Return(
1889 m.Int32Add(m.Int32Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); 1920 m.Int32Add(m.Int32Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2)));
1890 FOR_INT32_INPUTS(i) { 1921 FOR_INT32_INPUTS(i) {
1891 FOR_INT32_INPUTS(j) { 1922 FOR_INT32_INPUTS(j) {
1892 FOR_INT32_INPUTS(k) { 1923 FOR_INT32_INPUTS(k) {
1893 int32_t p0 = *i; 1924 int32_t p0 = *i;
1894 int32_t p1 = *j; 1925 int32_t p1 = *j;
1895 int32_t p2 = *k; 1926 int32_t p2 = *k;
1896 int expected = static_cast<int32_t>(p0 * p1) + p2; 1927 int expected = static_cast<int32_t>(p0 * p1) + p2;
1897 CHECK_EQ(expected, m.Call(p0, p1, p2)); 1928 CHECK_EQ(expected, m.Call(p0, p1, p2));
(...skipping 15 matching lines...) Expand all
1913 CHECK_EQ(expected, bt.call(p0, p1)); 1944 CHECK_EQ(expected, bt.call(p0, p1));
1914 } 1945 }
1915 } 1946 }
1916 } 1947 }
1917 } 1948 }
1918 } 1949 }
1919 1950
1920 1951
1921 TEST(RunInt32MulAndInt32SubP) { 1952 TEST(RunInt32MulAndInt32SubP) {
1922 { 1953 {
1923 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachInt32); 1954 RawMachineAssemblerTester<int32_t> m(
1955 MachineType::Uint32(), MachineType::Int32(), MachineType::Int32());
1924 m.Return( 1956 m.Return(
1925 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); 1957 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2))));
1926 FOR_UINT32_INPUTS(i) { 1958 FOR_UINT32_INPUTS(i) {
1927 FOR_INT32_INPUTS(j) { 1959 FOR_INT32_INPUTS(j) {
1928 FOR_INT32_INPUTS(k) { 1960 FOR_INT32_INPUTS(k) {
1929 uint32_t p0 = *i; 1961 uint32_t p0 = *i;
1930 int32_t p1 = *j; 1962 int32_t p1 = *j;
1931 int32_t p2 = *k; 1963 int32_t p2 = *k;
1932 // Use uint32_t because signed overflow is UB in C. 1964 // Use uint32_t because signed overflow is UB in C.
1933 int expected = p0 - static_cast<uint32_t>(p1 * p2); 1965 int expected = p0 - static_cast<uint32_t>(p1 * p2);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 CHECK_EQ(expected, bt.call(*i, *j)); 2255 CHECK_EQ(expected, bt.call(*i, *j));
2224 } 2256 }
2225 } 2257 }
2226 } 2258 }
2227 } 2259 }
2228 2260
2229 2261
2230 TEST(RunWord32AndImm) { 2262 TEST(RunWord32AndImm) {
2231 { 2263 {
2232 FOR_UINT32_INPUTS(i) { 2264 FOR_UINT32_INPUTS(i) {
2233 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2265 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2234 m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0))); 2266 m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0)));
2235 FOR_UINT32_INPUTS(j) { 2267 FOR_UINT32_INPUTS(j) {
2236 uint32_t expected = *i & *j; 2268 uint32_t expected = *i & *j;
2237 CHECK_EQ(expected, m.Call(*j)); 2269 CHECK_EQ(expected, m.Call(*j));
2238 } 2270 }
2239 } 2271 }
2240 } 2272 }
2241 { 2273 {
2242 FOR_UINT32_INPUTS(i) { 2274 FOR_UINT32_INPUTS(i) {
2243 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2275 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2244 m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); 2276 m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
2245 FOR_UINT32_INPUTS(j) { 2277 FOR_UINT32_INPUTS(j) {
2246 uint32_t expected = *i & ~(*j); 2278 uint32_t expected = *i & ~(*j);
2247 CHECK_EQ(expected, m.Call(*j)); 2279 CHECK_EQ(expected, m.Call(*j));
2248 } 2280 }
2249 } 2281 }
2250 } 2282 }
2251 } 2283 }
2252 2284
2253 2285
(...skipping 30 matching lines...) Expand all
2284 bt.AddReturn(m.Int32Constant(0 - constant)); 2316 bt.AddReturn(m.Int32Constant(0 - constant));
2285 FOR_UINT32_INPUTS(i) { 2317 FOR_UINT32_INPUTS(i) {
2286 FOR_UINT32_INPUTS(j) { 2318 FOR_UINT32_INPUTS(j) {
2287 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; 2319 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant;
2288 CHECK_EQ(expected, bt.call(*i, *j)); 2320 CHECK_EQ(expected, bt.call(*i, *j));
2289 } 2321 }
2290 } 2322 }
2291 } 2323 }
2292 { 2324 {
2293 FOR_UINT32_INPUTS(i) { 2325 FOR_UINT32_INPUTS(i) {
2294 RawMachineAssemblerTester<int32_t> m(kMachUint32); 2326 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
2295 RawMachineLabel blocka, blockb; 2327 RawMachineLabel blocka, blockb;
2296 m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), 2328 m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)),
2297 m.Int32Constant(0)), 2329 m.Int32Constant(0)),
2298 &blocka, &blockb); 2330 &blocka, &blockb);
2299 m.Bind(&blocka); 2331 m.Bind(&blocka);
2300 m.Return(m.Int32Constant(constant)); 2332 m.Return(m.Int32Constant(constant));
2301 m.Bind(&blockb); 2333 m.Bind(&blockb);
2302 m.Return(m.Int32Constant(0 - constant)); 2334 m.Return(m.Int32Constant(0 - constant));
2303 FOR_UINT32_INPUTS(j) { 2335 FOR_UINT32_INPUTS(j) {
2304 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; 2336 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant;
2305 CHECK_EQ(expected, m.Call(*j)); 2337 CHECK_EQ(expected, m.Call(*j));
2306 } 2338 }
2307 } 2339 }
2308 } 2340 }
2309 { 2341 {
2310 FOR_UINT32_INPUTS(i) { 2342 FOR_UINT32_INPUTS(i) {
2311 RawMachineAssemblerTester<int32_t> m(kMachUint32); 2343 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
2312 RawMachineLabel blocka, blockb; 2344 RawMachineLabel blocka, blockb;
2313 m.Branch( 2345 m.Branch(
2314 m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), 2346 m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)),
2315 m.Int32Constant(0)), 2347 m.Int32Constant(0)),
2316 &blocka, &blockb); 2348 &blocka, &blockb);
2317 m.Bind(&blocka); 2349 m.Bind(&blocka);
2318 m.Return(m.Int32Constant(constant)); 2350 m.Return(m.Int32Constant(constant));
2319 m.Bind(&blockb); 2351 m.Bind(&blockb);
2320 m.Return(m.Int32Constant(0 - constant)); 2352 m.Return(m.Int32Constant(0 - constant));
2321 FOR_UINT32_INPUTS(j) { 2353 FOR_UINT32_INPUTS(j) {
2322 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; 2354 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant;
2323 CHECK_EQ(expected, m.Call(*j)); 2355 CHECK_EQ(expected, m.Call(*j));
2324 } 2356 }
2325 } 2357 }
2326 } 2358 }
2327 { 2359 {
2328 RawMachineAssemblerTester<void> m; 2360 RawMachineAssemblerTester<void> m;
2329 const Operator* shops[] = {m.machine()->Word32Sar(), 2361 const Operator* shops[] = {m.machine()->Word32Sar(),
2330 m.machine()->Word32Shl(), 2362 m.machine()->Word32Shl(),
2331 m.machine()->Word32Shr()}; 2363 m.machine()->Word32Shr()};
2332 for (size_t n = 0; n < arraysize(shops); n++) { 2364 for (size_t n = 0; n < arraysize(shops); n++) {
2333 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, 2365 RawMachineAssemblerTester<int32_t> m(
2334 kMachUint32); 2366 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
2335 RawMachineLabel blocka, blockb; 2367 RawMachineLabel blocka, blockb;
2336 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), 2368 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0),
2337 m.AddNode(shops[n], m.Parameter(1), 2369 m.AddNode(shops[n], m.Parameter(1),
2338 m.Parameter(2))), 2370 m.Parameter(2))),
2339 m.Int32Constant(0)), 2371 m.Int32Constant(0)),
2340 &blocka, &blockb); 2372 &blocka, &blockb);
2341 m.Bind(&blocka); 2373 m.Bind(&blocka);
2342 m.Return(m.Int32Constant(constant)); 2374 m.Return(m.Int32Constant(constant));
2343 m.Bind(&blockb); 2375 m.Bind(&blockb);
2344 m.Return(m.Int32Constant(0 - constant)); 2376 m.Return(m.Int32Constant(0 - constant));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 m.Word32Equal(m.Int32Constant(0), m.Word32And(bt.param0, bt.param1))); 2421 m.Word32Equal(m.Int32Constant(0), m.Word32And(bt.param0, bt.param1)));
2390 FOR_UINT32_INPUTS(i) { 2422 FOR_UINT32_INPUTS(i) {
2391 FOR_UINT32_INPUTS(j) { 2423 FOR_UINT32_INPUTS(j) {
2392 uint32_t expected = (*i & *j) == 0; 2424 uint32_t expected = (*i & *j) == 0;
2393 CHECK_EQ(expected, bt.call(*i, *j)); 2425 CHECK_EQ(expected, bt.call(*i, *j));
2394 } 2426 }
2395 } 2427 }
2396 } 2428 }
2397 { 2429 {
2398 FOR_UINT32_INPUTS(i) { 2430 FOR_UINT32_INPUTS(i) {
2399 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2431 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2400 m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), 2432 m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)),
2401 m.Int32Constant(0))); 2433 m.Int32Constant(0)));
2402 FOR_UINT32_INPUTS(j) { 2434 FOR_UINT32_INPUTS(j) {
2403 uint32_t expected = (*i & *j) == 0; 2435 uint32_t expected = (*i & *j) == 0;
2404 CHECK_EQ(expected, m.Call(*j)); 2436 CHECK_EQ(expected, m.Call(*j));
2405 } 2437 }
2406 } 2438 }
2407 } 2439 }
2408 { 2440 {
2409 FOR_UINT32_INPUTS(i) { 2441 FOR_UINT32_INPUTS(i) {
2410 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2442 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2411 m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)), 2443 m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)),
2412 m.Int32Constant(0))); 2444 m.Int32Constant(0)));
2413 FOR_UINT32_INPUTS(j) { 2445 FOR_UINT32_INPUTS(j) {
2414 uint32_t expected = (*j & *i) == 0; 2446 uint32_t expected = (*j & *i) == 0;
2415 CHECK_EQ(expected, m.Call(*j)); 2447 CHECK_EQ(expected, m.Call(*j));
2416 } 2448 }
2417 } 2449 }
2418 } 2450 }
2419 } 2451 }
2420 2452
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 CHECK_EQ(expected, bt.call(*i, *j)); 2484 CHECK_EQ(expected, bt.call(*i, *j));
2453 } 2485 }
2454 } 2486 }
2455 } 2487 }
2456 } 2488 }
2457 2489
2458 2490
2459 TEST(RunWord32OrImm) { 2491 TEST(RunWord32OrImm) {
2460 { 2492 {
2461 FOR_UINT32_INPUTS(i) { 2493 FOR_UINT32_INPUTS(i) {
2462 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2494 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2463 m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0))); 2495 m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)));
2464 FOR_UINT32_INPUTS(j) { 2496 FOR_UINT32_INPUTS(j) {
2465 uint32_t expected = *i | *j; 2497 uint32_t expected = *i | *j;
2466 CHECK_EQ(expected, m.Call(*j)); 2498 CHECK_EQ(expected, m.Call(*j));
2467 } 2499 }
2468 } 2500 }
2469 } 2501 }
2470 { 2502 {
2471 FOR_UINT32_INPUTS(i) { 2503 FOR_UINT32_INPUTS(i) {
2472 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2504 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2473 m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); 2505 m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
2474 FOR_UINT32_INPUTS(j) { 2506 FOR_UINT32_INPUTS(j) {
2475 uint32_t expected = *i | ~(*j); 2507 uint32_t expected = *i | ~(*j);
2476 CHECK_EQ(expected, m.Call(*j)); 2508 CHECK_EQ(expected, m.Call(*j));
2477 } 2509 }
2478 } 2510 }
2479 } 2511 }
2480 } 2512 }
2481 2513
2482 2514
(...skipping 30 matching lines...) Expand all
2513 bt.AddReturn(m.Int32Constant(0 - constant)); 2545 bt.AddReturn(m.Int32Constant(0 - constant));
2514 FOR_INT32_INPUTS(i) { 2546 FOR_INT32_INPUTS(i) {
2515 FOR_INT32_INPUTS(j) { 2547 FOR_INT32_INPUTS(j) {
2516 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; 2548 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant;
2517 CHECK_EQ(expected, bt.call(*i, *j)); 2549 CHECK_EQ(expected, bt.call(*i, *j));
2518 } 2550 }
2519 } 2551 }
2520 } 2552 }
2521 { 2553 {
2522 FOR_INT32_INPUTS(i) { 2554 FOR_INT32_INPUTS(i) {
2523 RawMachineAssemblerTester<int32_t> m(kMachInt32); 2555 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
2524 RawMachineLabel blocka, blockb; 2556 RawMachineLabel blocka, blockb;
2525 m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), 2557 m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)),
2526 m.Int32Constant(0)), 2558 m.Int32Constant(0)),
2527 &blocka, &blockb); 2559 &blocka, &blockb);
2528 m.Bind(&blocka); 2560 m.Bind(&blocka);
2529 m.Return(m.Int32Constant(constant)); 2561 m.Return(m.Int32Constant(constant));
2530 m.Bind(&blockb); 2562 m.Bind(&blockb);
2531 m.Return(m.Int32Constant(0 - constant)); 2563 m.Return(m.Int32Constant(0 - constant));
2532 FOR_INT32_INPUTS(j) { 2564 FOR_INT32_INPUTS(j) {
2533 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; 2565 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant;
2534 CHECK_EQ(expected, m.Call(*j)); 2566 CHECK_EQ(expected, m.Call(*j));
2535 } 2567 }
2536 } 2568 }
2537 } 2569 }
2538 { 2570 {
2539 FOR_INT32_INPUTS(i) { 2571 FOR_INT32_INPUTS(i) {
2540 RawMachineAssemblerTester<int32_t> m(kMachInt32); 2572 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
2541 RawMachineLabel blocka, blockb; 2573 RawMachineLabel blocka, blockb;
2542 m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), 2574 m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)),
2543 m.Int32Constant(0)), 2575 m.Int32Constant(0)),
2544 &blocka, &blockb); 2576 &blocka, &blockb);
2545 m.Bind(&blocka); 2577 m.Bind(&blocka);
2546 m.Return(m.Int32Constant(constant)); 2578 m.Return(m.Int32Constant(constant));
2547 m.Bind(&blockb); 2579 m.Bind(&blockb);
2548 m.Return(m.Int32Constant(0 - constant)); 2580 m.Return(m.Int32Constant(0 - constant));
2549 FOR_INT32_INPUTS(j) { 2581 FOR_INT32_INPUTS(j) {
2550 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; 2582 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant;
2551 CHECK_EQ(expected, m.Call(*j)); 2583 CHECK_EQ(expected, m.Call(*j));
2552 } 2584 }
2553 } 2585 }
2554 } 2586 }
2555 { 2587 {
2556 RawMachineAssemblerTester<void> m; 2588 RawMachineAssemblerTester<void> m;
2557 const Operator* shops[] = {m.machine()->Word32Sar(), 2589 const Operator* shops[] = {m.machine()->Word32Sar(),
2558 m.machine()->Word32Shl(), 2590 m.machine()->Word32Shl(),
2559 m.machine()->Word32Shr()}; 2591 m.machine()->Word32Shr()};
2560 for (size_t n = 0; n < arraysize(shops); n++) { 2592 for (size_t n = 0; n < arraysize(shops); n++) {
2561 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, 2593 RawMachineAssemblerTester<int32_t> m(
2562 kMachUint32); 2594 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
2563 RawMachineLabel blocka, blockb; 2595 RawMachineLabel blocka, blockb;
2564 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), 2596 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0),
2565 m.AddNode(shops[n], m.Parameter(1), 2597 m.AddNode(shops[n], m.Parameter(1),
2566 m.Parameter(2))), 2598 m.Parameter(2))),
2567 m.Int32Constant(0)), 2599 m.Int32Constant(0)),
2568 &blocka, &blockb); 2600 &blocka, &blockb);
2569 m.Bind(&blocka); 2601 m.Bind(&blocka);
2570 m.Return(m.Int32Constant(constant)); 2602 m.Return(m.Int32Constant(constant));
2571 m.Bind(&blockb); 2603 m.Bind(&blockb);
2572 m.Return(m.Int32Constant(0 - constant)); 2604 m.Return(m.Int32Constant(0 - constant));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 m.Word32Equal(m.Int32Constant(0), m.Word32Or(bt.param0, bt.param1))); 2649 m.Word32Equal(m.Int32Constant(0), m.Word32Or(bt.param0, bt.param1)));
2618 FOR_UINT32_INPUTS(i) { 2650 FOR_UINT32_INPUTS(i) {
2619 FOR_UINT32_INPUTS(j) { 2651 FOR_UINT32_INPUTS(j) {
2620 int32_t expected = (*i | *j) == 0; 2652 int32_t expected = (*i | *j) == 0;
2621 CHECK_EQ(expected, bt.call(*i, *j)); 2653 CHECK_EQ(expected, bt.call(*i, *j));
2622 } 2654 }
2623 } 2655 }
2624 } 2656 }
2625 { 2657 {
2626 FOR_UINT32_INPUTS(i) { 2658 FOR_UINT32_INPUTS(i) {
2627 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2659 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2628 m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), 2660 m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)),
2629 m.Int32Constant(0))); 2661 m.Int32Constant(0)));
2630 FOR_UINT32_INPUTS(j) { 2662 FOR_UINT32_INPUTS(j) {
2631 uint32_t expected = (*i | *j) == 0; 2663 uint32_t expected = (*i | *j) == 0;
2632 CHECK_EQ(expected, m.Call(*j)); 2664 CHECK_EQ(expected, m.Call(*j));
2633 } 2665 }
2634 } 2666 }
2635 } 2667 }
2636 { 2668 {
2637 FOR_UINT32_INPUTS(i) { 2669 FOR_UINT32_INPUTS(i) {
2638 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2670 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2639 m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)), 2671 m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)),
2640 m.Int32Constant(0))); 2672 m.Int32Constant(0)));
2641 FOR_UINT32_INPUTS(j) { 2673 FOR_UINT32_INPUTS(j) {
2642 uint32_t expected = (*j | *i) == 0; 2674 uint32_t expected = (*j | *i) == 0;
2643 CHECK_EQ(expected, m.Call(*j)); 2675 CHECK_EQ(expected, m.Call(*j));
2644 } 2676 }
2645 } 2677 }
2646 } 2678 }
2647 } 2679 }
2648 2680
2649 2681
2650 TEST(RunWord32XorP) { 2682 TEST(RunWord32XorP) {
2651 { 2683 {
2652 FOR_UINT32_INPUTS(i) { 2684 FOR_UINT32_INPUTS(i) {
2653 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2685 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2654 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0))); 2686 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)));
2655 FOR_UINT32_INPUTS(j) { 2687 FOR_UINT32_INPUTS(j) {
2656 uint32_t expected = *i ^ *j; 2688 uint32_t expected = *i ^ *j;
2657 CHECK_EQ(expected, m.Call(*j)); 2689 CHECK_EQ(expected, m.Call(*j));
2658 } 2690 }
2659 } 2691 }
2660 } 2692 }
2661 { 2693 {
2662 RawMachineAssemblerTester<int32_t> m; 2694 RawMachineAssemblerTester<int32_t> m;
2663 Uint32BinopTester bt(&m); 2695 Uint32BinopTester bt(&m);
(...skipping 22 matching lines...) Expand all
2686 bt.AddReturn(m.Word32Xor(m.Word32Not(bt.param0), bt.param1)); 2718 bt.AddReturn(m.Word32Xor(m.Word32Not(bt.param0), bt.param1));
2687 FOR_INT32_INPUTS(i) { 2719 FOR_INT32_INPUTS(i) {
2688 FOR_INT32_INPUTS(j) { 2720 FOR_INT32_INPUTS(j) {
2689 int32_t expected = ~(*i) ^ *j; 2721 int32_t expected = ~(*i) ^ *j;
2690 CHECK_EQ(expected, bt.call(*i, *j)); 2722 CHECK_EQ(expected, bt.call(*i, *j));
2691 } 2723 }
2692 } 2724 }
2693 } 2725 }
2694 { 2726 {
2695 FOR_UINT32_INPUTS(i) { 2727 FOR_UINT32_INPUTS(i) {
2696 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2728 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2697 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); 2729 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
2698 FOR_UINT32_INPUTS(j) { 2730 FOR_UINT32_INPUTS(j) {
2699 uint32_t expected = *i ^ ~(*j); 2731 uint32_t expected = *i ^ ~(*j);
2700 CHECK_EQ(expected, m.Call(*j)); 2732 CHECK_EQ(expected, m.Call(*j));
2701 } 2733 }
2702 } 2734 }
2703 } 2735 }
2704 } 2736 }
2705 2737
2706 2738
(...skipping 30 matching lines...) Expand all
2737 bt.AddReturn(m.Int32Constant(0 - constant)); 2769 bt.AddReturn(m.Int32Constant(0 - constant));
2738 FOR_UINT32_INPUTS(i) { 2770 FOR_UINT32_INPUTS(i) {
2739 FOR_UINT32_INPUTS(j) { 2771 FOR_UINT32_INPUTS(j) {
2740 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; 2772 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant;
2741 CHECK_EQ(expected, bt.call(*i, *j)); 2773 CHECK_EQ(expected, bt.call(*i, *j));
2742 } 2774 }
2743 } 2775 }
2744 } 2776 }
2745 { 2777 {
2746 FOR_UINT32_INPUTS(i) { 2778 FOR_UINT32_INPUTS(i) {
2747 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2779 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2748 RawMachineLabel blocka, blockb; 2780 RawMachineLabel blocka, blockb;
2749 m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), 2781 m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)),
2750 m.Int32Constant(0)), 2782 m.Int32Constant(0)),
2751 &blocka, &blockb); 2783 &blocka, &blockb);
2752 m.Bind(&blocka); 2784 m.Bind(&blocka);
2753 m.Return(m.Int32Constant(constant)); 2785 m.Return(m.Int32Constant(constant));
2754 m.Bind(&blockb); 2786 m.Bind(&blockb);
2755 m.Return(m.Int32Constant(0 - constant)); 2787 m.Return(m.Int32Constant(0 - constant));
2756 FOR_UINT32_INPUTS(j) { 2788 FOR_UINT32_INPUTS(j) {
2757 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; 2789 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant;
2758 CHECK_EQ(expected, m.Call(*j)); 2790 CHECK_EQ(expected, m.Call(*j));
2759 } 2791 }
2760 } 2792 }
2761 } 2793 }
2762 { 2794 {
2763 FOR_UINT32_INPUTS(i) { 2795 FOR_UINT32_INPUTS(i) {
2764 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2796 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2765 RawMachineLabel blocka, blockb; 2797 RawMachineLabel blocka, blockb;
2766 m.Branch( 2798 m.Branch(
2767 m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), 2799 m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)),
2768 m.Int32Constant(0)), 2800 m.Int32Constant(0)),
2769 &blocka, &blockb); 2801 &blocka, &blockb);
2770 m.Bind(&blocka); 2802 m.Bind(&blocka);
2771 m.Return(m.Int32Constant(constant)); 2803 m.Return(m.Int32Constant(constant));
2772 m.Bind(&blockb); 2804 m.Bind(&blockb);
2773 m.Return(m.Int32Constant(0 - constant)); 2805 m.Return(m.Int32Constant(0 - constant));
2774 FOR_UINT32_INPUTS(j) { 2806 FOR_UINT32_INPUTS(j) {
2775 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; 2807 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant;
2776 CHECK_EQ(expected, m.Call(*j)); 2808 CHECK_EQ(expected, m.Call(*j));
2777 } 2809 }
2778 } 2810 }
2779 } 2811 }
2780 { 2812 {
2781 RawMachineAssemblerTester<void> m; 2813 RawMachineAssemblerTester<void> m;
2782 const Operator* shops[] = {m.machine()->Word32Sar(), 2814 const Operator* shops[] = {m.machine()->Word32Sar(),
2783 m.machine()->Word32Shl(), 2815 m.machine()->Word32Shl(),
2784 m.machine()->Word32Shr()}; 2816 m.machine()->Word32Shr()};
2785 for (size_t n = 0; n < arraysize(shops); n++) { 2817 for (size_t n = 0; n < arraysize(shops); n++) {
2786 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, 2818 RawMachineAssemblerTester<int32_t> m(
2787 kMachUint32); 2819 MachineType::Uint32(), MachineType::Int32(), MachineType::Uint32());
2788 RawMachineLabel blocka, blockb; 2820 RawMachineLabel blocka, blockb;
2789 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), 2821 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0),
2790 m.AddNode(shops[n], m.Parameter(1), 2822 m.AddNode(shops[n], m.Parameter(1),
2791 m.Parameter(2))), 2823 m.Parameter(2))),
2792 m.Int32Constant(0)), 2824 m.Int32Constant(0)),
2793 &blocka, &blockb); 2825 &blocka, &blockb);
2794 m.Bind(&blocka); 2826 m.Bind(&blocka);
2795 m.Return(m.Int32Constant(constant)); 2827 m.Return(m.Int32Constant(constant));
2796 m.Bind(&blockb); 2828 m.Bind(&blockb);
2797 m.Return(m.Int32Constant(0 - constant)); 2829 m.Return(m.Int32Constant(0 - constant));
(...skipping 20 matching lines...) Expand all
2818 } 2850 }
2819 } 2851 }
2820 } 2852 }
2821 } 2853 }
2822 } 2854 }
2823 2855
2824 2856
2825 TEST(RunWord32ShlP) { 2857 TEST(RunWord32ShlP) {
2826 { 2858 {
2827 FOR_UINT32_SHIFTS(shift) { 2859 FOR_UINT32_SHIFTS(shift) {
2828 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2860 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2829 m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))); 2861 m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)));
2830 FOR_UINT32_INPUTS(j) { 2862 FOR_UINT32_INPUTS(j) {
2831 uint32_t expected = *j << shift; 2863 uint32_t expected = *j << shift;
2832 CHECK_EQ(expected, m.Call(*j)); 2864 CHECK_EQ(expected, m.Call(*j));
2833 } 2865 }
2834 } 2866 }
2835 } 2867 }
2836 { 2868 {
2837 RawMachineAssemblerTester<int32_t> m; 2869 RawMachineAssemblerTester<int32_t> m;
2838 Uint32BinopTester bt(&m); 2870 Uint32BinopTester bt(&m);
(...skipping 28 matching lines...) Expand all
2867 m.Word32Equal(m.Int32Constant(0), m.Word32Shl(bt.param0, bt.param1))); 2899 m.Word32Equal(m.Int32Constant(0), m.Word32Shl(bt.param0, bt.param1)));
2868 FOR_UINT32_INPUTS(i) { 2900 FOR_UINT32_INPUTS(i) {
2869 FOR_UINT32_SHIFTS(shift) { 2901 FOR_UINT32_SHIFTS(shift) {
2870 uint32_t expected = 0 == (*i << shift); 2902 uint32_t expected = 0 == (*i << shift);
2871 CHECK_EQ(expected, bt.call(*i, shift)); 2903 CHECK_EQ(expected, bt.call(*i, shift));
2872 } 2904 }
2873 } 2905 }
2874 } 2906 }
2875 { 2907 {
2876 FOR_UINT32_SHIFTS(shift) { 2908 FOR_UINT32_SHIFTS(shift) {
2877 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2909 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2878 m.Return( 2910 m.Return(
2879 m.Word32Equal(m.Int32Constant(0), 2911 m.Word32Equal(m.Int32Constant(0),
2880 m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)))); 2912 m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))));
2881 FOR_UINT32_INPUTS(i) { 2913 FOR_UINT32_INPUTS(i) {
2882 uint32_t expected = 0 == (*i << shift); 2914 uint32_t expected = 0 == (*i << shift);
2883 CHECK_EQ(expected, m.Call(*i)); 2915 CHECK_EQ(expected, m.Call(*i));
2884 } 2916 }
2885 } 2917 }
2886 } 2918 }
2887 { 2919 {
2888 FOR_UINT32_SHIFTS(shift) { 2920 FOR_UINT32_SHIFTS(shift) {
2889 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2921 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2890 m.Return( 2922 m.Return(
2891 m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)), 2923 m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)),
2892 m.Int32Constant(0))); 2924 m.Int32Constant(0)));
2893 FOR_UINT32_INPUTS(i) { 2925 FOR_UINT32_INPUTS(i) {
2894 uint32_t expected = 0 == (*i << shift); 2926 uint32_t expected = 0 == (*i << shift);
2895 CHECK_EQ(expected, m.Call(*i)); 2927 CHECK_EQ(expected, m.Call(*i));
2896 } 2928 }
2897 } 2929 }
2898 } 2930 }
2899 } 2931 }
2900 2932
2901 2933
2902 TEST(RunWord32ShrP) { 2934 TEST(RunWord32ShrP) {
2903 { 2935 {
2904 FOR_UINT32_SHIFTS(shift) { 2936 FOR_UINT32_SHIFTS(shift) {
2905 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2937 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2906 m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))); 2938 m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)));
2907 FOR_UINT32_INPUTS(j) { 2939 FOR_UINT32_INPUTS(j) {
2908 uint32_t expected = *j >> shift; 2940 uint32_t expected = *j >> shift;
2909 CHECK_EQ(expected, m.Call(*j)); 2941 CHECK_EQ(expected, m.Call(*j));
2910 } 2942 }
2911 } 2943 }
2912 } 2944 }
2913 { 2945 {
2914 RawMachineAssemblerTester<int32_t> m; 2946 RawMachineAssemblerTester<int32_t> m;
2915 Uint32BinopTester bt(&m); 2947 Uint32BinopTester bt(&m);
(...skipping 29 matching lines...) Expand all
2945 m.Word32Equal(m.Int32Constant(0), m.Word32Shr(bt.param0, bt.param1))); 2977 m.Word32Equal(m.Int32Constant(0), m.Word32Shr(bt.param0, bt.param1)));
2946 FOR_UINT32_INPUTS(i) { 2978 FOR_UINT32_INPUTS(i) {
2947 FOR_UINT32_SHIFTS(shift) { 2979 FOR_UINT32_SHIFTS(shift) {
2948 uint32_t expected = 0 == (*i >> shift); 2980 uint32_t expected = 0 == (*i >> shift);
2949 CHECK_EQ(expected, bt.call(*i, shift)); 2981 CHECK_EQ(expected, bt.call(*i, shift));
2950 } 2982 }
2951 } 2983 }
2952 } 2984 }
2953 { 2985 {
2954 FOR_UINT32_SHIFTS(shift) { 2986 FOR_UINT32_SHIFTS(shift) {
2955 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2987 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2956 m.Return( 2988 m.Return(
2957 m.Word32Equal(m.Int32Constant(0), 2989 m.Word32Equal(m.Int32Constant(0),
2958 m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); 2990 m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))));
2959 FOR_UINT32_INPUTS(i) { 2991 FOR_UINT32_INPUTS(i) {
2960 uint32_t expected = 0 == (*i >> shift); 2992 uint32_t expected = 0 == (*i >> shift);
2961 CHECK_EQ(expected, m.Call(*i)); 2993 CHECK_EQ(expected, m.Call(*i));
2962 } 2994 }
2963 } 2995 }
2964 } 2996 }
2965 { 2997 {
2966 FOR_UINT32_SHIFTS(shift) { 2998 FOR_UINT32_SHIFTS(shift) {
2967 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 2999 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
2968 m.Return( 3000 m.Return(
2969 m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), 3001 m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)),
2970 m.Int32Constant(0))); 3002 m.Int32Constant(0)));
2971 FOR_UINT32_INPUTS(i) { 3003 FOR_UINT32_INPUTS(i) {
2972 uint32_t expected = 0 == (*i >> shift); 3004 uint32_t expected = 0 == (*i >> shift);
2973 CHECK_EQ(expected, m.Call(*i)); 3005 CHECK_EQ(expected, m.Call(*i));
2974 } 3006 }
2975 } 3007 }
2976 } 3008 }
2977 } 3009 }
2978 3010
2979 3011
2980 TEST(RunWord32SarP) { 3012 TEST(RunWord32SarP) {
2981 { 3013 {
2982 FOR_INT32_SHIFTS(shift) { 3014 FOR_INT32_SHIFTS(shift) {
2983 RawMachineAssemblerTester<int32_t> m(kMachInt32); 3015 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
2984 m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))); 3016 m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)));
2985 FOR_INT32_INPUTS(j) { 3017 FOR_INT32_INPUTS(j) {
2986 int32_t expected = *j >> shift; 3018 int32_t expected = *j >> shift;
2987 CHECK_EQ(expected, m.Call(*j)); 3019 CHECK_EQ(expected, m.Call(*j));
2988 } 3020 }
2989 } 3021 }
2990 } 3022 }
2991 { 3023 {
2992 RawMachineAssemblerTester<int32_t> m; 3024 RawMachineAssemblerTester<int32_t> m;
2993 Int32BinopTester bt(&m); 3025 Int32BinopTester bt(&m);
(...skipping 29 matching lines...) Expand all
3023 m.Word32Equal(m.Int32Constant(0), m.Word32Sar(bt.param0, bt.param1))); 3055 m.Word32Equal(m.Int32Constant(0), m.Word32Sar(bt.param0, bt.param1)));
3024 FOR_INT32_INPUTS(i) { 3056 FOR_INT32_INPUTS(i) {
3025 FOR_INT32_SHIFTS(shift) { 3057 FOR_INT32_SHIFTS(shift) {
3026 int32_t expected = 0 == (*i >> shift); 3058 int32_t expected = 0 == (*i >> shift);
3027 CHECK_EQ(expected, bt.call(*i, shift)); 3059 CHECK_EQ(expected, bt.call(*i, shift));
3028 } 3060 }
3029 } 3061 }
3030 } 3062 }
3031 { 3063 {
3032 FOR_INT32_SHIFTS(shift) { 3064 FOR_INT32_SHIFTS(shift) {
3033 RawMachineAssemblerTester<int32_t> m(kMachInt32); 3065 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
3034 m.Return( 3066 m.Return(
3035 m.Word32Equal(m.Int32Constant(0), 3067 m.Word32Equal(m.Int32Constant(0),
3036 m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)))); 3068 m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))));
3037 FOR_INT32_INPUTS(i) { 3069 FOR_INT32_INPUTS(i) {
3038 int32_t expected = 0 == (*i >> shift); 3070 int32_t expected = 0 == (*i >> shift);
3039 CHECK_EQ(expected, m.Call(*i)); 3071 CHECK_EQ(expected, m.Call(*i));
3040 } 3072 }
3041 } 3073 }
3042 } 3074 }
3043 { 3075 {
3044 FOR_INT32_SHIFTS(shift) { 3076 FOR_INT32_SHIFTS(shift) {
3045 RawMachineAssemblerTester<int32_t> m(kMachInt32); 3077 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
3046 m.Return( 3078 m.Return(
3047 m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)), 3079 m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)),
3048 m.Int32Constant(0))); 3080 m.Int32Constant(0)));
3049 FOR_INT32_INPUTS(i) { 3081 FOR_INT32_INPUTS(i) {
3050 int32_t expected = 0 == (*i >> shift); 3082 int32_t expected = 0 == (*i >> shift);
3051 CHECK_EQ(expected, m.Call(*i)); 3083 CHECK_EQ(expected, m.Call(*i));
3052 } 3084 }
3053 } 3085 }
3054 } 3086 }
3055 } 3087 }
3056 3088
3057 3089
3058 TEST(RunWord32RorP) { 3090 TEST(RunWord32RorP) {
3059 { 3091 {
3060 FOR_UINT32_SHIFTS(shift) { 3092 FOR_UINT32_SHIFTS(shift) {
3061 RawMachineAssemblerTester<int32_t> m(kMachUint32); 3093 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
3062 m.Return(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift))); 3094 m.Return(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)));
3063 FOR_UINT32_INPUTS(j) { 3095 FOR_UINT32_INPUTS(j) {
3064 int32_t expected = bits::RotateRight32(*j, shift); 3096 int32_t expected = bits::RotateRight32(*j, shift);
3065 CHECK_EQ(expected, m.Call(*j)); 3097 CHECK_EQ(expected, m.Call(*j));
3066 } 3098 }
3067 } 3099 }
3068 } 3100 }
3069 { 3101 {
3070 RawMachineAssemblerTester<int32_t> m; 3102 RawMachineAssemblerTester<int32_t> m;
3071 Uint32BinopTester bt(&m); 3103 Uint32BinopTester bt(&m);
(...skipping 28 matching lines...) Expand all
3100 m.Word32Equal(m.Int32Constant(0), m.Word32Ror(bt.param0, bt.param1))); 3132 m.Word32Equal(m.Int32Constant(0), m.Word32Ror(bt.param0, bt.param1)));
3101 FOR_UINT32_INPUTS(i) { 3133 FOR_UINT32_INPUTS(i) {
3102 FOR_UINT32_SHIFTS(shift) { 3134 FOR_UINT32_SHIFTS(shift) {
3103 uint32_t expected = 0 == bits::RotateRight32(*i, shift); 3135 uint32_t expected = 0 == bits::RotateRight32(*i, shift);
3104 CHECK_EQ(expected, bt.call(*i, shift)); 3136 CHECK_EQ(expected, bt.call(*i, shift));
3105 } 3137 }
3106 } 3138 }
3107 } 3139 }
3108 { 3140 {
3109 FOR_UINT32_SHIFTS(shift) { 3141 FOR_UINT32_SHIFTS(shift) {
3110 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 3142 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
3111 m.Return( 3143 m.Return(
3112 m.Word32Equal(m.Int32Constant(0), 3144 m.Word32Equal(m.Int32Constant(0),
3113 m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)))); 3145 m.Word32Ror(m.Parameter(0), m.Int32Constant(shift))));
3114 FOR_UINT32_INPUTS(i) { 3146 FOR_UINT32_INPUTS(i) {
3115 uint32_t expected = 0 == bits::RotateRight32(*i, shift); 3147 uint32_t expected = 0 == bits::RotateRight32(*i, shift);
3116 CHECK_EQ(expected, m.Call(*i)); 3148 CHECK_EQ(expected, m.Call(*i));
3117 } 3149 }
3118 } 3150 }
3119 } 3151 }
3120 { 3152 {
3121 FOR_UINT32_SHIFTS(shift) { 3153 FOR_UINT32_SHIFTS(shift) {
3122 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 3154 RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32());
3123 m.Return( 3155 m.Return(
3124 m.Word32Equal(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)), 3156 m.Word32Equal(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)),
3125 m.Int32Constant(0))); 3157 m.Int32Constant(0)));
3126 FOR_UINT32_INPUTS(i) { 3158 FOR_UINT32_INPUTS(i) {
3127 uint32_t expected = 0 == bits::RotateRight32(*i, shift); 3159 uint32_t expected = 0 == bits::RotateRight32(*i, shift);
3128 CHECK_EQ(expected, m.Call(*i)); 3160 CHECK_EQ(expected, m.Call(*i));
3129 } 3161 }
3130 } 3162 }
3131 } 3163 }
3132 } 3164 }
3133 3165
3134 3166
3135 TEST(RunWord32NotP) { 3167 TEST(RunWord32NotP) {
3136 RawMachineAssemblerTester<int32_t> m(kMachInt32); 3168 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
3137 m.Return(m.Word32Not(m.Parameter(0))); 3169 m.Return(m.Word32Not(m.Parameter(0)));
3138 FOR_INT32_INPUTS(i) { 3170 FOR_INT32_INPUTS(i) {
3139 int expected = ~(*i); 3171 int expected = ~(*i);
3140 CHECK_EQ(expected, m.Call(*i)); 3172 CHECK_EQ(expected, m.Call(*i));
3141 } 3173 }
3142 } 3174 }
3143 3175
3144 3176
3145 TEST(RunInt32NegP) { 3177 TEST(RunInt32NegP) {
3146 RawMachineAssemblerTester<int32_t> m(kMachInt32); 3178 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
3147 m.Return(m.Int32Neg(m.Parameter(0))); 3179 m.Return(m.Int32Neg(m.Parameter(0)));
3148 FOR_INT32_INPUTS(i) { 3180 FOR_INT32_INPUTS(i) {
3149 int expected = -*i; 3181 int expected = -*i;
3150 CHECK_EQ(expected, m.Call(*i)); 3182 CHECK_EQ(expected, m.Call(*i));
3151 } 3183 }
3152 } 3184 }
3153 3185
3154 3186
3155 TEST(RunWord32EqualAndWord32SarP) { 3187 TEST(RunWord32EqualAndWord32SarP) {
3156 { 3188 {
3157 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachUint32); 3189 RawMachineAssemblerTester<int32_t> m(
3190 MachineType::Int32(), MachineType::Int32(), MachineType::Uint32());
3158 m.Return(m.Word32Equal(m.Parameter(0), 3191 m.Return(m.Word32Equal(m.Parameter(0),
3159 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 3192 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
3160 FOR_INT32_INPUTS(i) { 3193 FOR_INT32_INPUTS(i) {
3161 FOR_INT32_INPUTS(j) { 3194 FOR_INT32_INPUTS(j) {
3162 FOR_UINT32_SHIFTS(shift) { 3195 FOR_UINT32_SHIFTS(shift) {
3163 int32_t expected = (*i == (*j >> shift)); 3196 int32_t expected = (*i == (*j >> shift));
3164 CHECK_EQ(expected, m.Call(*i, *j, shift)); 3197 CHECK_EQ(expected, m.Call(*i, *j, shift));
3165 } 3198 }
3166 } 3199 }
3167 } 3200 }
3168 } 3201 }
3169 { 3202 {
3170 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachInt32); 3203 RawMachineAssemblerTester<int32_t> m(
3204 MachineType::Int32(), MachineType::Uint32(), MachineType::Int32());
3171 m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 3205 m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
3172 m.Parameter(2))); 3206 m.Parameter(2)));
3173 FOR_INT32_INPUTS(i) { 3207 FOR_INT32_INPUTS(i) {
3174 FOR_UINT32_SHIFTS(shift) { 3208 FOR_UINT32_SHIFTS(shift) {
3175 FOR_INT32_INPUTS(k) { 3209 FOR_INT32_INPUTS(k) {
3176 int32_t expected = ((*i >> shift) == *k); 3210 int32_t expected = ((*i >> shift) == *k);
3177 CHECK_EQ(expected, m.Call(*i, shift, *k)); 3211 CHECK_EQ(expected, m.Call(*i, shift, *k));
3178 } 3212 }
3179 } 3213 }
3180 } 3214 }
3181 } 3215 }
3182 } 3216 }
3183 3217
3184 3218
3185 TEST(RunWord32EqualAndWord32ShlP) { 3219 TEST(RunWord32EqualAndWord32ShlP) {
3186 { 3220 {
3187 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); 3221 RawMachineAssemblerTester<int32_t> m(
3222 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
3188 m.Return(m.Word32Equal(m.Parameter(0), 3223 m.Return(m.Word32Equal(m.Parameter(0),
3189 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 3224 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
3190 FOR_UINT32_INPUTS(i) { 3225 FOR_UINT32_INPUTS(i) {
3191 FOR_UINT32_INPUTS(j) { 3226 FOR_UINT32_INPUTS(j) {
3192 FOR_UINT32_SHIFTS(shift) { 3227 FOR_UINT32_SHIFTS(shift) {
3193 int32_t expected = (*i == (*j << shift)); 3228 int32_t expected = (*i == (*j << shift));
3194 CHECK_EQ(expected, m.Call(*i, *j, shift)); 3229 CHECK_EQ(expected, m.Call(*i, *j, shift));
3195 } 3230 }
3196 } 3231 }
3197 } 3232 }
3198 } 3233 }
3199 { 3234 {
3200 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); 3235 RawMachineAssemblerTester<int32_t> m(
3236 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
3201 m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 3237 m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
3202 m.Parameter(2))); 3238 m.Parameter(2)));
3203 FOR_UINT32_INPUTS(i) { 3239 FOR_UINT32_INPUTS(i) {
3204 FOR_UINT32_SHIFTS(shift) { 3240 FOR_UINT32_SHIFTS(shift) {
3205 FOR_UINT32_INPUTS(k) { 3241 FOR_UINT32_INPUTS(k) {
3206 int32_t expected = ((*i << shift) == *k); 3242 int32_t expected = ((*i << shift) == *k);
3207 CHECK_EQ(expected, m.Call(*i, shift, *k)); 3243 CHECK_EQ(expected, m.Call(*i, shift, *k));
3208 } 3244 }
3209 } 3245 }
3210 } 3246 }
3211 } 3247 }
3212 } 3248 }
3213 3249
3214 3250
3215 TEST(RunWord32EqualAndWord32ShrP) { 3251 TEST(RunWord32EqualAndWord32ShrP) {
3216 { 3252 {
3217 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); 3253 RawMachineAssemblerTester<int32_t> m(
3254 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
3218 m.Return(m.Word32Equal(m.Parameter(0), 3255 m.Return(m.Word32Equal(m.Parameter(0),
3219 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 3256 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
3220 FOR_UINT32_INPUTS(i) { 3257 FOR_UINT32_INPUTS(i) {
3221 FOR_UINT32_INPUTS(j) { 3258 FOR_UINT32_INPUTS(j) {
3222 FOR_UINT32_SHIFTS(shift) { 3259 FOR_UINT32_SHIFTS(shift) {
3223 int32_t expected = (*i == (*j >> shift)); 3260 int32_t expected = (*i == (*j >> shift));
3224 CHECK_EQ(expected, m.Call(*i, *j, shift)); 3261 CHECK_EQ(expected, m.Call(*i, *j, shift));
3225 } 3262 }
3226 } 3263 }
3227 } 3264 }
3228 } 3265 }
3229 { 3266 {
3230 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); 3267 RawMachineAssemblerTester<int32_t> m(
3268 MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
3231 m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 3269 m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
3232 m.Parameter(2))); 3270 m.Parameter(2)));
3233 FOR_UINT32_INPUTS(i) { 3271 FOR_UINT32_INPUTS(i) {
3234 FOR_UINT32_SHIFTS(shift) { 3272 FOR_UINT32_SHIFTS(shift) {
3235 FOR_UINT32_INPUTS(k) { 3273 FOR_UINT32_INPUTS(k) {
3236 int32_t expected = ((*i >> shift) == *k); 3274 int32_t expected = ((*i >> shift) == *k);
3237 CHECK_EQ(expected, m.Call(*i, shift, *k)); 3275 CHECK_EQ(expected, m.Call(*i, shift, *k));
3238 } 3276 }
3239 } 3277 }
3240 } 3278 }
3241 } 3279 }
3242 } 3280 }
3243 3281
3244 3282
3245 TEST(RunDeadNodes) { 3283 TEST(RunDeadNodes) {
3246 for (int i = 0; true; i++) { 3284 for (int i = 0; true; i++) {
3247 RawMachineAssemblerTester<int32_t> m(i == 5 ? kMachInt32 : kMachNone); 3285 RawMachineAssemblerTester<int32_t> m(i == 5 ? MachineType::Int32()
3286 : MachineType::None());
3248 int constant = 0x55 + i; 3287 int constant = 0x55 + i;
3249 switch (i) { 3288 switch (i) {
3250 case 0: 3289 case 0:
3251 m.Int32Constant(44); 3290 m.Int32Constant(44);
3252 break; 3291 break;
3253 case 1: 3292 case 1:
3254 m.StringConstant("unused"); 3293 m.StringConstant("unused");
3255 break; 3294 break;
3256 case 2: 3295 case 2:
3257 m.NumberConstant(11.1); 3296 m.NumberConstant(11.1);
3258 break; 3297 break;
3259 case 3: 3298 case 3:
3260 m.PointerConstant(&constant); 3299 m.PointerConstant(&constant);
3261 break; 3300 break;
3262 case 4: 3301 case 4:
3263 m.LoadFromPointer(&constant, kMachInt32); 3302 m.LoadFromPointer(&constant, MachineType::Int32());
3264 break; 3303 break;
3265 case 5: 3304 case 5:
3266 m.Parameter(0); 3305 m.Parameter(0);
3267 break; 3306 break;
3268 default: 3307 default:
3269 return; 3308 return;
3270 } 3309 }
3271 m.Return(m.Int32Constant(constant)); 3310 m.Return(m.Int32Constant(constant));
3272 if (i != 5) { 3311 if (i != 5) {
3273 CHECK_EQ(constant, m.Call()); 3312 CHECK_EQ(constant, m.Call());
(...skipping 14 matching lines...) Expand all
3288 m.machine()->Word32Ror(), m.machine()->Word32Equal(), 3327 m.machine()->Word32Ror(), m.machine()->Word32Equal(),
3289 m.machine()->Int32Add(), m.machine()->Int32Sub(), 3328 m.machine()->Int32Add(), m.machine()->Int32Sub(),
3290 m.machine()->Int32Mul(), m.machine()->Int32MulHigh(), 3329 m.machine()->Int32Mul(), m.machine()->Int32MulHigh(),
3291 m.machine()->Int32Div(), m.machine()->Uint32Div(), 3330 m.machine()->Int32Div(), m.machine()->Uint32Div(),
3292 m.machine()->Int32Mod(), m.machine()->Uint32Mod(), 3331 m.machine()->Int32Mod(), m.machine()->Uint32Mod(),
3293 m.machine()->Uint32MulHigh(), m.machine()->Int32LessThan(), 3332 m.machine()->Uint32MulHigh(), m.machine()->Int32LessThan(),
3294 m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(), 3333 m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(),
3295 m.machine()->Uint32LessThanOrEqual()}; 3334 m.machine()->Uint32LessThanOrEqual()};
3296 3335
3297 for (size_t i = 0; i < arraysize(kOps); ++i) { 3336 for (size_t i = 0; i < arraysize(kOps); ++i) {
3298 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 3337 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
3338 MachineType::Int32());
3299 int32_t constant = static_cast<int32_t>(0x55555 + i); 3339 int32_t constant = static_cast<int32_t>(0x55555 + i);
3300 m.AddNode(kOps[i], m.Parameter(0), m.Parameter(1)); 3340 m.AddNode(kOps[i], m.Parameter(0), m.Parameter(1));
3301 m.Return(m.Int32Constant(constant)); 3341 m.Return(m.Int32Constant(constant));
3302 3342
3303 CHECK_EQ(constant, m.Call(1, 1)); 3343 CHECK_EQ(constant, m.Call(1, 1));
3304 } 3344 }
3305 } 3345 }
3306 3346
3307 3347
3308 template <typename Type> 3348 template <typename Type>
(...skipping 17 matching lines...) Expand all
3326 3366
3327 Type expected = buffer[i]; 3367 Type expected = buffer[i];
3328 Type actual = m.Call(); 3368 Type actual = m.Call();
3329 CHECK(expected == actual); 3369 CHECK(expected == actual);
3330 } 3370 }
3331 } 3371 }
3332 } 3372 }
3333 3373
3334 3374
3335 TEST(RunLoadImmIndex) { 3375 TEST(RunLoadImmIndex) {
3336 RunLoadImmIndex<int8_t>(kMachInt8); 3376 RunLoadImmIndex<int8_t>(MachineType::Int8());
3337 RunLoadImmIndex<uint8_t>(kMachUint8); 3377 RunLoadImmIndex<uint8_t>(MachineType::Uint8());
3338 RunLoadImmIndex<int16_t>(kMachInt16); 3378 RunLoadImmIndex<int16_t>(MachineType::Int16());
3339 RunLoadImmIndex<uint16_t>(kMachUint16); 3379 RunLoadImmIndex<uint16_t>(MachineType::Uint16());
3340 RunLoadImmIndex<int32_t>(kMachInt32); 3380 RunLoadImmIndex<int32_t>(MachineType::Int32());
3341 RunLoadImmIndex<uint32_t>(kMachUint32); 3381 RunLoadImmIndex<uint32_t>(MachineType::Uint32());
3342 RunLoadImmIndex<int32_t*>(kMachAnyTagged); 3382 RunLoadImmIndex<int32_t*>(MachineType::AnyTagged());
3343 3383
3344 // TODO(titzer): test kRepBit loads 3384 // TODO(titzer): test kRepBit loads
3345 // TODO(titzer): test kMachFloat64 loads 3385 // TODO(titzer): test MachineType::Float64() loads
3346 // TODO(titzer): test various indexing modes. 3386 // TODO(titzer): test various indexing modes.
3347 } 3387 }
3348 3388
3349 3389
3350 template <typename CType> 3390 template <typename CType>
3351 static void RunLoadStore(MachineType rep) { 3391 static void RunLoadStore(MachineType rep) {
3352 const int kNumElems = 4; 3392 const int kNumElems = 4;
3353 CType buffer[kNumElems]; 3393 CType buffer[kNumElems];
3354 3394
3355 for (int32_t x = 0; x < kNumElems; x++) { 3395 for (int32_t x = 0; x < kNumElems; x++) {
(...skipping 14 matching lines...) Expand all
3370 m.Return(m.Int32Constant(OK)); 3410 m.Return(m.Int32Constant(OK));
3371 3411
3372 CHECK(buffer[x] != buffer[y]); 3412 CHECK(buffer[x] != buffer[y]);
3373 CHECK_EQ(OK, m.Call()); 3413 CHECK_EQ(OK, m.Call());
3374 CHECK(buffer[x] == buffer[y]); 3414 CHECK(buffer[x] == buffer[y]);
3375 } 3415 }
3376 } 3416 }
3377 3417
3378 3418
3379 TEST(RunLoadStore) { 3419 TEST(RunLoadStore) {
3380 RunLoadStore<int8_t>(kMachInt8); 3420 RunLoadStore<int8_t>(MachineType::Int8());
3381 RunLoadStore<uint8_t>(kMachUint8); 3421 RunLoadStore<uint8_t>(MachineType::Uint8());
3382 RunLoadStore<int16_t>(kMachInt16); 3422 RunLoadStore<int16_t>(MachineType::Int16());
3383 RunLoadStore<uint16_t>(kMachUint16); 3423 RunLoadStore<uint16_t>(MachineType::Uint16());
3384 RunLoadStore<int32_t>(kMachInt32); 3424 RunLoadStore<int32_t>(MachineType::Int32());
3385 RunLoadStore<uint32_t>(kMachUint32); 3425 RunLoadStore<uint32_t>(MachineType::Uint32());
3386 RunLoadStore<void*>(kMachAnyTagged); 3426 RunLoadStore<void*>(MachineType::AnyTagged());
3387 RunLoadStore<float>(kMachFloat32); 3427 RunLoadStore<float>(MachineType::Float32());
3388 RunLoadStore<double>(kMachFloat64); 3428 RunLoadStore<double>(MachineType::Float64());
3389 } 3429 }
3390 3430
3391 3431
3392 TEST(RunFloat32Add) { 3432 TEST(RunFloat32Add) {
3393 BufferedRawMachineAssemblerTester<float> m(kMachFloat32, kMachFloat32); 3433 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(),
3434 MachineType::Float32());
3394 m.Return(m.Float32Add(m.Parameter(0), m.Parameter(1))); 3435 m.Return(m.Float32Add(m.Parameter(0), m.Parameter(1)));
3395 3436
3396 FOR_FLOAT32_INPUTS(i) { 3437 FOR_FLOAT32_INPUTS(i) {
3397 FOR_FLOAT32_INPUTS(j) { 3438 FOR_FLOAT32_INPUTS(j) {
3398 volatile float expected = *i + *j; 3439 volatile float expected = *i + *j;
3399 CheckFloatEq(expected, m.Call(*i, *j)); 3440 CheckFloatEq(expected, m.Call(*i, *j));
3400 } 3441 }
3401 } 3442 }
3402 } 3443 }
3403 3444
3404 3445
3405 TEST(RunFloat32Sub) { 3446 TEST(RunFloat32Sub) {
3406 BufferedRawMachineAssemblerTester<float> m(kMachFloat32, kMachFloat32); 3447 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(),
3448 MachineType::Float32());
3407 m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1))); 3449 m.Return(m.Float32Sub(m.Parameter(0), m.Parameter(1)));
3408 3450
3409 FOR_FLOAT32_INPUTS(i) { 3451 FOR_FLOAT32_INPUTS(i) {
3410 FOR_FLOAT32_INPUTS(j) { 3452 FOR_FLOAT32_INPUTS(j) {
3411 volatile float expected = *i - *j; 3453 volatile float expected = *i - *j;
3412 CheckFloatEq(expected, m.Call(*i, *j)); 3454 CheckFloatEq(expected, m.Call(*i, *j));
3413 } 3455 }
3414 } 3456 }
3415 } 3457 }
3416 3458
3417 3459
3418 TEST(RunFloat32Mul) { 3460 TEST(RunFloat32Mul) {
3419 BufferedRawMachineAssemblerTester<float> m(kMachFloat32, kMachFloat32); 3461 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(),
3462 MachineType::Float32());
3420 m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1))); 3463 m.Return(m.Float32Mul(m.Parameter(0), m.Parameter(1)));
3421 3464
3422 FOR_FLOAT32_INPUTS(i) { 3465 FOR_FLOAT32_INPUTS(i) {
3423 FOR_FLOAT32_INPUTS(j) { 3466 FOR_FLOAT32_INPUTS(j) {
3424 volatile float expected = *i * *j; 3467 volatile float expected = *i * *j;
3425 CheckFloatEq(expected, m.Call(*i, *j)); 3468 CheckFloatEq(expected, m.Call(*i, *j));
3426 } 3469 }
3427 } 3470 }
3428 } 3471 }
3429 3472
3430 3473
3431 TEST(RunFloat32Div) { 3474 TEST(RunFloat32Div) {
3432 BufferedRawMachineAssemblerTester<float> m(kMachFloat32, kMachFloat32); 3475 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32(),
3476 MachineType::Float32());
3433 m.Return(m.Float32Div(m.Parameter(0), m.Parameter(1))); 3477 m.Return(m.Float32Div(m.Parameter(0), m.Parameter(1)));
3434 3478
3435 FOR_FLOAT32_INPUTS(i) { 3479 FOR_FLOAT32_INPUTS(i) {
3436 FOR_FLOAT32_INPUTS(j) { 3480 FOR_FLOAT32_INPUTS(j) {
3437 volatile float expected = *i / *j; 3481 volatile float expected = *i / *j;
3438 CheckFloatEq(expected, m.Call(*i, *j)); 3482 CheckFloatEq(expected, m.Call(*i, *j));
3439 } 3483 }
3440 } 3484 }
3441 } 3485 }
3442 3486
3443 3487
3444 TEST(RunFloat64Add) { 3488 TEST(RunFloat64Add) {
3445 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); 3489 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3490 MachineType::Float64());
3446 m.Return(m.Float64Add(m.Parameter(0), m.Parameter(1))); 3491 m.Return(m.Float64Add(m.Parameter(0), m.Parameter(1)));
3447 3492
3448 FOR_FLOAT64_INPUTS(i) { 3493 FOR_FLOAT64_INPUTS(i) {
3449 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(*i + *j, m.Call(*i, *j)); } 3494 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(*i + *j, m.Call(*i, *j)); }
3450 } 3495 }
3451 } 3496 }
3452 3497
3453 3498
3454 TEST(RunFloat64Sub) { 3499 TEST(RunFloat64Sub) {
3455 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); 3500 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3501 MachineType::Float64());
3456 m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1))); 3502 m.Return(m.Float64Sub(m.Parameter(0), m.Parameter(1)));
3457 3503
3458 FOR_FLOAT64_INPUTS(i) { 3504 FOR_FLOAT64_INPUTS(i) {
3459 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(*i - *j, m.Call(*i, *j)); } 3505 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(*i - *j, m.Call(*i, *j)); }
3460 } 3506 }
3461 } 3507 }
3462 3508
3463 3509
3464 TEST(RunFloat64Mul) { 3510 TEST(RunFloat64Mul) {
3465 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); 3511 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3512 MachineType::Float64());
3466 m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1))); 3513 m.Return(m.Float64Mul(m.Parameter(0), m.Parameter(1)));
3467 3514
3468 FOR_FLOAT64_INPUTS(i) { 3515 FOR_FLOAT64_INPUTS(i) {
3469 FOR_FLOAT64_INPUTS(j) { 3516 FOR_FLOAT64_INPUTS(j) {
3470 volatile double expected = *i * *j; 3517 volatile double expected = *i * *j;
3471 CheckDoubleEq(expected, m.Call(*i, *j)); 3518 CheckDoubleEq(expected, m.Call(*i, *j));
3472 } 3519 }
3473 } 3520 }
3474 } 3521 }
3475 3522
3476 3523
3477 TEST(RunFloat64Div) { 3524 TEST(RunFloat64Div) {
3478 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); 3525 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3526 MachineType::Float64());
3479 m.Return(m.Float64Div(m.Parameter(0), m.Parameter(1))); 3527 m.Return(m.Float64Div(m.Parameter(0), m.Parameter(1)));
3480 3528
3481 FOR_FLOAT64_INPUTS(i) { 3529 FOR_FLOAT64_INPUTS(i) {
3482 FOR_FLOAT64_INPUTS(j) { 3530 FOR_FLOAT64_INPUTS(j) {
3483 volatile double expected = *i / *j; 3531 volatile double expected = *i / *j;
3484 CheckDoubleEq(expected, m.Call(*i, *j)); 3532 CheckDoubleEq(expected, m.Call(*i, *j));
3485 } 3533 }
3486 } 3534 }
3487 } 3535 }
3488 3536
3489 3537
3490 TEST(RunFloat64Mod) { 3538 TEST(RunFloat64Mod) {
3491 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64); 3539 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
3540 MachineType::Float64());
3492 m.Return(m.Float64Mod(m.Parameter(0), m.Parameter(1))); 3541 m.Return(m.Float64Mod(m.Parameter(0), m.Parameter(1)));
3493 3542
3494 FOR_FLOAT64_INPUTS(i) { 3543 FOR_FLOAT64_INPUTS(i) {
3495 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(modulo(*i, *j), m.Call(*i, *j)); } 3544 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(modulo(*i, *j), m.Call(*i, *j)); }
3496 } 3545 }
3497 } 3546 }
3498 3547
3499 3548
3500 TEST(RunDeadFloat32Binops) { 3549 TEST(RunDeadFloat32Binops) {
3501 RawMachineAssemblerTester<int32_t> m; 3550 RawMachineAssemblerTester<int32_t> m;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 FOR_FLOAT32_INPUTS(pr) { 3684 FOR_FLOAT32_INPUTS(pr) {
3636 float expected = *pl - *pr; 3685 float expected = *pl - *pr;
3637 CheckFloatEq(expected, bt.call(*pl, *pr)); 3686 CheckFloatEq(expected, bt.call(*pl, *pr));
3638 } 3687 }
3639 } 3688 }
3640 } 3689 }
3641 3690
3642 3691
3643 TEST(RunFloat32SubImm1) { 3692 TEST(RunFloat32SubImm1) {
3644 FOR_FLOAT32_INPUTS(i) { 3693 FOR_FLOAT32_INPUTS(i) {
3645 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); 3694 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
3646 m.Return(m.Float32Sub(m.Float32Constant(*i), m.Parameter(0))); 3695 m.Return(m.Float32Sub(m.Float32Constant(*i), m.Parameter(0)));
3647 3696
3648 FOR_FLOAT32_INPUTS(j) { 3697 FOR_FLOAT32_INPUTS(j) {
3649 volatile float expected = *i - *j; 3698 volatile float expected = *i - *j;
3650 CheckFloatEq(expected, m.Call(*j)); 3699 CheckFloatEq(expected, m.Call(*j));
3651 } 3700 }
3652 } 3701 }
3653 } 3702 }
3654 3703
3655 3704
3656 TEST(RunFloat32SubImm2) { 3705 TEST(RunFloat32SubImm2) {
3657 FOR_FLOAT32_INPUTS(i) { 3706 FOR_FLOAT32_INPUTS(i) {
3658 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); 3707 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
3659 m.Return(m.Float32Sub(m.Parameter(0), m.Float32Constant(*i))); 3708 m.Return(m.Float32Sub(m.Parameter(0), m.Float32Constant(*i)));
3660 3709
3661 FOR_FLOAT32_INPUTS(j) { 3710 FOR_FLOAT32_INPUTS(j) {
3662 volatile float expected = *j - *i; 3711 volatile float expected = *j - *i;
3663 CheckFloatEq(expected, m.Call(*j)); 3712 CheckFloatEq(expected, m.Call(*j));
3664 } 3713 }
3665 } 3714 }
3666 } 3715 }
3667 3716
3668 3717
3669 TEST(RunFloat64SubImm1) { 3718 TEST(RunFloat64SubImm1) {
3670 FOR_FLOAT64_INPUTS(i) { 3719 FOR_FLOAT64_INPUTS(i) {
3671 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 3720 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
3672 m.Return(m.Float64Sub(m.Float64Constant(*i), m.Parameter(0))); 3721 m.Return(m.Float64Sub(m.Float64Constant(*i), m.Parameter(0)));
3673 3722
3674 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i - *j, m.Call(*j)); } 3723 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i - *j, m.Call(*j)); }
3675 } 3724 }
3676 } 3725 }
3677 3726
3678 3727
3679 TEST(RunFloat64SubImm2) { 3728 TEST(RunFloat64SubImm2) {
3680 FOR_FLOAT64_INPUTS(i) { 3729 FOR_FLOAT64_INPUTS(i) {
3681 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 3730 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
3682 m.Return(m.Float64Sub(m.Parameter(0), m.Float64Constant(*i))); 3731 m.Return(m.Float64Sub(m.Parameter(0), m.Float64Constant(*i)));
3683 3732
3684 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j - *i, m.Call(*j)); } 3733 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j - *i, m.Call(*j)); }
3685 } 3734 }
3686 } 3735 }
3687 3736
3688 3737
3689 TEST(RunFloat64SubP) { 3738 TEST(RunFloat64SubP) {
3690 RawMachineAssemblerTester<int32_t> m; 3739 RawMachineAssemblerTester<int32_t> m;
3691 Float64BinopTester bt(&m); 3740 Float64BinopTester bt(&m);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3725 FOR_FLOAT64_INPUTS(pl) { 3774 FOR_FLOAT64_INPUTS(pl) {
3726 FOR_FLOAT64_INPUTS(pr) { 3775 FOR_FLOAT64_INPUTS(pr) {
3727 double expected = *pl * *pr; 3776 double expected = *pl * *pr;
3728 CheckDoubleEq(expected, bt.call(*pl, *pr)); 3777 CheckDoubleEq(expected, bt.call(*pl, *pr));
3729 } 3778 }
3730 } 3779 }
3731 } 3780 }
3732 3781
3733 3782
3734 TEST(RunFloat64MulAndFloat64Add1) { 3783 TEST(RunFloat64MulAndFloat64Add1) {
3735 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64, 3784 BufferedRawMachineAssemblerTester<double> m(
3736 kMachFloat64); 3785 MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
3737 m.Return(m.Float64Add(m.Float64Mul(m.Parameter(0), m.Parameter(1)), 3786 m.Return(m.Float64Add(m.Float64Mul(m.Parameter(0), m.Parameter(1)),
3738 m.Parameter(2))); 3787 m.Parameter(2)));
3739 3788
3740 FOR_FLOAT64_INPUTS(i) { 3789 FOR_FLOAT64_INPUTS(i) {
3741 FOR_FLOAT64_INPUTS(j) { 3790 FOR_FLOAT64_INPUTS(j) {
3742 FOR_FLOAT64_INPUTS(k) { 3791 FOR_FLOAT64_INPUTS(k) {
3743 CheckDoubleEq((*i * *j) + *k, m.Call(*i, *j, *k)); 3792 CheckDoubleEq((*i * *j) + *k, m.Call(*i, *j, *k));
3744 } 3793 }
3745 } 3794 }
3746 } 3795 }
3747 } 3796 }
3748 3797
3749 3798
3750 TEST(RunFloat64MulAndFloat64Add2) { 3799 TEST(RunFloat64MulAndFloat64Add2) {
3751 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64, 3800 BufferedRawMachineAssemblerTester<double> m(
3752 kMachFloat64); 3801 MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
3753 m.Return(m.Float64Add(m.Parameter(0), 3802 m.Return(m.Float64Add(m.Parameter(0),
3754 m.Float64Mul(m.Parameter(1), m.Parameter(2)))); 3803 m.Float64Mul(m.Parameter(1), m.Parameter(2))));
3755 3804
3756 FOR_FLOAT64_INPUTS(i) { 3805 FOR_FLOAT64_INPUTS(i) {
3757 FOR_FLOAT64_INPUTS(j) { 3806 FOR_FLOAT64_INPUTS(j) {
3758 FOR_FLOAT64_INPUTS(k) { 3807 FOR_FLOAT64_INPUTS(k) {
3759 CheckDoubleEq(*i + (*j * *k), m.Call(*i, *j, *k)); 3808 CheckDoubleEq(*i + (*j * *k), m.Call(*i, *j, *k));
3760 } 3809 }
3761 } 3810 }
3762 } 3811 }
3763 } 3812 }
3764 3813
3765 3814
3766 TEST(RunFloat64MulAndFloat64Sub1) { 3815 TEST(RunFloat64MulAndFloat64Sub1) {
3767 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64, 3816 BufferedRawMachineAssemblerTester<double> m(
3768 kMachFloat64); 3817 MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
3769 m.Return(m.Float64Sub(m.Float64Mul(m.Parameter(0), m.Parameter(1)), 3818 m.Return(m.Float64Sub(m.Float64Mul(m.Parameter(0), m.Parameter(1)),
3770 m.Parameter(2))); 3819 m.Parameter(2)));
3771 3820
3772 FOR_FLOAT64_INPUTS(i) { 3821 FOR_FLOAT64_INPUTS(i) {
3773 FOR_FLOAT64_INPUTS(j) { 3822 FOR_FLOAT64_INPUTS(j) {
3774 FOR_FLOAT64_INPUTS(k) { 3823 FOR_FLOAT64_INPUTS(k) {
3775 CheckDoubleEq((*i * *j) - *k, m.Call(*i, *j, *k)); 3824 CheckDoubleEq((*i * *j) - *k, m.Call(*i, *j, *k));
3776 } 3825 }
3777 } 3826 }
3778 } 3827 }
3779 } 3828 }
3780 3829
3781 3830
3782 TEST(RunFloat64MulAndFloat64Sub2) { 3831 TEST(RunFloat64MulAndFloat64Sub2) {
3783 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachFloat64, 3832 BufferedRawMachineAssemblerTester<double> m(
3784 kMachFloat64); 3833 MachineType::Float64(), MachineType::Float64(), MachineType::Float64());
3785 m.Return(m.Float64Sub(m.Parameter(0), 3834 m.Return(m.Float64Sub(m.Parameter(0),
3786 m.Float64Mul(m.Parameter(1), m.Parameter(2)))); 3835 m.Float64Mul(m.Parameter(1), m.Parameter(2))));
3787 3836
3788 FOR_FLOAT64_INPUTS(i) { 3837 FOR_FLOAT64_INPUTS(i) {
3789 FOR_FLOAT64_INPUTS(j) { 3838 FOR_FLOAT64_INPUTS(j) {
3790 FOR_FLOAT64_INPUTS(k) { 3839 FOR_FLOAT64_INPUTS(k) {
3791 CheckDoubleEq(*i - (*j * *k), m.Call(*i, *j, *k)); 3840 CheckDoubleEq(*i - (*j * *k), m.Call(*i, *j, *k));
3792 } 3841 }
3793 } 3842 }
3794 } 3843 }
3795 } 3844 }
3796 3845
3797 3846
3798 TEST(RunFloat64MulImm1) { 3847 TEST(RunFloat64MulImm1) {
3799 FOR_FLOAT64_INPUTS(i) { 3848 FOR_FLOAT64_INPUTS(i) {
3800 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 3849 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
3801 m.Return(m.Float64Mul(m.Float64Constant(*i), m.Parameter(0))); 3850 m.Return(m.Float64Mul(m.Float64Constant(*i), m.Parameter(0)));
3802 3851
3803 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i * *j, m.Call(*j)); } 3852 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*i * *j, m.Call(*j)); }
3804 } 3853 }
3805 } 3854 }
3806 3855
3807 3856
3808 TEST(RunFloat64MulImm2) { 3857 TEST(RunFloat64MulImm2) {
3809 FOR_FLOAT64_INPUTS(i) { 3858 FOR_FLOAT64_INPUTS(i) {
3810 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 3859 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
3811 m.Return(m.Float64Mul(m.Parameter(0), m.Float64Constant(*i))); 3860 m.Return(m.Float64Mul(m.Parameter(0), m.Float64Constant(*i)));
3812 3861
3813 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j * *i, m.Call(*j)); } 3862 FOR_FLOAT64_INPUTS(j) { CheckFloatEq(*j * *i, m.Call(*j)); }
3814 } 3863 }
3815 } 3864 }
3816 3865
3817 3866
3818 TEST(RunFloat32DivP) { 3867 TEST(RunFloat32DivP) {
3819 RawMachineAssemblerTester<int32_t> m; 3868 RawMachineAssemblerTester<int32_t> m;
3820 Float32BinopTester bt(&m); 3869 Float32BinopTester bt(&m);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 3912
3864 TEST(RunChangeInt32ToFloat64_A) { 3913 TEST(RunChangeInt32ToFloat64_A) {
3865 int32_t magic = 0x986234; 3914 int32_t magic = 0x986234;
3866 BufferedRawMachineAssemblerTester<double> m; 3915 BufferedRawMachineAssemblerTester<double> m;
3867 m.Return(m.ChangeInt32ToFloat64(m.Int32Constant(magic))); 3916 m.Return(m.ChangeInt32ToFloat64(m.Int32Constant(magic)));
3868 CheckDoubleEq(static_cast<double>(magic), m.Call()); 3917 CheckDoubleEq(static_cast<double>(magic), m.Call());
3869 } 3918 }
3870 3919
3871 3920
3872 TEST(RunChangeInt32ToFloat64_B) { 3921 TEST(RunChangeInt32ToFloat64_B) {
3873 BufferedRawMachineAssemblerTester<double> m(kMachInt32); 3922 BufferedRawMachineAssemblerTester<double> m(MachineType::Int32());
3874 m.Return(m.ChangeInt32ToFloat64(m.Parameter(0))); 3923 m.Return(m.ChangeInt32ToFloat64(m.Parameter(0)));
3875 3924
3876 FOR_INT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } 3925 FOR_INT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); }
3877 } 3926 }
3878 3927
3879 3928
3880 TEST(RunChangeUint32ToFloat64) { 3929 TEST(RunChangeUint32ToFloat64) {
3881 BufferedRawMachineAssemblerTester<double> m(kMachUint32); 3930 BufferedRawMachineAssemblerTester<double> m(MachineType::Uint32());
3882 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); 3931 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0)));
3883 3932
3884 FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } 3933 FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); }
3885 } 3934 }
3886 3935
3887 3936
3888 TEST(RunChangeFloat64ToInt32_A) { 3937 TEST(RunChangeFloat64ToInt32_A) {
3889 BufferedRawMachineAssemblerTester<int32_t> m; 3938 BufferedRawMachineAssemblerTester<int32_t> m;
3890 double magic = 11.1; 3939 double magic = 11.1;
3891 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); 3940 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic)));
3892 CHECK_EQ(static_cast<int32_t>(magic), m.Call()); 3941 CHECK_EQ(static_cast<int32_t>(magic), m.Call());
3893 } 3942 }
3894 3943
3895 3944
3896 TEST(RunChangeFloat64ToInt32_B) { 3945 TEST(RunChangeFloat64ToInt32_B) {
3897 BufferedRawMachineAssemblerTester<int32_t> m(kMachFloat64); 3946 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float64());
3898 m.Return(m.ChangeFloat64ToInt32(m.Parameter(0))); 3947 m.Return(m.ChangeFloat64ToInt32(m.Parameter(0)));
3899 3948
3900 // Note we don't check fractional inputs, or inputs outside the range of 3949 // Note we don't check fractional inputs, or inputs outside the range of
3901 // int32, because these Convert operators really should be Change operators. 3950 // int32, because these Convert operators really should be Change operators.
3902 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, m.Call(static_cast<double>(*i))); } 3951 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, m.Call(static_cast<double>(*i))); }
3903 3952
3904 for (int32_t n = 1; n < 31; ++n) { 3953 for (int32_t n = 1; n < 31; ++n) {
3905 CHECK_EQ(1 << n, m.Call(static_cast<double>(1 << n))); 3954 CHECK_EQ(1 << n, m.Call(static_cast<double>(1 << n)));
3906 } 3955 }
3907 3956
3908 for (int32_t n = 1; n < 31; ++n) { 3957 for (int32_t n = 1; n < 31; ++n) {
3909 CHECK_EQ(3 << n, m.Call(static_cast<double>(3 << n))); 3958 CHECK_EQ(3 << n, m.Call(static_cast<double>(3 << n)));
3910 } 3959 }
3911 } 3960 }
3912 3961
3913 3962
3914 TEST(RunChangeFloat64ToUint32) { 3963 TEST(RunChangeFloat64ToUint32) {
3915 BufferedRawMachineAssemblerTester<uint32_t> m(kMachFloat64); 3964 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64());
3916 m.Return(m.ChangeFloat64ToUint32(m.Parameter(0))); 3965 m.Return(m.ChangeFloat64ToUint32(m.Parameter(0)));
3917 3966
3918 { 3967 {
3919 FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, m.Call(static_cast<double>(*i))); } 3968 FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, m.Call(static_cast<double>(*i))); }
3920 } 3969 }
3921 3970
3922 // Check various powers of 2. 3971 // Check various powers of 2.
3923 for (int32_t n = 1; n < 31; ++n) { 3972 for (int32_t n = 1; n < 31; ++n) {
3924 { CHECK_EQ(1u << n, m.Call(static_cast<double>(1u << n))); } 3973 { CHECK_EQ(1u << n, m.Call(static_cast<double>(1u << n))); }
3925 3974
3926 { CHECK_EQ(3u << n, m.Call(static_cast<double>(3u << n))); } 3975 { CHECK_EQ(3u << n, m.Call(static_cast<double>(3u << n))); }
3927 } 3976 }
3928 // Note we don't check fractional inputs, because these Convert operators 3977 // Note we don't check fractional inputs, because these Convert operators
3929 // really should be Change operators. 3978 // really should be Change operators.
3930 } 3979 }
3931 3980
3932 3981
3933 TEST(RunTruncateFloat64ToFloat32) { 3982 TEST(RunTruncateFloat64ToFloat32) {
3934 BufferedRawMachineAssemblerTester<float> m(kMachFloat64); 3983 BufferedRawMachineAssemblerTester<float> m(MachineType::Float64());
3935 3984
3936 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); 3985 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0)));
3937 3986
3938 FOR_FLOAT64_INPUTS(i) { CheckFloatEq(DoubleToFloat32(*i), m.Call(*i)); } 3987 FOR_FLOAT64_INPUTS(i) { CheckFloatEq(DoubleToFloat32(*i), m.Call(*i)); }
3939 } 3988 }
3940 3989
3941 3990
3942 TEST(RunDeadChangeFloat64ToInt32) { 3991 TEST(RunDeadChangeFloat64ToInt32) {
3943 RawMachineAssemblerTester<int32_t> m; 3992 RawMachineAssemblerTester<int32_t> m;
3944 const int magic = 0x88abcda4; 3993 const int magic = 0x88abcda4;
(...skipping 15 matching lines...) Expand all
3960 TEST(RunLoopPhiInduction2) { 4009 TEST(RunLoopPhiInduction2) {
3961 RawMachineAssemblerTester<int32_t> m; 4010 RawMachineAssemblerTester<int32_t> m;
3962 4011
3963 int false_val = 0x10777; 4012 int false_val = 0x10777;
3964 4013
3965 // x = false_val; while(false) { x++; } return x; 4014 // x = false_val; while(false) { x++; } return x;
3966 RawMachineLabel header, body, end; 4015 RawMachineLabel header, body, end;
3967 Node* false_node = m.Int32Constant(false_val); 4016 Node* false_node = m.Int32Constant(false_val);
3968 m.Goto(&header); 4017 m.Goto(&header);
3969 m.Bind(&header); 4018 m.Bind(&header);
3970 Node* phi = m.Phi(kMachInt32, false_node, false_node); 4019 Node* phi = m.Phi(MachineRepresentation::kWord32, false_node, false_node);
3971 m.Branch(m.Int32Constant(0), &body, &end); 4020 m.Branch(m.Int32Constant(0), &body, &end);
3972 m.Bind(&body); 4021 m.Bind(&body);
3973 Node* add = m.Int32Add(phi, m.Int32Constant(1)); 4022 Node* add = m.Int32Add(phi, m.Int32Constant(1));
3974 phi->ReplaceInput(1, add); 4023 phi->ReplaceInput(1, add);
3975 m.Goto(&header); 4024 m.Goto(&header);
3976 m.Bind(&end); 4025 m.Bind(&end);
3977 m.Return(phi); 4026 m.Return(phi);
3978 4027
3979 CHECK_EQ(false_val, m.Call()); 4028 CHECK_EQ(false_val, m.Call());
3980 } 4029 }
3981 4030
3982 4031
3983 TEST(RunFloatDiamond) { 4032 TEST(RunFloatDiamond) {
3984 RawMachineAssemblerTester<int32_t> m; 4033 RawMachineAssemblerTester<int32_t> m;
3985 4034
3986 const int magic = 99645; 4035 const int magic = 99645;
3987 float buffer = 0.1f; 4036 float buffer = 0.1f;
3988 float constant = 99.99f; 4037 float constant = 99.99f;
3989 4038
3990 RawMachineLabel blocka, blockb, end; 4039 RawMachineLabel blocka, blockb, end;
3991 Node* k1 = m.Float32Constant(constant); 4040 Node* k1 = m.Float32Constant(constant);
3992 Node* k2 = m.Float32Constant(0 - constant); 4041 Node* k2 = m.Float32Constant(0 - constant);
3993 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4042 m.Branch(m.Int32Constant(0), &blocka, &blockb);
3994 m.Bind(&blocka); 4043 m.Bind(&blocka);
3995 m.Goto(&end); 4044 m.Goto(&end);
3996 m.Bind(&blockb); 4045 m.Bind(&blockb);
3997 m.Goto(&end); 4046 m.Goto(&end);
3998 m.Bind(&end); 4047 m.Bind(&end);
3999 Node* phi = m.Phi(kMachFloat32, k2, k1); 4048 Node* phi = m.Phi(MachineRepresentation::kFloat32, k2, k1);
4000 m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi, 4049 m.Store(MachineType::Float32(), m.PointerConstant(&buffer),
4001 kNoWriteBarrier); 4050 m.IntPtrConstant(0), phi, kNoWriteBarrier);
4002 m.Return(m.Int32Constant(magic)); 4051 m.Return(m.Int32Constant(magic));
4003 4052
4004 CHECK_EQ(magic, m.Call()); 4053 CHECK_EQ(magic, m.Call());
4005 CHECK(constant == buffer); 4054 CHECK(constant == buffer);
4006 } 4055 }
4007 4056
4008 4057
4009 TEST(RunDoubleDiamond) { 4058 TEST(RunDoubleDiamond) {
4010 RawMachineAssemblerTester<int32_t> m; 4059 RawMachineAssemblerTester<int32_t> m;
4011 4060
4012 const int magic = 99645; 4061 const int magic = 99645;
4013 double buffer = 0.1; 4062 double buffer = 0.1;
4014 double constant = 99.99; 4063 double constant = 99.99;
4015 4064
4016 RawMachineLabel blocka, blockb, end; 4065 RawMachineLabel blocka, blockb, end;
4017 Node* k1 = m.Float64Constant(constant); 4066 Node* k1 = m.Float64Constant(constant);
4018 Node* k2 = m.Float64Constant(0 - constant); 4067 Node* k2 = m.Float64Constant(0 - constant);
4019 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4068 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4020 m.Bind(&blocka); 4069 m.Bind(&blocka);
4021 m.Goto(&end); 4070 m.Goto(&end);
4022 m.Bind(&blockb); 4071 m.Bind(&blockb);
4023 m.Goto(&end); 4072 m.Goto(&end);
4024 m.Bind(&end); 4073 m.Bind(&end);
4025 Node* phi = m.Phi(kMachFloat64, k2, k1); 4074 Node* phi = m.Phi(MachineRepresentation::kFloat64, k2, k1);
4026 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, 4075 m.Store(MachineType::Float64(), m.PointerConstant(&buffer),
4027 kNoWriteBarrier); 4076 m.Int32Constant(0), phi, kNoWriteBarrier);
4028 m.Return(m.Int32Constant(magic)); 4077 m.Return(m.Int32Constant(magic));
4029 4078
4030 CHECK_EQ(magic, m.Call()); 4079 CHECK_EQ(magic, m.Call());
4031 CHECK_EQ(constant, buffer); 4080 CHECK_EQ(constant, buffer);
4032 } 4081 }
4033 4082
4034 4083
4035 TEST(RunRefDiamond) { 4084 TEST(RunRefDiamond) {
4036 RawMachineAssemblerTester<int32_t> m; 4085 RawMachineAssemblerTester<int32_t> m;
4037 4086
4038 const int magic = 99644; 4087 const int magic = 99644;
4039 Handle<String> rexpected = 4088 Handle<String> rexpected =
4040 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); 4089 CcTest::i_isolate()->factory()->InternalizeUtf8String("A");
4041 String* buffer; 4090 String* buffer;
4042 4091
4043 RawMachineLabel blocka, blockb, end; 4092 RawMachineLabel blocka, blockb, end;
4044 Node* k1 = m.StringConstant("A"); 4093 Node* k1 = m.StringConstant("A");
4045 Node* k2 = m.StringConstant("B"); 4094 Node* k2 = m.StringConstant("B");
4046 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4095 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4047 m.Bind(&blocka); 4096 m.Bind(&blocka);
4048 m.Goto(&end); 4097 m.Goto(&end);
4049 m.Bind(&blockb); 4098 m.Bind(&blockb);
4050 m.Goto(&end); 4099 m.Goto(&end);
4051 m.Bind(&end); 4100 m.Bind(&end);
4052 Node* phi = m.Phi(kMachAnyTagged, k2, k1); 4101 Node* phi = m.Phi(MachineRepresentation::kTagged, k2, k1);
4053 m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi, 4102 m.Store(MachineType::AnyTagged(), m.PointerConstant(&buffer),
4054 kNoWriteBarrier); 4103 m.Int32Constant(0), phi, kNoWriteBarrier);
4055 m.Return(m.Int32Constant(magic)); 4104 m.Return(m.Int32Constant(magic));
4056 4105
4057 CHECK_EQ(magic, m.Call()); 4106 CHECK_EQ(magic, m.Call());
4058 CHECK(rexpected->SameValue(buffer)); 4107 CHECK(rexpected->SameValue(buffer));
4059 } 4108 }
4060 4109
4061 4110
4062 TEST(RunDoubleRefDiamond) { 4111 TEST(RunDoubleRefDiamond) {
4063 RawMachineAssemblerTester<int32_t> m; 4112 RawMachineAssemblerTester<int32_t> m;
4064 4113
4065 const int magic = 99648; 4114 const int magic = 99648;
4066 double dbuffer = 0.1; 4115 double dbuffer = 0.1;
4067 double dconstant = 99.99; 4116 double dconstant = 99.99;
4068 Handle<String> rexpected = 4117 Handle<String> rexpected =
4069 CcTest::i_isolate()->factory()->InternalizeUtf8String("AX"); 4118 CcTest::i_isolate()->factory()->InternalizeUtf8String("AX");
4070 String* rbuffer; 4119 String* rbuffer;
4071 4120
4072 RawMachineLabel blocka, blockb, end; 4121 RawMachineLabel blocka, blockb, end;
4073 Node* d1 = m.Float64Constant(dconstant); 4122 Node* d1 = m.Float64Constant(dconstant);
4074 Node* d2 = m.Float64Constant(0 - dconstant); 4123 Node* d2 = m.Float64Constant(0 - dconstant);
4075 Node* r1 = m.StringConstant("AX"); 4124 Node* r1 = m.StringConstant("AX");
4076 Node* r2 = m.StringConstant("BX"); 4125 Node* r2 = m.StringConstant("BX");
4077 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4126 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4078 m.Bind(&blocka); 4127 m.Bind(&blocka);
4079 m.Goto(&end); 4128 m.Goto(&end);
4080 m.Bind(&blockb); 4129 m.Bind(&blockb);
4081 m.Goto(&end); 4130 m.Goto(&end);
4082 m.Bind(&end); 4131 m.Bind(&end);
4083 Node* dphi = m.Phi(kMachFloat64, d2, d1); 4132 Node* dphi = m.Phi(MachineRepresentation::kFloat64, d2, d1);
4084 Node* rphi = m.Phi(kMachAnyTagged, r2, r1); 4133 Node* rphi = m.Phi(MachineRepresentation::kTagged, r2, r1);
4085 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi, 4134 m.Store(MachineType::Float64(), m.PointerConstant(&dbuffer),
4086 kNoWriteBarrier); 4135 m.Int32Constant(0), dphi, kNoWriteBarrier);
4087 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi, 4136 m.Store(MachineType::AnyTagged(), m.PointerConstant(&rbuffer),
4088 kNoWriteBarrier); 4137 m.Int32Constant(0), rphi, kNoWriteBarrier);
4089 m.Return(m.Int32Constant(magic)); 4138 m.Return(m.Int32Constant(magic));
4090 4139
4091 CHECK_EQ(magic, m.Call()); 4140 CHECK_EQ(magic, m.Call());
4092 CHECK_EQ(dconstant, dbuffer); 4141 CHECK_EQ(dconstant, dbuffer);
4093 CHECK(rexpected->SameValue(rbuffer)); 4142 CHECK(rexpected->SameValue(rbuffer));
4094 } 4143 }
4095 4144
4096 4145
4097 TEST(RunDoubleRefDoubleDiamond) { 4146 TEST(RunDoubleRefDoubleDiamond) {
4098 RawMachineAssemblerTester<int32_t> m; 4147 RawMachineAssemblerTester<int32_t> m;
4099 4148
4100 const int magic = 99649; 4149 const int magic = 99649;
4101 double dbuffer = 0.1; 4150 double dbuffer = 0.1;
4102 double dconstant = 99.997; 4151 double dconstant = 99.997;
4103 Handle<String> rexpected = 4152 Handle<String> rexpected =
4104 CcTest::i_isolate()->factory()->InternalizeUtf8String("AD"); 4153 CcTest::i_isolate()->factory()->InternalizeUtf8String("AD");
4105 String* rbuffer; 4154 String* rbuffer;
4106 4155
4107 RawMachineLabel blocka, blockb, mid, blockd, blocke, end; 4156 RawMachineLabel blocka, blockb, mid, blockd, blocke, end;
4108 Node* d1 = m.Float64Constant(dconstant); 4157 Node* d1 = m.Float64Constant(dconstant);
4109 Node* d2 = m.Float64Constant(0 - dconstant); 4158 Node* d2 = m.Float64Constant(0 - dconstant);
4110 Node* r1 = m.StringConstant("AD"); 4159 Node* r1 = m.StringConstant("AD");
4111 Node* r2 = m.StringConstant("BD"); 4160 Node* r2 = m.StringConstant("BD");
4112 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4161 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4113 m.Bind(&blocka); 4162 m.Bind(&blocka);
4114 m.Goto(&mid); 4163 m.Goto(&mid);
4115 m.Bind(&blockb); 4164 m.Bind(&blockb);
4116 m.Goto(&mid); 4165 m.Goto(&mid);
4117 m.Bind(&mid); 4166 m.Bind(&mid);
4118 Node* dphi1 = m.Phi(kMachFloat64, d2, d1); 4167 Node* dphi1 = m.Phi(MachineRepresentation::kFloat64, d2, d1);
4119 Node* rphi1 = m.Phi(kMachAnyTagged, r2, r1); 4168 Node* rphi1 = m.Phi(MachineRepresentation::kTagged, r2, r1);
4120 m.Branch(m.Int32Constant(0), &blockd, &blocke); 4169 m.Branch(m.Int32Constant(0), &blockd, &blocke);
4121 4170
4122 m.Bind(&blockd); 4171 m.Bind(&blockd);
4123 m.Goto(&end); 4172 m.Goto(&end);
4124 m.Bind(&blocke); 4173 m.Bind(&blocke);
4125 m.Goto(&end); 4174 m.Goto(&end);
4126 m.Bind(&end); 4175 m.Bind(&end);
4127 Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1); 4176 Node* dphi2 = m.Phi(MachineRepresentation::kFloat64, d1, dphi1);
4128 Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1); 4177 Node* rphi2 = m.Phi(MachineRepresentation::kTagged, r1, rphi1);
4129 4178
4130 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2, 4179 m.Store(MachineType::Float64(), m.PointerConstant(&dbuffer),
4131 kNoWriteBarrier); 4180 m.Int32Constant(0), dphi2, kNoWriteBarrier);
4132 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), 4181 m.Store(MachineType::AnyTagged(), m.PointerConstant(&rbuffer),
4133 rphi2, kNoWriteBarrier); 4182 m.Int32Constant(0), rphi2, kNoWriteBarrier);
4134 m.Return(m.Int32Constant(magic)); 4183 m.Return(m.Int32Constant(magic));
4135 4184
4136 CHECK_EQ(magic, m.Call()); 4185 CHECK_EQ(magic, m.Call());
4137 CHECK_EQ(dconstant, dbuffer); 4186 CHECK_EQ(dconstant, dbuffer);
4138 CHECK(rexpected->SameValue(rbuffer)); 4187 CHECK(rexpected->SameValue(rbuffer));
4139 } 4188 }
4140 4189
4141 4190
4142 TEST(RunDoubleLoopPhi) { 4191 TEST(RunDoubleLoopPhi) {
4143 RawMachineAssemblerTester<int32_t> m; 4192 RawMachineAssemblerTester<int32_t> m;
4144 RawMachineLabel header, body, end; 4193 RawMachineLabel header, body, end;
4145 4194
4146 int magic = 99773; 4195 int magic = 99773;
4147 double buffer = 0.99; 4196 double buffer = 0.99;
4148 double dconstant = 777.1; 4197 double dconstant = 777.1;
4149 4198
4150 Node* zero = m.Int32Constant(0); 4199 Node* zero = m.Int32Constant(0);
4151 Node* dk = m.Float64Constant(dconstant); 4200 Node* dk = m.Float64Constant(dconstant);
4152 4201
4153 m.Goto(&header); 4202 m.Goto(&header);
4154 m.Bind(&header); 4203 m.Bind(&header);
4155 Node* phi = m.Phi(kMachFloat64, dk, dk); 4204 Node* phi = m.Phi(MachineRepresentation::kFloat64, dk, dk);
4156 phi->ReplaceInput(1, phi); 4205 phi->ReplaceInput(1, phi);
4157 m.Branch(zero, &body, &end); 4206 m.Branch(zero, &body, &end);
4158 m.Bind(&body); 4207 m.Bind(&body);
4159 m.Goto(&header); 4208 m.Goto(&header);
4160 m.Bind(&end); 4209 m.Bind(&end);
4161 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, 4210 m.Store(MachineType::Float64(), m.PointerConstant(&buffer),
4162 kNoWriteBarrier); 4211 m.Int32Constant(0), phi, kNoWriteBarrier);
4163 m.Return(m.Int32Constant(magic)); 4212 m.Return(m.Int32Constant(magic));
4164 4213
4165 CHECK_EQ(magic, m.Call()); 4214 CHECK_EQ(magic, m.Call());
4166 } 4215 }
4167 4216
4168 4217
4169 TEST(RunCountToTenAccRaw) { 4218 TEST(RunCountToTenAccRaw) {
4170 RawMachineAssemblerTester<int32_t> m; 4219 RawMachineAssemblerTester<int32_t> m;
4171 4220
4172 Node* zero = m.Int32Constant(0); 4221 Node* zero = m.Int32Constant(0);
4173 Node* ten = m.Int32Constant(10); 4222 Node* ten = m.Int32Constant(10);
4174 Node* one = m.Int32Constant(1); 4223 Node* one = m.Int32Constant(1);
4175 4224
4176 RawMachineLabel header, body, body_cont, end; 4225 RawMachineLabel header, body, body_cont, end;
4177 4226
4178 m.Goto(&header); 4227 m.Goto(&header);
4179 4228
4180 m.Bind(&header); 4229 m.Bind(&header);
4181 Node* i = m.Phi(kMachInt32, zero, zero); 4230 Node* i = m.Phi(MachineRepresentation::kWord32, zero, zero);
4182 Node* j = m.Phi(kMachInt32, zero, zero); 4231 Node* j = m.Phi(MachineRepresentation::kWord32, zero, zero);
4183 m.Goto(&body); 4232 m.Goto(&body);
4184 4233
4185 m.Bind(&body); 4234 m.Bind(&body);
4186 Node* next_i = m.Int32Add(i, one); 4235 Node* next_i = m.Int32Add(i, one);
4187 Node* next_j = m.Int32Add(j, one); 4236 Node* next_j = m.Int32Add(j, one);
4188 m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont); 4237 m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont);
4189 4238
4190 m.Bind(&body_cont); 4239 m.Bind(&body_cont);
4191 i->ReplaceInput(1, next_i); 4240 i->ReplaceInput(1, next_i);
4192 j->ReplaceInput(1, next_j); 4241 j->ReplaceInput(1, next_j);
(...skipping 11 matching lines...) Expand all
4204 4253
4205 Node* zero = m.Int32Constant(0); 4254 Node* zero = m.Int32Constant(0);
4206 Node* ten = m.Int32Constant(10); 4255 Node* ten = m.Int32Constant(10);
4207 Node* one = m.Int32Constant(1); 4256 Node* one = m.Int32Constant(1);
4208 4257
4209 RawMachineLabel header, body, body_cont, end; 4258 RawMachineLabel header, body, body_cont, end;
4210 4259
4211 m.Goto(&header); 4260 m.Goto(&header);
4212 4261
4213 m.Bind(&header); 4262 m.Bind(&header);
4214 Node* i = m.Phi(kMachInt32, zero, zero); 4263 Node* i = m.Phi(MachineRepresentation::kWord32, zero, zero);
4215 Node* j = m.Phi(kMachInt32, zero, zero); 4264 Node* j = m.Phi(MachineRepresentation::kWord32, zero, zero);
4216 Node* k = m.Phi(kMachInt32, zero, zero); 4265 Node* k = m.Phi(MachineRepresentation::kWord32, zero, zero);
4217 m.Goto(&body); 4266 m.Goto(&body);
4218 4267
4219 m.Bind(&body); 4268 m.Bind(&body);
4220 Node* next_i = m.Int32Add(i, one); 4269 Node* next_i = m.Int32Add(i, one);
4221 Node* next_j = m.Int32Add(j, one); 4270 Node* next_j = m.Int32Add(j, one);
4222 Node* next_k = m.Int32Add(j, one); 4271 Node* next_k = m.Int32Add(j, one);
4223 m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont); 4272 m.Branch(m.Word32Equal(next_i, ten), &end, &body_cont);
4224 4273
4225 m.Bind(&body_cont); 4274 m.Bind(&body_cont);
4226 i->ReplaceInput(1, next_i); 4275 i->ReplaceInput(1, next_i);
4227 j->ReplaceInput(1, next_j); 4276 j->ReplaceInput(1, next_j);
4228 k->ReplaceInput(1, next_k); 4277 k->ReplaceInput(1, next_k);
4229 m.Goto(&header); 4278 m.Goto(&header);
4230 4279
4231 m.Bind(&end); 4280 m.Bind(&end);
4232 m.Return(ten); 4281 m.Return(ten);
4233 4282
4234 CHECK_EQ(10, m.Call()); 4283 CHECK_EQ(10, m.Call());
4235 } 4284 }
4236 4285
4237 4286
4238 TEST(RunAddTree) { 4287 TEST(RunAddTree) {
4239 RawMachineAssemblerTester<int32_t> m; 4288 RawMachineAssemblerTester<int32_t> m;
4240 int32_t inputs[] = {11, 12, 13, 14, 15, 16, 17, 18}; 4289 int32_t inputs[] = {11, 12, 13, 14, 15, 16, 17, 18};
4241 4290
4242 Node* base = m.PointerConstant(inputs); 4291 Node* base = m.PointerConstant(inputs);
4243 Node* n0 = m.Load(kMachInt32, base, m.Int32Constant(0 * sizeof(int32_t))); 4292 Node* n0 =
4244 Node* n1 = m.Load(kMachInt32, base, m.Int32Constant(1 * sizeof(int32_t))); 4293 m.Load(MachineType::Int32(), base, m.Int32Constant(0 * sizeof(int32_t)));
4245 Node* n2 = m.Load(kMachInt32, base, m.Int32Constant(2 * sizeof(int32_t))); 4294 Node* n1 =
4246 Node* n3 = m.Load(kMachInt32, base, m.Int32Constant(3 * sizeof(int32_t))); 4295 m.Load(MachineType::Int32(), base, m.Int32Constant(1 * sizeof(int32_t)));
4247 Node* n4 = m.Load(kMachInt32, base, m.Int32Constant(4 * sizeof(int32_t))); 4296 Node* n2 =
4248 Node* n5 = m.Load(kMachInt32, base, m.Int32Constant(5 * sizeof(int32_t))); 4297 m.Load(MachineType::Int32(), base, m.Int32Constant(2 * sizeof(int32_t)));
4249 Node* n6 = m.Load(kMachInt32, base, m.Int32Constant(6 * sizeof(int32_t))); 4298 Node* n3 =
4250 Node* n7 = m.Load(kMachInt32, base, m.Int32Constant(7 * sizeof(int32_t))); 4299 m.Load(MachineType::Int32(), base, m.Int32Constant(3 * sizeof(int32_t)));
4300 Node* n4 =
4301 m.Load(MachineType::Int32(), base, m.Int32Constant(4 * sizeof(int32_t)));
4302 Node* n5 =
4303 m.Load(MachineType::Int32(), base, m.Int32Constant(5 * sizeof(int32_t)));
4304 Node* n6 =
4305 m.Load(MachineType::Int32(), base, m.Int32Constant(6 * sizeof(int32_t)));
4306 Node* n7 =
4307 m.Load(MachineType::Int32(), base, m.Int32Constant(7 * sizeof(int32_t)));
4251 4308
4252 Node* i1 = m.Int32Add(n0, n1); 4309 Node* i1 = m.Int32Add(n0, n1);
4253 Node* i2 = m.Int32Add(n2, n3); 4310 Node* i2 = m.Int32Add(n2, n3);
4254 Node* i3 = m.Int32Add(n4, n5); 4311 Node* i3 = m.Int32Add(n4, n5);
4255 Node* i4 = m.Int32Add(n6, n7); 4312 Node* i4 = m.Int32Add(n6, n7);
4256 4313
4257 Node* i5 = m.Int32Add(i1, i2); 4314 Node* i5 = m.Int32Add(i1, i2);
4258 Node* i6 = m.Int32Add(i3, i4); 4315 Node* i6 = m.Int32Add(i3, i4);
4259 4316
4260 Node* i7 = m.Int32Add(i5, i6); 4317 Node* i7 = m.Int32Add(i5, i6);
(...skipping 11 matching lines...) Expand all
4272 int test_case, int node_type, double x, 4329 int test_case, int node_type, double x,
4273 double y) { 4330 double y) {
4274 static double buffer[2]; 4331 static double buffer[2];
4275 buffer[0] = x; 4332 buffer[0] = x;
4276 buffer[1] = y; 4333 buffer[1] = y;
4277 CHECK(0 <= test_case && test_case < kFloat64CompareHelperTestCases); 4334 CHECK(0 <= test_case && test_case < kFloat64CompareHelperTestCases);
4278 CHECK(0 <= node_type && node_type < kFloat64CompareHelperNodeType); 4335 CHECK(0 <= node_type && node_type < kFloat64CompareHelperNodeType);
4279 CHECK(x < y); 4336 CHECK(x < y);
4280 bool load_a = node_type / 2 == 1; 4337 bool load_a = node_type / 2 == 1;
4281 bool load_b = node_type % 2 == 1; 4338 bool load_b = node_type % 2 == 1;
4282 Node* a = load_a ? m->Load(kMachFloat64, m->PointerConstant(&buffer[0])) 4339 Node* a =
4283 : m->Float64Constant(x); 4340 load_a ? m->Load(MachineType::Float64(), m->PointerConstant(&buffer[0]))
4284 Node* b = load_b ? m->Load(kMachFloat64, m->PointerConstant(&buffer[1])) 4341 : m->Float64Constant(x);
4285 : m->Float64Constant(y); 4342 Node* b =
4343 load_b ? m->Load(MachineType::Float64(), m->PointerConstant(&buffer[1]))
4344 : m->Float64Constant(y);
4286 Node* cmp = NULL; 4345 Node* cmp = NULL;
4287 bool expected = false; 4346 bool expected = false;
4288 switch (test_case) { 4347 switch (test_case) {
4289 // Equal tests. 4348 // Equal tests.
4290 case 0: 4349 case 0:
4291 cmp = m->Float64Equal(a, b); 4350 cmp = m->Float64Equal(a, b);
4292 expected = false; 4351 expected = false;
4293 break; 4352 break;
4294 case 1: 4353 case 1:
4295 cmp = m->Float64Equal(a, a); 4354 cmp = m->Float64Equal(a, a);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
4402 } 4461 }
4403 } 4462 }
4404 } 4463 }
4405 4464
4406 4465
4407 TEST(RunFloat64Equal) { 4466 TEST(RunFloat64Equal) {
4408 double input_a = 0.0; 4467 double input_a = 0.0;
4409 double input_b = 0.0; 4468 double input_b = 0.0;
4410 4469
4411 RawMachineAssemblerTester<int32_t> m; 4470 RawMachineAssemblerTester<int32_t> m;
4412 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); 4471 Node* a = m.LoadFromPointer(&input_a, MachineType::Float64());
4413 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); 4472 Node* b = m.LoadFromPointer(&input_b, MachineType::Float64());
4414 m.Return(m.Float64Equal(a, b)); 4473 m.Return(m.Float64Equal(a, b));
4415 4474
4416 CompareWrapper cmp(IrOpcode::kFloat64Equal); 4475 CompareWrapper cmp(IrOpcode::kFloat64Equal);
4417 FOR_FLOAT64_INPUTS(pl) { 4476 FOR_FLOAT64_INPUTS(pl) {
4418 FOR_FLOAT64_INPUTS(pr) { 4477 FOR_FLOAT64_INPUTS(pr) {
4419 input_a = *pl; 4478 input_a = *pl;
4420 input_b = *pr; 4479 input_b = *pr;
4421 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0; 4480 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0;
4422 CHECK_EQ(expected, m.Call()); 4481 CHECK_EQ(expected, m.Call());
4423 } 4482 }
4424 } 4483 }
4425 } 4484 }
4426 4485
4427 4486
4428 TEST(RunFloat64LessThan) { 4487 TEST(RunFloat64LessThan) {
4429 double input_a = 0.0; 4488 double input_a = 0.0;
4430 double input_b = 0.0; 4489 double input_b = 0.0;
4431 4490
4432 RawMachineAssemblerTester<int32_t> m; 4491 RawMachineAssemblerTester<int32_t> m;
4433 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); 4492 Node* a = m.LoadFromPointer(&input_a, MachineType::Float64());
4434 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); 4493 Node* b = m.LoadFromPointer(&input_b, MachineType::Float64());
4435 m.Return(m.Float64LessThan(a, b)); 4494 m.Return(m.Float64LessThan(a, b));
4436 4495
4437 CompareWrapper cmp(IrOpcode::kFloat64LessThan); 4496 CompareWrapper cmp(IrOpcode::kFloat64LessThan);
4438 FOR_FLOAT64_INPUTS(pl) { 4497 FOR_FLOAT64_INPUTS(pl) {
4439 FOR_FLOAT64_INPUTS(pr) { 4498 FOR_FLOAT64_INPUTS(pr) {
4440 input_a = *pl; 4499 input_a = *pl;
4441 input_b = *pr; 4500 input_b = *pr;
4442 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0; 4501 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0;
4443 CHECK_EQ(expected, m.Call()); 4502 CHECK_EQ(expected, m.Call());
4444 } 4503 }
4445 } 4504 }
4446 } 4505 }
4447 4506
4448 4507
4449 template <typename IntType, MachineType kRepresentation> 4508 template <typename IntType>
4450 static void LoadStoreTruncation() { 4509 static void LoadStoreTruncation(MachineType kRepresentation) {
4451 IntType input; 4510 IntType input;
4452 4511
4453 RawMachineAssemblerTester<int32_t> m; 4512 RawMachineAssemblerTester<int32_t> m;
4454 Node* a = m.LoadFromPointer(&input, kRepresentation); 4513 Node* a = m.LoadFromPointer(&input, kRepresentation);
4455 Node* ap1 = m.Int32Add(a, m.Int32Constant(1)); 4514 Node* ap1 = m.Int32Add(a, m.Int32Constant(1));
4456 m.StoreToPointer(&input, kRepresentation, ap1); 4515 m.StoreToPointer(&input, kRepresentation, ap1);
4457 m.Return(ap1); 4516 m.Return(ap1);
4458 4517
4459 const IntType max = std::numeric_limits<IntType>::max(); 4518 const IntType max = std::numeric_limits<IntType>::max();
4460 const IntType min = std::numeric_limits<IntType>::min(); 4519 const IntType min = std::numeric_limits<IntType>::min();
(...skipping 12 matching lines...) Expand all
4473 for (int i = -127; i < 127; i++) { 4532 for (int i = -127; i < 127; i++) {
4474 input = i; 4533 input = i;
4475 int expected = i >= 0 ? i + 1 : max + (i - min) + 2; 4534 int expected = i >= 0 ? i + 1 : max + (i - min) + 2;
4476 CHECK_EQ(static_cast<IntType>(expected), m.Call()); 4535 CHECK_EQ(static_cast<IntType>(expected), m.Call());
4477 CHECK_EQ(static_cast<IntType>(i + 1), input); 4536 CHECK_EQ(static_cast<IntType>(i + 1), input);
4478 } 4537 }
4479 } 4538 }
4480 4539
4481 4540
4482 TEST(RunLoadStoreTruncation) { 4541 TEST(RunLoadStoreTruncation) {
4483 LoadStoreTruncation<int8_t, kMachInt8>(); 4542 LoadStoreTruncation<int8_t>(MachineType::Int8());
4484 LoadStoreTruncation<int16_t, kMachInt16>(); 4543 LoadStoreTruncation<int16_t>(MachineType::Int16());
4485 } 4544 }
4486 4545
4487 4546
4488 static void IntPtrCompare(intptr_t left, intptr_t right) { 4547 static void IntPtrCompare(intptr_t left, intptr_t right) {
4489 for (int test = 0; test < 7; test++) { 4548 for (int test = 0; test < 7; test++) {
4490 RawMachineAssemblerTester<bool> m(kMachPtr, kMachPtr); 4549 RawMachineAssemblerTester<bool> m(MachineType::Pointer(),
4550 MachineType::Pointer());
4491 Node* p0 = m.Parameter(0); 4551 Node* p0 = m.Parameter(0);
4492 Node* p1 = m.Parameter(1); 4552 Node* p1 = m.Parameter(1);
4493 Node* res = NULL; 4553 Node* res = NULL;
4494 bool expected = false; 4554 bool expected = false;
4495 switch (test) { 4555 switch (test) {
4496 case 0: 4556 case 0:
4497 res = m.IntPtrLessThan(p0, p1); 4557 res = m.IntPtrLessThan(p0, p1);
4498 expected = true; 4558 expected = true;
4499 break; 4559 break;
4500 case 1: 4560 case 1:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4549 int32_t outputs[kInputSize]; 4609 int32_t outputs[kInputSize];
4550 for (int i = 0; i < kInputSize; i++) { 4610 for (int i = 0; i < kInputSize; i++) {
4551 inputs[i] = i; 4611 inputs[i] = i;
4552 outputs[i] = -1; 4612 outputs[i] = -1;
4553 } 4613 }
4554 RawMachineAssemblerTester<int32_t*> m; 4614 RawMachineAssemblerTester<int32_t*> m;
4555 Node* input = m.PointerConstant(&inputs[0]); 4615 Node* input = m.PointerConstant(&inputs[0]);
4556 Node* output = m.PointerConstant(&outputs[kInputSize - 1]); 4616 Node* output = m.PointerConstant(&outputs[kInputSize - 1]);
4557 Node* elem_size = m.IntPtrConstant(sizeof(inputs[0])); 4617 Node* elem_size = m.IntPtrConstant(sizeof(inputs[0]));
4558 for (int i = 0; i < kInputSize; i++) { 4618 for (int i = 0; i < kInputSize; i++) {
4559 m.Store(kMachInt32, output, m.Load(kMachInt32, input), kNoWriteBarrier); 4619 m.Store(MachineType::Int32(), output, m.Load(MachineType::Int32(), input),
4620 kNoWriteBarrier);
4560 input = m.IntPtrAdd(input, elem_size); 4621 input = m.IntPtrAdd(input, elem_size);
4561 output = m.IntPtrSub(output, elem_size); 4622 output = m.IntPtrSub(output, elem_size);
4562 } 4623 }
4563 m.Return(input); 4624 m.Return(input);
4564 CHECK_EQ(&inputs[kInputSize], m.Call()); 4625 CHECK_EQ(&inputs[kInputSize], m.Call());
4565 for (int i = 0; i < kInputSize; i++) { 4626 for (int i = 0; i < kInputSize; i++) {
4566 CHECK_EQ(i, inputs[i]); 4627 CHECK_EQ(i, inputs[i]);
4567 CHECK_EQ(kInputSize - i - 1, outputs[i]); 4628 CHECK_EQ(kInputSize - i - 1, outputs[i]);
4568 } 4629 }
4569 } 4630 }
4570 4631
4571 4632
4572 TEST(RunSpillLotsOfThings) { 4633 TEST(RunSpillLotsOfThings) {
4573 static const int kInputSize = 1000; 4634 static const int kInputSize = 1000;
4574 RawMachineAssemblerTester<int32_t> m; 4635 RawMachineAssemblerTester<int32_t> m;
4575 Node* accs[kInputSize]; 4636 Node* accs[kInputSize];
4576 int32_t outputs[kInputSize]; 4637 int32_t outputs[kInputSize];
4577 Node* one = m.Int32Constant(1); 4638 Node* one = m.Int32Constant(1);
4578 Node* acc = one; 4639 Node* acc = one;
4579 for (int i = 0; i < kInputSize; i++) { 4640 for (int i = 0; i < kInputSize; i++) {
4580 acc = m.Int32Add(acc, one); 4641 acc = m.Int32Add(acc, one);
4581 accs[i] = acc; 4642 accs[i] = acc;
4582 } 4643 }
4583 for (int i = 0; i < kInputSize; i++) { 4644 for (int i = 0; i < kInputSize; i++) {
4584 m.StoreToPointer(&outputs[i], kMachInt32, accs[i]); 4645 m.StoreToPointer(&outputs[i], MachineType::Int32(), accs[i]);
4585 } 4646 }
4586 m.Return(one); 4647 m.Return(one);
4587 m.Call(); 4648 m.Call();
4588 for (int i = 0; i < kInputSize; i++) { 4649 for (int i = 0; i < kInputSize; i++) {
4589 CHECK_EQ(outputs[i], i + 2); 4650 CHECK_EQ(outputs[i], i + 2);
4590 } 4651 }
4591 } 4652 }
4592 4653
4593 4654
4594 TEST(RunSpillConstantsAndParameters) { 4655 TEST(RunSpillConstantsAndParameters) {
4595 static const int kInputSize = 1000; 4656 static const int kInputSize = 1000;
4596 static const int32_t kBase = 987; 4657 static const int32_t kBase = 987;
4597 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 4658 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
4659 MachineType::Int32());
4598 int32_t outputs[kInputSize]; 4660 int32_t outputs[kInputSize];
4599 Node* csts[kInputSize]; 4661 Node* csts[kInputSize];
4600 Node* accs[kInputSize]; 4662 Node* accs[kInputSize];
4601 Node* acc = m.Int32Constant(0); 4663 Node* acc = m.Int32Constant(0);
4602 for (int i = 0; i < kInputSize; i++) { 4664 for (int i = 0; i < kInputSize; i++) {
4603 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i)); 4665 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i));
4604 } 4666 }
4605 for (int i = 0; i < kInputSize; i++) { 4667 for (int i = 0; i < kInputSize; i++) {
4606 acc = m.Int32Add(acc, csts[i]); 4668 acc = m.Int32Add(acc, csts[i]);
4607 accs[i] = acc; 4669 accs[i] = acc;
4608 } 4670 }
4609 for (int i = 0; i < kInputSize; i++) { 4671 for (int i = 0; i < kInputSize; i++) {
4610 m.StoreToPointer(&outputs[i], kMachInt32, accs[i]); 4672 m.StoreToPointer(&outputs[i], MachineType::Int32(), accs[i]);
4611 } 4673 }
4612 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); 4674 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1))));
4613 FOR_INT32_INPUTS(i) { 4675 FOR_INT32_INPUTS(i) {
4614 FOR_INT32_INPUTS(j) { 4676 FOR_INT32_INPUTS(j) {
4615 int32_t expected = *i + *j; 4677 int32_t expected = *i + *j;
4616 for (int k = 0; k < kInputSize; k++) { 4678 for (int k = 0; k < kInputSize; k++) {
4617 expected += kBase + k; 4679 expected += kBase + k;
4618 } 4680 }
4619 CHECK_EQ(expected, m.Call(*i, *j)); 4681 CHECK_EQ(expected, m.Call(*i, *j));
4620 expected = 0; 4682 expected = 0;
4621 for (int k = 0; k < kInputSize; k++) { 4683 for (int k = 0; k < kInputSize; k++) {
4622 expected += kBase + k; 4684 expected += kBase + k;
4623 CHECK_EQ(expected, outputs[k]); 4685 CHECK_EQ(expected, outputs[k]);
4624 } 4686 }
4625 } 4687 }
4626 } 4688 }
4627 } 4689 }
4628 4690
4629 4691
4630 TEST(RunNewSpaceConstantsInPhi) { 4692 TEST(RunNewSpaceConstantsInPhi) {
4631 RawMachineAssemblerTester<Object*> m(kMachInt32); 4693 RawMachineAssemblerTester<Object*> m(MachineType::Int32());
4632 4694
4633 Isolate* isolate = CcTest::i_isolate(); 4695 Isolate* isolate = CcTest::i_isolate();
4634 Handle<HeapNumber> true_val = isolate->factory()->NewHeapNumber(11.2); 4696 Handle<HeapNumber> true_val = isolate->factory()->NewHeapNumber(11.2);
4635 Handle<HeapNumber> false_val = isolate->factory()->NewHeapNumber(11.3); 4697 Handle<HeapNumber> false_val = isolate->factory()->NewHeapNumber(11.3);
4636 Node* true_node = m.HeapConstant(true_val); 4698 Node* true_node = m.HeapConstant(true_val);
4637 Node* false_node = m.HeapConstant(false_val); 4699 Node* false_node = m.HeapConstant(false_val);
4638 4700
4639 RawMachineLabel blocka, blockb, end; 4701 RawMachineLabel blocka, blockb, end;
4640 m.Branch(m.Parameter(0), &blocka, &blockb); 4702 m.Branch(m.Parameter(0), &blocka, &blockb);
4641 m.Bind(&blocka); 4703 m.Bind(&blocka);
4642 m.Goto(&end); 4704 m.Goto(&end);
4643 m.Bind(&blockb); 4705 m.Bind(&blockb);
4644 m.Goto(&end); 4706 m.Goto(&end);
4645 4707
4646 m.Bind(&end); 4708 m.Bind(&end);
4647 Node* phi = m.Phi(kMachAnyTagged, true_node, false_node); 4709 Node* phi = m.Phi(MachineRepresentation::kTagged, true_node, false_node);
4648 m.Return(phi); 4710 m.Return(phi);
4649 4711
4650 CHECK_EQ(*false_val, m.Call(0)); 4712 CHECK_EQ(*false_val, m.Call(0));
4651 CHECK_EQ(*true_val, m.Call(1)); 4713 CHECK_EQ(*true_val, m.Call(1));
4652 } 4714 }
4653 4715
4654 4716
4655 TEST(RunInt32AddWithOverflowP) { 4717 TEST(RunInt32AddWithOverflowP) {
4656 int32_t actual_val = -1; 4718 int32_t actual_val = -1;
4657 RawMachineAssemblerTester<int32_t> m; 4719 RawMachineAssemblerTester<int32_t> m;
4658 Int32BinopTester bt(&m); 4720 Int32BinopTester bt(&m);
4659 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); 4721 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1);
4660 Node* val = m.Projection(0, add); 4722 Node* val = m.Projection(0, add);
4661 Node* ovf = m.Projection(1, add); 4723 Node* ovf = m.Projection(1, add);
4662 m.StoreToPointer(&actual_val, kMachInt32, val); 4724 m.StoreToPointer(&actual_val, MachineType::Int32(), val);
4663 bt.AddReturn(ovf); 4725 bt.AddReturn(ovf);
4664 FOR_INT32_INPUTS(i) { 4726 FOR_INT32_INPUTS(i) {
4665 FOR_INT32_INPUTS(j) { 4727 FOR_INT32_INPUTS(j) {
4666 int32_t expected_val; 4728 int32_t expected_val;
4667 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4729 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4668 CHECK_EQ(expected_ovf, bt.call(*i, *j)); 4730 CHECK_EQ(expected_ovf, bt.call(*i, *j));
4669 CHECK_EQ(expected_val, actual_val); 4731 CHECK_EQ(expected_val, actual_val);
4670 } 4732 }
4671 } 4733 }
4672 } 4734 }
4673 4735
4674 4736
4675 TEST(RunInt32AddWithOverflowImm) { 4737 TEST(RunInt32AddWithOverflowImm) {
4676 int32_t actual_val = -1, expected_val = 0; 4738 int32_t actual_val = -1, expected_val = 0;
4677 FOR_INT32_INPUTS(i) { 4739 FOR_INT32_INPUTS(i) {
4678 { 4740 {
4679 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4741 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
4680 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); 4742 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0));
4681 Node* val = m.Projection(0, add); 4743 Node* val = m.Projection(0, add);
4682 Node* ovf = m.Projection(1, add); 4744 Node* ovf = m.Projection(1, add);
4683 m.StoreToPointer(&actual_val, kMachInt32, val); 4745 m.StoreToPointer(&actual_val, MachineType::Int32(), val);
4684 m.Return(ovf); 4746 m.Return(ovf);
4685 FOR_INT32_INPUTS(j) { 4747 FOR_INT32_INPUTS(j) {
4686 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4748 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4687 CHECK_EQ(expected_ovf, m.Call(*j)); 4749 CHECK_EQ(expected_ovf, m.Call(*j));
4688 CHECK_EQ(expected_val, actual_val); 4750 CHECK_EQ(expected_val, actual_val);
4689 } 4751 }
4690 } 4752 }
4691 { 4753 {
4692 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4754 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
4693 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); 4755 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i));
4694 Node* val = m.Projection(0, add); 4756 Node* val = m.Projection(0, add);
4695 Node* ovf = m.Projection(1, add); 4757 Node* ovf = m.Projection(1, add);
4696 m.StoreToPointer(&actual_val, kMachInt32, val); 4758 m.StoreToPointer(&actual_val, MachineType::Int32(), val);
4697 m.Return(ovf); 4759 m.Return(ovf);
4698 FOR_INT32_INPUTS(j) { 4760 FOR_INT32_INPUTS(j) {
4699 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4761 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4700 CHECK_EQ(expected_ovf, m.Call(*j)); 4762 CHECK_EQ(expected_ovf, m.Call(*j));
4701 CHECK_EQ(expected_val, actual_val); 4763 CHECK_EQ(expected_val, actual_val);
4702 } 4764 }
4703 } 4765 }
4704 FOR_INT32_INPUTS(j) { 4766 FOR_INT32_INPUTS(j) {
4705 RawMachineAssemblerTester<int32_t> m; 4767 RawMachineAssemblerTester<int32_t> m;
4706 Node* add = 4768 Node* add =
4707 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); 4769 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j));
4708 Node* val = m.Projection(0, add); 4770 Node* val = m.Projection(0, add);
4709 Node* ovf = m.Projection(1, add); 4771 Node* ovf = m.Projection(1, add);
4710 m.StoreToPointer(&actual_val, kMachInt32, val); 4772 m.StoreToPointer(&actual_val, MachineType::Int32(), val);
4711 m.Return(ovf); 4773 m.Return(ovf);
4712 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4774 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4713 CHECK_EQ(expected_ovf, m.Call()); 4775 CHECK_EQ(expected_ovf, m.Call());
4714 CHECK_EQ(expected_val, actual_val); 4776 CHECK_EQ(expected_val, actual_val);
4715 } 4777 }
4716 } 4778 }
4717 } 4779 }
4718 4780
4719 4781
4720 TEST(RunInt32AddWithOverflowInBranchP) { 4782 TEST(RunInt32AddWithOverflowInBranchP) {
(...skipping 19 matching lines...) Expand all
4740 } 4802 }
4741 4803
4742 4804
4743 TEST(RunInt32SubWithOverflowP) { 4805 TEST(RunInt32SubWithOverflowP) {
4744 int32_t actual_val = -1; 4806 int32_t actual_val = -1;
4745 RawMachineAssemblerTester<int32_t> m; 4807 RawMachineAssemblerTester<int32_t> m;
4746 Int32BinopTester bt(&m); 4808 Int32BinopTester bt(&m);
4747 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); 4809 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1);
4748 Node* val = m.Projection(0, add); 4810 Node* val = m.Projection(0, add);
4749 Node* ovf = m.Projection(1, add); 4811 Node* ovf = m.Projection(1, add);
4750 m.StoreToPointer(&actual_val, kMachInt32, val); 4812 m.StoreToPointer(&actual_val, MachineType::Int32(), val);
4751 bt.AddReturn(ovf); 4813 bt.AddReturn(ovf);
4752 FOR_INT32_INPUTS(i) { 4814 FOR_INT32_INPUTS(i) {
4753 FOR_INT32_INPUTS(j) { 4815 FOR_INT32_INPUTS(j) {
4754 int32_t expected_val; 4816 int32_t expected_val;
4755 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4817 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4756 CHECK_EQ(expected_ovf, bt.call(*i, *j)); 4818 CHECK_EQ(expected_ovf, bt.call(*i, *j));
4757 CHECK_EQ(expected_val, actual_val); 4819 CHECK_EQ(expected_val, actual_val);
4758 } 4820 }
4759 } 4821 }
4760 } 4822 }
4761 4823
4762 4824
4763 TEST(RunInt32SubWithOverflowImm) { 4825 TEST(RunInt32SubWithOverflowImm) {
4764 int32_t actual_val = -1, expected_val = 0; 4826 int32_t actual_val = -1, expected_val = 0;
4765 FOR_INT32_INPUTS(i) { 4827 FOR_INT32_INPUTS(i) {
4766 { 4828 {
4767 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4829 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
4768 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); 4830 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0));
4769 Node* val = m.Projection(0, add); 4831 Node* val = m.Projection(0, add);
4770 Node* ovf = m.Projection(1, add); 4832 Node* ovf = m.Projection(1, add);
4771 m.StoreToPointer(&actual_val, kMachInt32, val); 4833 m.StoreToPointer(&actual_val, MachineType::Int32(), val);
4772 m.Return(ovf); 4834 m.Return(ovf);
4773 FOR_INT32_INPUTS(j) { 4835 FOR_INT32_INPUTS(j) {
4774 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4836 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4775 CHECK_EQ(expected_ovf, m.Call(*j)); 4837 CHECK_EQ(expected_ovf, m.Call(*j));
4776 CHECK_EQ(expected_val, actual_val); 4838 CHECK_EQ(expected_val, actual_val);
4777 } 4839 }
4778 } 4840 }
4779 { 4841 {
4780 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4842 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
4781 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); 4843 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i));
4782 Node* val = m.Projection(0, add); 4844 Node* val = m.Projection(0, add);
4783 Node* ovf = m.Projection(1, add); 4845 Node* ovf = m.Projection(1, add);
4784 m.StoreToPointer(&actual_val, kMachInt32, val); 4846 m.StoreToPointer(&actual_val, MachineType::Int32(), val);
4785 m.Return(ovf); 4847 m.Return(ovf);
4786 FOR_INT32_INPUTS(j) { 4848 FOR_INT32_INPUTS(j) {
4787 int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val); 4849 int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val);
4788 CHECK_EQ(expected_ovf, m.Call(*j)); 4850 CHECK_EQ(expected_ovf, m.Call(*j));
4789 CHECK_EQ(expected_val, actual_val); 4851 CHECK_EQ(expected_val, actual_val);
4790 } 4852 }
4791 } 4853 }
4792 FOR_INT32_INPUTS(j) { 4854 FOR_INT32_INPUTS(j) {
4793 RawMachineAssemblerTester<int32_t> m; 4855 RawMachineAssemblerTester<int32_t> m;
4794 Node* add = 4856 Node* add =
4795 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); 4857 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j));
4796 Node* val = m.Projection(0, add); 4858 Node* val = m.Projection(0, add);
4797 Node* ovf = m.Projection(1, add); 4859 Node* ovf = m.Projection(1, add);
4798 m.StoreToPointer(&actual_val, kMachInt32, val); 4860 m.StoreToPointer(&actual_val, MachineType::Int32(), val);
4799 m.Return(ovf); 4861 m.Return(ovf);
4800 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4862 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4801 CHECK_EQ(expected_ovf, m.Call()); 4863 CHECK_EQ(expected_ovf, m.Call());
4802 CHECK_EQ(expected_val, actual_val); 4864 CHECK_EQ(expected_val, actual_val);
4803 } 4865 }
4804 } 4866 }
4805 } 4867 }
4806 4868
4807 4869
4808 TEST(RunInt32SubWithOverflowInBranchP) { 4870 TEST(RunInt32SubWithOverflowInBranchP) {
(...skipping 17 matching lines...) Expand all
4826 } 4888 }
4827 } 4889 }
4828 } 4890 }
4829 4891
4830 4892
4831 TEST(RunWord64EqualInBranchP) { 4893 TEST(RunWord64EqualInBranchP) {
4832 int64_t input; 4894 int64_t input;
4833 RawMachineLabel blocka, blockb; 4895 RawMachineLabel blocka, blockb;
4834 RawMachineAssemblerTester<int64_t> m; 4896 RawMachineAssemblerTester<int64_t> m;
4835 if (!m.machine()->Is64()) return; 4897 if (!m.machine()->Is64()) return;
4836 Node* value = m.LoadFromPointer(&input, kMachInt64); 4898 Node* value = m.LoadFromPointer(&input, MachineType::Int64());
4837 m.Branch(m.Word64Equal(value, m.Int64Constant(0)), &blocka, &blockb); 4899 m.Branch(m.Word64Equal(value, m.Int64Constant(0)), &blocka, &blockb);
4838 m.Bind(&blocka); 4900 m.Bind(&blocka);
4839 m.Return(m.Int32Constant(1)); 4901 m.Return(m.Int32Constant(1));
4840 m.Bind(&blockb); 4902 m.Bind(&blockb);
4841 m.Return(m.Int32Constant(2)); 4903 m.Return(m.Int32Constant(2));
4842 input = V8_INT64_C(0); 4904 input = V8_INT64_C(0);
4843 CHECK_EQ(1, m.Call()); 4905 CHECK_EQ(1, m.Call());
4844 input = V8_INT64_C(1); 4906 input = V8_INT64_C(1);
4845 CHECK_EQ(2, m.Call()); 4907 CHECK_EQ(2, m.Call());
4846 input = V8_INT64_C(0x100000000); 4908 input = V8_INT64_C(0x100000000);
4847 CHECK_EQ(2, m.Call()); 4909 CHECK_EQ(2, m.Call());
4848 } 4910 }
4849 4911
4850 4912
4851 TEST(RunChangeInt32ToInt64P) { 4913 TEST(RunChangeInt32ToInt64P) {
4852 if (kPointerSize < 8) return; 4914 if (kPointerSize < 8) return;
4853 int64_t actual = -1; 4915 int64_t actual = -1;
4854 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4916 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
4855 m.StoreToPointer(&actual, kMachInt64, m.ChangeInt32ToInt64(m.Parameter(0))); 4917 m.StoreToPointer(&actual, MachineType::Int64(),
4918 m.ChangeInt32ToInt64(m.Parameter(0)));
4856 m.Return(m.Int32Constant(0)); 4919 m.Return(m.Int32Constant(0));
4857 FOR_INT32_INPUTS(i) { 4920 FOR_INT32_INPUTS(i) {
4858 int64_t expected = *i; 4921 int64_t expected = *i;
4859 CHECK_EQ(0, m.Call(*i)); 4922 CHECK_EQ(0, m.Call(*i));
4860 CHECK_EQ(expected, actual); 4923 CHECK_EQ(expected, actual);
4861 } 4924 }
4862 } 4925 }
4863 4926
4864 4927
4865 TEST(RunChangeUint32ToUint64P) { 4928 TEST(RunChangeUint32ToUint64P) {
4866 if (kPointerSize < 8) return; 4929 if (kPointerSize < 8) return;
4867 int64_t actual = -1; 4930 int64_t actual = -1;
4868 RawMachineAssemblerTester<int32_t> m(kMachUint32); 4931 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32());
4869 m.StoreToPointer(&actual, kMachUint64, 4932 m.StoreToPointer(&actual, MachineType::Uint64(),
4870 m.ChangeUint32ToUint64(m.Parameter(0))); 4933 m.ChangeUint32ToUint64(m.Parameter(0)));
4871 m.Return(m.Int32Constant(0)); 4934 m.Return(m.Int32Constant(0));
4872 FOR_UINT32_INPUTS(i) { 4935 FOR_UINT32_INPUTS(i) {
4873 int64_t expected = static_cast<uint64_t>(*i); 4936 int64_t expected = static_cast<uint64_t>(*i);
4874 CHECK_EQ(0, m.Call(*i)); 4937 CHECK_EQ(0, m.Call(*i));
4875 CHECK_EQ(expected, actual); 4938 CHECK_EQ(expected, actual);
4876 } 4939 }
4877 } 4940 }
4878 4941
4879 4942
4880 TEST(RunTruncateInt64ToInt32P) { 4943 TEST(RunTruncateInt64ToInt32P) {
4881 if (kPointerSize < 8) return; 4944 if (kPointerSize < 8) return;
4882 int64_t expected = -1; 4945 int64_t expected = -1;
4883 RawMachineAssemblerTester<int32_t> m; 4946 RawMachineAssemblerTester<int32_t> m;
4884 m.Return(m.TruncateInt64ToInt32(m.LoadFromPointer(&expected, kMachInt64))); 4947 m.Return(m.TruncateInt64ToInt32(
4948 m.LoadFromPointer(&expected, MachineType::Int64())));
4885 FOR_UINT32_INPUTS(i) { 4949 FOR_UINT32_INPUTS(i) {
4886 FOR_UINT32_INPUTS(j) { 4950 FOR_UINT32_INPUTS(j) {
4887 expected = (static_cast<uint64_t>(*j) << 32) | *i; 4951 expected = (static_cast<uint64_t>(*j) << 32) | *i;
4888 CHECK_EQ(static_cast<int32_t>(expected), m.Call()); 4952 CHECK_EQ(static_cast<int32_t>(expected), m.Call());
4889 } 4953 }
4890 } 4954 }
4891 } 4955 }
4892 4956
4893 4957
4894 TEST(RunTruncateFloat64ToInt32P) { 4958 TEST(RunTruncateFloat64ToInt32P) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4945 {9.6714157802890681e+24, -2147483648.0}, 5009 {9.6714157802890681e+24, -2147483648.0},
4946 {-9.6714157802890681e+24, -2147483648.0}, 5010 {-9.6714157802890681e+24, -2147483648.0},
4947 {1.9342813113834065e+25, 2147483648.0}, 5011 {1.9342813113834065e+25, 2147483648.0},
4948 {-1.9342813113834065e+25, 2147483648.0}, 5012 {-1.9342813113834065e+25, 2147483648.0},
4949 {3.868562622766813e+25, 0}, 5013 {3.868562622766813e+25, 0},
4950 {-3.868562622766813e+25, 0}, 5014 {-3.868562622766813e+25, 0},
4951 {1.7976931348623157e+308, 0}, 5015 {1.7976931348623157e+308, 0},
4952 {-1.7976931348623157e+308, 0}}; 5016 {-1.7976931348623157e+308, 0}};
4953 double input = -1.0; 5017 double input = -1.0;
4954 RawMachineAssemblerTester<int32_t> m; 5018 RawMachineAssemblerTester<int32_t> m;
4955 m.Return(m.TruncateFloat64ToInt32(TruncationMode::kJavaScript, 5019 m.Return(m.TruncateFloat64ToInt32(
4956 m.LoadFromPointer(&input, kMachFloat64))); 5020 TruncationMode::kJavaScript,
5021 m.LoadFromPointer(&input, MachineType::Float64())));
4957 for (size_t i = 0; i < arraysize(kValues); ++i) { 5022 for (size_t i = 0; i < arraysize(kValues); ++i) {
4958 input = kValues[i].from; 5023 input = kValues[i].from;
4959 uint64_t expected = static_cast<int64_t>(kValues[i].raw); 5024 uint64_t expected = static_cast<int64_t>(kValues[i].raw);
4960 CHECK_EQ(static_cast<int>(expected), m.Call()); 5025 CHECK_EQ(static_cast<int>(expected), m.Call());
4961 } 5026 }
4962 } 5027 }
4963 5028
4964 5029
4965 TEST(RunChangeFloat32ToFloat64) { 5030 TEST(RunChangeFloat32ToFloat64) {
4966 BufferedRawMachineAssemblerTester<double> m(kMachFloat32); 5031 BufferedRawMachineAssemblerTester<double> m(MachineType::Float32());
4967 5032
4968 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0))); 5033 m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0)));
4969 5034
4970 FOR_FLOAT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } 5035 FOR_FLOAT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); }
4971 } 5036 }
4972 5037
4973 5038
4974 TEST(RunFloat32Constant) { 5039 TEST(RunFloat32Constant) {
4975 FOR_FLOAT32_INPUTS(i) { 5040 FOR_FLOAT32_INPUTS(i) {
4976 BufferedRawMachineAssemblerTester<float> m; 5041 BufferedRawMachineAssemblerTester<float> m;
4977 m.Return(m.Float32Constant(*i)); 5042 m.Return(m.Float32Constant(*i));
4978 CheckFloatEq(*i, m.Call()); 5043 CheckFloatEq(*i, m.Call());
4979 } 5044 }
4980 } 5045 }
4981 5046
4982 5047
4983 TEST(RunFloat64ExtractLowWord32) { 5048 TEST(RunFloat64ExtractLowWord32) {
4984 BufferedRawMachineAssemblerTester<uint32_t> m(kMachFloat64); 5049 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64());
4985 m.Return(m.Float64ExtractLowWord32(m.Parameter(0))); 5050 m.Return(m.Float64ExtractLowWord32(m.Parameter(0)));
4986 FOR_FLOAT64_INPUTS(i) { 5051 FOR_FLOAT64_INPUTS(i) {
4987 uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i)); 5052 uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i));
4988 CHECK_EQ(expected, m.Call(*i)); 5053 CHECK_EQ(expected, m.Call(*i));
4989 } 5054 }
4990 } 5055 }
4991 5056
4992 5057
4993 TEST(RunFloat64ExtractHighWord32) { 5058 TEST(RunFloat64ExtractHighWord32) {
4994 BufferedRawMachineAssemblerTester<uint32_t> m(kMachFloat64); 5059 BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Float64());
4995 m.Return(m.Float64ExtractHighWord32(m.Parameter(0))); 5060 m.Return(m.Float64ExtractHighWord32(m.Parameter(0)));
4996 FOR_FLOAT64_INPUTS(i) { 5061 FOR_FLOAT64_INPUTS(i) {
4997 uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i) >> 32); 5062 uint32_t expected = static_cast<uint32_t>(bit_cast<uint64_t>(*i) >> 32);
4998 CHECK_EQ(expected, m.Call(*i)); 5063 CHECK_EQ(expected, m.Call(*i));
4999 } 5064 }
5000 } 5065 }
5001 5066
5002 5067
5003 TEST(RunFloat64InsertLowWord32) { 5068 TEST(RunFloat64InsertLowWord32) {
5004 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachInt32); 5069 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
5070 MachineType::Int32());
5005 m.Return(m.Float64InsertLowWord32(m.Parameter(0), m.Parameter(1))); 5071 m.Return(m.Float64InsertLowWord32(m.Parameter(0), m.Parameter(1)));
5006 FOR_FLOAT64_INPUTS(i) { 5072 FOR_FLOAT64_INPUTS(i) {
5007 FOR_INT32_INPUTS(j) { 5073 FOR_INT32_INPUTS(j) {
5008 double expected = bit_cast<double>( 5074 double expected = bit_cast<double>(
5009 (bit_cast<uint64_t>(*i) & ~(V8_UINT64_C(0xFFFFFFFF))) | 5075 (bit_cast<uint64_t>(*i) & ~(V8_UINT64_C(0xFFFFFFFF))) |
5010 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)))); 5076 (static_cast<uint64_t>(bit_cast<uint32_t>(*j))));
5011 CheckDoubleEq(expected, m.Call(*i, *j)); 5077 CheckDoubleEq(expected, m.Call(*i, *j));
5012 } 5078 }
5013 } 5079 }
5014 } 5080 }
5015 5081
5016 5082
5017 TEST(RunFloat64InsertHighWord32) { 5083 TEST(RunFloat64InsertHighWord32) {
5018 BufferedRawMachineAssemblerTester<double> m(kMachFloat64, kMachUint32); 5084 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(),
5085 MachineType::Uint32());
5019 m.Return(m.Float64InsertHighWord32(m.Parameter(0), m.Parameter(1))); 5086 m.Return(m.Float64InsertHighWord32(m.Parameter(0), m.Parameter(1)));
5020 FOR_FLOAT64_INPUTS(i) { 5087 FOR_FLOAT64_INPUTS(i) {
5021 FOR_UINT32_INPUTS(j) { 5088 FOR_UINT32_INPUTS(j) {
5022 uint64_t expected = (bit_cast<uint64_t>(*i) & 0xFFFFFFFF) | 5089 uint64_t expected = (bit_cast<uint64_t>(*i) & 0xFFFFFFFF) |
5023 (static_cast<uint64_t>(*j) << 32); 5090 (static_cast<uint64_t>(*j) << 32);
5024 5091
5025 CheckDoubleEq(bit_cast<double>(expected), m.Call(*i, *j)); 5092 CheckDoubleEq(bit_cast<double>(expected), m.Call(*i, *j));
5026 } 5093 }
5027 } 5094 }
5028 } 5095 }
5029 5096
5030 5097
5031 TEST(RunFloat32Abs) { 5098 TEST(RunFloat32Abs) {
5032 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); 5099 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5033 m.Return(m.Float32Abs(m.Parameter(0))); 5100 m.Return(m.Float32Abs(m.Parameter(0)));
5034 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(std::abs(*i), m.Call(*i)); } 5101 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(std::abs(*i), m.Call(*i)); }
5035 } 5102 }
5036 5103
5037 5104
5038 TEST(RunFloat64Abs) { 5105 TEST(RunFloat64Abs) {
5039 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 5106 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5040 m.Return(m.Float64Abs(m.Parameter(0))); 5107 m.Return(m.Float64Abs(m.Parameter(0)));
5041 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::abs(*i), m.Call(*i)); } 5108 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::abs(*i), m.Call(*i)); }
5042 } 5109 }
5043 5110
5044 5111
5045 static double two_30 = 1 << 30; // 2^30 is a smi boundary. 5112 static double two_30 = 1 << 30; // 2^30 is a smi boundary.
5046 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. 5113 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary.
5047 static double kValues[] = {0.1, 5114 static double kValues[] = {0.1,
5048 0.2, 5115 0.2,
5049 0.49999999999999994, 5116 0.49999999999999994,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
5134 -two_52 - 0.1, 5201 -two_52 - 0.1,
5135 -two_52 - 0.5, 5202 -two_52 - 0.5,
5136 -two_52 - 0.7, 5203 -two_52 - 0.7,
5137 -two_52 + 1, 5204 -two_52 + 1,
5138 -two_52 + 1 - 0.1, 5205 -two_52 + 1 - 0.1,
5139 -two_52 + 1 - 0.5, 5206 -two_52 + 1 - 0.5,
5140 -two_52 + 1 - 0.7}; 5207 -two_52 + 1 - 0.7};
5141 5208
5142 5209
5143 TEST(RunFloat32RoundDown) { 5210 TEST(RunFloat32RoundDown) {
5144 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); 5211 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5145 if (!m.machine()->Float32RoundDown().IsSupported()) return; 5212 if (!m.machine()->Float32RoundDown().IsSupported()) return;
5146 5213
5147 m.Return(m.Float32RoundDown(m.Parameter(0))); 5214 m.Return(m.Float32RoundDown(m.Parameter(0)));
5148 5215
5149 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); } 5216 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); }
5150 } 5217 }
5151 5218
5152 5219
5153 TEST(RunFloat64RoundDown1) { 5220 TEST(RunFloat64RoundDown1) {
5154 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 5221 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5155 if (!m.machine()->Float64RoundDown().IsSupported()) return; 5222 if (!m.machine()->Float64RoundDown().IsSupported()) return;
5156 5223
5157 m.Return(m.Float64RoundDown(m.Parameter(0))); 5224 m.Return(m.Float64RoundDown(m.Parameter(0)));
5158 5225
5159 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(floor(*i), m.Call(*i)); } 5226 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(floor(*i), m.Call(*i)); }
5160 } 5227 }
5161 5228
5162 5229
5163 TEST(RunFloat64RoundDown2) { 5230 TEST(RunFloat64RoundDown2) {
5164 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 5231 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5165 if (!m.machine()->Float64RoundDown().IsSupported()) return; 5232 if (!m.machine()->Float64RoundDown().IsSupported()) return;
5166 m.Return(m.Float64Sub(m.Float64Constant(-0.0), 5233 m.Return(m.Float64Sub(m.Float64Constant(-0.0),
5167 m.Float64RoundDown(m.Float64Sub(m.Float64Constant(-0.0), 5234 m.Float64RoundDown(m.Float64Sub(m.Float64Constant(-0.0),
5168 m.Parameter(0))))); 5235 m.Parameter(0)))));
5169 5236
5170 for (size_t i = 0; i < arraysize(kValues); ++i) { 5237 for (size_t i = 0; i < arraysize(kValues); ++i) {
5171 CHECK_EQ(ceil(kValues[i]), m.Call(kValues[i])); 5238 CHECK_EQ(ceil(kValues[i]), m.Call(kValues[i]));
5172 } 5239 }
5173 } 5240 }
5174 5241
5175 5242
5176 TEST(RunFloat32RoundUp) { 5243 TEST(RunFloat32RoundUp) {
5177 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); 5244 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5178 if (!m.machine()->Float32RoundUp().IsSupported()) return; 5245 if (!m.machine()->Float32RoundUp().IsSupported()) return;
5179 m.Return(m.Float32RoundUp(m.Parameter(0))); 5246 m.Return(m.Float32RoundUp(m.Parameter(0)));
5180 5247
5181 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(ceilf(*i), m.Call(*i)); } 5248 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(ceilf(*i), m.Call(*i)); }
5182 } 5249 }
5183 5250
5184 5251
5185 TEST(RunFloat64RoundUp) { 5252 TEST(RunFloat64RoundUp) {
5186 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 5253 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5187 if (!m.machine()->Float64RoundUp().IsSupported()) return; 5254 if (!m.machine()->Float64RoundUp().IsSupported()) return;
5188 m.Return(m.Float64RoundUp(m.Parameter(0))); 5255 m.Return(m.Float64RoundUp(m.Parameter(0)));
5189 5256
5190 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(ceil(*i), m.Call(*i)); } 5257 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(ceil(*i), m.Call(*i)); }
5191 } 5258 }
5192 5259
5193 5260
5194 TEST(RunFloat32RoundTiesEven) { 5261 TEST(RunFloat32RoundTiesEven) {
5195 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); 5262 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5196 if (!m.machine()->Float32RoundTiesEven().IsSupported()) return; 5263 if (!m.machine()->Float32RoundTiesEven().IsSupported()) return;
5197 m.Return(m.Float32RoundTiesEven(m.Parameter(0))); 5264 m.Return(m.Float32RoundTiesEven(m.Parameter(0)));
5198 5265
5199 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(nearbyint(*i), m.Call(*i)); } 5266 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(nearbyint(*i), m.Call(*i)); }
5200 } 5267 }
5201 5268
5202 5269
5203 TEST(RunFloat64RoundTiesEven) { 5270 TEST(RunFloat64RoundTiesEven) {
5204 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 5271 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5205 if (!m.machine()->Float64RoundTiesEven().IsSupported()) return; 5272 if (!m.machine()->Float64RoundTiesEven().IsSupported()) return;
5206 m.Return(m.Float64RoundTiesEven(m.Parameter(0))); 5273 m.Return(m.Float64RoundTiesEven(m.Parameter(0)));
5207 5274
5208 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), m.Call(*i)); } 5275 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), m.Call(*i)); }
5209 } 5276 }
5210 5277
5211 5278
5212 TEST(RunFloat32RoundTruncate) { 5279 TEST(RunFloat32RoundTruncate) {
5213 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); 5280 BufferedRawMachineAssemblerTester<float> m(MachineType::Float32());
5214 if (!m.machine()->Float32RoundTruncate().IsSupported()) return; 5281 if (!m.machine()->Float32RoundTruncate().IsSupported()) return;
5215 5282
5216 m.Return(m.Float32RoundTruncate(m.Parameter(0))); 5283 m.Return(m.Float32RoundTruncate(m.Parameter(0)));
5217 5284
5218 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(truncf(*i), m.Call(*i)); } 5285 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(truncf(*i), m.Call(*i)); }
5219 } 5286 }
5220 5287
5221 5288
5222 TEST(RunFloat64RoundTruncate) { 5289 TEST(RunFloat64RoundTruncate) {
5223 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 5290 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5224 if (!m.machine()->Float64RoundTruncate().IsSupported()) return; 5291 if (!m.machine()->Float64RoundTruncate().IsSupported()) return;
5225 m.Return(m.Float64RoundTruncate(m.Parameter(0))); 5292 m.Return(m.Float64RoundTruncate(m.Parameter(0)));
5226 for (size_t i = 0; i < arraysize(kValues); ++i) { 5293 for (size_t i = 0; i < arraysize(kValues); ++i) {
5227 CHECK_EQ(trunc(kValues[i]), m.Call(kValues[i])); 5294 CHECK_EQ(trunc(kValues[i]), m.Call(kValues[i]));
5228 } 5295 }
5229 } 5296 }
5230 5297
5231 5298
5232 TEST(RunFloat64RoundTiesAway) { 5299 TEST(RunFloat64RoundTiesAway) {
5233 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); 5300 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64());
5234 if (!m.machine()->Float64RoundTiesAway().IsSupported()) return; 5301 if (!m.machine()->Float64RoundTiesAway().IsSupported()) return;
5235 m.Return(m.Float64RoundTiesAway(m.Parameter(0))); 5302 m.Return(m.Float64RoundTiesAway(m.Parameter(0)));
5236 for (size_t i = 0; i < arraysize(kValues); ++i) { 5303 for (size_t i = 0; i < arraysize(kValues); ++i) {
5237 CHECK_EQ(round(kValues[i]), m.Call(kValues[i])); 5304 CHECK_EQ(round(kValues[i]), m.Call(kValues[i]));
5238 } 5305 }
5239 } 5306 }
5240 5307
5241 5308
5242 #if !USE_SIMULATOR 5309 #if !USE_SIMULATOR
5243 5310
(...skipping 15 matching lines...) Expand all
5259 int32_t g, int32_t h) { 5326 int32_t g, int32_t h) {
5260 return a + b + c + d + e + f + g + h; 5327 return a + b + c + d + e + f + g + h;
5261 } 5328 }
5262 5329
5263 } // namespace 5330 } // namespace
5264 5331
5265 5332
5266 TEST(RunCallCFunction0) { 5333 TEST(RunCallCFunction0) {
5267 auto* foo0_ptr = &foo0; 5334 auto* foo0_ptr = &foo0;
5268 RawMachineAssemblerTester<int32_t> m; 5335 RawMachineAssemblerTester<int32_t> m;
5269 Node* function = m.LoadFromPointer(&foo0_ptr, kMachPtr); 5336 Node* function = m.LoadFromPointer(&foo0_ptr, MachineType::Pointer());
5270 m.Return(m.CallCFunction0(kMachInt32, function)); 5337 m.Return(m.CallCFunction0(MachineType::Int32(), function));
5271 CHECK_EQ(kMagicFoo0, m.Call()); 5338 CHECK_EQ(kMagicFoo0, m.Call());
5272 } 5339 }
5273 5340
5274 5341
5275 TEST(RunCallCFunction1) { 5342 TEST(RunCallCFunction1) {
5276 auto* foo1_ptr = &foo1; 5343 auto* foo1_ptr = &foo1;
5277 RawMachineAssemblerTester<int32_t> m(kMachInt32); 5344 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
5278 Node* function = m.LoadFromPointer(&foo1_ptr, kMachPtr); 5345 Node* function = m.LoadFromPointer(&foo1_ptr, MachineType::Pointer());
5279 m.Return(m.CallCFunction1(kMachInt32, kMachInt32, function, m.Parameter(0))); 5346 m.Return(m.CallCFunction1(MachineType::Int32(), MachineType::Int32(),
5347 function, m.Parameter(0)));
5280 FOR_INT32_INPUTS(i) { 5348 FOR_INT32_INPUTS(i) {
5281 int32_t const expected = *i; 5349 int32_t const expected = *i;
5282 CHECK_EQ(expected, m.Call(expected)); 5350 CHECK_EQ(expected, m.Call(expected));
5283 } 5351 }
5284 } 5352 }
5285 5353
5286 5354
5287 TEST(RunCallCFunction2) { 5355 TEST(RunCallCFunction2) {
5288 auto* foo2_ptr = &foo2; 5356 auto* foo2_ptr = &foo2;
5289 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 5357 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
5290 Node* function = m.LoadFromPointer(&foo2_ptr, kMachPtr); 5358 MachineType::Int32());
5291 m.Return(m.CallCFunction2(kMachInt32, kMachInt32, kMachInt32, function, 5359 Node* function = m.LoadFromPointer(&foo2_ptr, MachineType::Pointer());
5292 m.Parameter(0), m.Parameter(1))); 5360 m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Int32(),
5361 MachineType::Int32(), function, m.Parameter(0),
5362 m.Parameter(1)));
5293 FOR_INT32_INPUTS(i) { 5363 FOR_INT32_INPUTS(i) {
5294 int32_t const x = *i; 5364 int32_t const x = *i;
5295 FOR_INT32_INPUTS(j) { 5365 FOR_INT32_INPUTS(j) {
5296 int32_t const y = *j; 5366 int32_t const y = *j;
5297 CHECK_EQ(x - y, m.Call(x, y)); 5367 CHECK_EQ(x - y, m.Call(x, y));
5298 } 5368 }
5299 } 5369 }
5300 } 5370 }
5301 5371
5302 5372
5303 TEST(RunCallCFunction8) { 5373 TEST(RunCallCFunction8) {
5304 auto* foo8_ptr = &foo8; 5374 auto* foo8_ptr = &foo8;
5305 RawMachineAssemblerTester<int32_t> m(kMachInt32); 5375 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
5306 Node* function = m.LoadFromPointer(&foo8_ptr, kMachPtr); 5376 Node* function = m.LoadFromPointer(&foo8_ptr, MachineType::Pointer());
5307 Node* param = m.Parameter(0); 5377 Node* param = m.Parameter(0);
5308 m.Return(m.CallCFunction8(kMachInt32, kMachInt32, kMachInt32, kMachInt32, 5378 m.Return(m.CallCFunction8(
5309 kMachInt32, kMachInt32, kMachInt32, kMachInt32, 5379 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(),
5310 kMachInt32, function, param, param, param, param, 5380 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(),
5311 param, param, param, param)); 5381 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(),
5382 function, param, param, param, param, param, param, param, param));
5312 FOR_INT32_INPUTS(i) { 5383 FOR_INT32_INPUTS(i) {
5313 int32_t const x = *i; 5384 int32_t const x = *i;
5314 CHECK_EQ(x * 8, m.Call(x)); 5385 CHECK_EQ(x * 8, m.Call(x));
5315 } 5386 }
5316 } 5387 }
5317 #endif // USE_SIMULATOR 5388 #endif // USE_SIMULATOR
5318 5389
5319 #if V8_TARGET_ARCH_64_BIT 5390 #if V8_TARGET_ARCH_64_BIT
5320 // TODO(titzer): run int64 tests on all platforms when supported. 5391 // TODO(titzer): run int64 tests on all platforms when supported.
5321 TEST(RunCheckedLoadInt64) { 5392 TEST(RunCheckedLoadInt64) {
5322 int64_t buffer[] = {0x66bbccddeeff0011LL, 0x1122334455667788LL}; 5393 int64_t buffer[] = {0x66bbccddeeff0011LL, 0x1122334455667788LL};
5323 RawMachineAssemblerTester<int64_t> m(kMachInt32); 5394 RawMachineAssemblerTester<int64_t> m(MachineType::Int32());
5324 Node* base = m.PointerConstant(buffer); 5395 Node* base = m.PointerConstant(buffer);
5325 Node* index = m.Parameter(0); 5396 Node* index = m.Parameter(0);
5326 Node* length = m.Int32Constant(16); 5397 Node* length = m.Int32Constant(16);
5327 Node* load = 5398 Node* load = m.AddNode(m.machine()->CheckedLoad(MachineType::Int64()), base,
5328 m.AddNode(m.machine()->CheckedLoad(kMachInt64), base, index, length); 5399 index, length);
5329 m.Return(load); 5400 m.Return(load);
5330 5401
5331 CHECK_EQ(buffer[0], m.Call(0)); 5402 CHECK_EQ(buffer[0], m.Call(0));
5332 CHECK_EQ(buffer[1], m.Call(8)); 5403 CHECK_EQ(buffer[1], m.Call(8));
5333 CHECK_EQ(0, m.Call(16)); 5404 CHECK_EQ(0, m.Call(16));
5334 } 5405 }
5335 5406
5336 5407
5337 TEST(RunCheckedStoreInt64) { 5408 TEST(RunCheckedStoreInt64) {
5338 const int64_t write = 0x5566778899aabbLL; 5409 const int64_t write = 0x5566778899aabbLL;
5339 const int64_t before = 0x33bbccddeeff0011LL; 5410 const int64_t before = 0x33bbccddeeff0011LL;
5340 int64_t buffer[] = {before, before}; 5411 int64_t buffer[] = {before, before};
5341 RawMachineAssemblerTester<int32_t> m(kMachInt32); 5412 RawMachineAssemblerTester<int32_t> m(MachineType::Int32());
5342 Node* base = m.PointerConstant(buffer); 5413 Node* base = m.PointerConstant(buffer);
5343 Node* index = m.Parameter(0); 5414 Node* index = m.Parameter(0);
5344 Node* length = m.Int32Constant(16); 5415 Node* length = m.Int32Constant(16);
5345 Node* value = m.Int64Constant(write); 5416 Node* value = m.Int64Constant(write);
5346 Node* store = m.AddNode(m.machine()->CheckedStore(kMachInt64), base, index, 5417 Node* store = m.AddNode(m.machine()->CheckedStore(MachineType::Int64()), base,
5347 length, value); 5418 index, length, value);
5348 USE(store); 5419 USE(store);
5349 m.Return(m.Int32Constant(11)); 5420 m.Return(m.Int32Constant(11));
5350 5421
5351 CHECK_EQ(11, m.Call(16)); 5422 CHECK_EQ(11, m.Call(16));
5352 CHECK_EQ(before, buffer[0]); 5423 CHECK_EQ(before, buffer[0]);
5353 CHECK_EQ(before, buffer[1]); 5424 CHECK_EQ(before, buffer[1]);
5354 5425
5355 CHECK_EQ(11, m.Call(0)); 5426 CHECK_EQ(11, m.Call(0));
5356 CHECK_EQ(write, buffer[0]); 5427 CHECK_EQ(write, buffer[0]);
5357 CHECK_EQ(before, buffer[1]); 5428 CHECK_EQ(before, buffer[1]);
5358 5429
5359 CHECK_EQ(11, m.Call(8)); 5430 CHECK_EQ(11, m.Call(8));
5360 CHECK_EQ(write, buffer[0]); 5431 CHECK_EQ(write, buffer[0]);
5361 CHECK_EQ(write, buffer[1]); 5432 CHECK_EQ(write, buffer[1]);
5362 } 5433 }
5363 5434
5364 5435
5365 TEST(RunBitcastInt64ToFloat64) { 5436 TEST(RunBitcastInt64ToFloat64) {
5366 int64_t input = 1; 5437 int64_t input = 1;
5367 double output = 0.0; 5438 double output = 0.0;
5368 RawMachineAssemblerTester<int32_t> m; 5439 RawMachineAssemblerTester<int32_t> m;
5369 m.StoreToPointer( 5440 m.StoreToPointer(
5370 &output, kMachFloat64, 5441 &output, MachineType::Float64(),
5371 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, kMachInt64))); 5442 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, MachineType::Int64())));
5372 m.Return(m.Int32Constant(11)); 5443 m.Return(m.Int32Constant(11));
5373 FOR_INT64_INPUTS(i) { 5444 FOR_INT64_INPUTS(i) {
5374 input = *i; 5445 input = *i;
5375 CHECK_EQ(11, m.Call()); 5446 CHECK_EQ(11, m.Call());
5376 double expected = bit_cast<double>(input); 5447 double expected = bit_cast<double>(input);
5377 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output)); 5448 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output));
5378 } 5449 }
5379 } 5450 }
5380 5451
5381 5452
5382 TEST(RunBitcastFloat64ToInt64) { 5453 TEST(RunBitcastFloat64ToInt64) {
5383 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); 5454 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64());
5384 5455
5385 m.Return(m.BitcastFloat64ToInt64(m.Parameter(0))); 5456 m.Return(m.BitcastFloat64ToInt64(m.Parameter(0)));
5386 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(bit_cast<int64_t>(*i), m.Call(*i)); } 5457 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(bit_cast<int64_t>(*i), m.Call(*i)); }
5387 } 5458 }
5388 5459
5389 5460
5390 TEST(RunTryTruncateFloat32ToInt64WithoutCheck) { 5461 TEST(RunTryTruncateFloat32ToInt64WithoutCheck) {
5391 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat32); 5462 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float32());
5392 m.Return(m.TryTruncateFloat32ToInt64(m.Parameter(0))); 5463 m.Return(m.TryTruncateFloat32ToInt64(m.Parameter(0)));
5393 5464
5394 FOR_INT64_INPUTS(i) { 5465 FOR_INT64_INPUTS(i) {
5395 float input = static_cast<float>(*i); 5466 float input = static_cast<float>(*i);
5396 if (input < 9223372036854775808.0 && input > -9223372036854775809.0) { 5467 if (input < 9223372036854775808.0 && input > -9223372036854775809.0) {
5397 CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); 5468 CHECK_EQ(static_cast<int64_t>(input), m.Call(input));
5398 } 5469 }
5399 } 5470 }
5400 } 5471 }
5401 5472
5402 5473
5403 TEST(RunTryTruncateFloat32ToInt64WithCheck) { 5474 TEST(RunTryTruncateFloat32ToInt64WithCheck) {
5404 int64_t success = 0; 5475 int64_t success = 0;
5405 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat32); 5476 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float32());
5406 Node* trunc = m.TryTruncateFloat32ToInt64(m.Parameter(0)); 5477 Node* trunc = m.TryTruncateFloat32ToInt64(m.Parameter(0));
5407 Node* val = m.Projection(0, trunc); 5478 Node* val = m.Projection(0, trunc);
5408 Node* check = m.Projection(1, trunc); 5479 Node* check = m.Projection(1, trunc);
5409 m.StoreToPointer(&success, kMachInt64, check); 5480 m.StoreToPointer(&success, MachineType::Int64(), check);
5410 m.Return(val); 5481 m.Return(val);
5411 5482
5412 FOR_FLOAT32_INPUTS(i) { 5483 FOR_FLOAT32_INPUTS(i) {
5413 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { 5484 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) {
5414 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); 5485 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i));
5415 CHECK_NE(0, success); 5486 CHECK_NE(0, success);
5416 } else { 5487 } else {
5417 m.Call(*i); 5488 m.Call(*i);
5418 CHECK_EQ(0, success); 5489 CHECK_EQ(0, success);
5419 } 5490 }
5420 } 5491 }
5421 } 5492 }
5422 5493
5423 5494
5424 TEST(RunTryTruncateFloat64ToInt64WithoutCheck) { 5495 TEST(RunTryTruncateFloat64ToInt64WithoutCheck) {
5425 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); 5496 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64());
5426 m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0))); 5497 m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0)));
5427 5498
5428 FOR_INT64_INPUTS(i) { 5499 FOR_INT64_INPUTS(i) {
5429 double input = static_cast<double>(*i); 5500 double input = static_cast<double>(*i);
5430 CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); 5501 CHECK_EQ(static_cast<int64_t>(input), m.Call(input));
5431 } 5502 }
5432 } 5503 }
5433 5504
5434 5505
5435 TEST(RunTryTruncateFloat64ToInt64WithCheck) { 5506 TEST(RunTryTruncateFloat64ToInt64WithCheck) {
5436 int64_t success = 0; 5507 int64_t success = 0;
5437 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); 5508 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64());
5438 Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0)); 5509 Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0));
5439 Node* val = m.Projection(0, trunc); 5510 Node* val = m.Projection(0, trunc);
5440 Node* check = m.Projection(1, trunc); 5511 Node* check = m.Projection(1, trunc);
5441 m.StoreToPointer(&success, kMachInt64, check); 5512 m.StoreToPointer(&success, MachineType::Int64(), check);
5442 m.Return(val); 5513 m.Return(val);
5443 5514
5444 FOR_FLOAT64_INPUTS(i) { 5515 FOR_FLOAT64_INPUTS(i) {
5445 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { 5516 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) {
5446 // Conversions within this range should succeed. 5517 // Conversions within this range should succeed.
5447 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); 5518 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i));
5448 CHECK_NE(0, success); 5519 CHECK_NE(0, success);
5449 } else { 5520 } else {
5450 m.Call(*i); 5521 m.Call(*i);
5451 CHECK_EQ(0, success); 5522 CHECK_EQ(0, success);
5452 } 5523 }
5453 } 5524 }
5454 } 5525 }
5455 5526
5456 5527
5457 TEST(RunTruncateFloat32ToUint64) { 5528 TEST(RunTruncateFloat32ToUint64) {
5458 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat32); 5529 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float32());
5459 m.Return(m.TruncateFloat32ToUint64(m.Parameter(0))); 5530 m.Return(m.TruncateFloat32ToUint64(m.Parameter(0)));
5460 5531
5461 FOR_UINT64_INPUTS(i) { 5532 FOR_UINT64_INPUTS(i) {
5462 float input = static_cast<float>(*i); 5533 float input = static_cast<float>(*i);
5463 if (input < 18446744073709551616.0) { 5534 if (input < 18446744073709551616.0) {
5464 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5535 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5465 } 5536 }
5466 } 5537 }
5467 FOR_FLOAT32_INPUTS(j) { 5538 FOR_FLOAT32_INPUTS(j) {
5468 if (*j < 18446744073709551616.0 && *j >= 0) { 5539 if (*j < 18446744073709551616.0 && *j >= 0) {
5469 CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j)); 5540 CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j));
5470 } 5541 }
5471 } 5542 }
5472 } 5543 }
5473 5544
5474 5545
5475 TEST(RunTryTruncateFloat64ToUint64WithoutCheck) { 5546 TEST(RunTryTruncateFloat64ToUint64WithoutCheck) {
5476 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat64); 5547 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float64());
5477 m.Return(m.TruncateFloat64ToUint64(m.Parameter(0))); 5548 m.Return(m.TruncateFloat64ToUint64(m.Parameter(0)));
5478 5549
5479 FOR_UINT64_INPUTS(j) { 5550 FOR_UINT64_INPUTS(j) {
5480 double input = static_cast<double>(*j); 5551 double input = static_cast<double>(*j);
5481 5552
5482 if (input < 18446744073709551616.0) { 5553 if (input < 18446744073709551616.0) {
5483 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5554 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5484 } 5555 }
5485 } 5556 }
5486 } 5557 }
5487 5558
5488 5559
5489 TEST(RunTryTruncateFloat64ToUint64WithCheck) { 5560 TEST(RunTryTruncateFloat64ToUint64WithCheck) {
5490 int64_t success = 0; 5561 int64_t success = 0;
5491 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); 5562 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64());
5492 Node* trunc = m.TryTruncateFloat64ToUint64(m.Parameter(0)); 5563 Node* trunc = m.TryTruncateFloat64ToUint64(m.Parameter(0));
5493 Node* val = m.Projection(0, trunc); 5564 Node* val = m.Projection(0, trunc);
5494 Node* check = m.Projection(1, trunc); 5565 Node* check = m.Projection(1, trunc);
5495 m.StoreToPointer(&success, kMachInt64, check); 5566 m.StoreToPointer(&success, MachineType::Int64(), check);
5496 m.Return(val); 5567 m.Return(val);
5497 5568
5498 FOR_FLOAT64_INPUTS(i) { 5569 FOR_FLOAT64_INPUTS(i) {
5499 if (*i < 18446744073709551616.0 && *i >= 0) { 5570 if (*i < 18446744073709551616.0 && *i >= 0) {
5500 // Conversions within this range should succeed. 5571 // Conversions within this range should succeed.
5501 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i)); 5572 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i));
5502 CHECK_NE(0, success); 5573 CHECK_NE(0, success);
5503 } else { 5574 } else {
5504 m.Call(*i); 5575 m.Call(*i);
5505 CHECK_EQ(0, success); 5576 CHECK_EQ(0, success);
5506 } 5577 }
5507 } 5578 }
5508 } 5579 }
5509 5580
5510 5581
5511 TEST(RunRoundInt64ToFloat32) { 5582 TEST(RunRoundInt64ToFloat32) {
5512 BufferedRawMachineAssemblerTester<float> m(kMachInt64); 5583 BufferedRawMachineAssemblerTester<float> m(MachineType::Int64());
5513 m.Return(m.RoundInt64ToFloat32(m.Parameter(0))); 5584 m.Return(m.RoundInt64ToFloat32(m.Parameter(0)));
5514 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), m.Call(*i)); } 5585 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), m.Call(*i)); }
5515 } 5586 }
5516 5587
5517 5588
5518 TEST(RunRoundInt64ToFloat64) { 5589 TEST(RunRoundInt64ToFloat64) {
5519 BufferedRawMachineAssemblerTester<double> m(kMachInt64); 5590 BufferedRawMachineAssemblerTester<double> m(MachineType::Int64());
5520 m.Return(m.RoundInt64ToFloat64(m.Parameter(0))); 5591 m.Return(m.RoundInt64ToFloat64(m.Parameter(0)));
5521 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), m.Call(*i)); } 5592 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), m.Call(*i)); }
5522 } 5593 }
5523 5594
5524 5595
5525 TEST(RunRoundUint64ToFloat64) { 5596 TEST(RunRoundUint64ToFloat64) {
5526 struct { 5597 struct {
5527 uint64_t input; 5598 uint64_t input;
5528 uint64_t expected; 5599 uint64_t expected;
5529 } values[] = {{0x0, 0x0}, 5600 } values[] = {{0x0, 0x0},
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5595 {0x1fffffffffff, 0x42bfffffffffff00}, 5666 {0x1fffffffffff, 0x42bfffffffffff00},
5596 {0xfffffffffff, 0x42affffffffffe00}, 5667 {0xfffffffffff, 0x42affffffffffe00},
5597 {0x7ffffffffff, 0x429ffffffffffc00}, 5668 {0x7ffffffffff, 0x429ffffffffffc00},
5598 {0x3ffffffffff, 0x428ffffffffff800}, 5669 {0x3ffffffffff, 0x428ffffffffff800},
5599 {0x1ffffffffff, 0x427ffffffffff000}, 5670 {0x1ffffffffff, 0x427ffffffffff000},
5600 {0x8000008000000000, 0x43e0000010000000}, 5671 {0x8000008000000000, 0x43e0000010000000},
5601 {0x8000008000000001, 0x43e0000010000000}, 5672 {0x8000008000000001, 0x43e0000010000000},
5602 {0x8000000000000400, 0x43e0000000000000}, 5673 {0x8000000000000400, 0x43e0000000000000},
5603 {0x8000000000000401, 0x43e0000000000001}}; 5674 {0x8000000000000401, 0x43e0000000000001}};
5604 5675
5605 BufferedRawMachineAssemblerTester<double> m(kMachUint64); 5676 BufferedRawMachineAssemblerTester<double> m(MachineType::Uint64());
5606 m.Return(m.RoundUint64ToFloat64(m.Parameter(0))); 5677 m.Return(m.RoundUint64ToFloat64(m.Parameter(0)));
5607 5678
5608 for (size_t i = 0; i < arraysize(values); i++) { 5679 for (size_t i = 0; i < arraysize(values); i++) {
5609 CHECK_EQ(bit_cast<double>(values[i].expected), m.Call(values[i].input)); 5680 CHECK_EQ(bit_cast<double>(values[i].expected), m.Call(values[i].input));
5610 } 5681 }
5611 } 5682 }
5612 5683
5613 5684
5614 TEST(RunRoundUint64ToFloat32) { 5685 TEST(RunRoundUint64ToFloat32) {
5615 struct { 5686 struct {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
5685 {0x1fffffffffff, 0x56000000}, 5756 {0x1fffffffffff, 0x56000000},
5686 {0xfffffffffff, 0x55800000}, 5757 {0xfffffffffff, 0x55800000},
5687 {0x7ffffffffff, 0x55000000}, 5758 {0x7ffffffffff, 0x55000000},
5688 {0x3ffffffffff, 0x54800000}, 5759 {0x3ffffffffff, 0x54800000},
5689 {0x1ffffffffff, 0x54000000}, 5760 {0x1ffffffffff, 0x54000000},
5690 {0x8000008000000000, 0x5f000000}, 5761 {0x8000008000000000, 0x5f000000},
5691 {0x8000008000000001, 0x5f000001}, 5762 {0x8000008000000001, 0x5f000001},
5692 {0x8000000000000400, 0x5f000000}, 5763 {0x8000000000000400, 0x5f000000},
5693 {0x8000000000000401, 0x5f000000}}; 5764 {0x8000000000000401, 0x5f000000}};
5694 5765
5695 BufferedRawMachineAssemblerTester<float> m(kMachUint64); 5766 BufferedRawMachineAssemblerTester<float> m(MachineType::Uint64());
5696 m.Return(m.RoundUint64ToFloat32(m.Parameter(0))); 5767 m.Return(m.RoundUint64ToFloat32(m.Parameter(0)));
5697 5768
5698 for (size_t i = 0; i < arraysize(values); i++) { 5769 for (size_t i = 0; i < arraysize(values); i++) {
5699 CHECK_EQ(bit_cast<float>(values[i].expected), m.Call(values[i].input)); 5770 CHECK_EQ(bit_cast<float>(values[i].expected), m.Call(values[i].input));
5700 } 5771 }
5701 } 5772 }
5702 5773
5703 5774
5704 #endif 5775 #endif
5705 5776
5706 5777
5707 TEST(RunBitcastFloat32ToInt32) { 5778 TEST(RunBitcastFloat32ToInt32) {
5708 float input = 32.25; 5779 float input = 32.25;
5709 RawMachineAssemblerTester<int32_t> m; 5780 RawMachineAssemblerTester<int32_t> m;
5710 m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32))); 5781 m.Return(m.BitcastFloat32ToInt32(
5782 m.LoadFromPointer(&input, MachineType::Float32())));
5711 FOR_FLOAT32_INPUTS(i) { 5783 FOR_FLOAT32_INPUTS(i) {
5712 input = *i; 5784 input = *i;
5713 int32_t expected = bit_cast<int32_t>(input); 5785 int32_t expected = bit_cast<int32_t>(input);
5714 CHECK_EQ(expected, m.Call()); 5786 CHECK_EQ(expected, m.Call());
5715 } 5787 }
5716 } 5788 }
5717 5789
5718 5790
5719 TEST(RunBitcastInt32ToFloat32) { 5791 TEST(RunBitcastInt32ToFloat32) {
5720 int32_t input = 1; 5792 int32_t input = 1;
5721 float output = 0.0; 5793 float output = 0.0;
5722 RawMachineAssemblerTester<int32_t> m; 5794 RawMachineAssemblerTester<int32_t> m;
5723 m.StoreToPointer( 5795 m.StoreToPointer(
5724 &output, kMachFloat32, 5796 &output, MachineType::Float32(),
5725 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32))); 5797 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32())));
5726 m.Return(m.Int32Constant(11)); 5798 m.Return(m.Int32Constant(11));
5727 FOR_INT32_INPUTS(i) { 5799 FOR_INT32_INPUTS(i) {
5728 input = *i; 5800 input = *i;
5729 CHECK_EQ(11, m.Call()); 5801 CHECK_EQ(11, m.Call());
5730 float expected = bit_cast<float>(input); 5802 float expected = bit_cast<float>(input);
5731 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); 5803 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output));
5732 } 5804 }
5733 } 5805 }
5734 5806
5735 5807
5736 TEST(RunComputedCodeObject) { 5808 TEST(RunComputedCodeObject) {
5737 GraphBuilderTester<int32_t> a; 5809 GraphBuilderTester<int32_t> a;
5738 a.Return(a.Int32Constant(33)); 5810 a.Return(a.Int32Constant(33));
5739 a.End(); 5811 a.End();
5740 Handle<Code> code_a = a.GetCode(); 5812 Handle<Code> code_a = a.GetCode();
5741 5813
5742 GraphBuilderTester<int32_t> b; 5814 GraphBuilderTester<int32_t> b;
5743 b.Return(b.Int32Constant(44)); 5815 b.Return(b.Int32Constant(44));
5744 b.End(); 5816 b.End();
5745 Handle<Code> code_b = b.GetCode(); 5817 Handle<Code> code_b = b.GetCode();
5746 5818
5747 RawMachineAssemblerTester<int32_t> r(kMachInt32); 5819 RawMachineAssemblerTester<int32_t> r(MachineType::Int32());
5748 RawMachineLabel tlabel; 5820 RawMachineLabel tlabel;
5749 RawMachineLabel flabel; 5821 RawMachineLabel flabel;
5750 RawMachineLabel merge; 5822 RawMachineLabel merge;
5751 r.Branch(r.Parameter(0), &tlabel, &flabel); 5823 r.Branch(r.Parameter(0), &tlabel, &flabel);
5752 r.Bind(&tlabel); 5824 r.Bind(&tlabel);
5753 Node* fa = r.HeapConstant(code_a); 5825 Node* fa = r.HeapConstant(code_a);
5754 r.Goto(&merge); 5826 r.Goto(&merge);
5755 r.Bind(&flabel); 5827 r.Bind(&flabel);
5756 Node* fb = r.HeapConstant(code_b); 5828 Node* fb = r.HeapConstant(code_b);
5757 r.Goto(&merge); 5829 r.Goto(&merge);
5758 r.Bind(&merge); 5830 r.Bind(&merge);
5759 Node* phi = r.Phi(kMachInt32, fa, fb); 5831 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb);
5760 5832
5761 // TODO(titzer): all this descriptor hackery is just to call the above 5833 // TODO(titzer): all this descriptor hackery is just to call the above
5762 // functions as code objects instead of direct addresses. 5834 // functions as code objects instead of direct addresses.
5763 CSignature0<int32_t> sig; 5835 CSignature0<int32_t> sig;
5764 CallDescriptor* c = Linkage::GetSimplifiedCDescriptor(r.zone(), &sig); 5836 CallDescriptor* c = Linkage::GetSimplifiedCDescriptor(r.zone(), &sig);
5765 LinkageLocation ret[] = {c->GetReturnLocation(0)}; 5837 LinkageLocation ret[] = {c->GetReturnLocation(0)};
5766 Signature<LinkageLocation> loc(1, 0, ret); 5838 Signature<LinkageLocation> loc(1, 0, ret);
5767 CallDescriptor* desc = new (r.zone()) CallDescriptor( // -- 5839 CallDescriptor* desc = new (r.zone()) CallDescriptor( // --
5768 CallDescriptor::kCallCodeObject, // kind 5840 CallDescriptor::kCallCodeObject, // kind
5769 kMachAnyTagged, // target_type 5841 MachineType::AnyTagged(), // target_type
5770 c->GetInputLocation(0), // target_loc 5842 c->GetInputLocation(0), // target_loc
5771 &sig, // machine_sig 5843 &sig, // machine_sig
5772 &loc, // location_sig 5844 &loc, // location_sig
5773 0, // stack count 5845 0, // stack count
5774 Operator::kNoProperties, // properties 5846 Operator::kNoProperties, // properties
5775 c->CalleeSavedRegisters(), // callee saved 5847 c->CalleeSavedRegisters(), // callee saved
5776 c->CalleeSavedFPRegisters(), // callee saved FP 5848 c->CalleeSavedFPRegisters(), // callee saved FP
5777 CallDescriptor::kNoFlags, // flags 5849 CallDescriptor::kNoFlags, // flags
5778 "c-call-as-code"); 5850 "c-call-as-code");
5779 Node* call = r.AddNode(r.common()->Call(desc), phi); 5851 Node* call = r.AddNode(r.common()->Call(desc), phi);
5780 r.Return(call); 5852 r.Return(call);
5781 5853
5782 CHECK_EQ(33, r.Call(1)); 5854 CHECK_EQ(33, r.Call(1));
5783 CHECK_EQ(44, r.Call(0)); 5855 CHECK_EQ(44, r.Call(0));
5784 } 5856 }
5785 5857
5786 } // namespace compiler 5858 } // namespace compiler
5787 } // namespace internal 5859 } // namespace internal
5788 } // namespace v8 5860 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-representation-change.cc ('k') | test/cctest/compiler/test-run-native-calls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698