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 <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 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 addressing_mode = kMode_MRI; | 2307 addressing_mode = kMode_MRI; |
2308 } else { | 2308 } else { |
2309 inputs[input_count++] = g.UseUniqueRegister(index); | 2309 inputs[input_count++] = g.UseUniqueRegister(index); |
2310 addressing_mode = kMode_MR1; | 2310 addressing_mode = kMode_MR1; |
2311 } | 2311 } |
2312 outputs[0] = g.DefineSameAsFirst(node); | 2312 outputs[0] = g.DefineSameAsFirst(node); |
2313 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); | 2313 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); |
2314 Emit(code, 1, outputs, input_count, inputs); | 2314 Emit(code, 1, outputs, input_count, inputs); |
2315 } | 2315 } |
2316 | 2316 |
| 2317 void InstructionSelector::VisitAtomicCompareExchange(Node* node) { |
| 2318 X64OperandGenerator g(this); |
| 2319 Node* base = node->InputAt(0); |
| 2320 Node* index = node->InputAt(1); |
| 2321 Node* old_value = node->InputAt(2); |
| 2322 Node* new_value = node->InputAt(3); |
| 2323 |
| 2324 MachineType type = AtomicCompareExchangeRepresentationOf(node->op()); |
| 2325 ArchOpcode opcode = kArchNop; |
| 2326 if (type == MachineType::Int8()) { |
| 2327 opcode = kAtomicCompareExchangeInt8; |
| 2328 } else if (type == MachineType::Uint8()) { |
| 2329 opcode = kAtomicCompareExchangeUint8; |
| 2330 } else if (type == MachineType::Int16()) { |
| 2331 opcode = kAtomicCompareExchangeInt16; |
| 2332 } else if (type == MachineType::Uint16()) { |
| 2333 opcode = kAtomicCompareExchangeUint16; |
| 2334 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { |
| 2335 opcode = kAtomicCompareExchangeWord32; |
| 2336 } else { |
| 2337 UNREACHABLE(); |
| 2338 return; |
| 2339 } |
| 2340 InstructionOperand outputs[1]; |
| 2341 AddressingMode addressing_mode; |
| 2342 InstructionOperand inputs[4]; |
| 2343 size_t input_count = 0; |
| 2344 inputs[input_count++] = g.UseFixed(old_value, rax); |
| 2345 inputs[input_count++] = g.UseUniqueRegister(new_value); |
| 2346 inputs[input_count++] = g.UseUniqueRegister(base); |
| 2347 if (g.CanBeImmediate(index)) { |
| 2348 inputs[input_count++] = g.UseImmediate(index); |
| 2349 addressing_mode = kMode_MRI; |
| 2350 } else { |
| 2351 inputs[input_count++] = g.UseUniqueRegister(index); |
| 2352 addressing_mode = kMode_MR1; |
| 2353 } |
| 2354 outputs[0] = g.DefineAsFixed(node, rax); |
| 2355 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); |
| 2356 Emit(code, 1, outputs, input_count, inputs); |
| 2357 } |
| 2358 |
2317 void InstructionSelector::VisitInt32x4Splat(Node* node) { | 2359 void InstructionSelector::VisitInt32x4Splat(Node* node) { |
2318 X64OperandGenerator g(this); | 2360 X64OperandGenerator g(this); |
2319 Emit(kX64Int32x4Splat, g.DefineAsRegister(node), g.Use(node->InputAt(0))); | 2361 Emit(kX64Int32x4Splat, g.DefineAsRegister(node), g.Use(node->InputAt(0))); |
2320 } | 2362 } |
2321 | 2363 |
2322 void InstructionSelector::VisitInt32x4ExtractLane(Node* node) { | 2364 void InstructionSelector::VisitInt32x4ExtractLane(Node* node) { |
2323 X64OperandGenerator g(this); | 2365 X64OperandGenerator g(this); |
2324 int32_t lane = OpParameter<int32_t>(node); | 2366 int32_t lane = OpParameter<int32_t>(node); |
2325 Emit(kX64Int32x4ExtractLane, g.DefineAsRegister(node), | 2367 Emit(kX64Int32x4ExtractLane, g.DefineAsRegister(node), |
2326 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); | 2368 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2392 // static | 2434 // static |
2393 MachineOperatorBuilder::AlignmentRequirements | 2435 MachineOperatorBuilder::AlignmentRequirements |
2394 InstructionSelector::AlignmentRequirements() { | 2436 InstructionSelector::AlignmentRequirements() { |
2395 return MachineOperatorBuilder::AlignmentRequirements:: | 2437 return MachineOperatorBuilder::AlignmentRequirements:: |
2396 FullUnalignedAccessSupport(); | 2438 FullUnalignedAccessSupport(); |
2397 } | 2439 } |
2398 | 2440 |
2399 } // namespace compiler | 2441 } // namespace compiler |
2400 } // namespace internal | 2442 } // namespace internal |
2401 } // namespace v8 | 2443 } // namespace v8 |
OLD | NEW |