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 2378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2389 m.Load(MachineType::Uint32(), m.Parameter(0), m.Parameter(1)))); | 2389 m.Load(MachineType::Uint32(), m.Parameter(0), m.Parameter(1)))); |
2390 Stream s = m.Build(); | 2390 Stream s = m.Build(); |
2391 ASSERT_EQ(1U, s.size()); | 2391 ASSERT_EQ(1U, s.size()); |
2392 EXPECT_EQ(kArm64LdrW, s[0]->arch_opcode()); | 2392 EXPECT_EQ(kArm64LdrW, s[0]->arch_opcode()); |
2393 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); | 2393 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); |
2394 EXPECT_EQ(2U, s[0]->InputCount()); | 2394 EXPECT_EQ(2U, s[0]->InputCount()); |
2395 EXPECT_EQ(1U, s[0]->OutputCount()); | 2395 EXPECT_EQ(1U, s[0]->OutputCount()); |
2396 } | 2396 } |
2397 } | 2397 } |
2398 | 2398 |
| 2399 TEST_F(InstructionSelectorTest, ChangeInt32ToInt64AfterLoad) { |
| 2400 // For each case, test that the conversion is merged into the load |
| 2401 // operation. |
| 2402 // ChangeInt32ToInt64(Load_Uint8) -> Ldrb |
| 2403 { |
| 2404 StreamBuilder m(this, MachineType::Int64(), MachineType::Pointer(), |
| 2405 MachineType::Int32()); |
| 2406 m.Return(m.ChangeInt32ToInt64( |
| 2407 m.Load(MachineType::Uint8(), m.Parameter(0), m.Parameter(1)))); |
| 2408 Stream s = m.Build(); |
| 2409 ASSERT_EQ(1U, s.size()); |
| 2410 EXPECT_EQ(kArm64Ldrb, s[0]->arch_opcode()); |
| 2411 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); |
| 2412 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2413 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2414 } |
| 2415 // ChangeInt32ToInt64(Load_Int8) -> Ldrsb |
| 2416 { |
| 2417 StreamBuilder m(this, MachineType::Int64(), MachineType::Pointer(), |
| 2418 MachineType::Int32()); |
| 2419 m.Return(m.ChangeInt32ToInt64( |
| 2420 m.Load(MachineType::Int8(), m.Parameter(0), m.Parameter(1)))); |
| 2421 Stream s = m.Build(); |
| 2422 ASSERT_EQ(1U, s.size()); |
| 2423 EXPECT_EQ(kArm64Ldrsb, s[0]->arch_opcode()); |
| 2424 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); |
| 2425 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2426 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2427 } |
| 2428 // ChangeInt32ToInt64(Load_Uint16) -> Ldrh |
| 2429 { |
| 2430 StreamBuilder m(this, MachineType::Int64(), MachineType::Pointer(), |
| 2431 MachineType::Int32()); |
| 2432 m.Return(m.ChangeInt32ToInt64( |
| 2433 m.Load(MachineType::Uint16(), m.Parameter(0), m.Parameter(1)))); |
| 2434 Stream s = m.Build(); |
| 2435 ASSERT_EQ(1U, s.size()); |
| 2436 EXPECT_EQ(kArm64Ldrh, s[0]->arch_opcode()); |
| 2437 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); |
| 2438 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2439 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2440 } |
| 2441 // ChangeInt32ToInt64(Load_Int16) -> Ldrsh |
| 2442 { |
| 2443 StreamBuilder m(this, MachineType::Int64(), MachineType::Pointer(), |
| 2444 MachineType::Int32()); |
| 2445 m.Return(m.ChangeInt32ToInt64( |
| 2446 m.Load(MachineType::Int16(), m.Parameter(0), m.Parameter(1)))); |
| 2447 Stream s = m.Build(); |
| 2448 ASSERT_EQ(1U, s.size()); |
| 2449 EXPECT_EQ(kArm64Ldrsh, s[0]->arch_opcode()); |
| 2450 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); |
| 2451 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2452 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2453 } |
| 2454 // ChangeInt32ToInt64(Load_Uint32) -> Ldrsw |
| 2455 { |
| 2456 StreamBuilder m(this, MachineType::Int64(), MachineType::Pointer(), |
| 2457 MachineType::Int32()); |
| 2458 m.Return(m.ChangeInt32ToInt64( |
| 2459 m.Load(MachineType::Uint32(), m.Parameter(0), m.Parameter(1)))); |
| 2460 Stream s = m.Build(); |
| 2461 ASSERT_EQ(1U, s.size()); |
| 2462 EXPECT_EQ(kArm64Ldrsw, s[0]->arch_opcode()); |
| 2463 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); |
| 2464 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2465 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2466 } |
| 2467 // ChangeInt32ToInt64(Load_Int32) -> Ldrsw |
| 2468 { |
| 2469 StreamBuilder m(this, MachineType::Int64(), MachineType::Pointer(), |
| 2470 MachineType::Int32()); |
| 2471 m.Return(m.ChangeInt32ToInt64( |
| 2472 m.Load(MachineType::Int32(), m.Parameter(0), m.Parameter(1)))); |
| 2473 Stream s = m.Build(); |
| 2474 ASSERT_EQ(1U, s.size()); |
| 2475 EXPECT_EQ(kArm64Ldrsw, s[0]->arch_opcode()); |
| 2476 EXPECT_EQ(kMode_MRR, s[0]->addressing_mode()); |
| 2477 EXPECT_EQ(2U, s[0]->InputCount()); |
| 2478 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 2479 } |
| 2480 } |
| 2481 |
2399 // ----------------------------------------------------------------------------- | 2482 // ----------------------------------------------------------------------------- |
2400 // Memory access instructions. | 2483 // Memory access instructions. |
2401 | 2484 |
2402 | 2485 |
2403 namespace { | 2486 namespace { |
2404 | 2487 |
2405 struct MemoryAccess { | 2488 struct MemoryAccess { |
2406 MachineType type; | 2489 MachineType type; |
2407 ArchOpcode ldr_opcode; | 2490 ArchOpcode ldr_opcode; |
2408 ArchOpcode str_opcode; | 2491 ArchOpcode str_opcode; |
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4212 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); | 4295 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); |
4213 ASSERT_EQ(1U, s[0]->InputCount()); | 4296 ASSERT_EQ(1U, s[0]->InputCount()); |
4214 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 4297 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
4215 ASSERT_EQ(1U, s[0]->OutputCount()); | 4298 ASSERT_EQ(1U, s[0]->OutputCount()); |
4216 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 4299 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
4217 } | 4300 } |
4218 | 4301 |
4219 } // namespace compiler | 4302 } // namespace compiler |
4220 } // namespace internal | 4303 } // namespace internal |
4221 } // namespace v8 | 4304 } // namespace v8 |
OLD | NEW |