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 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 m.Return(n); | 1296 m.Return(n); |
1297 Stream s = m.Build(); | 1297 Stream s = m.Build(); |
1298 ASSERT_EQ(1U, s.size()); | 1298 ASSERT_EQ(1U, s.size()); |
1299 EXPECT_EQ(kX64Lzcnt32, s[0]->arch_opcode()); | 1299 EXPECT_EQ(kX64Lzcnt32, s[0]->arch_opcode()); |
1300 ASSERT_EQ(1U, s[0]->InputCount()); | 1300 ASSERT_EQ(1U, s[0]->InputCount()); |
1301 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1301 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1302 ASSERT_EQ(1U, s[0]->OutputCount()); | 1302 ASSERT_EQ(1U, s[0]->OutputCount()); |
1303 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1303 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1304 } | 1304 } |
1305 | 1305 |
| 1306 TEST_F(InstructionSelectorTest, LoadAndWord64ShiftRight32) { |
| 1307 { |
| 1308 StreamBuilder m(this, MachineType::Uint64(), MachineType::Uint32()); |
| 1309 Node* const p0 = m.Parameter(0); |
| 1310 Node* const load = m.Load(MachineType::Uint64(), p0); |
| 1311 Node* const shift = m.Word64Shr(load, m.Int32Constant(32)); |
| 1312 m.Return(shift); |
| 1313 Stream s = m.Build(); |
| 1314 ASSERT_EQ(1U, s.size()); |
| 1315 EXPECT_EQ(kX64Movl, s[0]->arch_opcode()); |
| 1316 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1317 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1318 EXPECT_EQ(4, s.ToInt32(s[0]->InputAt(1))); |
| 1319 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1320 EXPECT_EQ(s.ToVreg(shift), s.ToVreg(s[0]->Output())); |
| 1321 } |
| 1322 { |
| 1323 StreamBuilder m(this, MachineType::Int64(), MachineType::Int32()); |
| 1324 Node* const p0 = m.Parameter(0); |
| 1325 Node* const load = m.Load(MachineType::Int64(), p0); |
| 1326 Node* const shift = m.Word64Sar(load, m.Int32Constant(32)); |
| 1327 m.Return(shift); |
| 1328 Stream s = m.Build(); |
| 1329 ASSERT_EQ(1U, s.size()); |
| 1330 EXPECT_EQ(kX64Movsxlq, s[0]->arch_opcode()); |
| 1331 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1332 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1333 EXPECT_EQ(4, s.ToInt32(s[0]->InputAt(1))); |
| 1334 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1335 EXPECT_EQ(s.ToVreg(shift), s.ToVreg(s[0]->Output())); |
| 1336 } |
| 1337 { |
| 1338 StreamBuilder m(this, MachineType::Int64(), MachineType::Int32()); |
| 1339 Node* const p0 = m.Parameter(0); |
| 1340 Node* const load = m.Load(MachineType::Int64(), p0); |
| 1341 Node* const shift = m.Word64Sar(load, m.Int32Constant(32)); |
| 1342 Node* const truncate = m.TruncateInt64ToInt32(shift); |
| 1343 m.Return(truncate); |
| 1344 Stream s = m.Build(); |
| 1345 ASSERT_EQ(1U, s.size()); |
| 1346 EXPECT_EQ(kX64Movl, s[0]->arch_opcode()); |
| 1347 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1348 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1349 EXPECT_EQ(4, s.ToInt32(s[0]->InputAt(1))); |
| 1350 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1351 EXPECT_EQ(s.ToVreg(shift), s.ToVreg(s[0]->Output())); |
| 1352 } |
| 1353 } |
| 1354 |
1306 } // namespace compiler | 1355 } // namespace compiler |
1307 } // namespace internal | 1356 } // namespace internal |
1308 } // namespace v8 | 1357 } // namespace v8 |
OLD | NEW |