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

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

Powered by Google App Engine
This is Rietveld 408576698