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

Side by Side Diff: src/compiler/x64/instruction-selector-x64.cc

Issue 2623633003: [Atomics] Make Atomics.exchange a builtin using TF (Closed)
Patch Set: [Atomics] Make Atomics.exchange a builtin using TF Created 3 years, 11 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
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "src/base/adapters.h" 7 #include "src/base/adapters.h"
8 #include "src/compiler/instruction-selector-impl.h" 8 #include "src/compiler/instruction-selector-impl.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 void InstructionSelector::VisitAtomicStore(Node* node) { 2355 void InstructionSelector::VisitAtomicStore(Node* node) {
2356 X64OperandGenerator g(this); 2356 X64OperandGenerator g(this);
2357 Node* base = node->InputAt(0); 2357 Node* base = node->InputAt(0);
2358 Node* index = node->InputAt(1); 2358 Node* index = node->InputAt(1);
2359 Node* value = node->InputAt(2); 2359 Node* value = node->InputAt(2);
2360 2360
2361 MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); 2361 MachineRepresentation rep = AtomicStoreRepresentationOf(node->op());
2362 ArchOpcode opcode = kArchNop; 2362 ArchOpcode opcode = kArchNop;
2363 switch (rep) { 2363 switch (rep) {
2364 case MachineRepresentation::kWord8: 2364 case MachineRepresentation::kWord8:
2365 opcode = kX64Xchgb; 2365 opcode = kAtomicExchangeInt8;
2366 break; 2366 break;
2367 case MachineRepresentation::kWord16: 2367 case MachineRepresentation::kWord16:
2368 opcode = kX64Xchgw; 2368 opcode = kAtomicExchangeInt16;
2369 break; 2369 break;
2370 case MachineRepresentation::kWord32: 2370 case MachineRepresentation::kWord32:
2371 opcode = kX64Xchgl; 2371 opcode = kAtomicExchangeWord32;
2372 break; 2372 break;
2373 default: 2373 default:
2374 UNREACHABLE(); 2374 UNREACHABLE();
2375 return; 2375 return;
2376 } 2376 }
2377 AddressingMode addressing_mode; 2377 AddressingMode addressing_mode;
2378 InstructionOperand inputs[4]; 2378 InstructionOperand inputs[4];
2379 size_t input_count = 0; 2379 size_t input_count = 0;
2380 inputs[input_count++] = g.UseUniqueRegister(value);
2380 inputs[input_count++] = g.UseUniqueRegister(base); 2381 inputs[input_count++] = g.UseUniqueRegister(base);
2381 if (g.CanBeImmediate(index)) { 2382 if (g.CanBeImmediate(index)) {
2382 inputs[input_count++] = g.UseImmediate(index); 2383 inputs[input_count++] = g.UseImmediate(index);
2383 addressing_mode = kMode_MRI; 2384 addressing_mode = kMode_MRI;
2384 } else { 2385 } else {
2385 inputs[input_count++] = g.UseUniqueRegister(index); 2386 inputs[input_count++] = g.UseUniqueRegister(index);
2386 addressing_mode = kMode_MR1; 2387 addressing_mode = kMode_MR1;
2387 } 2388 }
2388 inputs[input_count++] = g.UseUniqueRegister(value);
2389 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); 2389 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
2390 Emit(code, 0, static_cast<InstructionOperand*>(nullptr), input_count, inputs); 2390 Emit(code, 0, static_cast<InstructionOperand*>(nullptr), input_count, inputs);
2391 } 2391 }
2392 2392
2393 void InstructionSelector::VisitAtomicExchange(Node* node) {
2394 X64OperandGenerator g(this);
2395 Node* base = node->InputAt(0);
2396 Node* index = node->InputAt(1);
2397 Node* value = node->InputAt(2);
2398
2399 MachineType type = AtomicExchangeRepresentationOf(node->op());
2400 ArchOpcode opcode = kArchNop;
2401 if (type == MachineType::Int8()) {
2402 opcode = kAtomicExchangeInt8;
2403 } else if (type == MachineType::Uint8()) {
2404 opcode = kAtomicExchangeUint8;
2405 } else if (type == MachineType::Int16()) {
2406 opcode = kAtomicExchangeInt16;
2407 } else if (type == MachineType::Uint16()) {
2408 opcode = kAtomicExchangeUint16;
2409 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
2410 opcode = kAtomicExchangeWord32;
2411 } else {
2412 UNREACHABLE();
2413 return;
2414 }
2415 InstructionOperand outputs[1];
2416 AddressingMode addressing_mode;
2417 InstructionOperand inputs[4];
2418 size_t input_count = 0;
2419 inputs[input_count++] = g.UseUniqueRegister(value);
2420 inputs[input_count++] = g.UseUniqueRegister(base);
2421 if (g.CanBeImmediate(index)) {
2422 inputs[input_count++] = g.UseImmediate(index);
2423 addressing_mode = kMode_MRI;
2424 } else {
2425 inputs[input_count++] = g.UseUniqueRegister(index);
2426 addressing_mode = kMode_MR1;
2427 }
2428 outputs[0] = g.DefineSameAsFirst(node);
2429 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
2430 Emit(code, 1, outputs, input_count, inputs);
2431 }
2432
2393 void InstructionSelector::VisitCreateInt32x4(Node* node) { 2433 void InstructionSelector::VisitCreateInt32x4(Node* node) {
2394 X64OperandGenerator g(this); 2434 X64OperandGenerator g(this);
2395 Emit(kX64Int32x4Create, g.DefineAsRegister(node), g.Use(node->InputAt(0))); 2435 Emit(kX64Int32x4Create, g.DefineAsRegister(node), g.Use(node->InputAt(0)));
2396 } 2436 }
2397 2437
2398 void InstructionSelector::VisitInt32x4ExtractLane(Node* node) { 2438 void InstructionSelector::VisitInt32x4ExtractLane(Node* node) {
2399 X64OperandGenerator g(this); 2439 X64OperandGenerator g(this);
2400 int32_t lane = OpParameter<int32_t>(node); 2440 int32_t lane = OpParameter<int32_t>(node);
2401 Emit(kX64Int32x4ExtractLane, g.DefineAsRegister(node), 2441 Emit(kX64Int32x4ExtractLane, g.DefineAsRegister(node),
2402 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); 2442 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 // static 2488 // static
2449 MachineOperatorBuilder::AlignmentRequirements 2489 MachineOperatorBuilder::AlignmentRequirements
2450 InstructionSelector::AlignmentRequirements() { 2490 InstructionSelector::AlignmentRequirements() {
2451 return MachineOperatorBuilder::AlignmentRequirements:: 2491 return MachineOperatorBuilder::AlignmentRequirements::
2452 FullUnalignedAccessSupport(); 2492 FullUnalignedAccessSupport();
2453 } 2493 }
2454 2494
2455 } // namespace compiler 2495 } // namespace compiler
2456 } // namespace internal 2496 } // namespace internal
2457 } // namespace v8 2497 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698