| OLD | NEW |
| 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 "test/unittests/compiler/instruction-selector-unittest.h" | 5 #include "test/unittests/compiler/instruction-selector-unittest.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace compiler { | 9 namespace compiler { |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 {&RawMachineAssembler::Word64And, "Word64And", kArm64And, kMachInt64}, | 67 {&RawMachineAssembler::Word64And, "Word64And", kArm64And, kMachInt64}, |
| 68 {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Or32, kMachInt32}, | 68 {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Or32, kMachInt32}, |
| 69 {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Or, kMachInt64}, | 69 {&RawMachineAssembler::Word64Or, "Word64Or", kArm64Or, kMachInt64}, |
| 70 {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eor32, kMachInt32}, | 70 {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eor32, kMachInt32}, |
| 71 {&RawMachineAssembler::Word64Xor, "Word64Xor", kArm64Eor, kMachInt64}}; | 71 {&RawMachineAssembler::Word64Xor, "Word64Xor", kArm64Eor, kMachInt64}}; |
| 72 | 72 |
| 73 | 73 |
| 74 // ARM64 logical immediates: contiguous set bits, rotated about a power of two | 74 // ARM64 logical immediates: contiguous set bits, rotated about a power of two |
| 75 // sized block. The block is then duplicated across the word. Below is a random | 75 // sized block. The block is then duplicated across the word. Below is a random |
| 76 // subset of the 32-bit immediates. | 76 // subset of the 32-bit immediates. |
| 77 static const uint32_t kLogicalImmediates[] = { | 77 static const uint32_t kLogical32Immediates[] = { |
| 78 0x00000002, 0x00000003, 0x00000070, 0x00000080, 0x00000100, 0x000001c0, | 78 0x00000002, 0x00000003, 0x00000070, 0x00000080, 0x00000100, 0x000001c0, |
| 79 0x00000300, 0x000007e0, 0x00003ffc, 0x00007fc0, 0x0003c000, 0x0003f000, | 79 0x00000300, 0x000007e0, 0x00003ffc, 0x00007fc0, 0x0003c000, 0x0003f000, |
| 80 0x0003ffc0, 0x0003fff8, 0x0007ff00, 0x0007ffe0, 0x000e0000, 0x001e0000, | 80 0x0003ffc0, 0x0003fff8, 0x0007ff00, 0x0007ffe0, 0x000e0000, 0x001e0000, |
| 81 0x001ffffc, 0x003f0000, 0x003f8000, 0x00780000, 0x007fc000, 0x00ff0000, | 81 0x001ffffc, 0x003f0000, 0x003f8000, 0x00780000, 0x007fc000, 0x00ff0000, |
| 82 0x01800000, 0x01800180, 0x01f801f8, 0x03fe0000, 0x03ffffc0, 0x03fffffc, | 82 0x01800000, 0x01800180, 0x01f801f8, 0x03fe0000, 0x03ffffc0, 0x03fffffc, |
| 83 0x06000000, 0x07fc0000, 0x07ffc000, 0x07ffffc0, 0x07ffffe0, 0x0ffe0ffe, | 83 0x06000000, 0x07fc0000, 0x07ffc000, 0x07ffffc0, 0x07ffffe0, 0x0ffe0ffe, |
| 84 0x0ffff800, 0x0ffffff0, 0x0fffffff, 0x18001800, 0x1f001f00, 0x1f801f80, | 84 0x0ffff800, 0x0ffffff0, 0x0fffffff, 0x18001800, 0x1f001f00, 0x1f801f80, |
| 85 0x30303030, 0x3ff03ff0, 0x3ff83ff8, 0x3fff0000, 0x3fff8000, 0x3fffffc0, | 85 0x30303030, 0x3ff03ff0, 0x3ff83ff8, 0x3fff0000, 0x3fff8000, 0x3fffffc0, |
| 86 0x70007000, 0x7f7f7f7f, 0x7fc00000, 0x7fffffc0, 0x8000001f, 0x800001ff, | 86 0x70007000, 0x7f7f7f7f, 0x7fc00000, 0x7fffffc0, 0x8000001f, 0x800001ff, |
| 87 0x81818181, 0x9fff9fff, 0xc00007ff, 0xc0ffffff, 0xdddddddd, 0xe00001ff, | 87 0x81818181, 0x9fff9fff, 0xc00007ff, 0xc0ffffff, 0xdddddddd, 0xe00001ff, |
| 88 0xe00003ff, 0xe007ffff, 0xefffefff, 0xf000003f, 0xf001f001, 0xf3fff3ff, | 88 0xe00003ff, 0xe007ffff, 0xefffefff, 0xf000003f, 0xf001f001, 0xf3fff3ff, |
| 89 0xf800001f, 0xf80fffff, 0xf87ff87f, 0xfbfbfbfb, 0xfc00001f, 0xfc0000ff, | 89 0xf800001f, 0xf80fffff, 0xf87ff87f, 0xfbfbfbfb, 0xfc00001f, 0xfc0000ff, |
| 90 0xfc0001ff, 0xfc03fc03, 0xfe0001ff, 0xff000001, 0xff03ff03, 0xff800000, | 90 0xfc0001ff, 0xfc03fc03, 0xfe0001ff, 0xff000001, 0xff03ff03, 0xff800000, |
| 91 0xff800fff, 0xff801fff, 0xff87ffff, 0xffc0003f, 0xffc007ff, 0xffcfffcf, | 91 0xff800fff, 0xff801fff, 0xff87ffff, 0xffc0003f, 0xffc007ff, 0xffcfffcf, |
| 92 0xffe00003, 0xffe1ffff, 0xfff0001f, 0xfff07fff, 0xfff80007, 0xfff87fff, | 92 0xffe00003, 0xffe1ffff, 0xfff0001f, 0xfff07fff, 0xfff80007, 0xfff87fff, |
| 93 0xfffc00ff, 0xfffe07ff, 0xffff00ff, 0xffffc001, 0xfffff007, 0xfffff3ff, | 93 0xfffc00ff, 0xfffe07ff, 0xffff00ff, 0xffffc001, 0xfffff007, 0xfffff3ff, |
| 94 0xfffff807, 0xfffff9ff, 0xfffffc0f, 0xfffffeff}; | 94 0xfffff807, 0xfffff9ff, 0xfffffc0f, 0xfffffeff}; |
| 95 | 95 |
| 96 | 96 |
| 97 // Random subset of 64-bit logical immediates. |
| 98 static const uint64_t kLogical64Immediates[] = { |
| 99 0x0000000000000001, 0x0000000000000002, 0x0000000000000003, |
| 100 0x0000000000000070, 0x0000000000000080, 0x0000000000000100, |
| 101 0x00000000000001c0, 0x0000000000000300, 0x0000000000000600, |
| 102 0x00000000000007e0, 0x0000000000003ffc, 0x0000000000007fc0, |
| 103 0x0000000600000000, 0x0000003ffffffffc, 0x000000f000000000, |
| 104 0x000001f800000000, 0x0003fc0000000000, 0x0003fc000003fc00, |
| 105 0x0003ffffffc00000, 0x0003ffffffffffc0, 0x0006000000060000, |
| 106 0x003ffffffffc0000, 0x0180018001800180, 0x01f801f801f801f8, |
| 107 0x0600000000000000, 0x1000000010000000, 0x1000100010001000, |
| 108 0x1010101010101010, 0x1111111111111111, 0x1f001f001f001f00, |
| 109 0x1f1f1f1f1f1f1f1f, 0x1ffffffffffffffe, 0x3ffc3ffc3ffc3ffc, |
| 110 0x5555555555555555, 0x7f7f7f7f7f7f7f7f, 0x8000000000000000, |
| 111 0x8000001f8000001f, 0x8181818181818181, 0x9999999999999999, |
| 112 0x9fff9fff9fff9fff, 0xaaaaaaaaaaaaaaaa, 0xdddddddddddddddd, |
| 113 0xe0000000000001ff, 0xf800000000000000, 0xf8000000000001ff, |
| 114 0xf807f807f807f807, 0xfefefefefefefefe, 0xfffefffefffefffe, |
| 115 0xfffff807fffff807, 0xfffff9fffffff9ff, 0xfffffc0ffffffc0f, |
| 116 0xfffffc0fffffffff, 0xfffffefffffffeff, 0xfffffeffffffffff, |
| 117 0xffffff8000000000, 0xfffffffefffffffe, 0xffffffffefffffff, |
| 118 0xfffffffff9ffffff, 0xffffffffff800000, 0xffffffffffffc0ff, |
| 119 0xfffffffffffffffe}; |
| 120 |
| 121 |
| 97 // ARM64 arithmetic instructions. | 122 // ARM64 arithmetic instructions. |
| 98 struct AddSub { | 123 struct AddSub { |
| 99 MachInst2 mi; | 124 MachInst2 mi; |
| 100 ArchOpcode negate_arch_opcode; | 125 ArchOpcode negate_arch_opcode; |
| 101 }; | 126 }; |
| 102 | 127 |
| 103 | 128 |
| 104 std::ostream& operator<<(std::ostream& os, const AddSub& op) { | 129 std::ostream& operator<<(std::ostream& os, const AddSub& op) { |
| 105 return os << op.mi; | 130 return os << op.mi; |
| 106 } | 131 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 131 6004736, 6193152, 6385664, 6795264, 7114752, 7233536, 7348224, | 156 6004736, 6193152, 6385664, 6795264, 7114752, 7233536, 7348224, |
| 132 7499776, 7573504, 7729152, 8634368, 8937472, 9465856, 10354688, | 157 7499776, 7573504, 7729152, 8634368, 8937472, 9465856, 10354688, |
| 133 10682368, 11059200, 11460608, 13168640, 13176832, 14336000, 15028224, | 158 10682368, 11059200, 11460608, 13168640, 13176832, 14336000, 15028224, |
| 134 15597568, 15892480, 16773120}; | 159 15597568, 15892480, 16773120}; |
| 135 | 160 |
| 136 | 161 |
| 137 // ARM64 flag setting data processing instructions. | 162 // ARM64 flag setting data processing instructions. |
| 138 static const MachInst2 kDPFlagSetInstructions[] = { | 163 static const MachInst2 kDPFlagSetInstructions[] = { |
| 139 {&RawMachineAssembler::Word32And, "Word32And", kArm64Tst32, kMachInt32}, | 164 {&RawMachineAssembler::Word32And, "Word32And", kArm64Tst32, kMachInt32}, |
| 140 {&RawMachineAssembler::Int32Add, "Int32Add", kArm64Cmn32, kMachInt32}, | 165 {&RawMachineAssembler::Int32Add, "Int32Add", kArm64Cmn32, kMachInt32}, |
| 141 {&RawMachineAssembler::Int32Sub, "Int32Sub", kArm64Cmp32, kMachInt32}}; | 166 {&RawMachineAssembler::Int32Sub, "Int32Sub", kArm64Cmp32, kMachInt32}, |
| 167 {&RawMachineAssembler::Word64And, "Word64And", kArm64Tst, kMachInt64}}; |
| 142 | 168 |
| 143 | 169 |
| 144 // ARM64 arithmetic with overflow instructions. | 170 // ARM64 arithmetic with overflow instructions. |
| 145 static const MachInst2 kOvfAddSubInstructions[] = { | 171 static const MachInst2 kOvfAddSubInstructions[] = { |
| 146 {&RawMachineAssembler::Int32AddWithOverflow, "Int32AddWithOverflow", | 172 {&RawMachineAssembler::Int32AddWithOverflow, "Int32AddWithOverflow", |
| 147 kArm64Add32, kMachInt32}, | 173 kArm64Add32, kMachInt32}, |
| 148 {&RawMachineAssembler::Int32SubWithOverflow, "Int32SubWithOverflow", | 174 {&RawMachineAssembler::Int32SubWithOverflow, "Int32SubWithOverflow", |
| 149 kArm64Sub32, kMachInt32}}; | 175 kArm64Sub32, kMachInt32}}; |
| 150 | 176 |
| 151 | 177 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 EXPECT_EQ(1U, s[0]->OutputCount()); | 306 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 281 } | 307 } |
| 282 | 308 |
| 283 | 309 |
| 284 TEST_P(InstructionSelectorLogicalTest, Immediate) { | 310 TEST_P(InstructionSelectorLogicalTest, Immediate) { |
| 285 const MachInst2 dpi = GetParam(); | 311 const MachInst2 dpi = GetParam(); |
| 286 const MachineType type = dpi.machine_type; | 312 const MachineType type = dpi.machine_type; |
| 287 // TODO(all): Add support for testing 64-bit immediates. | 313 // TODO(all): Add support for testing 64-bit immediates. |
| 288 if (type == kMachInt32) { | 314 if (type == kMachInt32) { |
| 289 // Immediate on the right. | 315 // Immediate on the right. |
| 290 TRACED_FOREACH(int32_t, imm, kLogicalImmediates) { | 316 TRACED_FOREACH(int32_t, imm, kLogical32Immediates) { |
| 291 StreamBuilder m(this, type, type); | 317 StreamBuilder m(this, type, type); |
| 292 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); | 318 m.Return((m.*dpi.constructor)(m.Parameter(0), m.Int32Constant(imm))); |
| 293 Stream s = m.Build(); | 319 Stream s = m.Build(); |
| 294 ASSERT_EQ(1U, s.size()); | 320 ASSERT_EQ(1U, s.size()); |
| 295 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 321 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 296 ASSERT_EQ(2U, s[0]->InputCount()); | 322 ASSERT_EQ(2U, s[0]->InputCount()); |
| 297 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 323 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 298 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 324 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 299 EXPECT_EQ(1U, s[0]->OutputCount()); | 325 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 300 } | 326 } |
| 301 | 327 |
| 302 // Immediate on the left; all logical ops should commute. | 328 // Immediate on the left; all logical ops should commute. |
| 303 TRACED_FOREACH(int32_t, imm, kLogicalImmediates) { | 329 TRACED_FOREACH(int32_t, imm, kLogical32Immediates) { |
| 304 StreamBuilder m(this, type, type); | 330 StreamBuilder m(this, type, type); |
| 305 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); | 331 m.Return((m.*dpi.constructor)(m.Int32Constant(imm), m.Parameter(0))); |
| 306 Stream s = m.Build(); | 332 Stream s = m.Build(); |
| 307 ASSERT_EQ(1U, s.size()); | 333 ASSERT_EQ(1U, s.size()); |
| 308 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); | 334 EXPECT_EQ(dpi.arch_opcode, s[0]->arch_opcode()); |
| 309 ASSERT_EQ(2U, s[0]->InputCount()); | 335 ASSERT_EQ(2U, s[0]->InputCount()); |
| 310 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); | 336 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); |
| 311 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); | 337 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); |
| 312 EXPECT_EQ(1U, s[0]->OutputCount()); | 338 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 313 } | 339 } |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 640 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 615 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 641 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 616 } | 642 } |
| 617 | 643 |
| 618 | 644 |
| 619 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 645 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
| 620 InstructionSelectorDPFlagSetTest, | 646 InstructionSelectorDPFlagSetTest, |
| 621 ::testing::ValuesIn(kDPFlagSetInstructions)); | 647 ::testing::ValuesIn(kDPFlagSetInstructions)); |
| 622 | 648 |
| 623 | 649 |
| 624 TEST_F(InstructionSelectorTest, AndBranchWithImmediateOnRight) { | 650 TEST_F(InstructionSelectorTest, Word32AndBranchWithImmediateOnRight) { |
| 625 TRACED_FOREACH(int32_t, imm, kLogicalImmediates) { | 651 TRACED_FOREACH(int32_t, imm, kLogical32Immediates) { |
| 626 StreamBuilder m(this, kMachInt32, kMachInt32); | 652 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 627 MLabel a, b; | 653 MLabel a, b; |
| 628 m.Branch(m.Word32And(m.Parameter(0), m.Int32Constant(imm)), &a, &b); | 654 m.Branch(m.Word32And(m.Parameter(0), m.Int32Constant(imm)), &a, &b); |
| 629 m.Bind(&a); | 655 m.Bind(&a); |
| 630 m.Return(m.Int32Constant(1)); | 656 m.Return(m.Int32Constant(1)); |
| 631 m.Bind(&b); | 657 m.Bind(&b); |
| 632 m.Return(m.Int32Constant(0)); | 658 m.Return(m.Int32Constant(0)); |
| 633 Stream s = m.Build(); | 659 Stream s = m.Build(); |
| 634 ASSERT_EQ(1U, s.size()); | 660 ASSERT_EQ(1U, s.size()); |
| 635 EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode()); | 661 EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode()); |
| 636 EXPECT_EQ(4U, s[0]->InputCount()); | 662 EXPECT_EQ(4U, s[0]->InputCount()); |
| 637 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 663 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
| 638 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 664 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 639 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 665 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 640 } | 666 } |
| 641 } | 667 } |
| 642 | 668 |
| 643 | 669 |
| 670 TEST_F(InstructionSelectorTest, Word64AndBranchWithImmediateOnRight) { |
| 671 TRACED_FOREACH(int64_t, imm, kLogical64Immediates) { |
| 672 StreamBuilder m(this, kMachInt64, kMachInt64); |
| 673 MLabel a, b; |
| 674 m.Branch(m.Word64And(m.Parameter(0), m.Int64Constant(imm)), &a, &b); |
| 675 m.Bind(&a); |
| 676 m.Return(m.Int32Constant(1)); |
| 677 m.Bind(&b); |
| 678 m.Return(m.Int32Constant(0)); |
| 679 Stream s = m.Build(); |
| 680 ASSERT_EQ(1U, s.size()); |
| 681 EXPECT_EQ(kArm64Tst, s[0]->arch_opcode()); |
| 682 EXPECT_EQ(4U, s[0]->InputCount()); |
| 683 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
| 684 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 685 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 686 } |
| 687 } |
| 688 |
| 689 |
| 644 TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnRight) { | 690 TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnRight) { |
| 645 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { | 691 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { |
| 646 StreamBuilder m(this, kMachInt32, kMachInt32); | 692 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 647 MLabel a, b; | 693 MLabel a, b; |
| 648 m.Branch(m.Int32Add(m.Parameter(0), m.Int32Constant(imm)), &a, &b); | 694 m.Branch(m.Int32Add(m.Parameter(0), m.Int32Constant(imm)), &a, &b); |
| 649 m.Bind(&a); | 695 m.Bind(&a); |
| 650 m.Return(m.Int32Constant(1)); | 696 m.Return(m.Int32Constant(1)); |
| 651 m.Bind(&b); | 697 m.Bind(&b); |
| 652 m.Return(m.Int32Constant(0)); | 698 m.Return(m.Int32Constant(0)); |
| 653 Stream s = m.Build(); | 699 Stream s = m.Build(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 670 m.Return(m.Int32Constant(0)); | 716 m.Return(m.Int32Constant(0)); |
| 671 Stream s = m.Build(); | 717 Stream s = m.Build(); |
| 672 ASSERT_EQ(1U, s.size()); | 718 ASSERT_EQ(1U, s.size()); |
| 673 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); | 719 EXPECT_EQ(kArm64Cmp32, s[0]->arch_opcode()); |
| 674 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 720 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 675 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 721 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 676 } | 722 } |
| 677 } | 723 } |
| 678 | 724 |
| 679 | 725 |
| 680 TEST_F(InstructionSelectorTest, AndBranchWithImmediateOnLeft) { | 726 TEST_F(InstructionSelectorTest, Word32AndBranchWithImmediateOnLeft) { |
| 681 TRACED_FOREACH(int32_t, imm, kLogicalImmediates) { | 727 TRACED_FOREACH(int32_t, imm, kLogical32Immediates) { |
| 682 StreamBuilder m(this, kMachInt32, kMachInt32); | 728 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 683 MLabel a, b; | 729 MLabel a, b; |
| 684 m.Branch(m.Word32And(m.Int32Constant(imm), m.Parameter(0)), &a, &b); | 730 m.Branch(m.Word32And(m.Int32Constant(imm), m.Parameter(0)), &a, &b); |
| 685 m.Bind(&a); | 731 m.Bind(&a); |
| 686 m.Return(m.Int32Constant(1)); | 732 m.Return(m.Int32Constant(1)); |
| 687 m.Bind(&b); | 733 m.Bind(&b); |
| 688 m.Return(m.Int32Constant(0)); | 734 m.Return(m.Int32Constant(0)); |
| 689 Stream s = m.Build(); | 735 Stream s = m.Build(); |
| 690 ASSERT_EQ(1U, s.size()); | 736 ASSERT_EQ(1U, s.size()); |
| 691 EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode()); | 737 EXPECT_EQ(kArm64Tst32, s[0]->arch_opcode()); |
| 692 EXPECT_EQ(4U, s[0]->InputCount()); | 738 EXPECT_EQ(4U, s[0]->InputCount()); |
| 693 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); | 739 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
| 694 ASSERT_LE(1U, s[0]->InputCount()); | 740 ASSERT_LE(1U, s[0]->InputCount()); |
| 695 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); | 741 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 696 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); | 742 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 697 } | 743 } |
| 698 } | 744 } |
| 699 | 745 |
| 700 | 746 |
| 747 TEST_F(InstructionSelectorTest, Word64AndBranchWithImmediateOnLeft) { |
| 748 TRACED_FOREACH(int64_t, imm, kLogical64Immediates) { |
| 749 StreamBuilder m(this, kMachInt64, kMachInt64); |
| 750 MLabel a, b; |
| 751 m.Branch(m.Word64And(m.Int64Constant(imm), m.Parameter(0)), &a, &b); |
| 752 m.Bind(&a); |
| 753 m.Return(m.Int32Constant(1)); |
| 754 m.Bind(&b); |
| 755 m.Return(m.Int32Constant(0)); |
| 756 Stream s = m.Build(); |
| 757 ASSERT_EQ(1U, s.size()); |
| 758 EXPECT_EQ(kArm64Tst, s[0]->arch_opcode()); |
| 759 EXPECT_EQ(4U, s[0]->InputCount()); |
| 760 EXPECT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind()); |
| 761 ASSERT_LE(1U, s[0]->InputCount()); |
| 762 EXPECT_EQ(kFlags_branch, s[0]->flags_mode()); |
| 763 EXPECT_EQ(kNotEqual, s[0]->flags_condition()); |
| 764 } |
| 765 } |
| 766 |
| 767 |
| 701 TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnLeft) { | 768 TEST_F(InstructionSelectorTest, AddBranchWithImmediateOnLeft) { |
| 702 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { | 769 TRACED_FOREACH(int32_t, imm, kAddSubImmediates) { |
| 703 StreamBuilder m(this, kMachInt32, kMachInt32); | 770 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 704 MLabel a, b; | 771 MLabel a, b; |
| 705 m.Branch(m.Int32Add(m.Int32Constant(imm), m.Parameter(0)), &a, &b); | 772 m.Branch(m.Int32Add(m.Int32Constant(imm), m.Parameter(0)), &a, &b); |
| 706 m.Bind(&a); | 773 m.Bind(&a); |
| 707 m.Return(m.Int32Constant(1)); | 774 m.Return(m.Int32Constant(1)); |
| 708 m.Bind(&b); | 775 m.Bind(&b); |
| 709 m.Return(m.Int32Constant(0)); | 776 m.Return(m.Int32Constant(0)); |
| 710 Stream s = m.Build(); | 777 Stream s = m.Build(); |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 ASSERT_EQ(2U, s[1]->InputCount()); | 1848 ASSERT_EQ(2U, s[1]->InputCount()); |
| 1782 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 1849 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 1783 EXPECT_EQ(32, s.ToInt64(s[1]->InputAt(1))); | 1850 EXPECT_EQ(32, s.ToInt64(s[1]->InputAt(1))); |
| 1784 ASSERT_EQ(1U, s[1]->OutputCount()); | 1851 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 1785 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[1]->Output())); | 1852 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[1]->Output())); |
| 1786 } | 1853 } |
| 1787 | 1854 |
| 1788 } // namespace compiler | 1855 } // namespace compiler |
| 1789 } // namespace internal | 1856 } // namespace internal |
| 1790 } // namespace v8 | 1857 } // namespace v8 |
| OLD | NEW |