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 <limits> |
| 6 |
5 #include "test/unittests/compiler/instruction-selector-unittest.h" | 7 #include "test/unittests/compiler/instruction-selector-unittest.h" |
6 | 8 |
7 namespace v8 { | 9 namespace v8 { |
8 namespace internal { | 10 namespace internal { |
9 namespace compiler { | 11 namespace compiler { |
10 | 12 |
11 namespace { | 13 namespace { |
12 | 14 |
13 typedef RawMachineAssembler::Label MLabel; | 15 typedef RawMachineAssembler::Label MLabel; |
14 typedef Node* (RawMachineAssembler::*Constructor)(Node*, Node*); | 16 typedef Node* (RawMachineAssembler::*Constructor)(Node*, Node*); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 {&RawMachineAssembler::Word32Shl, "Word32Shl", 0, 31, | 81 {&RawMachineAssembler::Word32Shl, "Word32Shl", 0, 31, |
80 kMode_Operand2_R_LSL_I, kMode_Operand2_R_LSL_R}, | 82 kMode_Operand2_R_LSL_I, kMode_Operand2_R_LSL_R}, |
81 {&RawMachineAssembler::Word32Shr, "Word32Shr", 1, 32, | 83 {&RawMachineAssembler::Word32Shr, "Word32Shr", 1, 32, |
82 kMode_Operand2_R_LSR_I, kMode_Operand2_R_LSR_R}, | 84 kMode_Operand2_R_LSR_I, kMode_Operand2_R_LSR_R}, |
83 {&RawMachineAssembler::Word32Ror, "Word32Ror", 1, 31, | 85 {&RawMachineAssembler::Word32Ror, "Word32Ror", 1, 31, |
84 kMode_Operand2_R_ROR_I, kMode_Operand2_R_ROR_R}}; | 86 kMode_Operand2_R_ROR_I, kMode_Operand2_R_ROR_R}}; |
85 | 87 |
86 | 88 |
87 // Immediates (random subset). | 89 // Immediates (random subset). |
88 static const int32_t kImmediates[] = { | 90 static const int32_t kImmediates[] = { |
89 -2147483617, -2147483606, -2113929216, -2080374784, -1996488704, | 91 std::numeric_limits<int32_t>::min(), -2147483617, -2147483606, -2113929216, |
90 -1879048192, -1459617792, -1358954496, -1342177265, -1275068414, | 92 -2080374784, -1996488704, -1879048192, -1459617792, |
91 -1073741818, -1073741777, -855638016, -805306368, -402653184, | 93 -1358954496, -1342177265, -1275068414, -1073741818, |
92 -268435444, -16777216, 0, 35, 61, | 94 -1073741777, -855638016, -805306368, -402653184, |
93 105, 116, 171, 245, 255, | 95 -268435444, -16777216, 0, 35, |
94 692, 1216, 1248, 1520, 1600, | 96 61, 105, 116, 171, |
95 1888, 3744, 4080, 5888, 8384, | 97 245, 255, 692, 1216, |
96 9344, 9472, 9792, 13312, 15040, | 98 1248, 1520, 1600, 1888, |
97 15360, 20736, 22272, 23296, 32000, | 99 3744, 4080, 5888, 8384, |
98 33536, 37120, 45824, 47872, 56320, | 100 9344, 9472, 9792, 13312, |
99 59392, 65280, 72704, 101376, 147456, | 101 15040, 15360, 20736, 22272, |
100 161792, 164864, 167936, 173056, 195584, | 102 23296, 32000, 33536, 37120, |
101 209920, 212992, 356352, 655360, 704512, | 103 45824, 47872, 56320, 59392, |
102 716800, 851968, 901120, 1044480, 1523712, | 104 65280, 72704, 101376, 147456, |
103 2572288, 3211264, 3588096, 3833856, 3866624, | 105 161792, 164864, 167936, 173056, |
104 4325376, 5177344, 6488064, 7012352, 7471104, | 106 195584, 209920, 212992, 356352, |
105 14090240, 16711680, 19398656, 22282240, 28573696, | 107 655360, 704512, 716800, 851968, |
106 30408704, 30670848, 43253760, 54525952, 55312384, | 108 901120, 1044480, 1523712, 2572288, |
107 56623104, 68157440, 115343360, 131072000, 187695104, | 109 3211264, 3588096, 3833856, 3866624, |
108 188743680, 195035136, 197132288, 203423744, 218103808, | 110 4325376, 5177344, 6488064, 7012352, |
109 267386880, 268435470, 285212672, 402653185, 415236096, | 111 7471104, 14090240, 16711680, 19398656, |
110 595591168, 603979776, 603979778, 629145600, 1073741835, | 112 22282240, 28573696, 30408704, 30670848, |
111 1073741855, 1073741861, 1073741884, 1157627904, 1476395008, | 113 43253760, 54525952, 55312384, 56623104, |
112 1476395010, 1610612741, 2030043136, 2080374785, 2097152000}; | 114 68157440, 115343360, 131072000, 187695104, |
| 115 188743680, 195035136, 197132288, 203423744, |
| 116 218103808, 267386880, 268435470, 285212672, |
| 117 402653185, 415236096, 595591168, 603979776, |
| 118 603979778, 629145600, 1073741835, 1073741855, |
| 119 1073741861, 1073741884, 1157627904, 1476395008, |
| 120 1476395010, 1610612741, 2030043136, 2080374785, |
| 121 2097152000}; |
113 | 122 |
114 } // namespace | 123 } // namespace |
115 | 124 |
116 | 125 |
117 // ----------------------------------------------------------------------------- | 126 // ----------------------------------------------------------------------------- |
118 // Data processing instructions. | 127 // Data processing instructions. |
119 | 128 |
120 | 129 |
121 typedef InstructionSelectorTestWithParam<DPI> InstructionSelectorDPITest; | 130 typedef InstructionSelectorTestWithParam<DPI> InstructionSelectorDPITest; |
122 | 131 |
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); | 1776 EXPECT_EQ(kArmUbfx, s[0]->arch_opcode()); |
1768 ASSERT_EQ(3U, s[0]->InputCount()); | 1777 ASSERT_EQ(3U, s[0]->InputCount()); |
1769 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); | 1778 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1))); |
1770 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1779 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
1771 } | 1780 } |
1772 } | 1781 } |
1773 | 1782 |
1774 | 1783 |
1775 TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { | 1784 TEST_F(InstructionSelectorTest, Word32AndWithBfcImmediateForARMv7) { |
1776 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 1785 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
1777 TRACED_FORRANGE(int32_t, width, 1, (32 - lsb) - 1) { | 1786 TRACED_FORRANGE(int32_t, width, 9, (32 - lsb) - 1) { |
1778 StreamBuilder m(this, kMachInt32, kMachInt32); | 1787 StreamBuilder m(this, kMachInt32, kMachInt32); |
1779 m.Return(m.Word32And( | 1788 m.Return(m.Word32And( |
1780 m.Parameter(0), | 1789 m.Parameter(0), |
1781 m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)))); | 1790 m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)))); |
1782 Stream s = m.Build(ARMv7); | 1791 Stream s = m.Build(ARMv7); |
1783 ASSERT_EQ(1U, s.size()); | 1792 ASSERT_EQ(1U, s.size()); |
1784 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); | 1793 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); |
1785 ASSERT_EQ(1U, s[0]->OutputCount()); | 1794 ASSERT_EQ(1U, s[0]->OutputCount()); |
1786 EXPECT_TRUE( | 1795 EXPECT_TRUE( |
1787 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1796 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
1788 ASSERT_EQ(3U, s[0]->InputCount()); | 1797 ASSERT_EQ(3U, s[0]->InputCount()); |
1789 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 1798 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
1790 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1799 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
1791 } | 1800 } |
1792 } | 1801 } |
1793 TRACED_FORRANGE(int32_t, lsb, 0, 31) { | 1802 TRACED_FORRANGE(int32_t, lsb, 0, 31) { |
1794 TRACED_FORRANGE(int32_t, width, 1, (32 - lsb) - 1) { | 1803 TRACED_FORRANGE(int32_t, width, 9, (32 - lsb) - 1) { |
1795 StreamBuilder m(this, kMachInt32, kMachInt32); | 1804 StreamBuilder m(this, kMachInt32, kMachInt32); |
1796 m.Return( | 1805 m.Return( |
1797 m.Word32And(m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)), | 1806 m.Word32And(m.Int32Constant(~((0xffffffffu >> (32 - width)) << lsb)), |
1798 m.Parameter(0))); | 1807 m.Parameter(0))); |
1799 Stream s = m.Build(ARMv7); | 1808 Stream s = m.Build(ARMv7); |
1800 ASSERT_EQ(1U, s.size()); | 1809 ASSERT_EQ(1U, s.size()); |
1801 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); | 1810 EXPECT_EQ(kArmBfc, s[0]->arch_opcode()); |
1802 ASSERT_EQ(1U, s[0]->OutputCount()); | 1811 ASSERT_EQ(1U, s[0]->OutputCount()); |
1803 EXPECT_TRUE( | 1812 EXPECT_TRUE( |
1804 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); | 1813 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 ASSERT_EQ(3U, s[0]->InputCount()); | 1994 ASSERT_EQ(3U, s[0]->InputCount()); |
1986 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); | 1995 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); |
1987 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); | 1996 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); |
1988 } | 1997 } |
1989 } | 1998 } |
1990 } | 1999 } |
1991 | 2000 |
1992 } // namespace compiler | 2001 } // namespace compiler |
1993 } // namespace internal | 2002 } // namespace internal |
1994 } // namespace v8 | 2003 } // namespace v8 |
OLD | NEW |