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

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

Issue 2623633003: [Atomics] Make Atomics.exchange a builtin using TF (Closed)
Patch Set: remove 0 extend for arm Created 3 years, 9 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 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 void InstructionSelector::VisitAtomicStore(Node* node) { 2239 void InstructionSelector::VisitAtomicStore(Node* node) {
2240 X64OperandGenerator g(this); 2240 X64OperandGenerator g(this);
2241 Node* base = node->InputAt(0); 2241 Node* base = node->InputAt(0);
2242 Node* index = node->InputAt(1); 2242 Node* index = node->InputAt(1);
2243 Node* value = node->InputAt(2); 2243 Node* value = node->InputAt(2);
2244 2244
2245 MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); 2245 MachineRepresentation rep = AtomicStoreRepresentationOf(node->op());
2246 ArchOpcode opcode = kArchNop; 2246 ArchOpcode opcode = kArchNop;
2247 switch (rep) { 2247 switch (rep) {
2248 case MachineRepresentation::kWord8: 2248 case MachineRepresentation::kWord8:
2249 opcode = kX64Xchgb; 2249 opcode = kAtomicExchangeInt8;
2250 break; 2250 break;
2251 case MachineRepresentation::kWord16: 2251 case MachineRepresentation::kWord16:
2252 opcode = kX64Xchgw; 2252 opcode = kAtomicExchangeInt16;
2253 break; 2253 break;
2254 case MachineRepresentation::kWord32: 2254 case MachineRepresentation::kWord32:
2255 opcode = kX64Xchgl; 2255 opcode = kAtomicExchangeWord32;
2256 break; 2256 break;
2257 default: 2257 default:
2258 UNREACHABLE(); 2258 UNREACHABLE();
2259 return; 2259 return;
2260 } 2260 }
2261 AddressingMode addressing_mode; 2261 AddressingMode addressing_mode;
2262 InstructionOperand inputs[4]; 2262 InstructionOperand inputs[4];
2263 size_t input_count = 0; 2263 size_t input_count = 0;
2264 inputs[input_count++] = g.UseUniqueRegister(value);
2264 inputs[input_count++] = g.UseUniqueRegister(base); 2265 inputs[input_count++] = g.UseUniqueRegister(base);
2265 if (g.CanBeImmediate(index)) { 2266 if (g.CanBeImmediate(index)) {
2266 inputs[input_count++] = g.UseImmediate(index); 2267 inputs[input_count++] = g.UseImmediate(index);
2267 addressing_mode = kMode_MRI; 2268 addressing_mode = kMode_MRI;
2268 } else { 2269 } else {
2269 inputs[input_count++] = g.UseUniqueRegister(index); 2270 inputs[input_count++] = g.UseUniqueRegister(index);
2270 addressing_mode = kMode_MR1; 2271 addressing_mode = kMode_MR1;
2271 } 2272 }
2272 inputs[input_count++] = g.UseUniqueRegister(value);
2273 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); 2273 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
2274 Emit(code, 0, static_cast<InstructionOperand*>(nullptr), input_count, inputs); 2274 Emit(code, 0, static_cast<InstructionOperand*>(nullptr), input_count, inputs);
2275 } 2275 }
2276 2276
2277 void InstructionSelector::VisitAtomicExchange(Node* node) {
2278 X64OperandGenerator g(this);
2279 Node* base = node->InputAt(0);
2280 Node* index = node->InputAt(1);
2281 Node* value = node->InputAt(2);
2282
2283 MachineType type = AtomicExchangeRepresentationOf(node->op());
2284 ArchOpcode opcode = kArchNop;
2285 if (type == MachineType::Int8()) {
2286 opcode = kAtomicExchangeInt8;
2287 } else if (type == MachineType::Uint8()) {
2288 opcode = kAtomicExchangeUint8;
2289 } else if (type == MachineType::Int16()) {
2290 opcode = kAtomicExchangeInt16;
2291 } else if (type == MachineType::Uint16()) {
2292 opcode = kAtomicExchangeUint16;
2293 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
2294 opcode = kAtomicExchangeWord32;
2295 } else {
2296 UNREACHABLE();
2297 return;
2298 }
2299 InstructionOperand outputs[1];
2300 AddressingMode addressing_mode;
2301 InstructionOperand inputs[4];
2302 size_t input_count = 0;
2303 inputs[input_count++] = g.UseUniqueRegister(value);
2304 inputs[input_count++] = g.UseUniqueRegister(base);
2305 if (g.CanBeImmediate(index)) {
2306 inputs[input_count++] = g.UseImmediate(index);
2307 addressing_mode = kMode_MRI;
2308 } else {
2309 inputs[input_count++] = g.UseUniqueRegister(index);
2310 addressing_mode = kMode_MR1;
2311 }
2312 outputs[0] = g.DefineSameAsFirst(node);
2313 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
2314 Emit(code, 1, outputs, input_count, inputs);
2315 }
2316
2277 void InstructionSelector::VisitInt32x4Splat(Node* node) { 2317 void InstructionSelector::VisitInt32x4Splat(Node* node) {
2278 X64OperandGenerator g(this); 2318 X64OperandGenerator g(this);
2279 Emit(kX64Int32x4Splat, g.DefineAsRegister(node), g.Use(node->InputAt(0))); 2319 Emit(kX64Int32x4Splat, g.DefineAsRegister(node), g.Use(node->InputAt(0)));
2280 } 2320 }
2281 2321
2282 void InstructionSelector::VisitInt32x4ExtractLane(Node* node) { 2322 void InstructionSelector::VisitInt32x4ExtractLane(Node* node) {
2283 X64OperandGenerator g(this); 2323 X64OperandGenerator g(this);
2284 int32_t lane = OpParameter<int32_t>(node); 2324 int32_t lane = OpParameter<int32_t>(node);
2285 Emit(kX64Int32x4ExtractLane, g.DefineAsRegister(node), 2325 Emit(kX64Int32x4ExtractLane, g.DefineAsRegister(node),
2286 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); 2326 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 // static 2392 // static
2353 MachineOperatorBuilder::AlignmentRequirements 2393 MachineOperatorBuilder::AlignmentRequirements
2354 InstructionSelector::AlignmentRequirements() { 2394 InstructionSelector::AlignmentRequirements() {
2355 return MachineOperatorBuilder::AlignmentRequirements:: 2395 return MachineOperatorBuilder::AlignmentRequirements::
2356 FullUnalignedAccessSupport(); 2396 FullUnalignedAccessSupport();
2357 } 2397 }
2358 2398
2359 } // namespace compiler 2399 } // namespace compiler
2360 } // namespace internal 2400 } // namespace internal
2361 } // namespace v8 2401 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698