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

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

Issue 470593002: Unify MachineType and RepType. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Forgot a RepresentationOf() in arm64. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <functional> 5 #include <functional>
6 #include <limits> 6 #include <limits>
7 7
8 #include "test/cctest/cctest.h" 8 #include "test/cctest/cctest.h"
9 #include "test/cctest/compiler/codegen-tester.h" 9 #include "test/cctest/compiler/codegen-tester.h"
10 #include "test/cctest/compiler/value-helper.h" 10 #include "test/cctest/compiler/value-helper.h"
11 11
12 #if V8_TURBOFAN_TARGET 12 #if V8_TURBOFAN_TARGET
13 13
14 #define CHECK_UINT32_EQ(x, y) \
Michael Starzinger 2014/08/13 15:40:05 *sigh*
Benedikt Meurer 2014/08/13 19:42:07 CheckEqualsHelper for unsigned.
titzer 2014/08/14 07:50:18 I tried that. C++ doesn't like ambiguous overloads
15 CHECK_EQ(static_cast<int32_t>(x), static_cast<int32_t>(y))
16
14 using namespace v8::internal; 17 using namespace v8::internal;
15 using namespace v8::internal::compiler; 18 using namespace v8::internal::compiler;
16 19
17 typedef RawMachineAssembler::Label MLabel; 20 typedef RawMachineAssembler::Label MLabel;
18 21
19 TEST(RunInt32Add) { 22 TEST(RunInt32Add) {
20 RawMachineAssemblerTester<int32_t> m; 23 RawMachineAssemblerTester<int32_t> m;
21 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); 24 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1));
22 m.Return(add); 25 m.Return(add);
23 CHECK_EQ(1, m.Call()); 26 CHECK_EQ(1, m.Call());
(...skipping 10 matching lines...) Expand all
34 return m->Int32Constant(0); 37 return m->Int32Constant(0);
35 case 3: 38 case 3:
36 return m->Int32Constant(1); 39 return m->Int32Constant(1);
37 case 4: 40 case 4:
38 return m->Int32Constant(-1); 41 return m->Int32Constant(-1);
39 case 5: 42 case 5:
40 return m->Int32Constant(0xff); 43 return m->Int32Constant(0xff);
41 case 6: 44 case 6:
42 return m->Int32Constant(0x01234567); 45 return m->Int32Constant(0x01234567);
43 case 7: 46 case 7:
44 return m->Load(kMachineWord32, m->PointerConstant(NULL)); 47 return m->Load(mInt32, m->PointerConstant(NULL));
45 default: 48 default:
46 return NULL; 49 return NULL;
47 } 50 }
48 } 51 }
49 52
50 53
51 TEST(CodeGenInt32Binop) { 54 TEST(CodeGenInt32Binop) {
52 RawMachineAssemblerTester<void> m; 55 RawMachineAssemblerTester<void> m;
53 56
54 Operator* ops[] = { 57 Operator* ops[] = {
55 m.machine()->Word32And(), m.machine()->Word32Or(), 58 m.machine()->Word32And(), m.machine()->Word32Or(),
56 m.machine()->Word32Xor(), m.machine()->Word32Shl(), 59 m.machine()->Word32Xor(), m.machine()->Word32Shl(),
57 m.machine()->Word32Shr(), m.machine()->Word32Sar(), 60 m.machine()->Word32Shr(), m.machine()->Word32Sar(),
58 m.machine()->Word32Equal(), m.machine()->Int32Add(), 61 m.machine()->Word32Equal(), m.machine()->Int32Add(),
59 m.machine()->Int32Sub(), m.machine()->Int32Mul(), 62 m.machine()->Int32Sub(), m.machine()->Int32Mul(),
60 m.machine()->Int32Div(), m.machine()->Int32UDiv(), 63 m.machine()->Int32Div(), m.machine()->Int32UDiv(),
61 m.machine()->Int32Mod(), m.machine()->Int32UMod(), 64 m.machine()->Int32Mod(), m.machine()->Int32UMod(),
62 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), 65 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(),
63 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual(), 66 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual(),
64 NULL}; 67 NULL};
65 68
66 for (int i = 0; ops[i] != NULL; i++) { 69 for (int i = 0; ops[i] != NULL; i++) {
67 for (int j = 0; j < 8; j++) { 70 for (int j = 0; j < 8; j++) {
68 for (int k = 0; k < 8; k++) { 71 for (int k = 0; k < 8; k++) {
69 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); 72 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32);
70 Node* a = Int32Input(&m, j); 73 Node* a = Int32Input(&m, j);
71 Node* b = Int32Input(&m, k); 74 Node* b = Int32Input(&m, k);
72 m.Return(m.NewNode(ops[i], a, b)); 75 m.Return(m.NewNode(ops[i], a, b));
73 m.GenerateCode(); 76 m.GenerateCode();
74 } 77 }
75 } 78 }
76 } 79 }
77 } 80 }
78 81
79 82
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 m->Bind(&blockb); 214 m->Bind(&blockb);
212 m->Goto(end); 215 m->Goto(end);
213 216
214 m->Bind(end); 217 m->Bind(end);
215 Node* phi = m->Phi(true_node, false_node); 218 Node* phi = m->Phi(true_node, false_node);
216 m->Return(phi); 219 m->Return(phi);
217 } 220 }
218 221
219 222
220 TEST(RunDiamondPhiConst) { 223 TEST(RunDiamondPhiConst) {
221 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 224 RawMachineAssemblerTester<int32_t> m(mInt32);
222 int false_val = 0xFF666; 225 int false_val = 0xFF666;
223 int true_val = 0x00DDD; 226 int true_val = 0x00DDD;
224 Node* true_node = m.Int32Constant(true_val); 227 Node* true_node = m.Int32Constant(true_val);
225 Node* false_node = m.Int32Constant(false_val); 228 Node* false_node = m.Int32Constant(false_val);
226 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); 229 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node);
227 CHECK_EQ(false_val, m.Call(0)); 230 CHECK_EQ(false_val, m.Call(0));
228 CHECK_EQ(true_val, m.Call(1)); 231 CHECK_EQ(true_val, m.Call(1));
229 } 232 }
230 233
231 234
232 TEST(RunDiamondPhiNumber) { 235 TEST(RunDiamondPhiNumber) {
233 RawMachineAssemblerTester<Object*> m(kMachineWord32); 236 RawMachineAssemblerTester<Object*> m(mInt32);
234 double false_val = -11.1; 237 double false_val = -11.1;
235 double true_val = 200.1; 238 double true_val = 200.1;
236 Node* true_node = m.NumberConstant(true_val); 239 Node* true_node = m.NumberConstant(true_val);
237 Node* false_node = m.NumberConstant(false_val); 240 Node* false_node = m.NumberConstant(false_val);
238 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); 241 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node);
239 m.CheckNumber(false_val, m.Call(0)); 242 m.CheckNumber(false_val, m.Call(0));
240 m.CheckNumber(true_val, m.Call(1)); 243 m.CheckNumber(true_val, m.Call(1));
241 } 244 }
242 245
243 246
244 TEST(RunDiamondPhiString) { 247 TEST(RunDiamondPhiString) {
245 RawMachineAssemblerTester<Object*> m(kMachineWord32); 248 RawMachineAssemblerTester<Object*> m(mInt32);
246 const char* false_val = "false"; 249 const char* false_val = "false";
247 const char* true_val = "true"; 250 const char* true_val = "true";
248 Node* true_node = m.StringConstant(true_val); 251 Node* true_node = m.StringConstant(true_val);
249 Node* false_node = m.StringConstant(false_val); 252 Node* false_node = m.StringConstant(false_val);
250 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); 253 BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node);
251 m.CheckString(false_val, m.Call(0)); 254 m.CheckString(false_val, m.Call(0));
252 m.CheckString(true_val, m.Call(1)); 255 m.CheckString(true_val, m.Call(1));
253 } 256 }
254 257
255 258
256 TEST(RunDiamondPhiParam) { 259 TEST(RunDiamondPhiParam) {
257 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 260 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32, mInt32);
258 kMachineWord32);
259 BuildDiamondPhi(&m, m.Parameter(0), m.Parameter(1), m.Parameter(2)); 261 BuildDiamondPhi(&m, m.Parameter(0), m.Parameter(1), m.Parameter(2));
260 int32_t c1 = 0x260cb75a; 262 int32_t c1 = 0x260cb75a;
261 int32_t c2 = 0xcd3e9c8b; 263 int32_t c2 = 0xcd3e9c8b;
262 int result = m.Call(0, c1, c2); 264 int result = m.Call(0, c1, c2);
263 CHECK_EQ(c2, result); 265 CHECK_EQ(c2, result);
264 result = m.Call(1, c1, c2); 266 result = m.Call(1, c1, c2);
265 CHECK_EQ(c1, result); 267 CHECK_EQ(c1, result);
266 } 268 }
267 269
268 270
(...skipping 17 matching lines...) Expand all
286 m.Bind(&body); 288 m.Bind(&body);
287 m.Goto(&header); 289 m.Goto(&header);
288 m.Bind(end); 290 m.Bind(end);
289 m.Return(phi); 291 m.Return(phi);
290 292
291 CHECK_EQ(false_val, m.Call()); 293 CHECK_EQ(false_val, m.Call());
292 } 294 }
293 295
294 296
295 TEST(RunLoopPhiParam) { 297 TEST(RunLoopPhiParam) {
296 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 298 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32, mInt32);
297 kMachineWord32);
298 299
299 MLabel blocka, blockb; 300 MLabel blocka, blockb;
300 MLabel* end = m.Exit(); 301 MLabel* end = m.Exit();
301 302
302 m.Goto(&blocka); 303 m.Goto(&blocka);
303 304
304 m.Bind(&blocka); 305 m.Bind(&blocka);
305 Node* phi = m.Phi(m.Parameter(1), m.Parameter(2)); 306 Node* phi = m.Phi(m.Parameter(1), m.Parameter(2));
306 Node* cond = m.Phi(m.Parameter(0), m.Int32Constant(0)); 307 Node* cond = m.Phi(m.Parameter(0), m.Int32Constant(0));
307 m.Branch(cond, &blockb, end); 308 m.Branch(cond, &blockb, end);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 m.Return(m.ChangeFloat64ToInt32(phi)); 486 m.Return(m.ChangeFloat64ToInt32(phi));
486 487
487 CHECK_EQ(10, m.Call()); 488 CHECK_EQ(10, m.Call());
488 } 489 }
489 490
490 491
491 TEST(RunLoadInt32) { 492 TEST(RunLoadInt32) {
492 RawMachineAssemblerTester<int32_t> m; 493 RawMachineAssemblerTester<int32_t> m;
493 494
494 int32_t p1 = 0; // loads directly from this location. 495 int32_t p1 = 0; // loads directly from this location.
495 m.Return(m.LoadFromPointer(&p1, kMachineWord32)); 496 m.Return(m.LoadFromPointer(&p1, mInt32));
496 497
497 FOR_INT32_INPUTS(i) { 498 FOR_INT32_INPUTS(i) {
498 p1 = *i; 499 p1 = *i;
499 CHECK_EQ(p1, m.Call()); 500 CHECK_EQ(p1, m.Call());
500 } 501 }
501 } 502 }
502 503
503 504
504 TEST(RunLoadInt32Offset) { 505 TEST(RunLoadInt32Offset) {
505 int32_t p1 = 0; // loads directly from this location. 506 int32_t p1 = 0; // loads directly from this location.
506 507
507 int32_t offsets[] = {-2000000, -100, -101, 1, 3, 508 int32_t offsets[] = {-2000000, -100, -101, 1, 3,
508 7, 120, 2000, 2000000000, 0xff}; 509 7, 120, 2000, 2000000000, 0xff};
509 510
510 for (size_t i = 0; i < ARRAY_SIZE(offsets); i++) { 511 for (size_t i = 0; i < ARRAY_SIZE(offsets); i++) {
511 RawMachineAssemblerTester<int32_t> m; 512 RawMachineAssemblerTester<int32_t> m;
512 int32_t offset = offsets[i]; 513 int32_t offset = offsets[i];
513 byte* pointer = reinterpret_cast<byte*>(&p1) - offset; 514 byte* pointer = reinterpret_cast<byte*>(&p1) - offset;
514 // generate load [#base + #index] 515 // generate load [#base + #index]
515 m.Return(m.LoadFromPointer(pointer, kMachineWord32, offset)); 516 m.Return(m.LoadFromPointer(pointer, mInt32, offset));
516 517
517 FOR_INT32_INPUTS(j) { 518 FOR_INT32_INPUTS(j) {
518 p1 = *j; 519 p1 = *j;
519 CHECK_EQ(p1, m.Call()); 520 CHECK_EQ(p1, m.Call());
520 } 521 }
521 } 522 }
522 } 523 }
523 524
524 525
525 TEST(RunLoadStoreFloat64Offset) { 526 TEST(RunLoadStoreFloat64Offset) {
526 double p1 = 0; // loads directly from this location. 527 double p1 = 0; // loads directly from this location.
527 double p2 = 0; // and stores directly into this location. 528 double p2 = 0; // and stores directly into this location.
528 529
529 FOR_INT32_INPUTS(i) { 530 FOR_INT32_INPUTS(i) {
530 int32_t magic = 0x2342aabb + *i * 3; 531 int32_t magic = 0x2342aabb + *i * 3;
531 RawMachineAssemblerTester<int32_t> m; 532 RawMachineAssemblerTester<int32_t> m;
532 int32_t offset = *i; 533 int32_t offset = *i;
533 byte* from = reinterpret_cast<byte*>(&p1) - offset; 534 byte* from = reinterpret_cast<byte*>(&p1) - offset;
534 byte* to = reinterpret_cast<byte*>(&p2) - offset; 535 byte* to = reinterpret_cast<byte*>(&p2) - offset;
535 // generate load [#base + #index] 536 // generate load [#base + #index]
536 Node* load = m.Load(kMachineFloat64, m.PointerConstant(from), 537 Node* load =
537 m.Int32Constant(offset)); 538 m.Load(mFloat64, m.PointerConstant(from), m.Int32Constant(offset));
538 m.Store(kMachineFloat64, m.PointerConstant(to), m.Int32Constant(offset), 539 m.Store(mFloat64, m.PointerConstant(to), m.Int32Constant(offset), load);
539 load);
540 m.Return(m.Int32Constant(magic)); 540 m.Return(m.Int32Constant(magic));
541 541
542 FOR_FLOAT64_INPUTS(j) { 542 FOR_FLOAT64_INPUTS(j) {
543 p1 = *j; 543 p1 = *j;
544 p2 = *j - 5; 544 p2 = *j - 5;
545 CHECK_EQ(magic, m.Call()); 545 CHECK_EQ(magic, m.Call());
546 CHECK_EQ(p1, p2); 546 CHECK_EQ(p1, p2);
547 } 547 }
548 } 548 }
549 } 549 }
(...skipping 10 matching lines...) Expand all
560 // Use uint32_t because signed overflow is UB in C. 560 // Use uint32_t because signed overflow is UB in C.
561 int expected = static_cast<int32_t>(*i + *j); 561 int expected = static_cast<int32_t>(*i + *j);
562 CHECK_EQ(expected, bt.call(*i, *j)); 562 CHECK_EQ(expected, bt.call(*i, *j));
563 } 563 }
564 } 564 }
565 } 565 }
566 566
567 567
568 TEST(RunInt32AddAndWord32SarP) { 568 TEST(RunInt32AddAndWord32SarP) {
569 { 569 {
570 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 570 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
571 kMachineWord32);
572 m.Return(m.Int32Add(m.Parameter(0), 571 m.Return(m.Int32Add(m.Parameter(0),
573 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 572 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
574 FOR_UINT32_INPUTS(i) { 573 FOR_UINT32_INPUTS(i) {
575 FOR_INT32_INPUTS(j) { 574 FOR_INT32_INPUTS(j) {
576 FOR_UINT32_SHIFTS(shift) { 575 FOR_UINT32_SHIFTS(shift) {
577 // Use uint32_t because signed overflow is UB in C. 576 // Use uint32_t because signed overflow is UB in C.
578 int32_t expected = *i + (*j >> shift); 577 int32_t expected = *i + (*j >> shift);
579 CHECK_EQ(expected, m.Call(*i, *j, shift)); 578 CHECK_EQ(expected, m.Call(*i, *j, shift));
580 } 579 }
581 } 580 }
582 } 581 }
583 } 582 }
584 { 583 {
585 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 584 RawMachineAssemblerTester<int32_t> m(mInt32, mUint32, mUint32);
586 kMachineWord32);
587 m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 585 m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
588 m.Parameter(2))); 586 m.Parameter(2)));
589 FOR_INT32_INPUTS(i) { 587 FOR_INT32_INPUTS(i) {
590 FOR_UINT32_SHIFTS(shift) { 588 FOR_UINT32_SHIFTS(shift) {
591 FOR_UINT32_INPUTS(k) { 589 FOR_UINT32_INPUTS(k) {
592 // Use uint32_t because signed overflow is UB in C. 590 // Use uint32_t because signed overflow is UB in C.
593 int32_t expected = (*i >> shift) + *k; 591 int32_t expected = (*i >> shift) + *k;
594 CHECK_EQ(expected, m.Call(*i, shift, *k)); 592 CHECK_EQ(expected, m.Call(*i, shift, *k));
595 } 593 }
596 } 594 }
597 } 595 }
598 } 596 }
599 } 597 }
600 598
601 599
602 TEST(RunInt32AddAndWord32ShlP) { 600 TEST(RunInt32AddAndWord32ShlP) {
603 { 601 {
604 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 602 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
605 kMachineWord32);
606 m.Return(m.Int32Add(m.Parameter(0), 603 m.Return(m.Int32Add(m.Parameter(0),
607 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 604 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
608 FOR_UINT32_INPUTS(i) { 605 FOR_UINT32_INPUTS(i) {
609 FOR_INT32_INPUTS(j) { 606 FOR_INT32_INPUTS(j) {
610 FOR_UINT32_SHIFTS(shift) { 607 FOR_UINT32_SHIFTS(shift) {
611 // Use uint32_t because signed overflow is UB in C. 608 // Use uint32_t because signed overflow is UB in C.
612 int32_t expected = *i + (*j << shift); 609 int32_t expected = *i + (*j << shift);
613 CHECK_EQ(expected, m.Call(*i, *j, shift)); 610 CHECK_EQ(expected, m.Call(*i, *j, shift));
614 } 611 }
615 } 612 }
616 } 613 }
617 } 614 }
618 { 615 {
619 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 616 RawMachineAssemblerTester<int32_t> m(mInt32, mUint32, mUint32);
620 kMachineWord32);
621 m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 617 m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
622 m.Parameter(2))); 618 m.Parameter(2)));
623 FOR_INT32_INPUTS(i) { 619 FOR_INT32_INPUTS(i) {
624 FOR_UINT32_SHIFTS(shift) { 620 FOR_UINT32_SHIFTS(shift) {
625 FOR_UINT32_INPUTS(k) { 621 FOR_UINT32_INPUTS(k) {
626 // Use uint32_t because signed overflow is UB in C. 622 // Use uint32_t because signed overflow is UB in C.
627 int32_t expected = (*i << shift) + *k; 623 int32_t expected = (*i << shift) + *k;
628 CHECK_EQ(expected, m.Call(*i, shift, *k)); 624 CHECK_EQ(expected, m.Call(*i, shift, *k));
629 } 625 }
630 } 626 }
631 } 627 }
632 } 628 }
633 } 629 }
634 630
635 631
636 TEST(RunInt32AddAndWord32ShrP) { 632 TEST(RunInt32AddAndWord32ShrP) {
637 { 633 {
638 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 634 RawMachineAssemblerTester<int32_t> m(mUint32, mUint32, mUint32);
639 kMachineWord32);
640 m.Return(m.Int32Add(m.Parameter(0), 635 m.Return(m.Int32Add(m.Parameter(0),
641 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 636 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
642 FOR_UINT32_INPUTS(i) { 637 FOR_UINT32_INPUTS(i) {
643 FOR_UINT32_INPUTS(j) { 638 FOR_UINT32_INPUTS(j) {
644 FOR_UINT32_SHIFTS(shift) { 639 FOR_UINT32_SHIFTS(shift) {
645 // Use uint32_t because signed overflow is UB in C. 640 // Use uint32_t because signed overflow is UB in C.
646 int32_t expected = *i + (*j >> shift); 641 int32_t expected = *i + (*j >> shift);
647 CHECK_EQ(expected, m.Call(*i, *j, shift)); 642 CHECK_EQ(expected, m.Call(*i, *j, shift));
648 } 643 }
649 } 644 }
650 } 645 }
651 } 646 }
652 { 647 {
653 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 648 RawMachineAssemblerTester<int32_t> m(mUint32, mUint32, mUint32);
654 kMachineWord32);
655 m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 649 m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
656 m.Parameter(2))); 650 m.Parameter(2)));
657 FOR_UINT32_INPUTS(i) { 651 FOR_UINT32_INPUTS(i) {
658 FOR_UINT32_SHIFTS(shift) { 652 FOR_UINT32_SHIFTS(shift) {
659 FOR_UINT32_INPUTS(k) { 653 FOR_UINT32_INPUTS(k) {
660 // Use uint32_t because signed overflow is UB in C. 654 // Use uint32_t because signed overflow is UB in C.
661 int32_t expected = (*i >> shift) + *k; 655 int32_t expected = (*i >> shift) + *k;
662 CHECK_EQ(expected, m.Call(*i, shift, *k)); 656 CHECK_EQ(expected, m.Call(*i, shift, *k));
663 } 657 }
664 } 658 }
665 } 659 }
666 } 660 }
667 } 661 }
668 662
669 663
670 TEST(RunInt32AddInBranch) { 664 TEST(RunInt32AddInBranch) {
671 static const int32_t constant = 987654321; 665 static const int32_t constant = 987654321;
672 { 666 {
673 RawMachineAssemblerTester<int32_t> m; 667 RawMachineAssemblerTester<int32_t> m;
674 Int32BinopTester bt(&m); 668 Uint32BinopTester bt(&m);
675 MLabel blocka, blockb; 669 MLabel blocka, blockb;
676 m.Branch( 670 m.Branch(
677 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), 671 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)),
678 &blocka, &blockb); 672 &blocka, &blockb);
679 m.Bind(&blocka); 673 m.Bind(&blocka);
680 bt.AddReturn(m.Int32Constant(constant)); 674 bt.AddReturn(m.Int32Constant(constant));
681 m.Bind(&blockb); 675 m.Bind(&blockb);
682 bt.AddReturn(m.Int32Constant(0 - constant)); 676 bt.AddReturn(m.Int32Constant(0 - constant));
683 FOR_UINT32_INPUTS(i) { 677 FOR_UINT32_INPUTS(i) {
684 FOR_UINT32_INPUTS(j) { 678 FOR_UINT32_INPUTS(j) {
685 int32_t expected = (*i + *j) == 0 ? constant : 0 - constant; 679 int32_t expected = (*i + *j) == 0 ? constant : 0 - constant;
686 CHECK_EQ(expected, bt.call(*i, *j)); 680 CHECK_EQ(expected, bt.call(*i, *j));
687 } 681 }
688 } 682 }
689 } 683 }
690 { 684 {
691 RawMachineAssemblerTester<int32_t> m; 685 RawMachineAssemblerTester<int32_t> m;
692 Int32BinopTester bt(&m); 686 Uint32BinopTester bt(&m);
693 MLabel blocka, blockb; 687 MLabel blocka, blockb;
694 m.Branch( 688 m.Branch(
695 m.Word32NotEqual(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), 689 m.Word32NotEqual(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)),
696 &blocka, &blockb); 690 &blocka, &blockb);
697 m.Bind(&blocka); 691 m.Bind(&blocka);
698 bt.AddReturn(m.Int32Constant(constant)); 692 bt.AddReturn(m.Int32Constant(constant));
699 m.Bind(&blockb); 693 m.Bind(&blockb);
700 bt.AddReturn(m.Int32Constant(0 - constant)); 694 bt.AddReturn(m.Int32Constant(0 - constant));
701 FOR_UINT32_INPUTS(i) { 695 FOR_UINT32_INPUTS(i) {
702 FOR_UINT32_INPUTS(j) { 696 FOR_UINT32_INPUTS(j) {
703 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; 697 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant;
704 CHECK_EQ(expected, bt.call(*i, *j)); 698 CHECK_EQ(expected, bt.call(*i, *j));
705 } 699 }
706 } 700 }
707 } 701 }
708 { 702 {
709 FOR_UINT32_INPUTS(i) { 703 FOR_UINT32_INPUTS(i) {
710 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 704 RawMachineAssemblerTester<uint32_t> m(mUint32);
711 MLabel blocka, blockb; 705 MLabel blocka, blockb;
712 m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), 706 m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)),
713 m.Int32Constant(0)), 707 m.Int32Constant(0)),
714 &blocka, &blockb); 708 &blocka, &blockb);
715 m.Bind(&blocka); 709 m.Bind(&blocka);
716 m.Return(m.Int32Constant(constant)); 710 m.Return(m.Int32Constant(constant));
717 m.Bind(&blockb); 711 m.Bind(&blockb);
718 m.Return(m.Int32Constant(0 - constant)); 712 m.Return(m.Int32Constant(0 - constant));
719 FOR_UINT32_INPUTS(j) { 713 FOR_UINT32_INPUTS(j) {
720 int32_t expected = (*i + *j) == 0 ? constant : 0 - constant; 714 uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant;
721 CHECK_EQ(expected, m.Call(*j)); 715 CHECK_UINT32_EQ(expected, m.Call(*j));
722 } 716 }
723 } 717 }
724 } 718 }
725 { 719 {
726 FOR_UINT32_INPUTS(i) { 720 FOR_UINT32_INPUTS(i) {
727 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 721 RawMachineAssemblerTester<uint32_t> m(mUint32);
728 MLabel blocka, blockb; 722 MLabel blocka, blockb;
729 m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), 723 m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)),
730 m.Int32Constant(0)), 724 m.Int32Constant(0)),
731 &blocka, &blockb); 725 &blocka, &blockb);
732 m.Bind(&blocka); 726 m.Bind(&blocka);
733 m.Return(m.Int32Constant(constant)); 727 m.Return(m.Int32Constant(constant));
734 m.Bind(&blockb); 728 m.Bind(&blockb);
735 m.Return(m.Int32Constant(0 - constant)); 729 m.Return(m.Int32Constant(0 - constant));
736 FOR_UINT32_INPUTS(j) { 730 FOR_UINT32_INPUTS(j) {
737 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; 731 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant;
738 CHECK_EQ(expected, m.Call(*j)); 732 CHECK_UINT32_EQ(expected, m.Call(*j));
739 } 733 }
740 } 734 }
741 } 735 }
742 { 736 {
743 RawMachineAssemblerTester<void> m; 737 RawMachineAssemblerTester<void> m;
744 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), 738 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
745 m.machine()->Word32Shr()}; 739 m.machine()->Word32Shr()};
746 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 740 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
747 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 741 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
748 kMachineWord32);
749 MLabel blocka, blockb; 742 MLabel blocka, blockb;
750 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), 743 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0),
751 m.NewNode(shops[n], m.Parameter(1), 744 m.NewNode(shops[n], m.Parameter(1),
752 m.Parameter(2))), 745 m.Parameter(2))),
753 m.Int32Constant(0)), 746 m.Int32Constant(0)),
754 &blocka, &blockb); 747 &blocka, &blockb);
755 m.Bind(&blocka); 748 m.Bind(&blocka);
756 m.Return(m.Int32Constant(constant)); 749 m.Return(m.Int32Constant(constant));
757 m.Bind(&blockb); 750 m.Bind(&blockb);
758 m.Return(m.Int32Constant(0 - constant)); 751 m.Return(m.Int32Constant(0 - constant));
(...skipping 20 matching lines...) Expand all
779 } 772 }
780 } 773 }
781 } 774 }
782 } 775 }
783 } 776 }
784 777
785 778
786 TEST(RunInt32AddInComparison) { 779 TEST(RunInt32AddInComparison) {
787 { 780 {
788 RawMachineAssemblerTester<int32_t> m; 781 RawMachineAssemblerTester<int32_t> m;
789 Int32BinopTester bt(&m); 782 Uint32BinopTester bt(&m);
790 bt.AddReturn( 783 bt.AddReturn(
791 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0))); 784 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)));
792 FOR_UINT32_INPUTS(i) { 785 FOR_UINT32_INPUTS(i) {
793 FOR_UINT32_INPUTS(j) { 786 FOR_UINT32_INPUTS(j) {
794 int32_t expected = (*i + *j) == 0; 787 uint32_t expected = (*i + *j) == 0;
795 CHECK_EQ(expected, bt.call(*i, *j)); 788 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
796 } 789 }
797 } 790 }
798 } 791 }
799 { 792 {
800 RawMachineAssemblerTester<int32_t> m; 793 RawMachineAssemblerTester<int32_t> m;
801 Int32BinopTester bt(&m); 794 Uint32BinopTester bt(&m);
802 bt.AddReturn( 795 bt.AddReturn(
803 m.Word32Equal(m.Int32Constant(0), m.Int32Add(bt.param0, bt.param1))); 796 m.Word32Equal(m.Int32Constant(0), m.Int32Add(bt.param0, bt.param1)));
804 FOR_UINT32_INPUTS(i) { 797 FOR_UINT32_INPUTS(i) {
805 FOR_UINT32_INPUTS(j) { 798 FOR_UINT32_INPUTS(j) {
806 int32_t expected = (*i + *j) == 0; 799 uint32_t expected = (*i + *j) == 0;
807 CHECK_EQ(expected, bt.call(*i, *j)); 800 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
808 } 801 }
809 } 802 }
810 } 803 }
811 { 804 {
812 FOR_UINT32_INPUTS(i) { 805 FOR_UINT32_INPUTS(i) {
813 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 806 RawMachineAssemblerTester<uint32_t> m(mUint32);
814 m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), 807 m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)),
815 m.Int32Constant(0))); 808 m.Int32Constant(0)));
816 FOR_UINT32_INPUTS(j) { 809 FOR_UINT32_INPUTS(j) {
817 int32_t expected = (*i + *j) == 0; 810 uint32_t expected = (*i + *j) == 0;
818 CHECK_EQ(expected, m.Call(*j)); 811 CHECK_UINT32_EQ(expected, m.Call(*j));
819 } 812 }
820 } 813 }
821 } 814 }
822 { 815 {
823 FOR_UINT32_INPUTS(i) { 816 FOR_UINT32_INPUTS(i) {
824 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 817 RawMachineAssemblerTester<uint32_t> m(mUint32);
825 m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), 818 m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)),
826 m.Int32Constant(0))); 819 m.Int32Constant(0)));
827 FOR_UINT32_INPUTS(j) { 820 FOR_UINT32_INPUTS(j) {
828 int32_t expected = (*j + *i) == 0; 821 uint32_t expected = (*j + *i) == 0;
829 CHECK_EQ(expected, m.Call(*j)); 822 CHECK_UINT32_EQ(expected, m.Call(*j));
830 } 823 }
831 } 824 }
832 } 825 }
833 { 826 {
834 RawMachineAssemblerTester<void> m; 827 RawMachineAssemblerTester<void> m;
835 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), 828 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
836 m.machine()->Word32Shr()}; 829 m.machine()->Word32Shr()};
837 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 830 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
838 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 831 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
839 kMachineWord32);
840 m.Return(m.Word32Equal( 832 m.Return(m.Word32Equal(
841 m.Int32Add(m.Parameter(0), 833 m.Int32Add(m.Parameter(0),
842 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), 834 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))),
843 m.Int32Constant(0))); 835 m.Int32Constant(0)));
844 FOR_UINT32_INPUTS(i) { 836 FOR_UINT32_INPUTS(i) {
845 FOR_INT32_INPUTS(j) { 837 FOR_INT32_INPUTS(j) {
846 FOR_UINT32_SHIFTS(shift) { 838 FOR_UINT32_SHIFTS(shift) {
847 int32_t right; 839 int32_t right;
848 switch (shops[n]->opcode()) { 840 switch (shops[n]->opcode()) {
849 default: 841 default:
(...skipping 13 matching lines...) Expand all
863 } 855 }
864 } 856 }
865 } 857 }
866 } 858 }
867 } 859 }
868 } 860 }
869 861
870 862
871 TEST(RunInt32SubP) { 863 TEST(RunInt32SubP) {
872 RawMachineAssemblerTester<int32_t> m; 864 RawMachineAssemblerTester<int32_t> m;
873 Int32BinopTester bt(&m); 865 Uint32BinopTester bt(&m);
874 866
875 m.Return(m.Int32Sub(bt.param0, bt.param1)); 867 m.Return(m.Int32Sub(bt.param0, bt.param1));
876 868
877 FOR_UINT32_INPUTS(i) { 869 FOR_UINT32_INPUTS(i) {
878 FOR_UINT32_INPUTS(j) { 870 FOR_UINT32_INPUTS(j) {
879 // Use uint32_t because signed overflow is UB in C. 871 uint32_t expected = static_cast<int32_t>(*i - *j);
880 int expected = static_cast<int32_t>(*i - *j); 872 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
881 CHECK_EQ(expected, bt.call(*i, *j));
882 } 873 }
883 } 874 }
884 } 875 }
885 876
886 877
887 TEST(RunInt32SubImm) { 878 TEST(RunInt32SubImm) {
888 { 879 {
889 FOR_UINT32_INPUTS(i) { 880 FOR_UINT32_INPUTS(i) {
890 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 881 RawMachineAssemblerTester<uint32_t> m(mUint32);
891 m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0))); 882 m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)));
892 FOR_UINT32_INPUTS(j) { 883 FOR_UINT32_INPUTS(j) {
893 // Use uint32_t because signed overflow is UB in C. 884 uint32_t expected = *i - *j;
894 int32_t expected = static_cast<int32_t>(*i - *j); 885 CHECK_UINT32_EQ(expected, m.Call(*j));
895 CHECK_EQ(expected, m.Call(*j));
896 } 886 }
897 } 887 }
898 } 888 }
899 { 889 {
900 FOR_UINT32_INPUTS(i) { 890 FOR_UINT32_INPUTS(i) {
901 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 891 RawMachineAssemblerTester<uint32_t> m(mUint32);
902 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i))); 892 m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)));
903 FOR_UINT32_INPUTS(j) { 893 FOR_UINT32_INPUTS(j) {
904 // Use uint32_t because signed overflow is UB in C. 894 uint32_t expected = *j - *i;
905 int32_t expected = static_cast<int32_t>(*j - *i); 895 CHECK_UINT32_EQ(expected, m.Call(*j));
906 CHECK_EQ(expected, m.Call(*j));
907 } 896 }
908 } 897 }
909 } 898 }
910 } 899 }
911 900
912 901
913 TEST(RunInt32SubAndWord32SarP) { 902 TEST(RunInt32SubAndWord32SarP) {
914 { 903 {
915 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 904 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
916 kMachineWord32);
917 m.Return(m.Int32Sub(m.Parameter(0), 905 m.Return(m.Int32Sub(m.Parameter(0),
918 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 906 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
919 FOR_UINT32_INPUTS(i) { 907 FOR_UINT32_INPUTS(i) {
920 FOR_INT32_INPUTS(j) { 908 FOR_INT32_INPUTS(j) {
921 FOR_UINT32_SHIFTS(shift) { 909 FOR_UINT32_SHIFTS(shift) {
922 // Use uint32_t because signed overflow is UB in C.
923 int32_t expected = *i - (*j >> shift); 910 int32_t expected = *i - (*j >> shift);
924 CHECK_EQ(expected, m.Call(*i, *j, shift)); 911 CHECK_EQ(expected, m.Call(*i, *j, shift));
925 } 912 }
926 } 913 }
927 } 914 }
928 } 915 }
929 { 916 {
930 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 917 RawMachineAssemblerTester<int32_t> m(mInt32, mUint32, mUint32);
931 kMachineWord32);
932 m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 918 m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
933 m.Parameter(2))); 919 m.Parameter(2)));
934 FOR_INT32_INPUTS(i) { 920 FOR_INT32_INPUTS(i) {
935 FOR_UINT32_SHIFTS(shift) { 921 FOR_UINT32_SHIFTS(shift) {
936 FOR_UINT32_INPUTS(k) { 922 FOR_UINT32_INPUTS(k) {
937 // Use uint32_t because signed overflow is UB in C.
938 int32_t expected = (*i >> shift) - *k; 923 int32_t expected = (*i >> shift) - *k;
939 CHECK_EQ(expected, m.Call(*i, shift, *k)); 924 CHECK_EQ(expected, m.Call(*i, shift, *k));
940 } 925 }
941 } 926 }
942 } 927 }
943 } 928 }
944 } 929 }
945 930
946 931
947 TEST(RunInt32SubAndWord32ShlP) { 932 TEST(RunInt32SubAndWord32ShlP) {
948 { 933 {
949 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 934 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
950 kMachineWord32);
951 m.Return(m.Int32Sub(m.Parameter(0), 935 m.Return(m.Int32Sub(m.Parameter(0),
952 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 936 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
953 FOR_UINT32_INPUTS(i) { 937 FOR_UINT32_INPUTS(i) {
954 FOR_INT32_INPUTS(j) { 938 FOR_INT32_INPUTS(j) {
955 FOR_UINT32_SHIFTS(shift) { 939 FOR_UINT32_SHIFTS(shift) {
956 // Use uint32_t because signed overflow is UB in C.
957 int32_t expected = *i - (*j << shift); 940 int32_t expected = *i - (*j << shift);
958 CHECK_EQ(expected, m.Call(*i, *j, shift)); 941 CHECK_EQ(expected, m.Call(*i, *j, shift));
959 } 942 }
960 } 943 }
961 } 944 }
962 } 945 }
963 { 946 {
964 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 947 RawMachineAssemblerTester<int32_t> m(mInt32, mUint32, mUint32);
965 kMachineWord32);
966 m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 948 m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
967 m.Parameter(2))); 949 m.Parameter(2)));
968 FOR_INT32_INPUTS(i) { 950 FOR_INT32_INPUTS(i) {
969 FOR_UINT32_SHIFTS(shift) { 951 FOR_UINT32_SHIFTS(shift) {
970 FOR_UINT32_INPUTS(k) { 952 FOR_UINT32_INPUTS(k) {
971 // Use uint32_t because signed overflow is UB in C. 953 // Use uint32_t because signed overflow is UB in C.
972 int32_t expected = (*i << shift) - *k; 954 int32_t expected = (*i << shift) - *k;
973 CHECK_EQ(expected, m.Call(*i, shift, *k)); 955 CHECK_EQ(expected, m.Call(*i, shift, *k));
974 } 956 }
975 } 957 }
976 } 958 }
977 } 959 }
978 } 960 }
979 961
980 962
981 TEST(RunInt32SubAndWord32ShrP) { 963 TEST(RunInt32SubAndWord32ShrP) {
982 { 964 {
983 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 965 RawMachineAssemblerTester<uint32_t> m(mUint32, mUint32, mUint32);
984 kMachineWord32);
985 m.Return(m.Int32Sub(m.Parameter(0), 966 m.Return(m.Int32Sub(m.Parameter(0),
986 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 967 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
987 FOR_UINT32_INPUTS(i) { 968 FOR_UINT32_INPUTS(i) {
988 FOR_UINT32_INPUTS(j) { 969 FOR_UINT32_INPUTS(j) {
989 FOR_UINT32_SHIFTS(shift) { 970 FOR_UINT32_SHIFTS(shift) {
990 // Use uint32_t because signed overflow is UB in C. 971 // Use uint32_t because signed overflow is UB in C.
991 int32_t expected = *i - (*j >> shift); 972 int32_t expected = *i - (*j >> shift);
992 CHECK_EQ(expected, m.Call(*i, *j, shift)); 973 CHECK_UINT32_EQ(expected, m.Call(*i, *j, shift));
993 } 974 }
994 } 975 }
995 } 976 }
996 } 977 }
997 { 978 {
998 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 979 RawMachineAssemblerTester<uint32_t> m(mUint32, mUint32, mUint32);
999 kMachineWord32);
1000 m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 980 m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
1001 m.Parameter(2))); 981 m.Parameter(2)));
1002 FOR_UINT32_INPUTS(i) { 982 FOR_UINT32_INPUTS(i) {
1003 FOR_UINT32_SHIFTS(shift) { 983 FOR_UINT32_SHIFTS(shift) {
1004 FOR_UINT32_INPUTS(k) { 984 FOR_UINT32_INPUTS(k) {
1005 // Use uint32_t because signed overflow is UB in C. 985 // Use uint32_t because signed overflow is UB in C.
1006 int32_t expected = (*i >> shift) - *k; 986 int32_t expected = (*i >> shift) - *k;
1007 CHECK_EQ(expected, m.Call(*i, shift, *k)); 987 CHECK_EQ(expected, m.Call(*i, shift, *k));
1008 } 988 }
1009 } 989 }
1010 } 990 }
1011 } 991 }
1012 } 992 }
1013 993
1014 994
1015 TEST(RunInt32SubInBranch) { 995 TEST(RunInt32SubInBranch) {
1016 static const int constant = 987654321; 996 static const int constant = 987654321;
1017 { 997 {
1018 RawMachineAssemblerTester<int32_t> m; 998 RawMachineAssemblerTester<int32_t> m;
1019 Int32BinopTester bt(&m); 999 Uint32BinopTester bt(&m);
1020 MLabel blocka, blockb; 1000 MLabel blocka, blockb;
1021 m.Branch( 1001 m.Branch(
1022 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), 1002 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)),
1023 &blocka, &blockb); 1003 &blocka, &blockb);
1024 m.Bind(&blocka); 1004 m.Bind(&blocka);
1025 bt.AddReturn(m.Int32Constant(constant)); 1005 bt.AddReturn(m.Int32Constant(constant));
1026 m.Bind(&blockb); 1006 m.Bind(&blockb);
1027 bt.AddReturn(m.Int32Constant(0 - constant)); 1007 bt.AddReturn(m.Int32Constant(0 - constant));
1028 FOR_UINT32_INPUTS(i) { 1008 FOR_UINT32_INPUTS(i) {
1029 FOR_UINT32_INPUTS(j) { 1009 FOR_UINT32_INPUTS(j) {
1030 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant; 1010 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant;
1031 CHECK_EQ(expected, bt.call(*i, *j)); 1011 CHECK_EQ(expected, bt.call(*i, *j));
1032 } 1012 }
1033 } 1013 }
1034 } 1014 }
1035 { 1015 {
1036 RawMachineAssemblerTester<int32_t> m; 1016 RawMachineAssemblerTester<int32_t> m;
1037 Int32BinopTester bt(&m); 1017 Uint32BinopTester bt(&m);
1038 MLabel blocka, blockb; 1018 MLabel blocka, blockb;
1039 m.Branch( 1019 m.Branch(
1040 m.Word32NotEqual(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), 1020 m.Word32NotEqual(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)),
1041 &blocka, &blockb); 1021 &blocka, &blockb);
1042 m.Bind(&blocka); 1022 m.Bind(&blocka);
1043 bt.AddReturn(m.Int32Constant(constant)); 1023 bt.AddReturn(m.Int32Constant(constant));
1044 m.Bind(&blockb); 1024 m.Bind(&blockb);
1045 bt.AddReturn(m.Int32Constant(0 - constant)); 1025 bt.AddReturn(m.Int32Constant(0 - constant));
1046 FOR_UINT32_INPUTS(i) { 1026 FOR_UINT32_INPUTS(i) {
1047 FOR_UINT32_INPUTS(j) { 1027 FOR_UINT32_INPUTS(j) {
1048 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; 1028 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant;
1049 CHECK_EQ(expected, bt.call(*i, *j)); 1029 CHECK_EQ(expected, bt.call(*i, *j));
1050 } 1030 }
1051 } 1031 }
1052 } 1032 }
1053 { 1033 {
1054 FOR_UINT32_INPUTS(i) { 1034 FOR_UINT32_INPUTS(i) {
1055 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1035 RawMachineAssemblerTester<uint32_t> m(mUint32);
1056 MLabel blocka, blockb; 1036 MLabel blocka, blockb;
1057 m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), 1037 m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)),
1058 m.Int32Constant(0)), 1038 m.Int32Constant(0)),
1059 &blocka, &blockb); 1039 &blocka, &blockb);
1060 m.Bind(&blocka); 1040 m.Bind(&blocka);
1061 m.Return(m.Int32Constant(constant)); 1041 m.Return(m.Int32Constant(constant));
1062 m.Bind(&blockb); 1042 m.Bind(&blockb);
1063 m.Return(m.Int32Constant(0 - constant)); 1043 m.Return(m.Int32Constant(0 - constant));
1064 FOR_UINT32_INPUTS(j) { 1044 FOR_UINT32_INPUTS(j) {
1065 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant; 1045 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant;
1066 CHECK_EQ(expected, m.Call(*j)); 1046 CHECK_EQ(expected, m.Call(*j));
1067 } 1047 }
1068 } 1048 }
1069 } 1049 }
1070 { 1050 {
1071 FOR_UINT32_INPUTS(i) { 1051 FOR_UINT32_INPUTS(i) {
1072 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1052 RawMachineAssemblerTester<int32_t> m(mUint32);
1073 MLabel blocka, blockb; 1053 MLabel blocka, blockb;
1074 m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), 1054 m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)),
1075 m.Int32Constant(0)), 1055 m.Int32Constant(0)),
1076 &blocka, &blockb); 1056 &blocka, &blockb);
1077 m.Bind(&blocka); 1057 m.Bind(&blocka);
1078 m.Return(m.Int32Constant(constant)); 1058 m.Return(m.Int32Constant(constant));
1079 m.Bind(&blockb); 1059 m.Bind(&blockb);
1080 m.Return(m.Int32Constant(0 - constant)); 1060 m.Return(m.Int32Constant(0 - constant));
1081 FOR_UINT32_INPUTS(j) { 1061 FOR_UINT32_INPUTS(j) {
1082 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; 1062 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant;
1083 CHECK_EQ(expected, m.Call(*j)); 1063 CHECK_EQ(expected, m.Call(*j));
1084 } 1064 }
1085 } 1065 }
1086 } 1066 }
1087 { 1067 {
1088 RawMachineAssemblerTester<void> m; 1068 RawMachineAssemblerTester<void> m;
1089 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), 1069 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
1090 m.machine()->Word32Shr()}; 1070 m.machine()->Word32Shr()};
1091 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 1071 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
1092 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 1072 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
1093 kMachineWord32);
1094 MLabel blocka, blockb; 1073 MLabel blocka, blockb;
1095 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), 1074 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0),
1096 m.NewNode(shops[n], m.Parameter(1), 1075 m.NewNode(shops[n], m.Parameter(1),
1097 m.Parameter(2))), 1076 m.Parameter(2))),
1098 m.Int32Constant(0)), 1077 m.Int32Constant(0)),
1099 &blocka, &blockb); 1078 &blocka, &blockb);
1100 m.Bind(&blocka); 1079 m.Bind(&blocka);
1101 m.Return(m.Int32Constant(constant)); 1080 m.Return(m.Int32Constant(constant));
1102 m.Bind(&blockb); 1081 m.Bind(&blockb);
1103 m.Return(m.Int32Constant(0 - constant)); 1082 m.Return(m.Int32Constant(0 - constant));
(...skipping 20 matching lines...) Expand all
1124 } 1103 }
1125 } 1104 }
1126 } 1105 }
1127 } 1106 }
1128 } 1107 }
1129 1108
1130 1109
1131 TEST(RunInt32SubInComparison) { 1110 TEST(RunInt32SubInComparison) {
1132 { 1111 {
1133 RawMachineAssemblerTester<int32_t> m; 1112 RawMachineAssemblerTester<int32_t> m;
1134 Int32BinopTester bt(&m); 1113 Uint32BinopTester bt(&m);
1135 bt.AddReturn( 1114 bt.AddReturn(
1136 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0))); 1115 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)));
1137 FOR_UINT32_INPUTS(i) { 1116 FOR_UINT32_INPUTS(i) {
1138 FOR_UINT32_INPUTS(j) { 1117 FOR_UINT32_INPUTS(j) {
1139 int32_t expected = (*i - *j) == 0; 1118 uint32_t expected = (*i - *j) == 0;
1140 CHECK_EQ(expected, bt.call(*i, *j)); 1119 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1141 } 1120 }
1142 } 1121 }
1143 } 1122 }
1144 { 1123 {
1145 RawMachineAssemblerTester<int32_t> m; 1124 RawMachineAssemblerTester<int32_t> m;
1146 Int32BinopTester bt(&m); 1125 Uint32BinopTester bt(&m);
1147 bt.AddReturn( 1126 bt.AddReturn(
1148 m.Word32Equal(m.Int32Constant(0), m.Int32Sub(bt.param0, bt.param1))); 1127 m.Word32Equal(m.Int32Constant(0), m.Int32Sub(bt.param0, bt.param1)));
1149 FOR_UINT32_INPUTS(i) { 1128 FOR_UINT32_INPUTS(i) {
1150 FOR_UINT32_INPUTS(j) { 1129 FOR_UINT32_INPUTS(j) {
1151 int32_t expected = (*i - *j) == 0; 1130 uint32_t expected = (*i - *j) == 0;
1152 CHECK_EQ(expected, bt.call(*i, *j)); 1131 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1153 } 1132 }
1154 } 1133 }
1155 } 1134 }
1156 { 1135 {
1157 FOR_UINT32_INPUTS(i) { 1136 FOR_UINT32_INPUTS(i) {
1158 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1137 RawMachineAssemblerTester<uint32_t> m(mUint32);
1159 m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), 1138 m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)),
1160 m.Int32Constant(0))); 1139 m.Int32Constant(0)));
1161 FOR_UINT32_INPUTS(j) { 1140 FOR_UINT32_INPUTS(j) {
1162 int32_t expected = (*i - *j) == 0; 1141 uint32_t expected = (*i - *j) == 0;
1163 CHECK_EQ(expected, m.Call(*j)); 1142 CHECK_UINT32_EQ(expected, m.Call(*j));
1164 } 1143 }
1165 } 1144 }
1166 } 1145 }
1167 { 1146 {
1168 FOR_UINT32_INPUTS(i) { 1147 FOR_UINT32_INPUTS(i) {
1169 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1148 RawMachineAssemblerTester<uint32_t> m(mUint32);
1170 m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), 1149 m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)),
1171 m.Int32Constant(0))); 1150 m.Int32Constant(0)));
1172 FOR_UINT32_INPUTS(j) { 1151 FOR_UINT32_INPUTS(j) {
1173 int32_t expected = (*j - *i) == 0; 1152 uint32_t expected = (*j - *i) == 0;
1174 CHECK_EQ(expected, m.Call(*j)); 1153 CHECK_UINT32_EQ(expected, m.Call(*j));
1175 } 1154 }
1176 } 1155 }
1177 } 1156 }
1178 { 1157 {
1179 RawMachineAssemblerTester<void> m; 1158 RawMachineAssemblerTester<void> m;
1180 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), 1159 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
1181 m.machine()->Word32Shr()}; 1160 m.machine()->Word32Shr()};
1182 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 1161 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
1183 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 1162 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
1184 kMachineWord32);
1185 m.Return(m.Word32Equal( 1163 m.Return(m.Word32Equal(
1186 m.Int32Sub(m.Parameter(0), 1164 m.Int32Sub(m.Parameter(0),
1187 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), 1165 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))),
1188 m.Int32Constant(0))); 1166 m.Int32Constant(0)));
1189 FOR_UINT32_INPUTS(i) { 1167 FOR_UINT32_INPUTS(i) {
1190 FOR_INT32_INPUTS(j) { 1168 FOR_INT32_INPUTS(j) {
1191 FOR_UINT32_SHIFTS(shift) { 1169 FOR_UINT32_SHIFTS(shift) {
1192 int32_t right; 1170 int32_t right;
1193 switch (shops[n]->opcode()) { 1171 switch (shops[n]->opcode()) {
1194 default: 1172 default:
(...skipping 25 matching lines...) Expand all
1220 bt.AddReturn(m.Int32Mul(bt.param0, bt.param1)); 1198 bt.AddReturn(m.Int32Mul(bt.param0, bt.param1));
1221 FOR_INT32_INPUTS(i) { 1199 FOR_INT32_INPUTS(i) {
1222 FOR_INT32_INPUTS(j) { 1200 FOR_INT32_INPUTS(j) {
1223 int expected = static_cast<int32_t>(*i * *j); 1201 int expected = static_cast<int32_t>(*i * *j);
1224 CHECK_EQ(expected, bt.call(*i, *j)); 1202 CHECK_EQ(expected, bt.call(*i, *j));
1225 } 1203 }
1226 } 1204 }
1227 } 1205 }
1228 { 1206 {
1229 RawMachineAssemblerTester<int32_t> m; 1207 RawMachineAssemblerTester<int32_t> m;
1230 Int32BinopTester bt(&m); 1208 Uint32BinopTester bt(&m);
1231 bt.AddReturn(m.Int32Mul(bt.param0, bt.param1)); 1209 bt.AddReturn(m.Int32Mul(bt.param0, bt.param1));
1232 FOR_UINT32_INPUTS(i) { 1210 FOR_UINT32_INPUTS(i) {
1233 FOR_UINT32_INPUTS(j) { 1211 FOR_UINT32_INPUTS(j) {
1234 int expected = static_cast<int32_t>(*i * *j); 1212 uint32_t expected = *i * *j;
1235 CHECK_EQ(expected, bt.call(*i, *j)); 1213 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1236 } 1214 }
1237 } 1215 }
1238 } 1216 }
1239 } 1217 }
1240 1218
1241 1219
1242 TEST(RunInt32MulImm) { 1220 TEST(RunInt32MulImm) {
1243 { 1221 {
1244 FOR_UINT32_INPUTS(i) { 1222 FOR_UINT32_INPUTS(i) {
1245 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1223 RawMachineAssemblerTester<uint32_t> m(mUint32);
1246 m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0))); 1224 m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0)));
1247 FOR_UINT32_INPUTS(j) { 1225 FOR_UINT32_INPUTS(j) {
1248 int32_t expected = static_cast<int32_t>(*i * *j); 1226 uint32_t expected = *i * *j;
1249 CHECK_EQ(expected, m.Call(*j)); 1227 CHECK_UINT32_EQ(expected, m.Call(*j));
1250 } 1228 }
1251 } 1229 }
1252 } 1230 }
1253 { 1231 {
1254 FOR_UINT32_INPUTS(i) { 1232 FOR_UINT32_INPUTS(i) {
1255 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1233 RawMachineAssemblerTester<uint32_t> m(mUint32);
1256 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i))); 1234 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i)));
1257 FOR_UINT32_INPUTS(j) { 1235 FOR_UINT32_INPUTS(j) {
1258 int32_t expected = static_cast<int32_t>(*j * *i); 1236 uint32_t expected = *j * *i;
1259 CHECK_EQ(expected, m.Call(*j)); 1237 CHECK_UINT32_EQ(expected, m.Call(*j));
1260 } 1238 }
1261 } 1239 }
1262 } 1240 }
1263 } 1241 }
1264 1242
1265 1243
1266 TEST(RunInt32MulAndInt32AddP) { 1244 TEST(RunInt32MulAndInt32AddP) {
1267 { 1245 {
1268 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 1246 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32, mInt32);
1269 kMachineWord32);
1270 m.Return( 1247 m.Return(
1271 m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); 1248 m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2))));
1272 FOR_INT32_INPUTS(i) { 1249 FOR_INT32_INPUTS(i) {
1273 FOR_INT32_INPUTS(j) { 1250 FOR_INT32_INPUTS(j) {
1274 FOR_INT32_INPUTS(k) { 1251 FOR_INT32_INPUTS(k) {
1275 int32_t p0 = *i; 1252 int32_t p0 = *i;
1276 int32_t p1 = *j; 1253 int32_t p1 = *j;
1277 int32_t p2 = *k; 1254 int32_t p2 = *k;
1278 int expected = p0 + static_cast<int32_t>(p1 * p2); 1255 int expected = p0 + static_cast<int32_t>(p1 * p2);
1279 CHECK_EQ(expected, m.Call(p0, p1, p2)); 1256 CHECK_EQ(expected, m.Call(p0, p1, p2));
1280 } 1257 }
1281 } 1258 }
1282 } 1259 }
1283 } 1260 }
1284 { 1261 {
1285 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 1262 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32, mInt32);
1286 kMachineWord32);
1287 m.Return( 1263 m.Return(
1288 m.Int32Add(m.Int32Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); 1264 m.Int32Add(m.Int32Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2)));
1289 FOR_INT32_INPUTS(i) { 1265 FOR_INT32_INPUTS(i) {
1290 FOR_INT32_INPUTS(j) { 1266 FOR_INT32_INPUTS(j) {
1291 FOR_INT32_INPUTS(k) { 1267 FOR_INT32_INPUTS(k) {
1292 int32_t p0 = *i; 1268 int32_t p0 = *i;
1293 int32_t p1 = *j; 1269 int32_t p1 = *j;
1294 int32_t p2 = *k; 1270 int32_t p2 = *k;
1295 int expected = static_cast<int32_t>(p0 * p1) + p2; 1271 int expected = static_cast<int32_t>(p0 * p1) + p2;
1296 CHECK_EQ(expected, m.Call(p0, p1, p2)); 1272 CHECK_EQ(expected, m.Call(p0, p1, p2));
(...skipping 15 matching lines...) Expand all
1312 CHECK_EQ(expected, bt.call(p0, p1)); 1288 CHECK_EQ(expected, bt.call(p0, p1));
1313 } 1289 }
1314 } 1290 }
1315 } 1291 }
1316 } 1292 }
1317 } 1293 }
1318 1294
1319 1295
1320 TEST(RunInt32MulAndInt32SubP) { 1296 TEST(RunInt32MulAndInt32SubP) {
1321 { 1297 {
1322 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 1298 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mInt32);
1323 kMachineWord32);
1324 m.Return( 1299 m.Return(
1325 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); 1300 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2))));
1326 FOR_UINT32_INPUTS(i) { 1301 FOR_UINT32_INPUTS(i) {
1327 FOR_INT32_INPUTS(j) { 1302 FOR_INT32_INPUTS(j) {
1328 FOR_INT32_INPUTS(k) { 1303 FOR_INT32_INPUTS(k) {
1329 uint32_t p0 = *i; 1304 uint32_t p0 = *i;
1330 int32_t p1 = *j; 1305 int32_t p1 = *j;
1331 int32_t p2 = *k; 1306 int32_t p2 = *k;
1332 // Use uint32_t because signed overflow is UB in C. 1307 // Use uint32_t because signed overflow is UB in C.
1333 int expected = p0 - static_cast<uint32_t>(p1 * p2); 1308 int expected = p0 - static_cast<uint32_t>(p1 * p2);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 CHECK_EQ(expected, bt.call(*i, *j)); 1500 CHECK_EQ(expected, bt.call(*i, *j));
1526 } 1501 }
1527 } 1502 }
1528 } 1503 }
1529 } 1504 }
1530 1505
1531 1506
1532 TEST(RunWord32AndAndWord32ShlP) { 1507 TEST(RunWord32AndAndWord32ShlP) {
1533 { 1508 {
1534 RawMachineAssemblerTester<int32_t> m; 1509 RawMachineAssemblerTester<int32_t> m;
1535 Int32BinopTester bt(&m); 1510 Uint32BinopTester bt(&m);
1536 bt.AddReturn( 1511 bt.AddReturn(
1537 m.Word32Shl(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); 1512 m.Word32Shl(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f))));
1538 FOR_UINT32_INPUTS(i) { 1513 FOR_UINT32_INPUTS(i) {
1539 FOR_UINT32_INPUTS(j) { 1514 FOR_UINT32_INPUTS(j) {
1540 uint32_t expected = *i << (*j & 0x1f); 1515 uint32_t expected = *i << (*j & 0x1f);
1541 CHECK_EQ(expected, bt.call(*i, *j)); 1516 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1542 } 1517 }
1543 } 1518 }
1544 } 1519 }
1545 { 1520 {
1546 RawMachineAssemblerTester<int32_t> m; 1521 RawMachineAssemblerTester<int32_t> m;
1547 Int32BinopTester bt(&m); 1522 Uint32BinopTester bt(&m);
1548 bt.AddReturn( 1523 bt.AddReturn(
1549 m.Word32Shl(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); 1524 m.Word32Shl(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1)));
1550 FOR_UINT32_INPUTS(i) { 1525 FOR_UINT32_INPUTS(i) {
1551 FOR_UINT32_INPUTS(j) { 1526 FOR_UINT32_INPUTS(j) {
1552 uint32_t expected = *i << (0x1f & *j); 1527 uint32_t expected = *i << (0x1f & *j);
1553 CHECK_EQ(expected, bt.call(*i, *j)); 1528 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1554 } 1529 }
1555 } 1530 }
1556 } 1531 }
1557 } 1532 }
1558 1533
1559 1534
1560 TEST(RunWord32AndAndWord32ShrP) { 1535 TEST(RunWord32AndAndWord32ShrP) {
1561 { 1536 {
1562 RawMachineAssemblerTester<int32_t> m; 1537 RawMachineAssemblerTester<int32_t> m;
1563 Int32BinopTester bt(&m); 1538 Uint32BinopTester bt(&m);
1564 bt.AddReturn( 1539 bt.AddReturn(
1565 m.Word32Shr(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); 1540 m.Word32Shr(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f))));
1566 FOR_UINT32_INPUTS(i) { 1541 FOR_UINT32_INPUTS(i) {
1567 FOR_UINT32_INPUTS(j) { 1542 FOR_UINT32_INPUTS(j) {
1568 uint32_t expected = *i >> (*j & 0x1f); 1543 uint32_t expected = *i >> (*j & 0x1f);
1569 CHECK_EQ(expected, bt.call(*i, *j)); 1544 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1570 } 1545 }
1571 } 1546 }
1572 } 1547 }
1573 { 1548 {
1574 RawMachineAssemblerTester<int32_t> m; 1549 RawMachineAssemblerTester<int32_t> m;
1575 Int32BinopTester bt(&m); 1550 Uint32BinopTester bt(&m);
1576 bt.AddReturn( 1551 bt.AddReturn(
1577 m.Word32Shr(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); 1552 m.Word32Shr(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1)));
1578 FOR_UINT32_INPUTS(i) { 1553 FOR_UINT32_INPUTS(i) {
1579 FOR_UINT32_INPUTS(j) { 1554 FOR_UINT32_INPUTS(j) {
1580 uint32_t expected = *i >> (0x1f & *j); 1555 uint32_t expected = *i >> (0x1f & *j);
1581 CHECK_EQ(expected, bt.call(*i, *j)); 1556 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1582 } 1557 }
1583 } 1558 }
1584 } 1559 }
1585 } 1560 }
1586 1561
1587 1562
1588 TEST(RunWord32AndAndWord32SarP) { 1563 TEST(RunWord32AndAndWord32SarP) {
1589 { 1564 {
1590 RawMachineAssemblerTester<int32_t> m; 1565 RawMachineAssemblerTester<int32_t> m;
1591 Int32BinopTester bt(&m); 1566 Int32BinopTester bt(&m);
1592 bt.AddReturn( 1567 bt.AddReturn(
1593 m.Word32Sar(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); 1568 m.Word32Sar(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f))));
1594 FOR_INT32_INPUTS(i) { 1569 FOR_INT32_INPUTS(i) {
1595 FOR_UINT32_INPUTS(j) { 1570 FOR_INT32_INPUTS(j) {
1596 uint32_t expected = *i >> (*j & 0x1f); 1571 int32_t expected = *i >> (*j & 0x1f);
1597 CHECK_EQ(expected, bt.call(*i, *j)); 1572 CHECK_EQ(expected, bt.call(*i, *j));
1598 } 1573 }
1599 } 1574 }
1600 } 1575 }
1601 { 1576 {
1602 RawMachineAssemblerTester<int32_t> m; 1577 RawMachineAssemblerTester<int32_t> m;
1603 Int32BinopTester bt(&m); 1578 Int32BinopTester bt(&m);
1604 bt.AddReturn( 1579 bt.AddReturn(
1605 m.Word32Sar(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); 1580 m.Word32Sar(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1)));
1606 FOR_INT32_INPUTS(i) { 1581 FOR_INT32_INPUTS(i) {
1607 FOR_UINT32_INPUTS(j) { 1582 FOR_INT32_INPUTS(j) {
1608 uint32_t expected = *i >> (0x1f & *j); 1583 uint32_t expected = *i >> (0x1f & *j);
1609 CHECK_EQ(expected, bt.call(*i, *j)); 1584 CHECK_EQ(expected, bt.call(*i, *j));
1610 } 1585 }
1611 } 1586 }
1612 } 1587 }
1613 } 1588 }
1614 1589
1615 1590
1616 TEST(RunWord32AndImm) { 1591 TEST(RunWord32AndImm) {
1617 { 1592 {
1618 FOR_UINT32_INPUTS(i) { 1593 FOR_UINT32_INPUTS(i) {
1619 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1594 RawMachineAssemblerTester<uint32_t> m(mUint32);
1620 m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0))); 1595 m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0)));
1621 FOR_UINT32_INPUTS(j) { 1596 FOR_UINT32_INPUTS(j) {
1622 uint32_t expected = *i & *j; 1597 uint32_t expected = *i & *j;
1623 CHECK_EQ(expected, m.Call(*j)); 1598 CHECK_UINT32_EQ(expected, m.Call(*j));
1624 } 1599 }
1625 } 1600 }
1626 } 1601 }
1627 { 1602 {
1628 FOR_UINT32_INPUTS(i) { 1603 FOR_UINT32_INPUTS(i) {
1629 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1604 RawMachineAssemblerTester<uint32_t> m(mUint32);
1630 m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); 1605 m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
1631 FOR_UINT32_INPUTS(j) { 1606 FOR_UINT32_INPUTS(j) {
1632 uint32_t expected = *i & ~(*j); 1607 uint32_t expected = *i & ~(*j);
1633 CHECK_EQ(expected, m.Call(*j)); 1608 CHECK_UINT32_EQ(expected, m.Call(*j));
1634 } 1609 }
1635 } 1610 }
1636 } 1611 }
1637 } 1612 }
1638 1613
1639 1614
1640 TEST(RunWord32AndInBranch) { 1615 TEST(RunWord32AndInBranch) {
1641 static const int constant = 987654321; 1616 static const int constant = 987654321;
1642 { 1617 {
1643 RawMachineAssemblerTester<int32_t> m; 1618 RawMachineAssemblerTester<int32_t> m;
1644 Int32BinopTester bt(&m); 1619 Uint32BinopTester bt(&m);
1645 MLabel blocka, blockb; 1620 MLabel blocka, blockb;
1646 m.Branch( 1621 m.Branch(
1647 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), 1622 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)),
1648 &blocka, &blockb); 1623 &blocka, &blockb);
1649 m.Bind(&blocka); 1624 m.Bind(&blocka);
1650 bt.AddReturn(m.Int32Constant(constant)); 1625 bt.AddReturn(m.Int32Constant(constant));
1651 m.Bind(&blockb); 1626 m.Bind(&blockb);
1652 bt.AddReturn(m.Int32Constant(0 - constant)); 1627 bt.AddReturn(m.Int32Constant(0 - constant));
1653 FOR_UINT32_INPUTS(i) { 1628 FOR_UINT32_INPUTS(i) {
1654 FOR_UINT32_INPUTS(j) { 1629 FOR_UINT32_INPUTS(j) {
1655 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; 1630 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant;
1656 CHECK_EQ(expected, bt.call(*i, *j)); 1631 CHECK_EQ(expected, bt.call(*i, *j));
1657 } 1632 }
1658 } 1633 }
1659 } 1634 }
1660 { 1635 {
1661 RawMachineAssemblerTester<int32_t> m; 1636 RawMachineAssemblerTester<int32_t> m;
1662 Int32BinopTester bt(&m); 1637 Uint32BinopTester bt(&m);
1663 MLabel blocka, blockb; 1638 MLabel blocka, blockb;
1664 m.Branch( 1639 m.Branch(
1665 m.Word32NotEqual(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), 1640 m.Word32NotEqual(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)),
1666 &blocka, &blockb); 1641 &blocka, &blockb);
1667 m.Bind(&blocka); 1642 m.Bind(&blocka);
1668 bt.AddReturn(m.Int32Constant(constant)); 1643 bt.AddReturn(m.Int32Constant(constant));
1669 m.Bind(&blockb); 1644 m.Bind(&blockb);
1670 bt.AddReturn(m.Int32Constant(0 - constant)); 1645 bt.AddReturn(m.Int32Constant(0 - constant));
1671 FOR_UINT32_INPUTS(i) { 1646 FOR_UINT32_INPUTS(i) {
1672 FOR_UINT32_INPUTS(j) { 1647 FOR_UINT32_INPUTS(j) {
1673 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; 1648 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant;
1674 CHECK_EQ(expected, bt.call(*i, *j)); 1649 CHECK_EQ(expected, bt.call(*i, *j));
1675 } 1650 }
1676 } 1651 }
1677 } 1652 }
1678 { 1653 {
1679 FOR_UINT32_INPUTS(i) { 1654 FOR_UINT32_INPUTS(i) {
1680 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1655 RawMachineAssemblerTester<int32_t> m(mUint32);
1681 MLabel blocka, blockb; 1656 MLabel blocka, blockb;
1682 m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), 1657 m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)),
1683 m.Int32Constant(0)), 1658 m.Int32Constant(0)),
1684 &blocka, &blockb); 1659 &blocka, &blockb);
1685 m.Bind(&blocka); 1660 m.Bind(&blocka);
1686 m.Return(m.Int32Constant(constant)); 1661 m.Return(m.Int32Constant(constant));
1687 m.Bind(&blockb); 1662 m.Bind(&blockb);
1688 m.Return(m.Int32Constant(0 - constant)); 1663 m.Return(m.Int32Constant(0 - constant));
1689 FOR_UINT32_INPUTS(j) { 1664 FOR_UINT32_INPUTS(j) {
1690 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; 1665 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant;
1691 CHECK_EQ(expected, m.Call(*j)); 1666 CHECK_EQ(expected, m.Call(*j));
1692 } 1667 }
1693 } 1668 }
1694 } 1669 }
1695 { 1670 {
1696 FOR_UINT32_INPUTS(i) { 1671 FOR_UINT32_INPUTS(i) {
1697 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1672 RawMachineAssemblerTester<int32_t> m(mUint32);
1698 MLabel blocka, blockb; 1673 MLabel blocka, blockb;
1699 m.Branch( 1674 m.Branch(
1700 m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), 1675 m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)),
1701 m.Int32Constant(0)), 1676 m.Int32Constant(0)),
1702 &blocka, &blockb); 1677 &blocka, &blockb);
1703 m.Bind(&blocka); 1678 m.Bind(&blocka);
1704 m.Return(m.Int32Constant(constant)); 1679 m.Return(m.Int32Constant(constant));
1705 m.Bind(&blockb); 1680 m.Bind(&blockb);
1706 m.Return(m.Int32Constant(0 - constant)); 1681 m.Return(m.Int32Constant(0 - constant));
1707 FOR_UINT32_INPUTS(j) { 1682 FOR_UINT32_INPUTS(j) {
1708 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; 1683 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant;
1709 CHECK_EQ(expected, m.Call(*j)); 1684 CHECK_EQ(expected, m.Call(*j));
1710 } 1685 }
1711 } 1686 }
1712 } 1687 }
1713 { 1688 {
1714 RawMachineAssemblerTester<void> m; 1689 RawMachineAssemblerTester<void> m;
1715 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), 1690 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
1716 m.machine()->Word32Shr()}; 1691 m.machine()->Word32Shr()};
1717 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 1692 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
1718 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 1693 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
1719 kMachineWord32);
1720 MLabel blocka, blockb; 1694 MLabel blocka, blockb;
1721 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), 1695 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0),
1722 m.NewNode(shops[n], m.Parameter(1), 1696 m.NewNode(shops[n], m.Parameter(1),
1723 m.Parameter(2))), 1697 m.Parameter(2))),
1724 m.Int32Constant(0)), 1698 m.Int32Constant(0)),
1725 &blocka, &blockb); 1699 &blocka, &blockb);
1726 m.Bind(&blocka); 1700 m.Bind(&blocka);
1727 m.Return(m.Int32Constant(constant)); 1701 m.Return(m.Int32Constant(constant));
1728 m.Bind(&blockb); 1702 m.Bind(&blockb);
1729 m.Return(m.Int32Constant(0 - constant)); 1703 m.Return(m.Int32Constant(0 - constant));
(...skipping 20 matching lines...) Expand all
1750 } 1724 }
1751 } 1725 }
1752 } 1726 }
1753 } 1727 }
1754 } 1728 }
1755 1729
1756 1730
1757 TEST(RunWord32AndInComparison) { 1731 TEST(RunWord32AndInComparison) {
1758 { 1732 {
1759 RawMachineAssemblerTester<int32_t> m; 1733 RawMachineAssemblerTester<int32_t> m;
1760 Int32BinopTester bt(&m); 1734 Uint32BinopTester bt(&m);
1761 bt.AddReturn( 1735 bt.AddReturn(
1762 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0))); 1736 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)));
1763 FOR_UINT32_INPUTS(i) { 1737 FOR_UINT32_INPUTS(i) {
1764 FOR_UINT32_INPUTS(j) { 1738 FOR_UINT32_INPUTS(j) {
1765 int32_t expected = (*i & *j) == 0; 1739 uint32_t expected = (*i & *j) == 0;
1766 CHECK_EQ(expected, bt.call(*i, *j)); 1740 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1767 } 1741 }
1768 } 1742 }
1769 } 1743 }
1770 { 1744 {
1771 RawMachineAssemblerTester<int32_t> m; 1745 RawMachineAssemblerTester<int32_t> m;
1772 Int32BinopTester bt(&m); 1746 Uint32BinopTester bt(&m);
1773 bt.AddReturn( 1747 bt.AddReturn(
1774 m.Word32Equal(m.Int32Constant(0), m.Word32And(bt.param0, bt.param1))); 1748 m.Word32Equal(m.Int32Constant(0), m.Word32And(bt.param0, bt.param1)));
1775 FOR_UINT32_INPUTS(i) { 1749 FOR_UINT32_INPUTS(i) {
1776 FOR_UINT32_INPUTS(j) { 1750 FOR_UINT32_INPUTS(j) {
1777 int32_t expected = (*i & *j) == 0; 1751 uint32_t expected = (*i & *j) == 0;
1778 CHECK_EQ(expected, bt.call(*i, *j)); 1752 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1779 } 1753 }
1780 } 1754 }
1781 } 1755 }
1782 { 1756 {
1783 FOR_UINT32_INPUTS(i) { 1757 FOR_UINT32_INPUTS(i) {
1784 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1758 RawMachineAssemblerTester<uint32_t> m(mUint32);
1785 m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), 1759 m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)),
1786 m.Int32Constant(0))); 1760 m.Int32Constant(0)));
1787 FOR_UINT32_INPUTS(j) { 1761 FOR_UINT32_INPUTS(j) {
1788 int32_t expected = (*i & *j) == 0; 1762 uint32_t expected = (*i & *j) == 0;
1789 CHECK_EQ(expected, m.Call(*j)); 1763 CHECK_UINT32_EQ(expected, m.Call(*j));
1790 } 1764 }
1791 } 1765 }
1792 } 1766 }
1793 { 1767 {
1794 FOR_UINT32_INPUTS(i) { 1768 FOR_UINT32_INPUTS(i) {
1795 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1769 RawMachineAssemblerTester<uint32_t> m(mUint32);
1796 m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)), 1770 m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)),
1797 m.Int32Constant(0))); 1771 m.Int32Constant(0)));
1798 FOR_UINT32_INPUTS(j) { 1772 FOR_UINT32_INPUTS(j) {
1799 int32_t expected = (*j & *i) == 0; 1773 uint32_t expected = (*j & *i) == 0;
1800 CHECK_EQ(expected, m.Call(*j)); 1774 CHECK_UINT32_EQ(expected, m.Call(*j));
1801 } 1775 }
1802 } 1776 }
1803 } 1777 }
1804 } 1778 }
1805 1779
1806 1780
1807 TEST(RunWord32OrP) { 1781 TEST(RunWord32OrP) {
1808 { 1782 {
1809 RawMachineAssemblerTester<int32_t> m; 1783 RawMachineAssemblerTester<int32_t> m;
1810 Int32BinopTester bt(&m); 1784 Uint32BinopTester bt(&m);
1811 bt.AddReturn(m.Word32Or(bt.param0, bt.param1)); 1785 bt.AddReturn(m.Word32Or(bt.param0, bt.param1));
1812 FOR_UINT32_INPUTS(i) { 1786 FOR_UINT32_INPUTS(i) {
1813 FOR_UINT32_INPUTS(j) { 1787 FOR_UINT32_INPUTS(j) {
1814 uint32_t expected = *i | *j; 1788 uint32_t expected = *i | *j;
1815 CHECK_EQ(expected, bt.call(*i, *j)); 1789 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1816 } 1790 }
1817 } 1791 }
1818 } 1792 }
1819 { 1793 {
1820 RawMachineAssemblerTester<int32_t> m; 1794 RawMachineAssemblerTester<int32_t> m;
1821 Int32BinopTester bt(&m); 1795 Uint32BinopTester bt(&m);
1822 bt.AddReturn(m.Word32Or(bt.param0, m.Word32Not(bt.param1))); 1796 bt.AddReturn(m.Word32Or(bt.param0, m.Word32Not(bt.param1)));
1823 FOR_UINT32_INPUTS(i) { 1797 FOR_UINT32_INPUTS(i) {
1824 FOR_UINT32_INPUTS(j) { 1798 FOR_UINT32_INPUTS(j) {
1825 uint32_t expected = *i | ~(*j); 1799 uint32_t expected = *i | ~(*j);
1826 CHECK_EQ(expected, bt.call(*i, *j)); 1800 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1827 } 1801 }
1828 } 1802 }
1829 } 1803 }
1830 { 1804 {
1831 RawMachineAssemblerTester<int32_t> m; 1805 RawMachineAssemblerTester<int32_t> m;
1832 Int32BinopTester bt(&m); 1806 Uint32BinopTester bt(&m);
1833 bt.AddReturn(m.Word32Or(m.Word32Not(bt.param0), bt.param1)); 1807 bt.AddReturn(m.Word32Or(m.Word32Not(bt.param0), bt.param1));
1834 FOR_UINT32_INPUTS(i) { 1808 FOR_UINT32_INPUTS(i) {
1835 FOR_UINT32_INPUTS(j) { 1809 FOR_UINT32_INPUTS(j) {
1836 uint32_t expected = ~(*i) | *j; 1810 uint32_t expected = ~(*i) | *j;
1837 CHECK_EQ(expected, bt.call(*i, *j)); 1811 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
1838 } 1812 }
1839 } 1813 }
1840 } 1814 }
1841 } 1815 }
1842 1816
1843 1817
1844 TEST(RunWord32OrImm) { 1818 TEST(RunWord32OrImm) {
1845 { 1819 {
1846 FOR_UINT32_INPUTS(i) { 1820 FOR_UINT32_INPUTS(i) {
1847 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1821 RawMachineAssemblerTester<uint32_t> m(mUint32);
1848 m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0))); 1822 m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)));
1849 FOR_UINT32_INPUTS(j) { 1823 FOR_UINT32_INPUTS(j) {
1850 uint32_t expected = *i | *j; 1824 uint32_t expected = *i | *j;
1851 CHECK_EQ(expected, m.Call(*j)); 1825 CHECK_UINT32_EQ(expected, m.Call(*j));
1852 } 1826 }
1853 } 1827 }
1854 } 1828 }
1855 { 1829 {
1856 FOR_UINT32_INPUTS(i) { 1830 FOR_UINT32_INPUTS(i) {
1857 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1831 RawMachineAssemblerTester<uint32_t> m(mUint32);
1858 m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); 1832 m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
1859 FOR_UINT32_INPUTS(j) { 1833 FOR_UINT32_INPUTS(j) {
1860 uint32_t expected = *i | ~(*j); 1834 uint32_t expected = *i | ~(*j);
1861 CHECK_EQ(expected, m.Call(*j)); 1835 CHECK_UINT32_EQ(expected, m.Call(*j));
1862 } 1836 }
1863 } 1837 }
1864 } 1838 }
1865 } 1839 }
1866 1840
1867 1841
1868 TEST(RunWord32OrInBranch) { 1842 TEST(RunWord32OrInBranch) {
1869 static const int constant = 987654321; 1843 static const int constant = 987654321;
1870 { 1844 {
1871 RawMachineAssemblerTester<int32_t> m; 1845 RawMachineAssemblerTester<int32_t> m;
1872 Int32BinopTester bt(&m); 1846 Int32BinopTester bt(&m);
1873 MLabel blocka, blockb; 1847 MLabel blocka, blockb;
1874 m.Branch( 1848 m.Branch(
1875 m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)), 1849 m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)),
1876 &blocka, &blockb); 1850 &blocka, &blockb);
1877 m.Bind(&blocka); 1851 m.Bind(&blocka);
1878 bt.AddReturn(m.Int32Constant(constant)); 1852 bt.AddReturn(m.Int32Constant(constant));
1879 m.Bind(&blockb); 1853 m.Bind(&blockb);
1880 bt.AddReturn(m.Int32Constant(0 - constant)); 1854 bt.AddReturn(m.Int32Constant(0 - constant));
1881 FOR_UINT32_INPUTS(i) { 1855 FOR_INT32_INPUTS(i) {
1882 FOR_UINT32_INPUTS(j) { 1856 FOR_INT32_INPUTS(j) {
1883 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; 1857 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant;
1884 CHECK_EQ(expected, bt.call(*i, *j)); 1858 CHECK_EQ(expected, bt.call(*i, *j));
1885 } 1859 }
1886 } 1860 }
1887 } 1861 }
1888 { 1862 {
1889 RawMachineAssemblerTester<int32_t> m; 1863 RawMachineAssemblerTester<int32_t> m;
1890 Int32BinopTester bt(&m); 1864 Int32BinopTester bt(&m);
1891 MLabel blocka, blockb; 1865 MLabel blocka, blockb;
1892 m.Branch( 1866 m.Branch(
1893 m.Word32NotEqual(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)), 1867 m.Word32NotEqual(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)),
1894 &blocka, &blockb); 1868 &blocka, &blockb);
1895 m.Bind(&blocka); 1869 m.Bind(&blocka);
1896 bt.AddReturn(m.Int32Constant(constant)); 1870 bt.AddReturn(m.Int32Constant(constant));
1897 m.Bind(&blockb); 1871 m.Bind(&blockb);
1898 bt.AddReturn(m.Int32Constant(0 - constant)); 1872 bt.AddReturn(m.Int32Constant(0 - constant));
1899 FOR_UINT32_INPUTS(i) { 1873 FOR_INT32_INPUTS(i) {
1900 FOR_UINT32_INPUTS(j) { 1874 FOR_INT32_INPUTS(j) {
1901 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; 1875 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant;
1902 CHECK_EQ(expected, bt.call(*i, *j)); 1876 CHECK_EQ(expected, bt.call(*i, *j));
1903 } 1877 }
1904 } 1878 }
1905 } 1879 }
1906 { 1880 {
1907 FOR_UINT32_INPUTS(i) { 1881 FOR_INT32_INPUTS(i) {
1908 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1882 RawMachineAssemblerTester<int32_t> m(mInt32);
1909 MLabel blocka, blockb; 1883 MLabel blocka, blockb;
1910 m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), 1884 m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)),
1911 m.Int32Constant(0)), 1885 m.Int32Constant(0)),
1912 &blocka, &blockb); 1886 &blocka, &blockb);
1913 m.Bind(&blocka); 1887 m.Bind(&blocka);
1914 m.Return(m.Int32Constant(constant)); 1888 m.Return(m.Int32Constant(constant));
1915 m.Bind(&blockb); 1889 m.Bind(&blockb);
1916 m.Return(m.Int32Constant(0 - constant)); 1890 m.Return(m.Int32Constant(0 - constant));
1917 FOR_UINT32_INPUTS(j) { 1891 FOR_INT32_INPUTS(j) {
1918 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; 1892 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant;
1919 CHECK_EQ(expected, m.Call(*j)); 1893 CHECK_EQ(expected, m.Call(*j));
1920 } 1894 }
1921 } 1895 }
1922 } 1896 }
1923 { 1897 {
1924 FOR_UINT32_INPUTS(i) { 1898 FOR_INT32_INPUTS(i) {
1925 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1899 RawMachineAssemblerTester<int32_t> m(mInt32);
1926 MLabel blocka, blockb; 1900 MLabel blocka, blockb;
1927 m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), 1901 m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)),
1928 m.Int32Constant(0)), 1902 m.Int32Constant(0)),
1929 &blocka, &blockb); 1903 &blocka, &blockb);
1930 m.Bind(&blocka); 1904 m.Bind(&blocka);
1931 m.Return(m.Int32Constant(constant)); 1905 m.Return(m.Int32Constant(constant));
1932 m.Bind(&blockb); 1906 m.Bind(&blockb);
1933 m.Return(m.Int32Constant(0 - constant)); 1907 m.Return(m.Int32Constant(0 - constant));
1934 FOR_UINT32_INPUTS(j) { 1908 FOR_INT32_INPUTS(j) {
1935 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; 1909 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant;
1936 CHECK_EQ(expected, m.Call(*j)); 1910 CHECK_EQ(expected, m.Call(*j));
1937 } 1911 }
1938 } 1912 }
1939 } 1913 }
1940 { 1914 {
1941 RawMachineAssemblerTester<void> m; 1915 RawMachineAssemblerTester<void> m;
1942 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), 1916 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
1943 m.machine()->Word32Shr()}; 1917 m.machine()->Word32Shr()};
1944 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 1918 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
1945 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 1919 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
1946 kMachineWord32);
1947 MLabel blocka, blockb; 1920 MLabel blocka, blockb;
1948 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), 1921 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0),
1949 m.NewNode(shops[n], m.Parameter(1), 1922 m.NewNode(shops[n], m.Parameter(1),
1950 m.Parameter(2))), 1923 m.Parameter(2))),
1951 m.Int32Constant(0)), 1924 m.Int32Constant(0)),
1952 &blocka, &blockb); 1925 &blocka, &blockb);
1953 m.Bind(&blocka); 1926 m.Bind(&blocka);
1954 m.Return(m.Int32Constant(constant)); 1927 m.Return(m.Int32Constant(constant));
1955 m.Bind(&blockb); 1928 m.Bind(&blockb);
1956 m.Return(m.Int32Constant(0 - constant)); 1929 m.Return(m.Int32Constant(0 - constant));
(...skipping 20 matching lines...) Expand all
1977 } 1950 }
1978 } 1951 }
1979 } 1952 }
1980 } 1953 }
1981 } 1954 }
1982 1955
1983 1956
1984 TEST(RunWord32OrInComparison) { 1957 TEST(RunWord32OrInComparison) {
1985 { 1958 {
1986 RawMachineAssemblerTester<int32_t> m; 1959 RawMachineAssemblerTester<int32_t> m;
1987 Int32BinopTester bt(&m); 1960 Uint32BinopTester bt(&m);
1988 bt.AddReturn( 1961 bt.AddReturn(
1989 m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0))); 1962 m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)));
1990 FOR_UINT32_INPUTS(i) { 1963 FOR_UINT32_INPUTS(i) {
1991 FOR_UINT32_INPUTS(j) { 1964 FOR_UINT32_INPUTS(j) {
1992 int32_t expected = (*i | *j) == 0; 1965 int32_t expected = (*i | *j) == 0;
1993 CHECK_EQ(expected, bt.call(*i, *j)); 1966 CHECK_EQ(expected, bt.call(*i, *j));
1994 } 1967 }
1995 } 1968 }
1996 } 1969 }
1997 { 1970 {
1998 RawMachineAssemblerTester<int32_t> m; 1971 RawMachineAssemblerTester<int32_t> m;
1999 Int32BinopTester bt(&m); 1972 Uint32BinopTester bt(&m);
2000 bt.AddReturn( 1973 bt.AddReturn(
2001 m.Word32Equal(m.Int32Constant(0), m.Word32Or(bt.param0, bt.param1))); 1974 m.Word32Equal(m.Int32Constant(0), m.Word32Or(bt.param0, bt.param1)));
2002 FOR_UINT32_INPUTS(i) { 1975 FOR_UINT32_INPUTS(i) {
2003 FOR_UINT32_INPUTS(j) { 1976 FOR_UINT32_INPUTS(j) {
2004 int32_t expected = (*i | *j) == 0; 1977 int32_t expected = (*i | *j) == 0;
2005 CHECK_EQ(expected, bt.call(*i, *j)); 1978 CHECK_EQ(expected, bt.call(*i, *j));
2006 } 1979 }
2007 } 1980 }
2008 } 1981 }
2009 { 1982 {
2010 FOR_UINT32_INPUTS(i) { 1983 FOR_UINT32_INPUTS(i) {
2011 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1984 RawMachineAssemblerTester<uint32_t> m(mUint32);
2012 m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), 1985 m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)),
2013 m.Int32Constant(0))); 1986 m.Int32Constant(0)));
2014 FOR_UINT32_INPUTS(j) { 1987 FOR_UINT32_INPUTS(j) {
2015 int32_t expected = (*i | *j) == 0; 1988 uint32_t expected = (*i | *j) == 0;
2016 CHECK_EQ(expected, m.Call(*j)); 1989 CHECK_UINT32_EQ(expected, m.Call(*j));
2017 } 1990 }
2018 } 1991 }
2019 } 1992 }
2020 { 1993 {
2021 FOR_UINT32_INPUTS(i) { 1994 FOR_UINT32_INPUTS(i) {
2022 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 1995 RawMachineAssemblerTester<uint32_t> m(mUint32);
2023 m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)), 1996 m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)),
2024 m.Int32Constant(0))); 1997 m.Int32Constant(0)));
2025 FOR_UINT32_INPUTS(j) { 1998 FOR_UINT32_INPUTS(j) {
2026 int32_t expected = (*j | *i) == 0; 1999 uint32_t expected = (*j | *i) == 0;
2027 CHECK_EQ(expected, m.Call(*j)); 2000 CHECK_UINT32_EQ(expected, m.Call(*j));
2028 } 2001 }
2029 } 2002 }
2030 } 2003 }
2031 } 2004 }
2032 2005
2033 2006
2034 TEST(RunWord32XorP) { 2007 TEST(RunWord32XorP) {
2035 { 2008 {
2036 FOR_UINT32_INPUTS(i) { 2009 FOR_UINT32_INPUTS(i) {
2037 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2010 RawMachineAssemblerTester<int32_t> m(mUint32);
2038 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0))); 2011 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)));
2039 FOR_UINT32_INPUTS(j) { 2012 FOR_UINT32_INPUTS(j) {
2040 uint32_t expected = *i ^ *j; 2013 uint32_t expected = *i ^ *j;
2041 CHECK_EQ(expected, m.Call(*j)); 2014 CHECK_UINT32_EQ(expected, m.Call(*j));
2042 } 2015 }
2043 } 2016 }
2044 } 2017 }
2045 { 2018 {
2046 RawMachineAssemblerTester<int32_t> m; 2019 RawMachineAssemblerTester<int32_t> m;
2047 Int32BinopTester bt(&m); 2020 Uint32BinopTester bt(&m);
2048 bt.AddReturn(m.Word32Xor(bt.param0, bt.param1)); 2021 bt.AddReturn(m.Word32Xor(bt.param0, bt.param1));
2049 FOR_UINT32_INPUTS(i) { 2022 FOR_UINT32_INPUTS(i) {
2050 FOR_UINT32_INPUTS(j) { 2023 FOR_UINT32_INPUTS(j) {
2051 uint32_t expected = *i ^ *j; 2024 int32_t expected = *i ^ *j;
2052 CHECK_EQ(expected, bt.call(*i, *j)); 2025 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
2053 } 2026 }
2054 } 2027 }
2055 } 2028 }
2056 { 2029 {
2057 RawMachineAssemblerTester<int32_t> m; 2030 RawMachineAssemblerTester<int32_t> m;
2058 Int32BinopTester bt(&m); 2031 Int32BinopTester bt(&m);
2059 bt.AddReturn(m.Word32Xor(bt.param0, m.Word32Not(bt.param1))); 2032 bt.AddReturn(m.Word32Xor(bt.param0, m.Word32Not(bt.param1)));
2060 FOR_UINT32_INPUTS(i) { 2033 FOR_INT32_INPUTS(i) {
2061 FOR_UINT32_INPUTS(j) { 2034 FOR_INT32_INPUTS(j) {
2062 uint32_t expected = *i ^ ~(*j); 2035 int32_t expected = *i ^ ~(*j);
2063 CHECK_EQ(expected, bt.call(*i, *j)); 2036 CHECK_EQ(expected, bt.call(*i, *j));
2064 } 2037 }
2065 } 2038 }
2066 } 2039 }
2067 { 2040 {
2068 RawMachineAssemblerTester<int32_t> m; 2041 RawMachineAssemblerTester<int32_t> m;
2069 Int32BinopTester bt(&m); 2042 Int32BinopTester bt(&m);
2070 bt.AddReturn(m.Word32Xor(m.Word32Not(bt.param0), bt.param1)); 2043 bt.AddReturn(m.Word32Xor(m.Word32Not(bt.param0), bt.param1));
2071 FOR_UINT32_INPUTS(i) { 2044 FOR_INT32_INPUTS(i) {
2072 FOR_UINT32_INPUTS(j) { 2045 FOR_INT32_INPUTS(j) {
2073 uint32_t expected = ~(*i) ^ *j; 2046 int32_t expected = ~(*i) ^ *j;
2074 CHECK_EQ(expected, bt.call(*i, *j)); 2047 CHECK_EQ(expected, bt.call(*i, *j));
2075 } 2048 }
2076 } 2049 }
2077 } 2050 }
2078 { 2051 {
2079 FOR_UINT32_INPUTS(i) { 2052 FOR_UINT32_INPUTS(i) {
2080 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2053 RawMachineAssemblerTester<uint32_t> m(mUint32);
2081 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); 2054 m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0))));
2082 FOR_UINT32_INPUTS(j) { 2055 FOR_UINT32_INPUTS(j) {
2083 uint32_t expected = *i ^ ~(*j); 2056 uint32_t expected = *i ^ ~(*j);
2084 CHECK_EQ(expected, m.Call(*j)); 2057 CHECK_UINT32_EQ(expected, m.Call(*j));
2085 } 2058 }
2086 } 2059 }
2087 } 2060 }
2088 } 2061 }
2089 2062
2090 2063
2091 TEST(RunWord32XorInBranch) { 2064 TEST(RunWord32XorInBranch) {
2092 static const int constant = 987654321; 2065 static const uint32_t constant = 987654321;
2093 { 2066 {
2094 RawMachineAssemblerTester<int32_t> m; 2067 RawMachineAssemblerTester<int32_t> m;
2095 Int32BinopTester bt(&m); 2068 Uint32BinopTester bt(&m);
2096 MLabel blocka, blockb; 2069 MLabel blocka, blockb;
2097 m.Branch( 2070 m.Branch(
2098 m.Word32Equal(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), 2071 m.Word32Equal(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)),
2099 &blocka, &blockb); 2072 &blocka, &blockb);
2100 m.Bind(&blocka); 2073 m.Bind(&blocka);
2101 bt.AddReturn(m.Int32Constant(constant)); 2074 bt.AddReturn(m.Int32Constant(constant));
2102 m.Bind(&blockb); 2075 m.Bind(&blockb);
2103 bt.AddReturn(m.Int32Constant(0 - constant)); 2076 bt.AddReturn(m.Int32Constant(0 - constant));
2104 FOR_UINT32_INPUTS(i) { 2077 FOR_UINT32_INPUTS(i) {
2105 FOR_UINT32_INPUTS(j) { 2078 FOR_UINT32_INPUTS(j) {
2106 int32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; 2079 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant;
2107 CHECK_EQ(expected, bt.call(*i, *j)); 2080 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
2108 } 2081 }
2109 } 2082 }
2110 } 2083 }
2111 { 2084 {
2112 RawMachineAssemblerTester<int32_t> m; 2085 RawMachineAssemblerTester<int32_t> m;
2113 Int32BinopTester bt(&m); 2086 Uint32BinopTester bt(&m);
2114 MLabel blocka, blockb; 2087 MLabel blocka, blockb;
2115 m.Branch( 2088 m.Branch(
2116 m.Word32NotEqual(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), 2089 m.Word32NotEqual(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)),
2117 &blocka, &blockb); 2090 &blocka, &blockb);
2118 m.Bind(&blocka); 2091 m.Bind(&blocka);
2119 bt.AddReturn(m.Int32Constant(constant)); 2092 bt.AddReturn(m.Int32Constant(constant));
2120 m.Bind(&blockb); 2093 m.Bind(&blockb);
2121 bt.AddReturn(m.Int32Constant(0 - constant)); 2094 bt.AddReturn(m.Int32Constant(0 - constant));
2122 FOR_UINT32_INPUTS(i) { 2095 FOR_UINT32_INPUTS(i) {
2123 FOR_UINT32_INPUTS(j) { 2096 FOR_UINT32_INPUTS(j) {
2124 int32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; 2097 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant;
2125 CHECK_EQ(expected, bt.call(*i, *j)); 2098 CHECK_UINT32_EQ(expected, bt.call(*i, *j));
2126 } 2099 }
2127 } 2100 }
2128 } 2101 }
2129 { 2102 {
2130 FOR_UINT32_INPUTS(i) { 2103 FOR_UINT32_INPUTS(i) {
2131 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2104 RawMachineAssemblerTester<uint32_t> m(mUint32);
2132 MLabel blocka, blockb; 2105 MLabel blocka, blockb;
2133 m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), 2106 m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)),
2134 m.Int32Constant(0)), 2107 m.Int32Constant(0)),
2135 &blocka, &blockb); 2108 &blocka, &blockb);
2136 m.Bind(&blocka); 2109 m.Bind(&blocka);
2137 m.Return(m.Int32Constant(constant)); 2110 m.Return(m.Int32Constant(constant));
2138 m.Bind(&blockb); 2111 m.Bind(&blockb);
2139 m.Return(m.Int32Constant(0 - constant)); 2112 m.Return(m.Int32Constant(0 - constant));
2140 FOR_UINT32_INPUTS(j) { 2113 FOR_UINT32_INPUTS(j) {
2141 int32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; 2114 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant;
2142 CHECK_EQ(expected, m.Call(*j)); 2115 CHECK_UINT32_EQ(expected, m.Call(*j));
2143 } 2116 }
2144 } 2117 }
2145 } 2118 }
2146 { 2119 {
2147 FOR_UINT32_INPUTS(i) { 2120 FOR_UINT32_INPUTS(i) {
2148 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2121 RawMachineAssemblerTester<uint32_t> m(mUint32);
2149 MLabel blocka, blockb; 2122 MLabel blocka, blockb;
2150 m.Branch( 2123 m.Branch(
2151 m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), 2124 m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)),
2152 m.Int32Constant(0)), 2125 m.Int32Constant(0)),
2153 &blocka, &blockb); 2126 &blocka, &blockb);
2154 m.Bind(&blocka); 2127 m.Bind(&blocka);
2155 m.Return(m.Int32Constant(constant)); 2128 m.Return(m.Int32Constant(constant));
2156 m.Bind(&blockb); 2129 m.Bind(&blockb);
2157 m.Return(m.Int32Constant(0 - constant)); 2130 m.Return(m.Int32Constant(0 - constant));
2158 FOR_UINT32_INPUTS(j) { 2131 FOR_UINT32_INPUTS(j) {
2159 int32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; 2132 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant;
2160 CHECK_EQ(expected, m.Call(*j)); 2133 CHECK_UINT32_EQ(expected, m.Call(*j));
2161 } 2134 }
2162 } 2135 }
2163 } 2136 }
2164 { 2137 {
2165 RawMachineAssemblerTester<void> m; 2138 RawMachineAssemblerTester<void> m;
2166 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), 2139 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(),
2167 m.machine()->Word32Shr()}; 2140 m.machine()->Word32Shr()};
2168 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { 2141 for (size_t n = 0; n < ARRAY_SIZE(shops); n++) {
2169 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2142 RawMachineAssemblerTester<int32_t> m(mUint32, mInt32, mUint32);
2170 kMachineWord32);
2171 MLabel blocka, blockb; 2143 MLabel blocka, blockb;
2172 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), 2144 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0),
2173 m.NewNode(shops[n], m.Parameter(1), 2145 m.NewNode(shops[n], m.Parameter(1),
2174 m.Parameter(2))), 2146 m.Parameter(2))),
2175 m.Int32Constant(0)), 2147 m.Int32Constant(0)),
2176 &blocka, &blockb); 2148 &blocka, &blockb);
2177 m.Bind(&blocka); 2149 m.Bind(&blocka);
2178 m.Return(m.Int32Constant(constant)); 2150 m.Return(m.Int32Constant(constant));
2179 m.Bind(&blockb); 2151 m.Bind(&blockb);
2180 m.Return(m.Int32Constant(0 - constant)); 2152 m.Return(m.Int32Constant(0 - constant));
(...skipping 20 matching lines...) Expand all
2201 } 2173 }
2202 } 2174 }
2203 } 2175 }
2204 } 2176 }
2205 } 2177 }
2206 2178
2207 2179
2208 TEST(RunWord32ShlP) { 2180 TEST(RunWord32ShlP) {
2209 { 2181 {
2210 FOR_UINT32_SHIFTS(shift) { 2182 FOR_UINT32_SHIFTS(shift) {
2211 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2183 RawMachineAssemblerTester<uint32_t> m(mUint32);
2212 m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))); 2184 m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)));
2213 FOR_UINT32_INPUTS(j) { 2185 FOR_UINT32_INPUTS(j) {
2214 uint32_t expected = *j << shift; 2186 uint32_t expected = *j << shift;
2215 CHECK_EQ(expected, m.Call(*j)); 2187 CHECK_UINT32_EQ(expected, m.Call(*j));
2216 } 2188 }
2217 } 2189 }
2218 } 2190 }
2219 { 2191 {
2220 RawMachineAssemblerTester<int32_t> m; 2192 RawMachineAssemblerTester<int32_t> m;
2221 Int32BinopTester bt(&m); 2193 Uint32BinopTester bt(&m);
2222 bt.AddReturn(m.Word32Shl(bt.param0, bt.param1)); 2194 bt.AddReturn(m.Word32Shl(bt.param0, bt.param1));
2223 FOR_UINT32_INPUTS(i) { 2195 FOR_UINT32_INPUTS(i) {
2224 FOR_UINT32_SHIFTS(shift) { 2196 FOR_UINT32_SHIFTS(shift) {
2225 uint32_t expected = *i << shift; 2197 uint32_t expected = *i << shift;
2226 CHECK_EQ(expected, bt.call(*i, shift)); 2198 CHECK_UINT32_EQ(expected, bt.call(*i, shift));
2227 } 2199 }
2228 } 2200 }
2229 } 2201 }
2230 } 2202 }
2231 2203
2232 2204
2233 TEST(RunWord32ShrP) { 2205 TEST(RunWord32ShrP) {
2234 { 2206 {
2235 FOR_UINT32_SHIFTS(shift) { 2207 FOR_UINT32_SHIFTS(shift) {
2236 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2208 RawMachineAssemblerTester<uint32_t> m(mUint32);
2237 m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))); 2209 m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)));
2238 FOR_UINT32_INPUTS(j) { 2210 FOR_UINT32_INPUTS(j) {
2239 uint32_t expected = *j >> shift; 2211 uint32_t expected = *j >> shift;
2240 CHECK_EQ(expected, m.Call(*j)); 2212 CHECK_UINT32_EQ(expected, m.Call(*j));
2241 } 2213 }
2242 } 2214 }
2243 } 2215 }
2244 { 2216 {
2245 RawMachineAssemblerTester<int32_t> m; 2217 RawMachineAssemblerTester<int32_t> m;
2246 Int32BinopTester bt(&m); 2218 Uint32BinopTester bt(&m);
2247 bt.AddReturn(m.Word32Shr(bt.param0, bt.param1)); 2219 bt.AddReturn(m.Word32Shr(bt.param0, bt.param1));
2248 FOR_UINT32_INPUTS(i) { 2220 FOR_UINT32_INPUTS(i) {
2249 FOR_UINT32_SHIFTS(shift) { 2221 FOR_UINT32_SHIFTS(shift) {
2250 uint32_t expected = *i >> shift; 2222 uint32_t expected = *i >> shift;
2251 CHECK_EQ(expected, bt.call(*i, shift)); 2223 CHECK_UINT32_EQ(expected, bt.call(*i, shift));
2252 } 2224 }
2253 } 2225 }
2254 CHECK_EQ(0x00010000, bt.call(0x80000000, 15)); 2226 CHECK_EQ(0x00010000, bt.call(0x80000000, 15));
2255 } 2227 }
2256 } 2228 }
2257 2229
2258 2230
2259 TEST(RunWord32SarP) { 2231 TEST(RunWord32SarP) {
2260 { 2232 {
2261 FOR_INT32_SHIFTS(shift) { 2233 FOR_INT32_SHIFTS(shift) {
2262 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2234 RawMachineAssemblerTester<int32_t> m(mInt32);
2263 m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))); 2235 m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)));
2264 FOR_INT32_INPUTS(j) { 2236 FOR_INT32_INPUTS(j) {
2265 int32_t expected = *j >> shift; 2237 int32_t expected = *j >> shift;
2266 CHECK_EQ(expected, m.Call(*j)); 2238 CHECK_EQ(expected, m.Call(*j));
2267 } 2239 }
2268 } 2240 }
2269 } 2241 }
2270 { 2242 {
2271 RawMachineAssemblerTester<int32_t> m; 2243 RawMachineAssemblerTester<int32_t> m;
2272 Int32BinopTester bt(&m); 2244 Int32BinopTester bt(&m);
2273 bt.AddReturn(m.Word32Sar(bt.param0, bt.param1)); 2245 bt.AddReturn(m.Word32Sar(bt.param0, bt.param1));
2274 FOR_INT32_INPUTS(i) { 2246 FOR_INT32_INPUTS(i) {
2275 FOR_INT32_SHIFTS(shift) { 2247 FOR_INT32_SHIFTS(shift) {
2276 int32_t expected = *i >> shift; 2248 int32_t expected = *i >> shift;
2277 CHECK_EQ(expected, bt.call(*i, shift)); 2249 CHECK_EQ(expected, bt.call(*i, shift));
2278 } 2250 }
2279 } 2251 }
2280 CHECK_EQ(0xFFFF0000, bt.call(0x80000000, 15)); 2252 CHECK_EQ(0xFFFF0000, bt.call(0x80000000, 15));
2281 } 2253 }
2282 } 2254 }
2283 2255
2284 2256
2285 TEST(RunWord32NotP) { 2257 TEST(RunWord32NotP) {
2286 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2258 RawMachineAssemblerTester<int32_t> m(mInt32);
2287 m.Return(m.Word32Not(m.Parameter(0))); 2259 m.Return(m.Word32Not(m.Parameter(0)));
2288 FOR_UINT32_INPUTS(i) { 2260 FOR_INT32_INPUTS(i) {
2289 int expected = ~(*i); 2261 int expected = ~(*i);
2290 CHECK_EQ(expected, m.Call(*i)); 2262 CHECK_EQ(expected, m.Call(*i));
2291 } 2263 }
2292 } 2264 }
2293 2265
2294 2266
2295 TEST(RunInt32NegP) { 2267 TEST(RunInt32NegP) {
2296 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2268 RawMachineAssemblerTester<int32_t> m(mInt32);
2297 m.Return(m.Int32Neg(m.Parameter(0))); 2269 m.Return(m.Int32Neg(m.Parameter(0)));
2298 FOR_INT32_INPUTS(i) { 2270 FOR_INT32_INPUTS(i) {
2299 int expected = -*i; 2271 int expected = -*i;
2300 CHECK_EQ(expected, m.Call(*i)); 2272 CHECK_EQ(expected, m.Call(*i));
2301 } 2273 }
2302 } 2274 }
2303 2275
2304 2276
2305 TEST(RunWord32EqualAndWord32SarP) { 2277 TEST(RunWord32EqualAndWord32SarP) {
2306 { 2278 {
2307 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2279 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32, mUint32);
2308 kMachineWord32);
2309 m.Return(m.Word32Equal(m.Parameter(0), 2280 m.Return(m.Word32Equal(m.Parameter(0),
2310 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 2281 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
2311 FOR_INT32_INPUTS(i) { 2282 FOR_INT32_INPUTS(i) {
2312 FOR_INT32_INPUTS(j) { 2283 FOR_INT32_INPUTS(j) {
2313 FOR_UINT32_SHIFTS(shift) { 2284 FOR_UINT32_SHIFTS(shift) {
2314 int32_t expected = (*i == (*j >> shift)); 2285 int32_t expected = (*i == (*j >> shift));
2315 CHECK_EQ(expected, m.Call(*i, *j, shift)); 2286 CHECK_EQ(expected, m.Call(*i, *j, shift));
2316 } 2287 }
2317 } 2288 }
2318 } 2289 }
2319 } 2290 }
2320 { 2291 {
2321 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2292 RawMachineAssemblerTester<int32_t> m(mInt32, mUint32, mInt32);
2322 kMachineWord32);
2323 m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)), 2293 m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)),
2324 m.Parameter(2))); 2294 m.Parameter(2)));
2325 FOR_INT32_INPUTS(i) { 2295 FOR_INT32_INPUTS(i) {
2326 FOR_UINT32_SHIFTS(shift) { 2296 FOR_UINT32_SHIFTS(shift) {
2327 FOR_INT32_INPUTS(k) { 2297 FOR_INT32_INPUTS(k) {
2328 int32_t expected = ((*i >> shift) == *k); 2298 int32_t expected = ((*i >> shift) == *k);
2329 CHECK_EQ(expected, m.Call(*i, shift, *k)); 2299 CHECK_EQ(expected, m.Call(*i, shift, *k));
2330 } 2300 }
2331 } 2301 }
2332 } 2302 }
2333 } 2303 }
2334 } 2304 }
2335 2305
2336 2306
2337 TEST(RunWord32EqualAndWord32ShlP) { 2307 TEST(RunWord32EqualAndWord32ShlP) {
2338 { 2308 {
2339 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2309 RawMachineAssemblerTester<int32_t> m(mUint32, mUint32, mUint32);
2340 kMachineWord32);
2341 m.Return(m.Word32Equal(m.Parameter(0), 2310 m.Return(m.Word32Equal(m.Parameter(0),
2342 m.Word32Shl(m.Parameter(1), m.Parameter(2)))); 2311 m.Word32Shl(m.Parameter(1), m.Parameter(2))));
2343 FOR_UINT32_INPUTS(i) { 2312 FOR_UINT32_INPUTS(i) {
2344 FOR_UINT32_INPUTS(j) { 2313 FOR_UINT32_INPUTS(j) {
2345 FOR_UINT32_SHIFTS(shift) { 2314 FOR_UINT32_SHIFTS(shift) {
2346 int32_t expected = (*i == (*j << shift)); 2315 int32_t expected = (*i == (*j << shift));
2347 CHECK_EQ(expected, m.Call(*i, *j, shift)); 2316 CHECK_EQ(expected, m.Call(*i, *j, shift));
2348 } 2317 }
2349 } 2318 }
2350 } 2319 }
2351 } 2320 }
2352 { 2321 {
2353 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2322 RawMachineAssemblerTester<int32_t> m(mUint32, mUint32, mUint32);
2354 kMachineWord32);
2355 m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)), 2323 m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)),
2356 m.Parameter(2))); 2324 m.Parameter(2)));
2357 FOR_UINT32_INPUTS(i) { 2325 FOR_UINT32_INPUTS(i) {
2358 FOR_UINT32_SHIFTS(shift) { 2326 FOR_UINT32_SHIFTS(shift) {
2359 FOR_UINT32_INPUTS(k) { 2327 FOR_UINT32_INPUTS(k) {
2360 int32_t expected = ((*i << shift) == *k); 2328 int32_t expected = ((*i << shift) == *k);
2361 CHECK_EQ(expected, m.Call(*i, shift, *k)); 2329 CHECK_EQ(expected, m.Call(*i, shift, *k));
2362 } 2330 }
2363 } 2331 }
2364 } 2332 }
2365 } 2333 }
2366 } 2334 }
2367 2335
2368 2336
2369 TEST(RunWord32EqualAndWord32ShrP) { 2337 TEST(RunWord32EqualAndWord32ShrP) {
2370 { 2338 {
2371 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2339 RawMachineAssemblerTester<int32_t> m(mUint32, mUint32, mUint32);
2372 kMachineWord32);
2373 m.Return(m.Word32Equal(m.Parameter(0), 2340 m.Return(m.Word32Equal(m.Parameter(0),
2374 m.Word32Shr(m.Parameter(1), m.Parameter(2)))); 2341 m.Word32Shr(m.Parameter(1), m.Parameter(2))));
2375 FOR_UINT32_INPUTS(i) { 2342 FOR_UINT32_INPUTS(i) {
2376 FOR_UINT32_INPUTS(j) { 2343 FOR_UINT32_INPUTS(j) {
2377 FOR_UINT32_SHIFTS(shift) { 2344 FOR_UINT32_SHIFTS(shift) {
2378 int32_t expected = (*i == (*j >> shift)); 2345 int32_t expected = (*i == (*j >> shift));
2379 CHECK_EQ(expected, m.Call(*i, *j, shift)); 2346 CHECK_EQ(expected, m.Call(*i, *j, shift));
2380 } 2347 }
2381 } 2348 }
2382 } 2349 }
2383 } 2350 }
2384 { 2351 {
2385 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, 2352 RawMachineAssemblerTester<int32_t> m(mUint32, mUint32, mUint32);
2386 kMachineWord32);
2387 m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)), 2353 m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)),
2388 m.Parameter(2))); 2354 m.Parameter(2)));
2389 FOR_UINT32_INPUTS(i) { 2355 FOR_UINT32_INPUTS(i) {
2390 FOR_UINT32_SHIFTS(shift) { 2356 FOR_UINT32_SHIFTS(shift) {
2391 FOR_UINT32_INPUTS(k) { 2357 FOR_UINT32_INPUTS(k) {
2392 int32_t expected = ((*i >> shift) == *k); 2358 int32_t expected = ((*i >> shift) == *k);
2393 CHECK_EQ(expected, m.Call(*i, shift, *k)); 2359 CHECK_EQ(expected, m.Call(*i, shift, *k));
2394 } 2360 }
2395 } 2361 }
2396 } 2362 }
2397 } 2363 }
2398 } 2364 }
2399 2365
2400 2366
2401 TEST(RunDeadNodes) { 2367 TEST(RunDeadNodes) {
2402 for (int i = 0; true; i++) { 2368 for (int i = 0; true; i++) {
2403 RawMachineAssemblerTester<int32_t> m(i == 5 ? kMachineWord32 2369 RawMachineAssemblerTester<int32_t> m(i == 5 ? mInt32 : mNone);
2404 : kMachineLast);
2405 int constant = 0x55 + i; 2370 int constant = 0x55 + i;
2406 switch (i) { 2371 switch (i) {
2407 case 0: 2372 case 0:
2408 m.Int32Constant(44); 2373 m.Int32Constant(44);
2409 break; 2374 break;
2410 case 1: 2375 case 1:
2411 m.StringConstant("unused"); 2376 m.StringConstant("unused");
2412 break; 2377 break;
2413 case 2: 2378 case 2:
2414 m.NumberConstant(11.1); 2379 m.NumberConstant(11.1);
2415 break; 2380 break;
2416 case 3: 2381 case 3:
2417 m.PointerConstant(&constant); 2382 m.PointerConstant(&constant);
2418 break; 2383 break;
2419 case 4: 2384 case 4:
2420 m.LoadFromPointer(&constant, kMachineWord32); 2385 m.LoadFromPointer(&constant, mInt32);
2421 break; 2386 break;
2422 case 5: 2387 case 5:
2423 m.Parameter(0); 2388 m.Parameter(0);
2424 break; 2389 break;
2425 default: 2390 default:
2426 return; 2391 return;
2427 } 2392 }
2428 m.Return(m.Int32Constant(constant)); 2393 m.Return(m.Int32Constant(constant));
2429 if (i != 5) { 2394 if (i != 5) {
2430 CHECK_EQ(constant, m.Call()); 2395 CHECK_EQ(constant, m.Call());
(...skipping 13 matching lines...) Expand all
2444 m.machine()->Word32Shr(), m.machine()->Word32Sar(), 2409 m.machine()->Word32Shr(), m.machine()->Word32Sar(),
2445 m.machine()->Word32Equal(), m.machine()->Int32Add(), 2410 m.machine()->Word32Equal(), m.machine()->Int32Add(),
2446 m.machine()->Int32Sub(), m.machine()->Int32Mul(), 2411 m.machine()->Int32Sub(), m.machine()->Int32Mul(),
2447 m.machine()->Int32Div(), m.machine()->Int32UDiv(), 2412 m.machine()->Int32Div(), m.machine()->Int32UDiv(),
2448 m.machine()->Int32Mod(), m.machine()->Int32UMod(), 2413 m.machine()->Int32Mod(), m.machine()->Int32UMod(),
2449 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), 2414 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(),
2450 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual(), 2415 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual(),
2451 NULL}; 2416 NULL};
2452 2417
2453 for (int i = 0; ops[i] != NULL; i++) { 2418 for (int i = 0; ops[i] != NULL; i++) {
2454 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); 2419 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32);
2455 int constant = 0x55555 + i; 2420 int constant = 0x55555 + i;
2456 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1)); 2421 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1));
2457 m.Return(m.Int32Constant(constant)); 2422 m.Return(m.Int32Constant(constant));
2458 2423
2459 CHECK_EQ(constant, m.Call(1, 1)); 2424 CHECK_EQ(constant, m.Call(1, 1));
2460 } 2425 }
2461 } 2426 }
2462 2427
2463 2428
2464 template <typename Type, typename CType> 2429 template <typename Type, typename CType>
(...skipping 18 matching lines...) Expand all
2483 Type expected = buffer[i]; 2448 Type expected = buffer[i];
2484 Type actual = static_cast<CType>(m.Call()); 2449 Type actual = static_cast<CType>(m.Call());
2485 CHECK_EQ(expected, actual); 2450 CHECK_EQ(expected, actual);
2486 printf("XXX\n"); 2451 printf("XXX\n");
2487 } 2452 }
2488 } 2453 }
2489 } 2454 }
2490 2455
2491 2456
2492 TEST(RunLoadImmIndex) { 2457 TEST(RunLoadImmIndex) {
2493 RunLoadImmIndex<int8_t, uint8_t>(kMachineWord8); 2458 RunLoadImmIndex<int8_t, uint8_t>(mInt8);
2494 RunLoadImmIndex<int16_t, uint16_t>(kMachineWord16); 2459 RunLoadImmIndex<int16_t, uint16_t>(mInt16);
2495 RunLoadImmIndex<int32_t, uint32_t>(kMachineWord32); 2460 RunLoadImmIndex<int32_t, uint32_t>(mInt32);
2496 RunLoadImmIndex<int32_t*, int32_t*>(kMachineTagged); 2461 RunLoadImmIndex<int32_t*, int32_t*>(mAnyTagged);
2497 2462
2498 // TODO(titzer): test kMachineFloat64 loads 2463 // TODO(titzer): test rBit loads
2464 // TODO(titzer): test mFloat64 loads
2499 // TODO(titzer): test various indexing modes. 2465 // TODO(titzer): test various indexing modes.
2500 } 2466 }
2501 2467
2502 2468
2503 template <typename CType> 2469 template <typename CType>
2504 static void RunLoadStore(MachineType rep) { 2470 static void RunLoadStore(MachineType rep) {
2505 const int kNumElems = 4; 2471 const int kNumElems = 4;
2506 CType buffer[kNumElems]; 2472 CType buffer[kNumElems];
2507 2473
2508 for (int32_t x = 0; x < kNumElems; x++) { 2474 for (int32_t x = 0; x < kNumElems; x++) {
(...skipping 14 matching lines...) Expand all
2523 m.Return(m.Int32Constant(OK)); 2489 m.Return(m.Int32Constant(OK));
2524 2490
2525 CHECK_NE(buffer[x], buffer[y]); 2491 CHECK_NE(buffer[x], buffer[y]);
2526 CHECK_EQ(OK, m.Call()); 2492 CHECK_EQ(OK, m.Call());
2527 CHECK_EQ(buffer[x], buffer[y]); 2493 CHECK_EQ(buffer[x], buffer[y]);
2528 } 2494 }
2529 } 2495 }
2530 2496
2531 2497
2532 TEST(RunLoadStore) { 2498 TEST(RunLoadStore) {
2533 RunLoadStore<int8_t>(kMachineWord8); 2499 RunLoadStore<int8_t>(mInt8);
2534 RunLoadStore<int16_t>(kMachineWord16); 2500 RunLoadStore<int16_t>(mInt16);
2535 RunLoadStore<int32_t>(kMachineWord32); 2501 RunLoadStore<int32_t>(mInt32);
2536 RunLoadStore<void*>(kMachineTagged); 2502 RunLoadStore<void*>(mAnyTagged);
2537 RunLoadStore<double>(kMachineFloat64); 2503 RunLoadStore<double>(mFloat64);
2538 } 2504 }
2539 2505
2540 2506
2541 TEST(RunFloat64Binop) { 2507 TEST(RunFloat64Binop) {
2542 RawMachineAssemblerTester<int32_t> m; 2508 RawMachineAssemblerTester<int32_t> m;
2543 double result; 2509 double result;
2544 2510
2545 Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), 2511 Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(),
2546 m.machine()->Float64Mul(), m.machine()->Float64Div(), 2512 m.machine()->Float64Mul(), m.machine()->Float64Div(),
2547 m.machine()->Float64Mod(), NULL}; 2513 m.machine()->Float64Mod(), NULL};
(...skipping 11 matching lines...) Expand all
2559 NULL}; 2525 NULL};
2560 2526
2561 for (int i = 0; ops[i] != NULL; i++) { 2527 for (int i = 0; ops[i] != NULL; i++) {
2562 for (int j = 0; inputs[j] != NULL; j += 2) { 2528 for (int j = 0; inputs[j] != NULL; j += 2) {
2563 RawMachineAssemblerTester<int32_t> m; 2529 RawMachineAssemblerTester<int32_t> m;
2564 Node* a = m.NewNode(inputs[j]); 2530 Node* a = m.NewNode(inputs[j]);
2565 Node* b = m.NewNode(inputs[j + 1]); 2531 Node* b = m.NewNode(inputs[j + 1]);
2566 Node* binop = m.NewNode(ops[i], a, b); 2532 Node* binop = m.NewNode(ops[i], a, b);
2567 Node* base = m.PointerConstant(&result); 2533 Node* base = m.PointerConstant(&result);
2568 Node* zero = m.Int32Constant(0); 2534 Node* zero = m.Int32Constant(0);
2569 m.Store(kMachineFloat64, base, zero, binop); 2535 m.Store(mFloat64, base, zero, binop);
2570 m.Return(m.Int32Constant(i + j)); 2536 m.Return(m.Int32Constant(i + j));
2571 CHECK_EQ(i + j, m.Call()); 2537 CHECK_EQ(i + j, m.Call());
2572 } 2538 }
2573 } 2539 }
2574 } 2540 }
2575 2541
2576 2542
2577 TEST(RunDeadFloat64Binops) { 2543 TEST(RunDeadFloat64Binops) {
2578 RawMachineAssemblerTester<int32_t> m; 2544 RawMachineAssemblerTester<int32_t> m;
2579 2545
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 } 2586 }
2621 } 2587 }
2622 2588
2623 2589
2624 TEST(RunFloat64SubImm1) { 2590 TEST(RunFloat64SubImm1) {
2625 double input = 0.0; 2591 double input = 0.0;
2626 double output = 0.0; 2592 double output = 0.0;
2627 2593
2628 FOR_FLOAT64_INPUTS(i) { 2594 FOR_FLOAT64_INPUTS(i) {
2629 RawMachineAssemblerTester<int32_t> m; 2595 RawMachineAssemblerTester<int32_t> m;
2630 Node* t0 = m.LoadFromPointer(&input, kMachineFloat64); 2596 Node* t0 = m.LoadFromPointer(&input, mFloat64);
2631 Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0); 2597 Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0);
2632 m.StoreToPointer(&output, kMachineFloat64, t1); 2598 m.StoreToPointer(&output, mFloat64, t1);
2633 m.Return(m.Int32Constant(0)); 2599 m.Return(m.Int32Constant(0));
2634 FOR_FLOAT64_INPUTS(j) { 2600 FOR_FLOAT64_INPUTS(j) {
2635 input = *j; 2601 input = *j;
2636 double expected = *i - input; 2602 double expected = *i - input;
2637 CHECK_EQ(0, m.Call()); 2603 CHECK_EQ(0, m.Call());
2638 CHECK_EQ(expected, output); 2604 CHECK_EQ(expected, output);
2639 } 2605 }
2640 } 2606 }
2641 } 2607 }
2642 2608
2643 2609
2644 TEST(RunFloat64SubImm2) { 2610 TEST(RunFloat64SubImm2) {
2645 double input = 0.0; 2611 double input = 0.0;
2646 double output = 0.0; 2612 double output = 0.0;
2647 2613
2648 FOR_FLOAT64_INPUTS(i) { 2614 FOR_FLOAT64_INPUTS(i) {
2649 RawMachineAssemblerTester<int32_t> m; 2615 RawMachineAssemblerTester<int32_t> m;
2650 Node* t0 = m.LoadFromPointer(&input, kMachineFloat64); 2616 Node* t0 = m.LoadFromPointer(&input, mFloat64);
2651 Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i)); 2617 Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i));
2652 m.StoreToPointer(&output, kMachineFloat64, t1); 2618 m.StoreToPointer(&output, mFloat64, t1);
2653 m.Return(m.Int32Constant(0)); 2619 m.Return(m.Int32Constant(0));
2654 FOR_FLOAT64_INPUTS(j) { 2620 FOR_FLOAT64_INPUTS(j) {
2655 input = *j; 2621 input = *j;
2656 double expected = input - *i; 2622 double expected = input - *i;
2657 CHECK_EQ(0, m.Call()); 2623 CHECK_EQ(0, m.Call());
2658 CHECK_EQ(expected, output); 2624 CHECK_EQ(expected, output);
2659 } 2625 }
2660 } 2626 }
2661 } 2627 }
2662 2628
(...skipping 14 matching lines...) Expand all
2677 2643
2678 2644
2679 TEST(RunFloat64MulAndFloat64AddP) { 2645 TEST(RunFloat64MulAndFloat64AddP) {
2680 double input_a = 0.0; 2646 double input_a = 0.0;
2681 double input_b = 0.0; 2647 double input_b = 0.0;
2682 double input_c = 0.0; 2648 double input_c = 0.0;
2683 double output = 0.0; 2649 double output = 0.0;
2684 2650
2685 { 2651 {
2686 RawMachineAssemblerTester<int32_t> m; 2652 RawMachineAssemblerTester<int32_t> m;
2687 Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); 2653 Node* a = m.LoadFromPointer(&input_a, mFloat64);
2688 Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); 2654 Node* b = m.LoadFromPointer(&input_b, mFloat64);
2689 Node* c = m.LoadFromPointer(&input_c, kMachineFloat64); 2655 Node* c = m.LoadFromPointer(&input_c, mFloat64);
2690 m.StoreToPointer(&output, kMachineFloat64, 2656 m.StoreToPointer(&output, mFloat64, m.Float64Add(m.Float64Mul(a, b), c));
2691 m.Float64Add(m.Float64Mul(a, b), c));
2692 m.Return(m.Int32Constant(0)); 2657 m.Return(m.Int32Constant(0));
2693 FOR_FLOAT64_INPUTS(i) { 2658 FOR_FLOAT64_INPUTS(i) {
2694 FOR_FLOAT64_INPUTS(j) { 2659 FOR_FLOAT64_INPUTS(j) {
2695 FOR_FLOAT64_INPUTS(k) { 2660 FOR_FLOAT64_INPUTS(k) {
2696 input_a = *i; 2661 input_a = *i;
2697 input_b = *j; 2662 input_b = *j;
2698 input_c = *k; 2663 input_c = *k;
2699 volatile double temp = input_a * input_b; 2664 volatile double temp = input_a * input_b;
2700 volatile double expected = temp + input_c; 2665 volatile double expected = temp + input_c;
2701 CHECK_EQ(0, m.Call()); 2666 CHECK_EQ(0, m.Call());
2702 CHECK_EQ(expected, output); 2667 CHECK_EQ(expected, output);
2703 } 2668 }
2704 } 2669 }
2705 } 2670 }
2706 } 2671 }
2707 { 2672 {
2708 RawMachineAssemblerTester<int32_t> m; 2673 RawMachineAssemblerTester<int32_t> m;
2709 Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); 2674 Node* a = m.LoadFromPointer(&input_a, mFloat64);
2710 Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); 2675 Node* b = m.LoadFromPointer(&input_b, mFloat64);
2711 Node* c = m.LoadFromPointer(&input_c, kMachineFloat64); 2676 Node* c = m.LoadFromPointer(&input_c, mFloat64);
2712 m.StoreToPointer(&output, kMachineFloat64, 2677 m.StoreToPointer(&output, mFloat64, m.Float64Add(a, m.Float64Mul(b, c)));
2713 m.Float64Add(a, m.Float64Mul(b, c)));
2714 m.Return(m.Int32Constant(0)); 2678 m.Return(m.Int32Constant(0));
2715 FOR_FLOAT64_INPUTS(i) { 2679 FOR_FLOAT64_INPUTS(i) {
2716 FOR_FLOAT64_INPUTS(j) { 2680 FOR_FLOAT64_INPUTS(j) {
2717 FOR_FLOAT64_INPUTS(k) { 2681 FOR_FLOAT64_INPUTS(k) {
2718 input_a = *i; 2682 input_a = *i;
2719 input_b = *j; 2683 input_b = *j;
2720 input_c = *k; 2684 input_c = *k;
2721 volatile double temp = input_b * input_c; 2685 volatile double temp = input_b * input_c;
2722 volatile double expected = input_a + temp; 2686 volatile double expected = input_a + temp;
2723 CHECK_EQ(0, m.Call()); 2687 CHECK_EQ(0, m.Call());
2724 CHECK_EQ(expected, output); 2688 CHECK_EQ(expected, output);
2725 } 2689 }
2726 } 2690 }
2727 } 2691 }
2728 } 2692 }
2729 } 2693 }
2730 2694
2731 2695
2732 TEST(RunFloat64MulAndFloat64SubP) { 2696 TEST(RunFloat64MulAndFloat64SubP) {
2733 double input_a = 0.0; 2697 double input_a = 0.0;
2734 double input_b = 0.0; 2698 double input_b = 0.0;
2735 double input_c = 0.0; 2699 double input_c = 0.0;
2736 double output = 0.0; 2700 double output = 0.0;
2737 2701
2738 RawMachineAssemblerTester<int32_t> m; 2702 RawMachineAssemblerTester<int32_t> m;
2739 Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); 2703 Node* a = m.LoadFromPointer(&input_a, mFloat64);
2740 Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); 2704 Node* b = m.LoadFromPointer(&input_b, mFloat64);
2741 Node* c = m.LoadFromPointer(&input_c, kMachineFloat64); 2705 Node* c = m.LoadFromPointer(&input_c, mFloat64);
2742 m.StoreToPointer(&output, kMachineFloat64, 2706 m.StoreToPointer(&output, mFloat64, m.Float64Sub(a, m.Float64Mul(b, c)));
2743 m.Float64Sub(a, m.Float64Mul(b, c)));
2744 m.Return(m.Int32Constant(0)); 2707 m.Return(m.Int32Constant(0));
2745 2708
2746 FOR_FLOAT64_INPUTS(i) { 2709 FOR_FLOAT64_INPUTS(i) {
2747 FOR_FLOAT64_INPUTS(j) { 2710 FOR_FLOAT64_INPUTS(j) {
2748 FOR_FLOAT64_INPUTS(k) { 2711 FOR_FLOAT64_INPUTS(k) {
2749 input_a = *i; 2712 input_a = *i;
2750 input_b = *j; 2713 input_b = *j;
2751 input_c = *k; 2714 input_c = *k;
2752 volatile double temp = input_b * input_c; 2715 volatile double temp = input_b * input_c;
2753 volatile double expected = input_a - temp; 2716 volatile double expected = input_a - temp;
2754 CHECK_EQ(0, m.Call()); 2717 CHECK_EQ(0, m.Call());
2755 CHECK_EQ(expected, output); 2718 CHECK_EQ(expected, output);
2756 } 2719 }
2757 } 2720 }
2758 } 2721 }
2759 } 2722 }
2760 2723
2761 2724
2762 TEST(RunFloat64MulImm) { 2725 TEST(RunFloat64MulImm) {
2763 double input = 0.0; 2726 double input = 0.0;
2764 double output = 0.0; 2727 double output = 0.0;
2765 2728
2766 { 2729 {
2767 FOR_FLOAT64_INPUTS(i) { 2730 FOR_FLOAT64_INPUTS(i) {
2768 RawMachineAssemblerTester<int32_t> m; 2731 RawMachineAssemblerTester<int32_t> m;
2769 Node* t0 = m.LoadFromPointer(&input, kMachineFloat64); 2732 Node* t0 = m.LoadFromPointer(&input, mFloat64);
2770 Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0); 2733 Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0);
2771 m.StoreToPointer(&output, kMachineFloat64, t1); 2734 m.StoreToPointer(&output, mFloat64, t1);
2772 m.Return(m.Int32Constant(0)); 2735 m.Return(m.Int32Constant(0));
2773 FOR_FLOAT64_INPUTS(j) { 2736 FOR_FLOAT64_INPUTS(j) {
2774 input = *j; 2737 input = *j;
2775 double expected = *i * input; 2738 double expected = *i * input;
2776 CHECK_EQ(0, m.Call()); 2739 CHECK_EQ(0, m.Call());
2777 CHECK_EQ(expected, output); 2740 CHECK_EQ(expected, output);
2778 } 2741 }
2779 } 2742 }
2780 } 2743 }
2781 { 2744 {
2782 FOR_FLOAT64_INPUTS(i) { 2745 FOR_FLOAT64_INPUTS(i) {
2783 RawMachineAssemblerTester<int32_t> m; 2746 RawMachineAssemblerTester<int32_t> m;
2784 Node* t0 = m.LoadFromPointer(&input, kMachineFloat64); 2747 Node* t0 = m.LoadFromPointer(&input, mFloat64);
2785 Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i)); 2748 Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i));
2786 m.StoreToPointer(&output, kMachineFloat64, t1); 2749 m.StoreToPointer(&output, mFloat64, t1);
2787 m.Return(m.Int32Constant(0)); 2750 m.Return(m.Int32Constant(0));
2788 FOR_FLOAT64_INPUTS(j) { 2751 FOR_FLOAT64_INPUTS(j) {
2789 input = *j; 2752 input = *j;
2790 double expected = input * *i; 2753 double expected = input * *i;
2791 CHECK_EQ(0, m.Call()); 2754 CHECK_EQ(0, m.Call());
2792 CHECK_EQ(expected, output); 2755 CHECK_EQ(expected, output);
2793 } 2756 }
2794 } 2757 }
2795 } 2758 }
2796 } 2759 }
(...skipping 29 matching lines...) Expand all
2826 } 2789 }
2827 } 2790 }
2828 2791
2829 2792
2830 TEST(RunChangeInt32ToFloat64_A) { 2793 TEST(RunChangeInt32ToFloat64_A) {
2831 RawMachineAssemblerTester<int32_t> m; 2794 RawMachineAssemblerTester<int32_t> m;
2832 int32_t magic = 0x986234; 2795 int32_t magic = 0x986234;
2833 double result = 0; 2796 double result = 0;
2834 2797
2835 Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic)); 2798 Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic));
2836 m.Store(kMachineFloat64, m.PointerConstant(&result), m.Int32Constant(0), 2799 m.Store(mFloat64, m.PointerConstant(&result), m.Int32Constant(0), convert);
2837 convert);
2838 m.Return(m.Int32Constant(magic)); 2800 m.Return(m.Int32Constant(magic));
2839 2801
2840 CHECK_EQ(magic, m.Call()); 2802 CHECK_EQ(magic, m.Call());
2841 CHECK_EQ(static_cast<double>(magic), result); 2803 CHECK_EQ(static_cast<double>(magic), result);
2842 } 2804 }
2843 2805
2844 2806
2845 TEST(RunChangeInt32ToFloat64_B) { 2807 TEST(RunChangeInt32ToFloat64_B) {
2846 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2808 RawMachineAssemblerTester<int32_t> m(mInt32);
2847 double output = 0; 2809 double output = 0;
2848 2810
2849 Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0)); 2811 Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0));
2850 m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0), 2812 m.Store(mFloat64, m.PointerConstant(&output), m.Int32Constant(0), convert);
2851 convert);
2852 m.Return(m.Parameter(0)); 2813 m.Return(m.Parameter(0));
2853 2814
2854 FOR_INT32_INPUTS(i) { 2815 FOR_INT32_INPUTS(i) {
2855 int32_t expect = *i; 2816 int32_t expect = *i;
2856 CHECK_EQ(expect, m.Call(expect)); 2817 CHECK_EQ(expect, m.Call(expect));
2857 CHECK_EQ(static_cast<double>(expect), output); 2818 CHECK_EQ(static_cast<double>(expect), output);
2858 } 2819 }
2859 } 2820 }
2860 2821
2861 2822
2862 TEST(RunChangeUint32ToFloat64_B) { 2823 TEST(RunChangeUint32ToFloat64_B) {
2863 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 2824 RawMachineAssemblerTester<int32_t> m(mUint32);
2864 double output = 0; 2825 double output = 0;
2865 2826
2866 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0)); 2827 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0));
2867 m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0), 2828 m.Store(mFloat64, m.PointerConstant(&output), m.Int32Constant(0), convert);
2868 convert);
2869 m.Return(m.Parameter(0)); 2829 m.Return(m.Parameter(0));
2870 2830
2871 FOR_UINT32_INPUTS(i) { 2831 FOR_UINT32_INPUTS(i) {
2872 uint32_t expect = *i; 2832 uint32_t expect = *i;
2873 CHECK_EQ(expect, m.Call(expect)); 2833 CHECK_EQ(expect, m.Call(expect));
2874 CHECK_EQ(static_cast<double>(expect), output); 2834 CHECK_EQ(static_cast<double>(expect), output);
2875 } 2835 }
2876 } 2836 }
2877 2837
2878 2838
2879 TEST(RunChangeFloat64ToInt32_A) { 2839 TEST(RunChangeFloat64ToInt32_A) {
2880 RawMachineAssemblerTester<int32_t> m; 2840 RawMachineAssemblerTester<int32_t> m;
2881 int32_t magic = 0x786234; 2841 int32_t magic = 0x786234;
2882 double input = 11.1; 2842 double input = 11.1;
2883 int32_t result = 0; 2843 int32_t result = 0;
2884 2844
2885 m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(0), 2845 m.Store(mInt32, m.PointerConstant(&result), m.Int32Constant(0),
2886 m.ChangeFloat64ToInt32(m.Float64Constant(input))); 2846 m.ChangeFloat64ToInt32(m.Float64Constant(input)));
2887 m.Return(m.Int32Constant(magic)); 2847 m.Return(m.Int32Constant(magic));
2888 2848
2889 CHECK_EQ(magic, m.Call()); 2849 CHECK_EQ(magic, m.Call());
2890 CHECK_EQ(static_cast<int32_t>(input), result); 2850 CHECK_EQ(static_cast<int32_t>(input), result);
2891 } 2851 }
2892 2852
2893 2853
2894 TEST(RunChangeFloat64ToInt32_B) { 2854 TEST(RunChangeFloat64ToInt32_B) {
2895 RawMachineAssemblerTester<int32_t> m; 2855 RawMachineAssemblerTester<int32_t> m;
2896 double input = 0; 2856 double input = 0;
2897 int32_t output = 0; 2857 int32_t output = 0;
2898 2858
2899 Node* load = 2859 Node* load = m.Load(mFloat64, m.PointerConstant(&input), m.Int32Constant(0));
2900 m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0));
2901 Node* convert = m.ChangeFloat64ToInt32(load); 2860 Node* convert = m.ChangeFloat64ToInt32(load);
2902 m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0), 2861 m.Store(mInt32, m.PointerConstant(&output), m.Int32Constant(0), convert);
2903 convert);
2904 m.Return(convert); 2862 m.Return(convert);
2905 2863
2906 { 2864 {
2907 FOR_INT32_INPUTS(i) { 2865 FOR_INT32_INPUTS(i) {
2908 input = *i; 2866 input = *i;
2909 int32_t expect = *i; 2867 int32_t expect = *i;
2910 CHECK_EQ(expect, m.Call()); 2868 CHECK_EQ(expect, m.Call());
2911 CHECK_EQ(expect, output); 2869 CHECK_EQ(expect, output);
2912 } 2870 }
2913 } 2871 }
(...skipping 17 matching lines...) Expand all
2931 // Note we don't check fractional inputs, because these Convert operators 2889 // Note we don't check fractional inputs, because these Convert operators
2932 // really should be Change operators. 2890 // really should be Change operators.
2933 } 2891 }
2934 2892
2935 2893
2936 TEST(RunChangeFloat64ToUint32_B) { 2894 TEST(RunChangeFloat64ToUint32_B) {
2937 RawMachineAssemblerTester<int32_t> m; 2895 RawMachineAssemblerTester<int32_t> m;
2938 double input = 0; 2896 double input = 0;
2939 int32_t output = 0; 2897 int32_t output = 0;
2940 2898
2941 Node* load = 2899 Node* load = m.Load(mFloat64, m.PointerConstant(&input), m.Int32Constant(0));
2942 m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0));
2943 Node* convert = m.ChangeFloat64ToUint32(load); 2900 Node* convert = m.ChangeFloat64ToUint32(load);
2944 m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0), 2901 m.Store(mInt32, m.PointerConstant(&output), m.Int32Constant(0), convert);
2945 convert);
2946 m.Return(convert); 2902 m.Return(convert);
2947 2903
2948 { 2904 {
2949 FOR_UINT32_INPUTS(i) { 2905 FOR_UINT32_INPUTS(i) {
2950 input = *i; 2906 input = *i;
2951 // TODO(titzer): add a CheckEqualsHelper overload for uint32_t. 2907 // TODO(titzer): add a CheckEqualsHelper overload for uint32_t.
2952 int32_t expect = static_cast<int32_t>(*i); 2908 int32_t expect = static_cast<int32_t>(*i);
2953 CHECK_EQ(expect, m.Call()); 2909 CHECK_EQ(expect, m.Call());
2954 CHECK_EQ(expect, output); 2910 CHECK_EQ(expect, output);
2955 } 2911 }
(...skipping 22 matching lines...) Expand all
2978 2934
2979 TEST(RunChangeFloat64ToInt32_spilled) { 2935 TEST(RunChangeFloat64ToInt32_spilled) {
2980 RawMachineAssemblerTester<int32_t> m; 2936 RawMachineAssemblerTester<int32_t> m;
2981 const int kNumInputs = 32; 2937 const int kNumInputs = 32;
2982 int32_t magic = 0x786234; 2938 int32_t magic = 0x786234;
2983 double input[kNumInputs]; 2939 double input[kNumInputs];
2984 int32_t result[kNumInputs]; 2940 int32_t result[kNumInputs];
2985 Node* input_node[kNumInputs]; 2941 Node* input_node[kNumInputs];
2986 2942
2987 for (int i = 0; i < kNumInputs; i++) { 2943 for (int i = 0; i < kNumInputs; i++) {
2988 input_node[i] = m.Load(kMachineFloat64, m.PointerConstant(&input), 2944 input_node[i] =
2989 m.Int32Constant(i * 8)); 2945 m.Load(mFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8));
2990 } 2946 }
2991 2947
2992 for (int i = 0; i < kNumInputs; i++) { 2948 for (int i = 0; i < kNumInputs; i++) {
2993 m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(i * 4), 2949 m.Store(mInt32, m.PointerConstant(&result), m.Int32Constant(i * 4),
2994 m.ChangeFloat64ToInt32(input_node[i])); 2950 m.ChangeFloat64ToInt32(input_node[i]));
2995 } 2951 }
2996 2952
2997 m.Return(m.Int32Constant(magic)); 2953 m.Return(m.Int32Constant(magic));
2998 2954
2999 for (int i = 0; i < kNumInputs; i++) { 2955 for (int i = 0; i < kNumInputs; i++) {
3000 input[i] = 100.9 + i; 2956 input[i] = 100.9 + i;
3001 } 2957 }
3002 2958
3003 CHECK_EQ(magic, m.Call()); 2959 CHECK_EQ(magic, m.Call());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3059 MLabel blocka, blockb, end; 3015 MLabel blocka, blockb, end;
3060 Node* k1 = m.Float64Constant(constant); 3016 Node* k1 = m.Float64Constant(constant);
3061 Node* k2 = m.Float64Constant(0 - constant); 3017 Node* k2 = m.Float64Constant(0 - constant);
3062 m.Branch(m.Int32Constant(0), &blocka, &blockb); 3018 m.Branch(m.Int32Constant(0), &blocka, &blockb);
3063 m.Bind(&blocka); 3019 m.Bind(&blocka);
3064 m.Goto(&end); 3020 m.Goto(&end);
3065 m.Bind(&blockb); 3021 m.Bind(&blockb);
3066 m.Goto(&end); 3022 m.Goto(&end);
3067 m.Bind(&end); 3023 m.Bind(&end);
3068 Node* phi = m.Phi(k2, k1); 3024 Node* phi = m.Phi(k2, k1);
3069 m.Store(kMachineFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); 3025 m.Store(mFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi);
3070 m.Return(m.Int32Constant(magic)); 3026 m.Return(m.Int32Constant(magic));
3071 3027
3072 CHECK_EQ(magic, m.Call()); 3028 CHECK_EQ(magic, m.Call());
3073 CHECK_EQ(constant, buffer); 3029 CHECK_EQ(constant, buffer);
3074 } 3030 }
3075 3031
3076 3032
3077 TEST(RunRefDiamond) { 3033 TEST(RunRefDiamond) {
3078 RawMachineAssemblerTester<int32_t> m; 3034 RawMachineAssemblerTester<int32_t> m;
3079 3035
3080 const int magic = 99644; 3036 const int magic = 99644;
3081 Handle<String> rexpected = 3037 Handle<String> rexpected =
3082 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); 3038 CcTest::i_isolate()->factory()->InternalizeUtf8String("A");
3083 String* buffer; 3039 String* buffer;
3084 3040
3085 MLabel blocka, blockb, end; 3041 MLabel blocka, blockb, end;
3086 Node* k1 = m.StringConstant("A"); 3042 Node* k1 = m.StringConstant("A");
3087 Node* k2 = m.StringConstant("B"); 3043 Node* k2 = m.StringConstant("B");
3088 m.Branch(m.Int32Constant(0), &blocka, &blockb); 3044 m.Branch(m.Int32Constant(0), &blocka, &blockb);
3089 m.Bind(&blocka); 3045 m.Bind(&blocka);
3090 m.Goto(&end); 3046 m.Goto(&end);
3091 m.Bind(&blockb); 3047 m.Bind(&blockb);
3092 m.Goto(&end); 3048 m.Goto(&end);
3093 m.Bind(&end); 3049 m.Bind(&end);
3094 Node* phi = m.Phi(k2, k1); 3050 Node* phi = m.Phi(k2, k1);
3095 m.Store(kMachineTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi); 3051 m.Store(mAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi);
3096 m.Return(m.Int32Constant(magic)); 3052 m.Return(m.Int32Constant(magic));
3097 3053
3098 CHECK_EQ(magic, m.Call()); 3054 CHECK_EQ(magic, m.Call());
3099 CHECK(rexpected->SameValue(buffer)); 3055 CHECK(rexpected->SameValue(buffer));
3100 } 3056 }
3101 3057
3102 3058
3103 TEST(RunDoubleRefDiamond) { 3059 TEST(RunDoubleRefDiamond) {
3104 RawMachineAssemblerTester<int32_t> m; 3060 RawMachineAssemblerTester<int32_t> m;
3105 3061
(...skipping 10 matching lines...) Expand all
3116 Node* r1 = m.StringConstant("AX"); 3072 Node* r1 = m.StringConstant("AX");
3117 Node* r2 = m.StringConstant("BX"); 3073 Node* r2 = m.StringConstant("BX");
3118 m.Branch(m.Int32Constant(0), &blocka, &blockb); 3074 m.Branch(m.Int32Constant(0), &blocka, &blockb);
3119 m.Bind(&blocka); 3075 m.Bind(&blocka);
3120 m.Goto(&end); 3076 m.Goto(&end);
3121 m.Bind(&blockb); 3077 m.Bind(&blockb);
3122 m.Goto(&end); 3078 m.Goto(&end);
3123 m.Bind(&end); 3079 m.Bind(&end);
3124 Node* dphi = m.Phi(d2, d1); 3080 Node* dphi = m.Phi(d2, d1);
3125 Node* rphi = m.Phi(r2, r1); 3081 Node* rphi = m.Phi(r2, r1);
3126 m.Store(kMachineFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), 3082 m.Store(mFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi);
3127 dphi); 3083 m.Store(mAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi);
3128 m.Store(kMachineTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0),
3129 rphi);
3130 m.Return(m.Int32Constant(magic)); 3084 m.Return(m.Int32Constant(magic));
3131 3085
3132 CHECK_EQ(magic, m.Call()); 3086 CHECK_EQ(magic, m.Call());
3133 CHECK_EQ(dconstant, dbuffer); 3087 CHECK_EQ(dconstant, dbuffer);
3134 CHECK(rexpected->SameValue(rbuffer)); 3088 CHECK(rexpected->SameValue(rbuffer));
3135 } 3089 }
3136 3090
3137 3091
3138 TEST(RunDoubleRefDoubleDiamond) { 3092 TEST(RunDoubleRefDoubleDiamond) {
3139 RawMachineAssemblerTester<int32_t> m; 3093 RawMachineAssemblerTester<int32_t> m;
(...skipping 21 matching lines...) Expand all
3161 m.Branch(m.Int32Constant(0), &blockd, &blocke); 3115 m.Branch(m.Int32Constant(0), &blockd, &blocke);
3162 3116
3163 m.Bind(&blockd); 3117 m.Bind(&blockd);
3164 m.Goto(&end); 3118 m.Goto(&end);
3165 m.Bind(&blocke); 3119 m.Bind(&blocke);
3166 m.Goto(&end); 3120 m.Goto(&end);
3167 m.Bind(&end); 3121 m.Bind(&end);
3168 Node* dphi2 = m.Phi(d1, dphi1); 3122 Node* dphi2 = m.Phi(d1, dphi1);
3169 Node* rphi2 = m.Phi(r1, rphi1); 3123 Node* rphi2 = m.Phi(r1, rphi1);
3170 3124
3171 m.Store(kMachineFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), 3125 m.Store(mFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2);
3172 dphi2); 3126 m.Store(mAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi2);
3173 m.Store(kMachineTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0),
3174 rphi2);
3175 m.Return(m.Int32Constant(magic)); 3127 m.Return(m.Int32Constant(magic));
3176 3128
3177 CHECK_EQ(magic, m.Call()); 3129 CHECK_EQ(magic, m.Call());
3178 CHECK_EQ(dconstant, dbuffer); 3130 CHECK_EQ(dconstant, dbuffer);
3179 CHECK(rexpected->SameValue(rbuffer)); 3131 CHECK(rexpected->SameValue(rbuffer));
3180 } 3132 }
3181 3133
3182 3134
3183 TEST(RunDoubleLoopPhi) { 3135 TEST(RunDoubleLoopPhi) {
3184 RawMachineAssemblerTester<int32_t> m; 3136 RawMachineAssemblerTester<int32_t> m;
3185 MLabel header, body, end; 3137 MLabel header, body, end;
3186 3138
3187 int magic = 99773; 3139 int magic = 99773;
3188 double buffer = 0.99; 3140 double buffer = 0.99;
3189 double dconstant = 777.1; 3141 double dconstant = 777.1;
3190 3142
3191 Node* zero = m.Int32Constant(0); 3143 Node* zero = m.Int32Constant(0);
3192 Node* dk = m.Float64Constant(dconstant); 3144 Node* dk = m.Float64Constant(dconstant);
3193 3145
3194 m.Goto(&header); 3146 m.Goto(&header);
3195 m.Bind(&header); 3147 m.Bind(&header);
3196 Node* phi = m.Phi(dk, dk); 3148 Node* phi = m.Phi(dk, dk);
3197 phi->ReplaceInput(1, phi); 3149 phi->ReplaceInput(1, phi);
3198 m.Branch(zero, &body, &end); 3150 m.Branch(zero, &body, &end);
3199 m.Bind(&body); 3151 m.Bind(&body);
3200 m.Goto(&header); 3152 m.Goto(&header);
3201 m.Bind(&end); 3153 m.Bind(&end);
3202 m.Store(kMachineFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); 3154 m.Store(mFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi);
3203 m.Return(m.Int32Constant(magic)); 3155 m.Return(m.Int32Constant(magic));
3204 3156
3205 CHECK_EQ(magic, m.Call()); 3157 CHECK_EQ(magic, m.Call());
3206 } 3158 }
3207 3159
3208 3160
3209 TEST(RunCountToTenAccRaw) { 3161 TEST(RunCountToTenAccRaw) {
3210 RawMachineAssemblerTester<int32_t> m; 3162 RawMachineAssemblerTester<int32_t> m;
3211 3163
3212 Node* zero = m.Int32Constant(0); 3164 Node* zero = m.Int32Constant(0);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 3225
3274 CHECK_EQ(10, m.Call()); 3226 CHECK_EQ(10, m.Call());
3275 } 3227 }
3276 3228
3277 3229
3278 TEST(RunAddTree) { 3230 TEST(RunAddTree) {
3279 RawMachineAssemblerTester<int32_t> m; 3231 RawMachineAssemblerTester<int32_t> m;
3280 int32_t inputs[] = {11, 12, 13, 14, 15, 16, 17, 18}; 3232 int32_t inputs[] = {11, 12, 13, 14, 15, 16, 17, 18};
3281 3233
3282 Node* base = m.PointerConstant(inputs); 3234 Node* base = m.PointerConstant(inputs);
3283 Node* n0 = m.Load(kMachineWord32, base, m.Int32Constant(0 * sizeof(int32_t))); 3235 Node* n0 = m.Load(mInt32, base, m.Int32Constant(0 * sizeof(int32_t)));
3284 Node* n1 = m.Load(kMachineWord32, base, m.Int32Constant(1 * sizeof(int32_t))); 3236 Node* n1 = m.Load(mInt32, base, m.Int32Constant(1 * sizeof(int32_t)));
3285 Node* n2 = m.Load(kMachineWord32, base, m.Int32Constant(2 * sizeof(int32_t))); 3237 Node* n2 = m.Load(mInt32, base, m.Int32Constant(2 * sizeof(int32_t)));
3286 Node* n3 = m.Load(kMachineWord32, base, m.Int32Constant(3 * sizeof(int32_t))); 3238 Node* n3 = m.Load(mInt32, base, m.Int32Constant(3 * sizeof(int32_t)));
3287 Node* n4 = m.Load(kMachineWord32, base, m.Int32Constant(4 * sizeof(int32_t))); 3239 Node* n4 = m.Load(mInt32, base, m.Int32Constant(4 * sizeof(int32_t)));
3288 Node* n5 = m.Load(kMachineWord32, base, m.Int32Constant(5 * sizeof(int32_t))); 3240 Node* n5 = m.Load(mInt32, base, m.Int32Constant(5 * sizeof(int32_t)));
3289 Node* n6 = m.Load(kMachineWord32, base, m.Int32Constant(6 * sizeof(int32_t))); 3241 Node* n6 = m.Load(mInt32, base, m.Int32Constant(6 * sizeof(int32_t)));
3290 Node* n7 = m.Load(kMachineWord32, base, m.Int32Constant(7 * sizeof(int32_t))); 3242 Node* n7 = m.Load(mInt32, base, m.Int32Constant(7 * sizeof(int32_t)));
3291 3243
3292 Node* i1 = m.Int32Add(n0, n1); 3244 Node* i1 = m.Int32Add(n0, n1);
3293 Node* i2 = m.Int32Add(n2, n3); 3245 Node* i2 = m.Int32Add(n2, n3);
3294 Node* i3 = m.Int32Add(n4, n5); 3246 Node* i3 = m.Int32Add(n4, n5);
3295 Node* i4 = m.Int32Add(n6, n7); 3247 Node* i4 = m.Int32Add(n6, n7);
3296 3248
3297 Node* i5 = m.Int32Add(i1, i2); 3249 Node* i5 = m.Int32Add(i1, i2);
3298 Node* i6 = m.Int32Add(i3, i4); 3250 Node* i6 = m.Int32Add(i3, i4);
3299 3251
3300 Node* i7 = m.Int32Add(i5, i6); 3252 Node* i7 = m.Int32Add(i5, i6);
(...skipping 17 matching lines...) Expand all
3318 void* function_address = 3270 void* function_address =
3319 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven)); 3271 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven));
3320 3272
3321 RawMachineAssemblerTester<int32_t> m; 3273 RawMachineAssemblerTester<int32_t> m;
3322 Node** args = NULL; 3274 Node** args = NULL;
3323 MachineType* arg_types = NULL; 3275 MachineType* arg_types = NULL;
3324 Node* function = 3276 Node* function =
3325 call_direct ? m.PointerConstant(function_address) 3277 call_direct ? m.PointerConstant(function_address)
3326 : m.LoadFromPointer(&function_address, 3278 : m.LoadFromPointer(&function_address,
3327 MachineOperatorBuilder::pointer_rep()); 3279 MachineOperatorBuilder::pointer_rep());
3328 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 0)); 3280 m.Return(m.CallC(function, mInt32, arg_types, args, 0));
3329 3281
3330 CHECK_EQ(7, m.Call()); 3282 CHECK_EQ(7, m.Call());
3331 } 3283 }
3332 } 3284 }
3333 3285
3334 3286
3335 TEST(RunCallUnaryMinus) { 3287 TEST(RunCallUnaryMinus) {
3336 for (int i = 0; i < 2; i++) { 3288 for (int i = 0; i < 2; i++) {
3337 bool call_direct = i == 0; 3289 bool call_direct = i == 0;
3338 void* function_address = 3290 void* function_address =
3339 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&UnaryMinus)); 3291 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&UnaryMinus));
3340 3292
3341 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 3293 RawMachineAssemblerTester<int32_t> m(mInt32);
3342 Node* args[] = {m.Parameter(0)}; 3294 Node* args[] = {m.Parameter(0)};
3343 MachineType arg_types[] = {kMachineWord32}; 3295 MachineType arg_types[] = {mInt32};
3344 Node* function = 3296 Node* function =
3345 call_direct ? m.PointerConstant(function_address) 3297 call_direct ? m.PointerConstant(function_address)
3346 : m.LoadFromPointer(&function_address, 3298 : m.LoadFromPointer(&function_address,
3347 MachineOperatorBuilder::pointer_rep()); 3299 MachineOperatorBuilder::pointer_rep());
3348 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 1)); 3300 m.Return(m.CallC(function, mInt32, arg_types, args, 1));
3349 3301
3350 FOR_INT32_INPUTS(i) { 3302 FOR_INT32_INPUTS(i) {
3351 int a = *i; 3303 int a = *i;
3352 CHECK_EQ(-a, m.Call(a)); 3304 CHECK_EQ(-a, m.Call(a));
3353 } 3305 }
3354 } 3306 }
3355 } 3307 }
3356 3308
3357 3309
3358 TEST(RunCallAPlusTwoB) { 3310 TEST(RunCallAPlusTwoB) {
3359 for (int i = 0; i < 2; i++) { 3311 for (int i = 0; i < 2; i++) {
3360 bool call_direct = i == 0; 3312 bool call_direct = i == 0;
3361 void* function_address = 3313 void* function_address =
3362 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&APlusTwoB)); 3314 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&APlusTwoB));
3363 3315
3364 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); 3316 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32);
3365 Node* args[] = {m.Parameter(0), m.Parameter(1)}; 3317 Node* args[] = {m.Parameter(0), m.Parameter(1)};
3366 MachineType arg_types[] = {kMachineWord32, kMachineWord32}; 3318 MachineType arg_types[] = {mInt32, mInt32};
3367 Node* function = 3319 Node* function =
3368 call_direct ? m.PointerConstant(function_address) 3320 call_direct ? m.PointerConstant(function_address)
3369 : m.LoadFromPointer(&function_address, 3321 : m.LoadFromPointer(&function_address,
3370 MachineOperatorBuilder::pointer_rep()); 3322 MachineOperatorBuilder::pointer_rep());
3371 m.Return(m.CallC(function, kMachineWord32, arg_types, args, 2)); 3323 m.Return(m.CallC(function, mInt32, arg_types, args, 2));
3372 3324
3373 FOR_INT32_INPUTS(i) { 3325 FOR_INT32_INPUTS(i) {
3374 FOR_INT32_INPUTS(j) { 3326 FOR_INT32_INPUTS(j) {
3375 int a = *i; 3327 int a = *i;
3376 int b = *j; 3328 int b = *j;
3377 int result = m.Call(a, b); 3329 int result = m.Call(a, b);
3378 CHECK_EQ(a + 2 * b, result); 3330 CHECK_EQ(a + 2 * b, result);
3379 } 3331 }
3380 } 3332 }
3381 } 3333 }
3382 } 3334 }
3383 3335
3384 #endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C 3336 #endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C
3385 3337
3386 3338
3387 static const int kFloat64CompareHelperTestCases = 15; 3339 static const int kFloat64CompareHelperTestCases = 15;
3388 static const int kFloat64CompareHelperNodeType = 4; 3340 static const int kFloat64CompareHelperNodeType = 4;
3389 3341
3390 static int Float64CompareHelper(RawMachineAssemblerTester<int32_t>* m, 3342 static int Float64CompareHelper(RawMachineAssemblerTester<int32_t>* m,
3391 int test_case, int node_type, double x, 3343 int test_case, int node_type, double x,
3392 double y) { 3344 double y) {
3393 static double buffer[2]; 3345 static double buffer[2];
3394 buffer[0] = x; 3346 buffer[0] = x;
3395 buffer[1] = y; 3347 buffer[1] = y;
3396 CHECK(0 <= test_case && test_case < kFloat64CompareHelperTestCases); 3348 CHECK(0 <= test_case && test_case < kFloat64CompareHelperTestCases);
3397 CHECK(0 <= node_type && node_type < kFloat64CompareHelperNodeType); 3349 CHECK(0 <= node_type && node_type < kFloat64CompareHelperNodeType);
3398 CHECK(x < y); 3350 CHECK(x < y);
3399 bool load_a = node_type / 2 == 1; 3351 bool load_a = node_type / 2 == 1;
3400 bool load_b = node_type % 2 == 1; 3352 bool load_b = node_type % 2 == 1;
3401 Node* a = load_a ? m->Load(kMachineFloat64, m->PointerConstant(&buffer[0])) 3353 Node* a = load_a ? m->Load(mFloat64, m->PointerConstant(&buffer[0]))
3402 : m->Float64Constant(x); 3354 : m->Float64Constant(x);
3403 Node* b = load_b ? m->Load(kMachineFloat64, m->PointerConstant(&buffer[1])) 3355 Node* b = load_b ? m->Load(mFloat64, m->PointerConstant(&buffer[1]))
3404 : m->Float64Constant(y); 3356 : m->Float64Constant(y);
3405 Node* cmp = NULL; 3357 Node* cmp = NULL;
3406 bool expected = false; 3358 bool expected = false;
3407 switch (test_case) { 3359 switch (test_case) {
3408 // Equal tests. 3360 // Equal tests.
3409 case 0: 3361 case 0:
3410 cmp = m->Float64Equal(a, b); 3362 cmp = m->Float64Equal(a, b);
3411 expected = false; 3363 expected = false;
3412 break; 3364 break;
3413 case 1: 3365 case 1:
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
3521 } 3473 }
3522 } 3474 }
3523 } 3475 }
3524 3476
3525 3477
3526 TEST(RunFloat64Equal) { 3478 TEST(RunFloat64Equal) {
3527 double input_a = 0.0; 3479 double input_a = 0.0;
3528 double input_b = 0.0; 3480 double input_b = 0.0;
3529 3481
3530 RawMachineAssemblerTester<int32_t> m; 3482 RawMachineAssemblerTester<int32_t> m;
3531 Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); 3483 Node* a = m.LoadFromPointer(&input_a, mFloat64);
3532 Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); 3484 Node* b = m.LoadFromPointer(&input_b, mFloat64);
3533 m.Return(m.Float64Equal(a, b)); 3485 m.Return(m.Float64Equal(a, b));
3534 3486
3535 CompareWrapper cmp(IrOpcode::kFloat64Equal); 3487 CompareWrapper cmp(IrOpcode::kFloat64Equal);
3536 FOR_FLOAT64_INPUTS(pl) { 3488 FOR_FLOAT64_INPUTS(pl) {
3537 FOR_FLOAT64_INPUTS(pr) { 3489 FOR_FLOAT64_INPUTS(pr) {
3538 input_a = *pl; 3490 input_a = *pl;
3539 input_b = *pr; 3491 input_b = *pr;
3540 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0; 3492 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0;
3541 CHECK_EQ(expected, m.Call()); 3493 CHECK_EQ(expected, m.Call());
3542 } 3494 }
3543 } 3495 }
3544 } 3496 }
3545 3497
3546 3498
3547 TEST(RunFloat64LessThan) { 3499 TEST(RunFloat64LessThan) {
3548 double input_a = 0.0; 3500 double input_a = 0.0;
3549 double input_b = 0.0; 3501 double input_b = 0.0;
3550 3502
3551 RawMachineAssemblerTester<int32_t> m; 3503 RawMachineAssemblerTester<int32_t> m;
3552 Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); 3504 Node* a = m.LoadFromPointer(&input_a, mFloat64);
3553 Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); 3505 Node* b = m.LoadFromPointer(&input_b, mFloat64);
3554 m.Return(m.Float64LessThan(a, b)); 3506 m.Return(m.Float64LessThan(a, b));
3555 3507
3556 CompareWrapper cmp(IrOpcode::kFloat64LessThan); 3508 CompareWrapper cmp(IrOpcode::kFloat64LessThan);
3557 FOR_FLOAT64_INPUTS(pl) { 3509 FOR_FLOAT64_INPUTS(pl) {
3558 FOR_FLOAT64_INPUTS(pr) { 3510 FOR_FLOAT64_INPUTS(pr) {
3559 input_a = *pl; 3511 input_a = *pl;
3560 input_b = *pr; 3512 input_b = *pr;
3561 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0; 3513 int32_t expected = cmp.Float64Compare(input_a, input_b) ? 1 : 0;
3562 CHECK_EQ(expected, m.Call()); 3514 CHECK_EQ(expected, m.Call());
3563 } 3515 }
(...skipping 28 matching lines...) Expand all
3592 for (int i = -127; i < 127; i++) { 3544 for (int i = -127; i < 127; i++) {
3593 input = i; 3545 input = i;
3594 int expected = i >= 0 ? i + 1 : max + (i - min) + 2; 3546 int expected = i >= 0 ? i + 1 : max + (i - min) + 2;
3595 CHECK_EQ(expected, m.Call()); 3547 CHECK_EQ(expected, m.Call());
3596 CHECK_EQ(i + 1, input); 3548 CHECK_EQ(i + 1, input);
3597 } 3549 }
3598 } 3550 }
3599 3551
3600 3552
3601 TEST(RunLoadStoreTruncation) { 3553 TEST(RunLoadStoreTruncation) {
3602 LoadStoreTruncation<int8_t, kMachineWord8>(); 3554 LoadStoreTruncation<int8_t, mInt8>();
3603 LoadStoreTruncation<int16_t, kMachineWord16>(); 3555 LoadStoreTruncation<int16_t, mInt16>();
3604 } 3556 }
3605 3557
3606 3558
3607 static void IntPtrCompare(intptr_t left, intptr_t right) { 3559 static void IntPtrCompare(intptr_t left, intptr_t right) {
3608 for (int test = 0; test < 7; test++) { 3560 for (int test = 0; test < 7; test++) {
3609 RawMachineAssemblerTester<bool> m(MachineOperatorBuilder::pointer_rep(), 3561 RawMachineAssemblerTester<bool> m(MachineOperatorBuilder::pointer_rep(),
3610 MachineOperatorBuilder::pointer_rep()); 3562 MachineOperatorBuilder::pointer_rep());
3611 Node* p0 = m.Parameter(0); 3563 Node* p0 = m.Parameter(0);
3612 Node* p1 = m.Parameter(1); 3564 Node* p1 = m.Parameter(1);
3613 Node* res = NULL; 3565 Node* res = NULL;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3669 int32_t outputs[kInputSize]; 3621 int32_t outputs[kInputSize];
3670 for (int i = 0; i < kInputSize; i++) { 3622 for (int i = 0; i < kInputSize; i++) {
3671 inputs[i] = i; 3623 inputs[i] = i;
3672 outputs[i] = -1; 3624 outputs[i] = -1;
3673 } 3625 }
3674 RawMachineAssemblerTester<int32_t*> m; 3626 RawMachineAssemblerTester<int32_t*> m;
3675 Node* input = m.PointerConstant(&inputs[0]); 3627 Node* input = m.PointerConstant(&inputs[0]);
3676 Node* output = m.PointerConstant(&outputs[kInputSize - 1]); 3628 Node* output = m.PointerConstant(&outputs[kInputSize - 1]);
3677 Node* elem_size = m.ConvertInt32ToIntPtr(m.Int32Constant(sizeof(inputs[0]))); 3629 Node* elem_size = m.ConvertInt32ToIntPtr(m.Int32Constant(sizeof(inputs[0])));
3678 for (int i = 0; i < kInputSize; i++) { 3630 for (int i = 0; i < kInputSize; i++) {
3679 m.Store(kMachineWord32, output, m.Load(kMachineWord32, input)); 3631 m.Store(mInt32, output, m.Load(mInt32, input));
3680 input = m.IntPtrAdd(input, elem_size); 3632 input = m.IntPtrAdd(input, elem_size);
3681 output = m.IntPtrSub(output, elem_size); 3633 output = m.IntPtrSub(output, elem_size);
3682 } 3634 }
3683 m.Return(input); 3635 m.Return(input);
3684 CHECK_EQ(&inputs[kInputSize], m.Call()); 3636 CHECK_EQ(&inputs[kInputSize], m.Call());
3685 for (int i = 0; i < kInputSize; i++) { 3637 for (int i = 0; i < kInputSize; i++) {
3686 CHECK_EQ(i, inputs[i]); 3638 CHECK_EQ(i, inputs[i]);
3687 CHECK_EQ(kInputSize - i - 1, outputs[i]); 3639 CHECK_EQ(kInputSize - i - 1, outputs[i]);
3688 } 3640 }
3689 } 3641 }
(...skipping 20 matching lines...) Expand all
3710 m.Word32Shl(bt.param0, m.Int32Sub(m.Int32Constant(32), bt.param1)), 3662 m.Word32Shl(bt.param0, m.Int32Sub(m.Int32Constant(32), bt.param1)),
3711 m.Word32Shr(bt.param0, bt.param1))); 3663 m.Word32Shr(bt.param0, bt.param1)));
3712 bt.Run(ValueHelper::uint32_vector(), ValueHelper::ror_vector(), rotr32); 3664 bt.Run(ValueHelper::uint32_vector(), ValueHelper::ror_vector(), rotr32);
3713 } 3665 }
3714 } 3666 }
3715 3667
3716 3668
3717 TEST(RunTestInt32RotateRightImm) { 3669 TEST(RunTestInt32RotateRightImm) {
3718 FOR_INPUTS(uint32_t, ror, i) { 3670 FOR_INPUTS(uint32_t, ror, i) {
3719 { 3671 {
3720 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 3672 RawMachineAssemblerTester<int32_t> m(mUint32);
3721 Node* value = m.Parameter(0); 3673 Node* value = m.Parameter(0);
3722 m.Return(m.Word32Or(m.Word32Shr(value, m.Int32Constant(*i)), 3674 m.Return(m.Word32Or(m.Word32Shr(value, m.Int32Constant(*i)),
3723 m.Word32Shl(value, m.Int32Constant(32 - *i)))); 3675 m.Word32Shl(value, m.Int32Constant(32 - *i))));
3724 m.Run(ValueHelper::uint32_vector(), 3676 m.Run(ValueHelper::uint32_vector(),
3725 std::bind2nd(std::ptr_fun(&rotr32), *i)); 3677 std::bind2nd(std::ptr_fun(&rotr32), *i));
3726 } 3678 }
3727 { 3679 {
3728 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 3680 RawMachineAssemblerTester<int32_t> m(mUint32);
3729 Node* value = m.Parameter(0); 3681 Node* value = m.Parameter(0);
3730 m.Return(m.Word32Or(m.Word32Shl(value, m.Int32Constant(32 - *i)), 3682 m.Return(m.Word32Or(m.Word32Shl(value, m.Int32Constant(32 - *i)),
3731 m.Word32Shr(value, m.Int32Constant(*i)))); 3683 m.Word32Shr(value, m.Int32Constant(*i))));
3732 m.Run(ValueHelper::uint32_vector(), 3684 m.Run(ValueHelper::uint32_vector(),
3733 std::bind2nd(std::ptr_fun(&rotr32), *i)); 3685 std::bind2nd(std::ptr_fun(&rotr32), *i));
3734 } 3686 }
3735 } 3687 }
3736 } 3688 }
3737 3689
3738 3690
3739 TEST(RunSpillLotsOfThings) { 3691 TEST(RunSpillLotsOfThings) {
3740 static const int kInputSize = 1000; 3692 static const int kInputSize = 1000;
3741 RawMachineAssemblerTester<void> m; 3693 RawMachineAssemblerTester<void> m;
3742 Node* accs[kInputSize]; 3694 Node* accs[kInputSize];
3743 int32_t outputs[kInputSize]; 3695 int32_t outputs[kInputSize];
3744 Node* one = m.Int32Constant(1); 3696 Node* one = m.Int32Constant(1);
3745 Node* acc = one; 3697 Node* acc = one;
3746 for (int i = 0; i < kInputSize; i++) { 3698 for (int i = 0; i < kInputSize; i++) {
3747 acc = m.Int32Add(acc, one); 3699 acc = m.Int32Add(acc, one);
3748 accs[i] = acc; 3700 accs[i] = acc;
3749 } 3701 }
3750 for (int i = 0; i < kInputSize; i++) { 3702 for (int i = 0; i < kInputSize; i++) {
3751 m.StoreToPointer(&outputs[i], kMachineWord32, accs[i]); 3703 m.StoreToPointer(&outputs[i], mInt32, accs[i]);
3752 } 3704 }
3753 m.Return(one); 3705 m.Return(one);
3754 m.Call(); 3706 m.Call();
3755 for (int i = 0; i < kInputSize; i++) { 3707 for (int i = 0; i < kInputSize; i++) {
3756 CHECK_EQ(outputs[i], i + 2); 3708 CHECK_EQ(outputs[i], i + 2);
3757 } 3709 }
3758 } 3710 }
3759 3711
3760 3712
3761 TEST(RunSpillConstantsAndParameters) { 3713 TEST(RunSpillConstantsAndParameters) {
3762 static const int kInputSize = 1000; 3714 static const int kInputSize = 1000;
3763 static const int32_t kBase = 987; 3715 static const int32_t kBase = 987;
3764 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); 3716 RawMachineAssemblerTester<int32_t> m(mInt32, mInt32);
3765 int32_t outputs[kInputSize]; 3717 int32_t outputs[kInputSize];
3766 Node* csts[kInputSize]; 3718 Node* csts[kInputSize];
3767 Node* accs[kInputSize]; 3719 Node* accs[kInputSize];
3768 Node* acc = m.Int32Constant(0); 3720 Node* acc = m.Int32Constant(0);
3769 for (int i = 0; i < kInputSize; i++) { 3721 for (int i = 0; i < kInputSize; i++) {
3770 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i)); 3722 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i));
3771 } 3723 }
3772 for (int i = 0; i < kInputSize; i++) { 3724 for (int i = 0; i < kInputSize; i++) {
3773 acc = m.Int32Add(acc, csts[i]); 3725 acc = m.Int32Add(acc, csts[i]);
3774 accs[i] = acc; 3726 accs[i] = acc;
3775 } 3727 }
3776 for (int i = 0; i < kInputSize; i++) { 3728 for (int i = 0; i < kInputSize; i++) {
3777 m.StoreToPointer(&outputs[i], kMachineWord32, accs[i]); 3729 m.StoreToPointer(&outputs[i], mInt32, accs[i]);
3778 } 3730 }
3779 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); 3731 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1))));
3780 FOR_INT32_INPUTS(i) { 3732 FOR_INT32_INPUTS(i) {
3781 FOR_INT32_INPUTS(j) { 3733 FOR_INT32_INPUTS(j) {
3782 int32_t expected = *i + *j; 3734 int32_t expected = *i + *j;
3783 for (int k = 0; k < kInputSize; k++) { 3735 for (int k = 0; k < kInputSize; k++) {
3784 expected += kBase + k; 3736 expected += kBase + k;
3785 } 3737 }
3786 CHECK_EQ(expected, m.Call(*i, *j)); 3738 CHECK_EQ(expected, m.Call(*i, *j));
3787 expected = 0; 3739 expected = 0;
3788 for (int k = 0; k < kInputSize; k++) { 3740 for (int k = 0; k < kInputSize; k++) {
3789 expected += kBase + k; 3741 expected += kBase + k;
3790 CHECK_EQ(expected, outputs[k]); 3742 CHECK_EQ(expected, outputs[k]);
3791 } 3743 }
3792 } 3744 }
3793 } 3745 }
3794 } 3746 }
3795 3747
3796 3748
3797 TEST(RunNewSpaceConstantsInPhi) { 3749 TEST(RunNewSpaceConstantsInPhi) {
3798 RawMachineAssemblerTester<Object*> m(kMachineWord32); 3750 RawMachineAssemblerTester<Object*> m(mInt32);
3799 3751
3800 Isolate* isolate = CcTest::i_isolate(); 3752 Isolate* isolate = CcTest::i_isolate();
3801 Handle<HeapNumber> true_val = isolate->factory()->NewHeapNumber(11.2); 3753 Handle<HeapNumber> true_val = isolate->factory()->NewHeapNumber(11.2);
3802 Handle<HeapNumber> false_val = isolate->factory()->NewHeapNumber(11.3); 3754 Handle<HeapNumber> false_val = isolate->factory()->NewHeapNumber(11.3);
3803 Node* true_node = m.HeapConstant(true_val); 3755 Node* true_node = m.HeapConstant(true_val);
3804 Node* false_node = m.HeapConstant(false_val); 3756 Node* false_node = m.HeapConstant(false_val);
3805 3757
3806 MLabel blocka, blockb, end; 3758 MLabel blocka, blockb, end;
3807 m.Branch(m.Parameter(0), &blocka, &blockb); 3759 m.Branch(m.Parameter(0), &blocka, &blockb);
3808 m.Bind(&blocka); 3760 m.Bind(&blocka);
(...skipping 21 matching lines...) Expand all
3830 Node* acc = one; 3782 Node* acc = one;
3831 for (int i = 0; i < kInputSize; i++) { 3783 for (int i = 0; i < kInputSize; i++) {
3832 acc = m.Int32Add(acc, one); 3784 acc = m.Int32Add(acc, one);
3833 accs[i] = acc; 3785 accs[i] = acc;
3834 } 3786 }
3835 // If the spill slot computation is wrong, it might load from the c frame 3787 // If the spill slot computation is wrong, it might load from the c frame
3836 { 3788 {
3837 void* func = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven)); 3789 void* func = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven));
3838 Node** args = NULL; 3790 Node** args = NULL;
3839 MachineType* arg_types = NULL; 3791 MachineType* arg_types = NULL;
3840 m.CallC(m.PointerConstant(func), kMachineWord32, arg_types, args, 0); 3792 m.CallC(m.PointerConstant(func), mInt32, arg_types, args, 0);
3841 } 3793 }
3842 for (int i = 0; i < kInputSize; i++) { 3794 for (int i = 0; i < kInputSize; i++) {
3843 m.StoreToPointer(&outputs[i], kMachineWord32, accs[i]); 3795 m.StoreToPointer(&outputs[i], mInt32, accs[i]);
3844 } 3796 }
3845 m.Return(one); 3797 m.Return(one);
3846 m.Call(); 3798 m.Call();
3847 for (int i = 0; i < kInputSize; i++) { 3799 for (int i = 0; i < kInputSize; i++) {
3848 CHECK_EQ(outputs[i], i + 2); 3800 CHECK_EQ(outputs[i], i + 2);
3849 } 3801 }
3850 } 3802 }
3851 3803
3852 #endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C 3804 #endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C
3853 3805
(...skipping 14 matching lines...) Expand all
3868 } 3820 }
3869 3821
3870 3822
3871 TEST(RunInt32AddWithOverflowP) { 3823 TEST(RunInt32AddWithOverflowP) {
3872 int32_t actual_val = -1; 3824 int32_t actual_val = -1;
3873 RawMachineAssemblerTester<int32_t> m; 3825 RawMachineAssemblerTester<int32_t> m;
3874 Int32BinopTester bt(&m); 3826 Int32BinopTester bt(&m);
3875 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); 3827 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1);
3876 Node* val = m.Projection(0, add); 3828 Node* val = m.Projection(0, add);
3877 Node* ovf = m.Projection(1, add); 3829 Node* ovf = m.Projection(1, add);
3878 m.StoreToPointer(&actual_val, kMachineWord32, val); 3830 m.StoreToPointer(&actual_val, mInt32, val);
3879 bt.AddReturn(ovf); 3831 bt.AddReturn(ovf);
3880 FOR_INT32_INPUTS(i) { 3832 FOR_INT32_INPUTS(i) {
3881 FOR_INT32_INPUTS(j) { 3833 FOR_INT32_INPUTS(j) {
3882 int32_t expected_val; 3834 int32_t expected_val;
3883 int expected_ovf = sadd_overflow(*i, *j, &expected_val); 3835 int expected_ovf = sadd_overflow(*i, *j, &expected_val);
3884 CHECK_EQ(expected_ovf, bt.call(*i, *j)); 3836 CHECK_EQ(expected_ovf, bt.call(*i, *j));
3885 CHECK_EQ(expected_val, actual_val); 3837 CHECK_EQ(expected_val, actual_val);
3886 } 3838 }
3887 } 3839 }
3888 } 3840 }
3889 3841
3890 3842
3891 TEST(RunInt32AddWithOverflowImm) { 3843 TEST(RunInt32AddWithOverflowImm) {
3892 int32_t actual_val = -1, expected_val = 0; 3844 int32_t actual_val = -1, expected_val = 0;
3893 FOR_INT32_INPUTS(i) { 3845 FOR_INT32_INPUTS(i) {
3894 { 3846 {
3895 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 3847 RawMachineAssemblerTester<int32_t> m(mInt32);
3896 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); 3848 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0));
3897 Node* val = m.Projection(0, add); 3849 Node* val = m.Projection(0, add);
3898 Node* ovf = m.Projection(1, add); 3850 Node* ovf = m.Projection(1, add);
3899 m.StoreToPointer(&actual_val, kMachineWord32, val); 3851 m.StoreToPointer(&actual_val, mInt32, val);
3900 m.Return(ovf); 3852 m.Return(ovf);
3901 FOR_INT32_INPUTS(j) { 3853 FOR_INT32_INPUTS(j) {
3902 int expected_ovf = sadd_overflow(*i, *j, &expected_val); 3854 int expected_ovf = sadd_overflow(*i, *j, &expected_val);
3903 CHECK_EQ(expected_ovf, m.Call(*j)); 3855 CHECK_EQ(expected_ovf, m.Call(*j));
3904 CHECK_EQ(expected_val, actual_val); 3856 CHECK_EQ(expected_val, actual_val);
3905 } 3857 }
3906 } 3858 }
3907 { 3859 {
3908 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 3860 RawMachineAssemblerTester<int32_t> m(mInt32);
3909 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); 3861 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i));
3910 Node* val = m.Projection(0, add); 3862 Node* val = m.Projection(0, add);
3911 Node* ovf = m.Projection(1, add); 3863 Node* ovf = m.Projection(1, add);
3912 m.StoreToPointer(&actual_val, kMachineWord32, val); 3864 m.StoreToPointer(&actual_val, mInt32, val);
3913 m.Return(ovf); 3865 m.Return(ovf);
3914 FOR_INT32_INPUTS(j) { 3866 FOR_INT32_INPUTS(j) {
3915 int expected_ovf = sadd_overflow(*i, *j, &expected_val); 3867 int expected_ovf = sadd_overflow(*i, *j, &expected_val);
3916 CHECK_EQ(expected_ovf, m.Call(*j)); 3868 CHECK_EQ(expected_ovf, m.Call(*j));
3917 CHECK_EQ(expected_val, actual_val); 3869 CHECK_EQ(expected_val, actual_val);
3918 } 3870 }
3919 } 3871 }
3920 FOR_INT32_INPUTS(j) { 3872 FOR_INT32_INPUTS(j) {
3921 RawMachineAssemblerTester<int32_t> m; 3873 RawMachineAssemblerTester<int32_t> m;
3922 Node* add = 3874 Node* add =
3923 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); 3875 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j));
3924 Node* val = m.Projection(0, add); 3876 Node* val = m.Projection(0, add);
3925 Node* ovf = m.Projection(1, add); 3877 Node* ovf = m.Projection(1, add);
3926 m.StoreToPointer(&actual_val, kMachineWord32, val); 3878 m.StoreToPointer(&actual_val, mInt32, val);
3927 m.Return(ovf); 3879 m.Return(ovf);
3928 int expected_ovf = sadd_overflow(*i, *j, &expected_val); 3880 int expected_ovf = sadd_overflow(*i, *j, &expected_val);
3929 CHECK_EQ(expected_ovf, m.Call()); 3881 CHECK_EQ(expected_ovf, m.Call());
3930 CHECK_EQ(expected_val, actual_val); 3882 CHECK_EQ(expected_val, actual_val);
3931 } 3883 }
3932 } 3884 }
3933 } 3885 }
3934 3886
3935 3887
3936 TEST(RunInt32AddWithOverflowInBranchP) { 3888 TEST(RunInt32AddWithOverflowInBranchP) {
3937 int constant = 911777; 3889 int constant = 911777;
3938 MLabel blocka, blockb; 3890 MLabel blocka, blockb;
3939 RawMachineAssemblerTester<int32_t> m; 3891 RawMachineAssemblerTester<int32_t> m;
3940 Int32BinopTester bt(&m); 3892 Int32BinopTester bt(&m);
3941 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); 3893 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1);
3942 Node* ovf = m.Projection(1, add); 3894 Node* ovf = m.Projection(1, add);
3943 m.Branch(ovf, &blocka, &blockb); 3895 m.Branch(ovf, &blocka, &blockb);
3944 m.Bind(&blocka); 3896 m.Bind(&blocka);
3945 bt.AddReturn(m.Int32Constant(constant)); 3897 bt.AddReturn(m.Int32Constant(constant));
3946 m.Bind(&blockb); 3898 m.Bind(&blockb);
3947 Node* val = m.Projection(0, add); 3899 Node* val = m.Projection(0, add);
3948 bt.AddReturn(val); 3900 bt.AddReturn(val);
3949 FOR_UINT32_INPUTS(i) { 3901 FOR_INT32_INPUTS(i) {
3950 FOR_UINT32_INPUTS(j) { 3902 FOR_INT32_INPUTS(j) {
3951 int32_t expected; 3903 int32_t expected;
3952 if (sadd_overflow(*i, *j, &expected)) expected = constant; 3904 if (sadd_overflow(*i, *j, &expected)) expected = constant;
3953 CHECK_EQ(expected, bt.call(*i, *j)); 3905 CHECK_EQ(expected, bt.call(*i, *j));
3954 } 3906 }
3955 } 3907 }
3956 } 3908 }
3957 3909
3958 3910
3959 TEST(RunInt32SubWithOverflowP) { 3911 TEST(RunInt32SubWithOverflowP) {
3960 int32_t actual_val = -1; 3912 int32_t actual_val = -1;
3961 RawMachineAssemblerTester<int32_t> m; 3913 RawMachineAssemblerTester<int32_t> m;
3962 Int32BinopTester bt(&m); 3914 Int32BinopTester bt(&m);
3963 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); 3915 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1);
3964 Node* val = m.Projection(0, add); 3916 Node* val = m.Projection(0, add);
3965 Node* ovf = m.Projection(1, add); 3917 Node* ovf = m.Projection(1, add);
3966 m.StoreToPointer(&actual_val, kMachineWord32, val); 3918 m.StoreToPointer(&actual_val, mInt32, val);
3967 bt.AddReturn(ovf); 3919 bt.AddReturn(ovf);
3968 FOR_INT32_INPUTS(i) { 3920 FOR_INT32_INPUTS(i) {
3969 FOR_INT32_INPUTS(j) { 3921 FOR_INT32_INPUTS(j) {
3970 int32_t expected_val; 3922 int32_t expected_val;
3971 int expected_ovf = ssub_overflow(*i, *j, &expected_val); 3923 int expected_ovf = ssub_overflow(*i, *j, &expected_val);
3972 CHECK_EQ(expected_ovf, bt.call(*i, *j)); 3924 CHECK_EQ(expected_ovf, bt.call(*i, *j));
3973 CHECK_EQ(expected_val, actual_val); 3925 CHECK_EQ(expected_val, actual_val);
3974 } 3926 }
3975 } 3927 }
3976 } 3928 }
3977 3929
3978 3930
3979 TEST(RunInt32SubWithOverflowImm) { 3931 TEST(RunInt32SubWithOverflowImm) {
3980 int32_t actual_val = -1, expected_val = 0; 3932 int32_t actual_val = -1, expected_val = 0;
3981 FOR_INT32_INPUTS(i) { 3933 FOR_INT32_INPUTS(i) {
3982 { 3934 {
3983 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 3935 RawMachineAssemblerTester<int32_t> m(mInt32);
3984 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); 3936 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0));
3985 Node* val = m.Projection(0, add); 3937 Node* val = m.Projection(0, add);
3986 Node* ovf = m.Projection(1, add); 3938 Node* ovf = m.Projection(1, add);
3987 m.StoreToPointer(&actual_val, kMachineWord32, val); 3939 m.StoreToPointer(&actual_val, mInt32, val);
3988 m.Return(ovf); 3940 m.Return(ovf);
3989 FOR_INT32_INPUTS(j) { 3941 FOR_INT32_INPUTS(j) {
3990 int expected_ovf = ssub_overflow(*i, *j, &expected_val); 3942 int expected_ovf = ssub_overflow(*i, *j, &expected_val);
3991 CHECK_EQ(expected_ovf, m.Call(*j)); 3943 CHECK_EQ(expected_ovf, m.Call(*j));
3992 CHECK_EQ(expected_val, actual_val); 3944 CHECK_EQ(expected_val, actual_val);
3993 } 3945 }
3994 } 3946 }
3995 { 3947 {
3996 RawMachineAssemblerTester<int32_t> m(kMachineWord32); 3948 RawMachineAssemblerTester<int32_t> m(mInt32);
3997 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); 3949 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i));
3998 Node* val = m.Projection(0, add); 3950 Node* val = m.Projection(0, add);
3999 Node* ovf = m.Projection(1, add); 3951 Node* ovf = m.Projection(1, add);
4000 m.StoreToPointer(&actual_val, kMachineWord32, val); 3952 m.StoreToPointer(&actual_val, mInt32, val);
4001 m.Return(ovf); 3953 m.Return(ovf);
4002 FOR_INT32_INPUTS(j) { 3954 FOR_INT32_INPUTS(j) {
4003 int expected_ovf = ssub_overflow(*j, *i, &expected_val); 3955 int expected_ovf = ssub_overflow(*j, *i, &expected_val);
4004 CHECK_EQ(expected_ovf, m.Call(*j)); 3956 CHECK_EQ(expected_ovf, m.Call(*j));
4005 CHECK_EQ(expected_val, actual_val); 3957 CHECK_EQ(expected_val, actual_val);
4006 } 3958 }
4007 } 3959 }
4008 FOR_INT32_INPUTS(j) { 3960 FOR_INT32_INPUTS(j) {
4009 RawMachineAssemblerTester<int32_t> m; 3961 RawMachineAssemblerTester<int32_t> m;
4010 Node* add = 3962 Node* add =
4011 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); 3963 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j));
4012 Node* val = m.Projection(0, add); 3964 Node* val = m.Projection(0, add);
4013 Node* ovf = m.Projection(1, add); 3965 Node* ovf = m.Projection(1, add);
4014 m.StoreToPointer(&actual_val, kMachineWord32, val); 3966 m.StoreToPointer(&actual_val, mInt32, val);
4015 m.Return(ovf); 3967 m.Return(ovf);
4016 int expected_ovf = ssub_overflow(*i, *j, &expected_val); 3968 int expected_ovf = ssub_overflow(*i, *j, &expected_val);
4017 CHECK_EQ(expected_ovf, m.Call()); 3969 CHECK_EQ(expected_ovf, m.Call());
4018 CHECK_EQ(expected_val, actual_val); 3970 CHECK_EQ(expected_val, actual_val);
4019 } 3971 }
4020 } 3972 }
4021 } 3973 }
4022 3974
4023 3975
4024 TEST(RunInt32SubWithOverflowInBranchP) { 3976 TEST(RunInt32SubWithOverflowInBranchP) {
4025 int constant = 911999; 3977 int constant = 911999;
4026 MLabel blocka, blockb; 3978 MLabel blocka, blockb;
4027 RawMachineAssemblerTester<int32_t> m; 3979 RawMachineAssemblerTester<int32_t> m;
4028 Int32BinopTester bt(&m); 3980 Int32BinopTester bt(&m);
4029 Node* sub = m.Int32SubWithOverflow(bt.param0, bt.param1); 3981 Node* sub = m.Int32SubWithOverflow(bt.param0, bt.param1);
4030 Node* ovf = m.Projection(1, sub); 3982 Node* ovf = m.Projection(1, sub);
4031 m.Branch(ovf, &blocka, &blockb); 3983 m.Branch(ovf, &blocka, &blockb);
4032 m.Bind(&blocka); 3984 m.Bind(&blocka);
4033 bt.AddReturn(m.Int32Constant(constant)); 3985 bt.AddReturn(m.Int32Constant(constant));
4034 m.Bind(&blockb); 3986 m.Bind(&blockb);
4035 Node* val = m.Projection(0, sub); 3987 Node* val = m.Projection(0, sub);
4036 bt.AddReturn(val); 3988 bt.AddReturn(val);
4037 FOR_UINT32_INPUTS(i) { 3989 FOR_INT32_INPUTS(i) {
4038 FOR_UINT32_INPUTS(j) { 3990 FOR_INT32_INPUTS(j) {
4039 int32_t expected; 3991 int32_t expected;
4040 if (ssub_overflow(*i, *j, &expected)) expected = constant; 3992 if (ssub_overflow(*i, *j, &expected)) expected = constant;
4041 CHECK_EQ(expected, bt.call(*i, *j)); 3993 CHECK_EQ(expected, bt.call(*i, *j));
4042 } 3994 }
4043 } 3995 }
4044 } 3996 }
4045 3997
4046 #endif // V8_TURBOFAN_TARGET 3998 #endif // V8_TURBOFAN_TARGET
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698