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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // The machine_type field in MachInst1 represents the destination type. | 60 // The machine_type field in MachInst1 represents the destination type. |
61 MachInst1 mi; | 61 MachInst1 mi; |
62 MachineType src_machine_type; | 62 MachineType src_machine_type; |
63 }; | 63 }; |
64 | 64 |
65 | 65 |
66 // ---------------------------------------------------------------------------- | 66 // ---------------------------------------------------------------------------- |
67 // Logical instructions. | 67 // Logical instructions. |
68 // ---------------------------------------------------------------------------- | 68 // ---------------------------------------------------------------------------- |
69 | 69 |
70 | |
71 const MachInst2 kLogicalInstructions[] = { | 70 const MachInst2 kLogicalInstructions[] = { |
72 {&RawMachineAssembler::Word32And, "Word32And", kMips64And, | 71 {&RawMachineAssembler::Word32And, "Word32And", kMips64And32, |
73 MachineType::Int32()}, | 72 MachineType::Int32()}, |
74 {&RawMachineAssembler::Word64And, "Word64And", kMips64And, | 73 {&RawMachineAssembler::Word64And, "Word64And", kMips64And, |
75 MachineType::Int64()}, | 74 MachineType::Int64()}, |
76 {&RawMachineAssembler::Word32Or, "Word32Or", kMips64Or, | 75 {&RawMachineAssembler::Word32Or, "Word32Or", kMips64Or32, |
77 MachineType::Int32()}, | 76 MachineType::Int32()}, |
78 {&RawMachineAssembler::Word64Or, "Word64Or", kMips64Or, | 77 {&RawMachineAssembler::Word64Or, "Word64Or", kMips64Or, |
79 MachineType::Int64()}, | 78 MachineType::Int64()}, |
80 {&RawMachineAssembler::Word32Xor, "Word32Xor", kMips64Xor, | 79 {&RawMachineAssembler::Word32Xor, "Word32Xor", kMips64Xor32, |
81 MachineType::Int32()}, | 80 MachineType::Int32()}, |
82 {&RawMachineAssembler::Word64Xor, "Word64Xor", kMips64Xor, | 81 {&RawMachineAssembler::Word64Xor, "Word64Xor", kMips64Xor, |
83 MachineType::Int64()}}; | 82 MachineType::Int64()}}; |
84 | 83 |
85 | |
86 // ---------------------------------------------------------------------------- | 84 // ---------------------------------------------------------------------------- |
87 // Shift instructions. | 85 // Shift instructions. |
88 // ---------------------------------------------------------------------------- | 86 // ---------------------------------------------------------------------------- |
89 | 87 |
90 | 88 |
91 const MachInst2 kShiftInstructions[] = { | 89 const MachInst2 kShiftInstructions[] = { |
92 {&RawMachineAssembler::Word32Shl, "Word32Shl", kMips64Shl, | 90 {&RawMachineAssembler::Word32Shl, "Word32Shl", kMips64Shl, |
93 MachineType::Int32()}, | 91 MachineType::Int32()}, |
94 {&RawMachineAssembler::Word64Shl, "Word64Shl", kMips64Dshl, | 92 {&RawMachineAssembler::Word64Shl, "Word64Shl", kMips64Dshl, |
95 MachineType::Int64()}, | 93 MachineType::Int64()}, |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 533 } |
536 } | 534 } |
537 | 535 |
538 | 536 |
539 TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { | 537 TEST_F(InstructionSelectorTest, Word32XorMinusOneWithParameter) { |
540 { | 538 { |
541 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); | 539 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
542 m.Return(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1))); | 540 m.Return(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1))); |
543 Stream s = m.Build(); | 541 Stream s = m.Build(); |
544 ASSERT_EQ(1U, s.size()); | 542 ASSERT_EQ(1U, s.size()); |
545 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 543 EXPECT_EQ(kMips64Nor32, s[0]->arch_opcode()); |
546 EXPECT_EQ(2U, s[0]->InputCount()); | 544 EXPECT_EQ(2U, s[0]->InputCount()); |
547 EXPECT_EQ(1U, s[0]->OutputCount()); | 545 EXPECT_EQ(1U, s[0]->OutputCount()); |
548 } | 546 } |
549 { | 547 { |
550 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); | 548 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
551 m.Return(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0))); | 549 m.Return(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0))); |
552 Stream s = m.Build(); | 550 Stream s = m.Build(); |
553 ASSERT_EQ(1U, s.size()); | 551 ASSERT_EQ(1U, s.size()); |
554 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 552 EXPECT_EQ(kMips64Nor32, s[0]->arch_opcode()); |
555 EXPECT_EQ(2U, s[0]->InputCount()); | 553 EXPECT_EQ(2U, s[0]->InputCount()); |
556 EXPECT_EQ(1U, s[0]->OutputCount()); | 554 EXPECT_EQ(1U, s[0]->OutputCount()); |
557 } | 555 } |
558 } | 556 } |
559 | 557 |
560 | 558 |
561 TEST_F(InstructionSelectorTest, Word64XorMinusOneWithWord64Or) { | 559 TEST_F(InstructionSelectorTest, Word64XorMinusOneWithWord64Or) { |
562 { | 560 { |
563 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); | 561 StreamBuilder m(this, MachineType::Int64(), MachineType::Int64()); |
564 m.Return(m.Word64Xor(m.Word64Or(m.Parameter(0), m.Parameter(0)), | 562 m.Return(m.Word64Xor(m.Word64Or(m.Parameter(0), m.Parameter(0)), |
(...skipping 17 matching lines...) Expand all Loading... |
582 } | 580 } |
583 | 581 |
584 | 582 |
585 TEST_F(InstructionSelectorTest, Word32XorMinusOneWithWord32Or) { | 583 TEST_F(InstructionSelectorTest, Word32XorMinusOneWithWord32Or) { |
586 { | 584 { |
587 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); | 585 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
588 m.Return(m.Word32Xor(m.Word32Or(m.Parameter(0), m.Parameter(0)), | 586 m.Return(m.Word32Xor(m.Word32Or(m.Parameter(0), m.Parameter(0)), |
589 m.Int32Constant(-1))); | 587 m.Int32Constant(-1))); |
590 Stream s = m.Build(); | 588 Stream s = m.Build(); |
591 ASSERT_EQ(1U, s.size()); | 589 ASSERT_EQ(1U, s.size()); |
592 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 590 EXPECT_EQ(kMips64Nor32, s[0]->arch_opcode()); |
593 EXPECT_EQ(2U, s[0]->InputCount()); | 591 EXPECT_EQ(2U, s[0]->InputCount()); |
594 EXPECT_EQ(1U, s[0]->OutputCount()); | 592 EXPECT_EQ(1U, s[0]->OutputCount()); |
595 } | 593 } |
596 { | 594 { |
597 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); | 595 StreamBuilder m(this, MachineType::Int32(), MachineType::Int32()); |
598 m.Return(m.Word32Xor(m.Int32Constant(-1), | 596 m.Return(m.Word32Xor(m.Int32Constant(-1), |
599 m.Word32Or(m.Parameter(0), m.Parameter(0)))); | 597 m.Word32Or(m.Parameter(0), m.Parameter(0)))); |
600 Stream s = m.Build(); | 598 Stream s = m.Build(); |
601 ASSERT_EQ(1U, s.size()); | 599 ASSERT_EQ(1U, s.size()); |
602 EXPECT_EQ(kMips64Nor, s[0]->arch_opcode()); | 600 EXPECT_EQ(kMips64Nor32, s[0]->arch_opcode()); |
603 EXPECT_EQ(2U, s[0]->InputCount()); | 601 EXPECT_EQ(2U, s[0]->InputCount()); |
604 EXPECT_EQ(1U, s[0]->OutputCount()); | 602 EXPECT_EQ(1U, s[0]->OutputCount()); |
605 } | 603 } |
606 } | 604 } |
607 | 605 |
608 | 606 |
609 TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { | 607 TEST_F(InstructionSelectorTest, Word32AndWithImmediateWithWord32Shr) { |
610 // The available shift operand range is `0 <= imm < 32`, but we also test | 608 // The available shift operand range is `0 <= imm < 32`, but we also test |
611 // that immediates outside this range are handled properly (modulo-32). | 609 // that immediates outside this range are handled properly (modulo-32). |
612 TRACED_FORRANGE(int32_t, shift, -32, 63) { | 610 TRACED_FORRANGE(int32_t, shift, -32, 63) { |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 ASSERT_EQ(1U, s.size()); | 1472 ASSERT_EQ(1U, s.size()); |
1475 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); | 1473 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); |
1476 ASSERT_EQ(2U, s[0]->InputCount()); | 1474 ASSERT_EQ(2U, s[0]->InputCount()); |
1477 ASSERT_EQ(1U, s[0]->OutputCount()); | 1475 ASSERT_EQ(1U, s[0]->OutputCount()); |
1478 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1476 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1479 } | 1477 } |
1480 | 1478 |
1481 } // namespace compiler | 1479 } // namespace compiler |
1482 } // namespace internal | 1480 } // namespace internal |
1483 } // namespace v8 | 1481 } // namespace v8 |
OLD | NEW |