OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2358 } | 2358 } |
2359 } | 2359 } |
2360 } else if (source->IsFPRegister()) { | 2360 } else if (source->IsFPRegister()) { |
2361 XMMRegister src = g.ToDoubleRegister(source); | 2361 XMMRegister src = g.ToDoubleRegister(source); |
2362 if (destination->IsFPRegister()) { | 2362 if (destination->IsFPRegister()) { |
2363 XMMRegister dst = g.ToDoubleRegister(destination); | 2363 XMMRegister dst = g.ToDoubleRegister(destination); |
2364 __ Movapd(dst, src); | 2364 __ Movapd(dst, src); |
2365 } else { | 2365 } else { |
2366 DCHECK(destination->IsFPStackSlot()); | 2366 DCHECK(destination->IsFPStackSlot()); |
2367 Operand dst = g.ToOperand(destination); | 2367 Operand dst = g.ToOperand(destination); |
2368 __ Movsd(dst, src); | 2368 MachineRepresentation rep = |
2369 LocationOperand::cast(source)->representation(); | |
2370 if (rep != MachineRepresentation::kSimd128) { | |
2371 __ Movsd(dst, src); | |
2372 } else { | |
2373 __ Movups(dst, src); | |
2374 } | |
2369 } | 2375 } |
2370 } else if (source->IsFPStackSlot()) { | 2376 } else if (source->IsFPStackSlot()) { |
2371 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); | 2377 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); |
2372 Operand src = g.ToOperand(source); | 2378 Operand src = g.ToOperand(source); |
2379 MachineRepresentation rep = LocationOperand::cast(source)->representation(); | |
2373 if (destination->IsFPRegister()) { | 2380 if (destination->IsFPRegister()) { |
2374 XMMRegister dst = g.ToDoubleRegister(destination); | 2381 XMMRegister dst = g.ToDoubleRegister(destination); |
2375 __ Movsd(dst, src); | 2382 if (rep != MachineRepresentation::kSimd128) { |
2383 __ Movsd(dst, src); | |
2384 } else { | |
2385 __ Movups(dst, src); | |
2386 } | |
2376 } else { | 2387 } else { |
2377 Operand dst = g.ToOperand(destination); | 2388 Operand dst = g.ToOperand(destination); |
2378 __ Movsd(kScratchDoubleReg, src); | 2389 if (rep != MachineRepresentation::kSimd128) { |
2379 __ Movsd(dst, kScratchDoubleReg); | 2390 __ Movsd(kScratchDoubleReg, src); |
2391 __ Movsd(dst, kScratchDoubleReg); | |
2392 } else { | |
2393 __ Movups(kScratchDoubleReg, src); | |
2394 __ Movups(dst, kScratchDoubleReg); | |
2395 } | |
2380 } | 2396 } |
2381 } else { | 2397 } else { |
2382 UNREACHABLE(); | 2398 UNREACHABLE(); |
2383 } | 2399 } |
2384 } | 2400 } |
2385 | 2401 |
2386 | 2402 |
2387 void CodeGenerator::AssembleSwap(InstructionOperand* source, | 2403 void CodeGenerator::AssembleSwap(InstructionOperand* source, |
2388 InstructionOperand* destination) { | 2404 InstructionOperand* destination) { |
2389 X64OperandConverter g(this, nullptr); | 2405 X64OperandConverter g(this, nullptr); |
(...skipping 11 matching lines...) Expand all Loading... | |
2401 __ pushq(src); | 2417 __ pushq(src); |
2402 frame_access_state()->IncreaseSPDelta(1); | 2418 frame_access_state()->IncreaseSPDelta(1); |
2403 Operand dst = g.ToOperand(destination); | 2419 Operand dst = g.ToOperand(destination); |
2404 __ movq(src, dst); | 2420 __ movq(src, dst); |
2405 frame_access_state()->IncreaseSPDelta(-1); | 2421 frame_access_state()->IncreaseSPDelta(-1); |
2406 dst = g.ToOperand(destination); | 2422 dst = g.ToOperand(destination); |
2407 __ popq(dst); | 2423 __ popq(dst); |
2408 } else if ((source->IsStackSlot() && destination->IsStackSlot()) || | 2424 } else if ((source->IsStackSlot() && destination->IsStackSlot()) || |
2409 (source->IsFPStackSlot() && destination->IsFPStackSlot())) { | 2425 (source->IsFPStackSlot() && destination->IsFPStackSlot())) { |
2410 // Memory-memory. | 2426 // Memory-memory. |
2411 Register tmp = kScratchRegister; | |
2412 Operand src = g.ToOperand(source); | 2427 Operand src = g.ToOperand(source); |
2413 Operand dst = g.ToOperand(destination); | 2428 Operand dst = g.ToOperand(destination); |
2414 __ movq(tmp, dst); | 2429 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
2415 __ pushq(src); | 2430 if (rep != MachineRepresentation::kSimd128) { |
2416 frame_access_state()->IncreaseSPDelta(1); | 2431 Register tmp = kScratchRegister; |
2417 src = g.ToOperand(source); | 2432 __ movq(tmp, dst); |
2418 __ movq(src, tmp); | 2433 __ pushq(src); |
2419 frame_access_state()->IncreaseSPDelta(-1); | 2434 frame_access_state()->IncreaseSPDelta(1); |
2420 dst = g.ToOperand(destination); | 2435 src = g.ToOperand(source); |
2421 __ popq(dst); | 2436 __ movq(src, tmp); |
2437 frame_access_state()->IncreaseSPDelta(-1); | |
2438 dst = g.ToOperand(destination); | |
2439 __ popq(dst); | |
2440 } else { | |
2441 // Use the XOR trick to swap without a temporary. | |
2442 __ Movups(kScratchDoubleReg, src); | |
2443 __ xorps(kScratchDoubleReg, dst); // scratch contains src ^ dst. | |
Benedikt Meurer
2016/07/11 03:43:18
Please do the same for xorps (sorry, missed this o
bbudge
2016/07/11 17:52:44
Done. I noticed that there are existing references
| |
2444 __ Movups(src, kScratchDoubleReg); | |
2445 __ xorps(kScratchDoubleReg, dst); // scratch contains src. | |
2446 __ Movups(dst, kScratchDoubleReg); | |
2447 __ xorps(kScratchDoubleReg, src); // scratch contains dst. | |
2448 __ Movups(src, kScratchDoubleReg); | |
2449 } | |
2422 } else if (source->IsFPRegister() && destination->IsFPRegister()) { | 2450 } else if (source->IsFPRegister() && destination->IsFPRegister()) { |
2423 // XMM register-register swap. | 2451 // XMM register-register swap. |
2424 XMMRegister src = g.ToDoubleRegister(source); | 2452 XMMRegister src = g.ToDoubleRegister(source); |
2425 XMMRegister dst = g.ToDoubleRegister(destination); | 2453 XMMRegister dst = g.ToDoubleRegister(destination); |
2426 __ Movapd(kScratchDoubleReg, src); | 2454 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
2427 __ Movapd(src, dst); | 2455 if (rep != MachineRepresentation::kSimd128) { |
2428 __ Movapd(dst, kScratchDoubleReg); | 2456 __ Movapd(kScratchDoubleReg, src); |
2457 __ Movapd(src, dst); | |
2458 __ Movapd(dst, kScratchDoubleReg); | |
2459 } else { | |
2460 __ Movups(kScratchDoubleReg, src); | |
2461 __ Movups(src, dst); | |
2462 __ Movups(dst, kScratchDoubleReg); | |
2463 } | |
2429 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { | 2464 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { |
2430 // XMM register-memory swap. | 2465 // XMM register-memory swap. |
2431 XMMRegister src = g.ToDoubleRegister(source); | 2466 XMMRegister src = g.ToDoubleRegister(source); |
2432 Operand dst = g.ToOperand(destination); | 2467 Operand dst = g.ToOperand(destination); |
2433 __ Movsd(kScratchDoubleReg, src); | 2468 MachineRepresentation rep = LocationOperand::cast(source)->representation(); |
2434 __ Movsd(src, dst); | 2469 if (rep != MachineRepresentation::kSimd128) { |
2435 __ Movsd(dst, kScratchDoubleReg); | 2470 __ Movsd(kScratchDoubleReg, src); |
2471 __ Movsd(src, dst); | |
2472 __ Movsd(dst, kScratchDoubleReg); | |
2473 } else { | |
2474 __ Movups(kScratchDoubleReg, src); | |
2475 __ Movups(src, dst); | |
2476 __ Movups(dst, kScratchDoubleReg); | |
2477 } | |
2436 } else { | 2478 } else { |
2437 // No other combinations are possible. | 2479 // No other combinations are possible. |
2438 UNREACHABLE(); | 2480 UNREACHABLE(); |
2439 } | 2481 } |
2440 } | 2482 } |
2441 | 2483 |
2442 | 2484 |
2443 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { | 2485 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { |
2444 for (size_t index = 0; index < target_count; ++index) { | 2486 for (size_t index = 0; index < target_count; ++index) { |
2445 __ dq(targets[index]); | 2487 __ dq(targets[index]); |
(...skipping 14 matching lines...) Expand all Loading... | |
2460 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2502 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2461 __ Nop(padding_size); | 2503 __ Nop(padding_size); |
2462 } | 2504 } |
2463 } | 2505 } |
2464 | 2506 |
2465 #undef __ | 2507 #undef __ |
2466 | 2508 |
2467 } // namespace compiler | 2509 } // namespace compiler |
2468 } // namespace internal | 2510 } // namespace internal |
2469 } // namespace v8 | 2511 } // namespace v8 |
OLD | NEW |