| 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 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2359 EXPECT_EQ(kArm64Asr, s[1]->arch_opcode()); | 2359 EXPECT_EQ(kArm64Asr, s[1]->arch_opcode()); |
| 2360 ASSERT_EQ(2U, s[1]->InputCount()); | 2360 ASSERT_EQ(2U, s[1]->InputCount()); |
| 2361 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); | 2361 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); |
| 2362 EXPECT_EQ(32, s.ToInt64(s[1]->InputAt(1))); | 2362 EXPECT_EQ(32, s.ToInt64(s[1]->InputAt(1))); |
| 2363 ASSERT_EQ(1U, s[1]->OutputCount()); | 2363 ASSERT_EQ(1U, s[1]->OutputCount()); |
| 2364 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[1]->Output())); | 2364 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[1]->Output())); |
| 2365 } | 2365 } |
| 2366 | 2366 |
| 2367 | 2367 |
| 2368 TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { | 2368 TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) { |
| 2369 { | 2369 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
| 2370 StreamBuilder m(this, kMachInt32, kMachInt32); | 2370 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 2371 Node* const p0 = m.Parameter(0); | 2371 Node* const p0 = m.Parameter(0); |
| 2372 Node* const r = | 2372 Node* const r = m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(shift)), |
| 2373 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24)); | 2373 m.Int32Constant(shift)); |
| 2374 m.Return(r); | 2374 m.Return(r); |
| 2375 Stream s = m.Build(); | 2375 Stream s = m.Build(); |
| 2376 ASSERT_EQ(1U, s.size()); | 2376 ASSERT_EQ(1U, s.size()); |
| 2377 EXPECT_EQ(kArm64Sxtb32, s[0]->arch_opcode()); | 2377 EXPECT_EQ(kArm64Sbfx32, s[0]->arch_opcode()); |
| 2378 ASSERT_EQ(1U, s[0]->InputCount()); | 2378 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2379 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2379 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2380 ASSERT_EQ(1U, s[0]->OutputCount()); | 2380 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2381 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2381 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2382 } | 2382 } |
| 2383 { | 2383 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
| 2384 StreamBuilder m(this, kMachInt32, kMachInt32); | 2384 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 2385 Node* const p0 = m.Parameter(0); | 2385 Node* const p0 = m.Parameter(0); |
| 2386 Node* const r = | 2386 Node* const r = m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(shift + 32)), |
| 2387 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16)); | 2387 m.Int32Constant(shift + 64)); |
| 2388 m.Return(r); | 2388 m.Return(r); |
| 2389 Stream s = m.Build(); | 2389 Stream s = m.Build(); |
| 2390 ASSERT_EQ(1U, s.size()); | 2390 ASSERT_EQ(1U, s.size()); |
| 2391 EXPECT_EQ(kArm64Sxth32, s[0]->arch_opcode()); | 2391 EXPECT_EQ(kArm64Sbfx32, s[0]->arch_opcode()); |
| 2392 ASSERT_EQ(1U, s[0]->InputCount()); | 2392 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2393 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2393 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2394 ASSERT_EQ(1U, s[0]->OutputCount()); | 2394 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2395 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); | 2395 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2396 } |
| 2397 } |
| 2398 |
| 2399 |
| 2400 TEST_F(InstructionSelectorTest, Word32ShrWithWord32Shl) { |
| 2401 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
| 2402 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 2403 Node* const p0 = m.Parameter(0); |
| 2404 Node* const r = m.Word32Shr(m.Word32Shl(p0, m.Int32Constant(shift)), |
| 2405 m.Int32Constant(shift)); |
| 2406 m.Return(r); |
| 2407 Stream s = m.Build(); |
| 2408 ASSERT_EQ(1U, s.size()); |
| 2409 EXPECT_EQ(kArm64Ubfx32, s[0]->arch_opcode()); |
| 2410 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2411 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2412 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2413 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2414 } |
| 2415 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
| 2416 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 2417 Node* const p0 = m.Parameter(0); |
| 2418 Node* const r = m.Word32Shr(m.Word32Shl(p0, m.Int32Constant(shift + 32)), |
| 2419 m.Int32Constant(shift + 64)); |
| 2420 m.Return(r); |
| 2421 Stream s = m.Build(); |
| 2422 ASSERT_EQ(1U, s.size()); |
| 2423 EXPECT_EQ(kArm64Ubfx32, s[0]->arch_opcode()); |
| 2424 ASSERT_EQ(3U, s[0]->InputCount()); |
| 2425 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2426 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2427 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output())); |
| 2396 } | 2428 } |
| 2397 } | 2429 } |
| 2398 | 2430 |
| 2399 | 2431 |
| 2400 TEST_F(InstructionSelectorTest, Word32Clz) { | 2432 TEST_F(InstructionSelectorTest, Word32Clz) { |
| 2401 StreamBuilder m(this, kMachUint32, kMachUint32); | 2433 StreamBuilder m(this, kMachUint32, kMachUint32); |
| 2402 Node* const p0 = m.Parameter(0); | 2434 Node* const p0 = m.Parameter(0); |
| 2403 Node* const n = m.Word32Clz(p0); | 2435 Node* const n = m.Word32Clz(p0); |
| 2404 m.Return(n); | 2436 m.Return(n); |
| 2405 Stream s = m.Build(); | 2437 Stream s = m.Build(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2452 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); | 2484 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); |
| 2453 ASSERT_EQ(1U, s[0]->InputCount()); | 2485 ASSERT_EQ(1U, s[0]->InputCount()); |
| 2454 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 2486 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 2455 ASSERT_EQ(1U, s[0]->OutputCount()); | 2487 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 2456 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 2488 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 2457 } | 2489 } |
| 2458 | 2490 |
| 2459 } // namespace compiler | 2491 } // namespace compiler |
| 2460 } // namespace internal | 2492 } // namespace internal |
| 2461 } // namespace v8 | 2493 } // namespace v8 |
| OLD | NEW |