Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: src/compiler/x64/code-generator-x64.cc

Issue 2139513002: [Turbofan] Support 128 bit moves/swaps for x64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 if (destination->IsFPRegister()) { 2352 if (destination->IsFPRegister()) {
2353 __ Move(g.ToDoubleRegister(destination), src_const); 2353 __ Move(g.ToDoubleRegister(destination), src_const);
2354 } else { 2354 } else {
2355 DCHECK(destination->IsFPStackSlot()); 2355 DCHECK(destination->IsFPStackSlot());
2356 __ movq(kScratchRegister, src_const); 2356 __ movq(kScratchRegister, src_const);
2357 __ movq(g.ToOperand(destination), kScratchRegister); 2357 __ movq(g.ToOperand(destination), kScratchRegister);
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 MachineRepresentation rep = LocationOperand::cast(source)->representation();
2362 if (destination->IsFPRegister()) { 2363 if (destination->IsFPRegister()) {
2363 XMMRegister dst = g.ToDoubleRegister(destination); 2364 XMMRegister dst = g.ToDoubleRegister(destination);
2364 __ Movapd(dst, src); 2365 if (rep != MachineRepresentation::kSimd128) {
Benedikt Meurer 2016/07/10 17:21:06 Can't we always do Movapd here?
bbudge 2016/07/10 22:45:22 You're right. Replaced original code.
2366 __ Movapd(dst, src);
2367 } else {
2368 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2369 __ movups(dst, src);
2370 }
2365 } else { 2371 } else {
2366 DCHECK(destination->IsFPStackSlot()); 2372 DCHECK(destination->IsFPStackSlot());
2367 Operand dst = g.ToOperand(destination); 2373 Operand dst = g.ToOperand(destination);
2368 __ Movsd(dst, src); 2374 if (rep != MachineRepresentation::kSimd128) {
2375 __ Movsd(dst, src);
2376 } else {
2377 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2378 __ movups(dst, src);
Benedikt Meurer 2016/07/10 17:21:06 You should introduce Movups, that uses AVX instruc
bbudge 2016/07/10 22:45:22 Done.
2379 }
2369 } 2380 }
2370 } else if (source->IsFPStackSlot()) { 2381 } else if (source->IsFPStackSlot()) {
2371 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); 2382 DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot());
2372 Operand src = g.ToOperand(source); 2383 Operand src = g.ToOperand(source);
2384 MachineRepresentation rep = LocationOperand::cast(source)->representation();
2373 if (destination->IsFPRegister()) { 2385 if (destination->IsFPRegister()) {
2374 XMMRegister dst = g.ToDoubleRegister(destination); 2386 XMMRegister dst = g.ToDoubleRegister(destination);
2375 __ Movsd(dst, src); 2387 if (rep != MachineRepresentation::kSimd128) {
2388 __ Movsd(dst, src);
2389 } else {
2390 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2391 __ movups(dst, src);
2392 }
2376 } else { 2393 } else {
2377 Operand dst = g.ToOperand(destination); 2394 Operand dst = g.ToOperand(destination);
2378 __ Movsd(kScratchDoubleReg, src); 2395 if (rep != MachineRepresentation::kSimd128) {
2379 __ Movsd(dst, kScratchDoubleReg); 2396 __ Movsd(kScratchDoubleReg, src);
2397 __ Movsd(dst, kScratchDoubleReg);
2398 } else {
2399 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2400 __ movups(kScratchDoubleReg, src);
2401 __ movups(dst, kScratchDoubleReg);
2402 }
2380 } 2403 }
2381 } else { 2404 } else {
2382 UNREACHABLE(); 2405 UNREACHABLE();
2383 } 2406 }
2384 } 2407 }
2385 2408
2386 2409
2387 void CodeGenerator::AssembleSwap(InstructionOperand* source, 2410 void CodeGenerator::AssembleSwap(InstructionOperand* source,
2388 InstructionOperand* destination) { 2411 InstructionOperand* destination) {
2389 X64OperandConverter g(this, nullptr); 2412 X64OperandConverter g(this, nullptr);
(...skipping 11 matching lines...) Expand all
2401 __ pushq(src); 2424 __ pushq(src);
2402 frame_access_state()->IncreaseSPDelta(1); 2425 frame_access_state()->IncreaseSPDelta(1);
2403 Operand dst = g.ToOperand(destination); 2426 Operand dst = g.ToOperand(destination);
2404 __ movq(src, dst); 2427 __ movq(src, dst);
2405 frame_access_state()->IncreaseSPDelta(-1); 2428 frame_access_state()->IncreaseSPDelta(-1);
2406 dst = g.ToOperand(destination); 2429 dst = g.ToOperand(destination);
2407 __ popq(dst); 2430 __ popq(dst);
2408 } else if ((source->IsStackSlot() && destination->IsStackSlot()) || 2431 } else if ((source->IsStackSlot() && destination->IsStackSlot()) ||
2409 (source->IsFPStackSlot() && destination->IsFPStackSlot())) { 2432 (source->IsFPStackSlot() && destination->IsFPStackSlot())) {
2410 // Memory-memory. 2433 // Memory-memory.
2411 Register tmp = kScratchRegister;
2412 Operand src = g.ToOperand(source); 2434 Operand src = g.ToOperand(source);
2413 Operand dst = g.ToOperand(destination); 2435 Operand dst = g.ToOperand(destination);
2414 __ movq(tmp, dst); 2436 MachineRepresentation rep = LocationOperand::cast(source)->representation();
2415 __ pushq(src); 2437 if (rep != MachineRepresentation::kSimd128) {
2416 frame_access_state()->IncreaseSPDelta(1); 2438 Register tmp = kScratchRegister;
2417 src = g.ToOperand(source); 2439 __ movq(tmp, dst);
2418 __ movq(src, tmp); 2440 __ pushq(src);
2419 frame_access_state()->IncreaseSPDelta(-1); 2441 frame_access_state()->IncreaseSPDelta(1);
2420 dst = g.ToOperand(destination); 2442 src = g.ToOperand(source);
2421 __ popq(dst); 2443 __ movq(src, tmp);
2444 frame_access_state()->IncreaseSPDelta(-1);
2445 dst = g.ToOperand(destination);
2446 __ popq(dst);
2447 } else {
2448 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2449 // Use the XOR trick to swap without a temporary.
2450 __ movups(kScratchDoubleReg, src);
2451 __ xorps(kScratchDoubleReg, dst); // scratch contains src ^ dst.
2452 __ movups(src, kScratchDoubleReg);
2453 __ xorps(kScratchDoubleReg, dst); // scratch contains src.
2454 __ movups(dst, kScratchDoubleReg);
2455 __ xorps(kScratchDoubleReg, src); // scratch contains dst.
2456 __ movups(src, kScratchDoubleReg);
2457 }
2422 } else if (source->IsFPRegister() && destination->IsFPRegister()) { 2458 } else if (source->IsFPRegister() && destination->IsFPRegister()) {
2423 // XMM register-register swap. 2459 // XMM register-register swap.
2424 XMMRegister src = g.ToDoubleRegister(source); 2460 XMMRegister src = g.ToDoubleRegister(source);
2425 XMMRegister dst = g.ToDoubleRegister(destination); 2461 XMMRegister dst = g.ToDoubleRegister(destination);
2426 __ Movapd(kScratchDoubleReg, src); 2462 MachineRepresentation rep = LocationOperand::cast(source)->representation();
2427 __ Movapd(src, dst); 2463 if (rep != MachineRepresentation::kSimd128) {
2428 __ Movapd(dst, kScratchDoubleReg); 2464 __ Movapd(kScratchDoubleReg, src);
2465 __ Movapd(src, dst);
2466 __ Movapd(dst, kScratchDoubleReg);
2467 } else {
2468 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2469 __ movups(kScratchDoubleReg, src);
2470 __ movups(src, dst);
2471 __ movups(dst, kScratchDoubleReg);
2472 }
2429 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) { 2473 } else if (source->IsFPRegister() && destination->IsFPStackSlot()) {
2430 // XMM register-memory swap. 2474 // XMM register-memory swap.
2431 XMMRegister src = g.ToDoubleRegister(source); 2475 XMMRegister src = g.ToDoubleRegister(source);
2432 Operand dst = g.ToOperand(destination); 2476 Operand dst = g.ToOperand(destination);
2433 __ Movsd(kScratchDoubleReg, src); 2477 MachineRepresentation rep = LocationOperand::cast(source)->representation();
2434 __ Movsd(src, dst); 2478 if (rep != MachineRepresentation::kSimd128) {
2435 __ Movsd(dst, kScratchDoubleReg); 2479 __ Movsd(kScratchDoubleReg, src);
2480 __ Movsd(src, dst);
2481 __ Movsd(dst, kScratchDoubleReg);
2482 } else {
2483 DCHECK_EQ(MachineRepresentation::kSimd128, rep);
2484 __ movups(kScratchDoubleReg, src);
2485 __ movups(src, dst);
2486 __ movups(dst, kScratchDoubleReg);
2487 }
2436 } else { 2488 } else {
2437 // No other combinations are possible. 2489 // No other combinations are possible.
2438 UNREACHABLE(); 2490 UNREACHABLE();
2439 } 2491 }
2440 } 2492 }
2441 2493
2442 2494
2443 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { 2495 void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) {
2444 for (size_t index = 0; index < target_count; ++index) { 2496 for (size_t index = 0; index < target_count; ++index) {
2445 __ dq(targets[index]); 2497 __ dq(targets[index]);
(...skipping 14 matching lines...) Expand all
2460 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 2512 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
2461 __ Nop(padding_size); 2513 __ Nop(padding_size);
2462 } 2514 }
2463 } 2515 }
2464 2516
2465 #undef __ 2517 #undef __
2466 2518
2467 } // namespace compiler 2519 } // namespace compiler
2468 } // namespace internal 2520 } // namespace internal
2469 } // namespace v8 2521 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698