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 "src/compiler/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 if (g.CanBeImmediate(index, immediate_mode)) { | 355 if (g.CanBeImmediate(index, immediate_mode)) { |
356 Emit(opcode | AddressingModeField::encode(kMode_MRI), NULL, | 356 Emit(opcode | AddressingModeField::encode(kMode_MRI), NULL, |
357 g.UseRegister(base), g.UseImmediate(index), g.UseRegister(value)); | 357 g.UseRegister(base), g.UseImmediate(index), g.UseRegister(value)); |
358 } else { | 358 } else { |
359 Emit(opcode | AddressingModeField::encode(kMode_MRR), NULL, | 359 Emit(opcode | AddressingModeField::encode(kMode_MRR), NULL, |
360 g.UseRegister(base), g.UseRegister(index), g.UseRegister(value)); | 360 g.UseRegister(base), g.UseRegister(index), g.UseRegister(value)); |
361 } | 361 } |
362 } | 362 } |
363 | 363 |
364 | 364 |
| 365 void InstructionSelector::VisitCheckedLoad(Node* node) { |
| 366 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); |
| 367 MachineType typ = TypeOf(OpParameter<MachineType>(node)); |
| 368 Arm64OperandGenerator g(this); |
| 369 Node* const buffer = node->InputAt(0); |
| 370 Node* const offset = node->InputAt(1); |
| 371 Node* const length = node->InputAt(2); |
| 372 ArchOpcode opcode; |
| 373 switch (rep) { |
| 374 case kRepWord8: |
| 375 opcode = typ == kTypeInt32 ? kCheckedLoadInt8 : kCheckedLoadUint8; |
| 376 break; |
| 377 case kRepWord16: |
| 378 opcode = typ == kTypeInt32 ? kCheckedLoadInt16 : kCheckedLoadUint16; |
| 379 break; |
| 380 case kRepWord32: |
| 381 opcode = kCheckedLoadWord32; |
| 382 break; |
| 383 case kRepFloat32: |
| 384 opcode = kCheckedLoadFloat32; |
| 385 break; |
| 386 case kRepFloat64: |
| 387 opcode = kCheckedLoadFloat64; |
| 388 break; |
| 389 default: |
| 390 UNREACHABLE(); |
| 391 return; |
| 392 } |
| 393 InstructionOperand* offset_operand = g.UseRegister(offset); |
| 394 Emit(opcode | AddressingModeField::encode(kMode_MRR), |
| 395 g.DefineAsRegister(node), offset_operand, g.UseRegister(length), |
| 396 g.UseRegister(buffer), offset_operand); |
| 397 } |
| 398 |
| 399 |
| 400 void InstructionSelector::VisitCheckedStore(Node* node) { |
| 401 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); |
| 402 Arm64OperandGenerator g(this); |
| 403 Node* const buffer = node->InputAt(0); |
| 404 Node* const offset = node->InputAt(1); |
| 405 Node* const length = node->InputAt(2); |
| 406 Node* const value = node->InputAt(3); |
| 407 ArchOpcode opcode; |
| 408 switch (rep) { |
| 409 case kRepWord8: |
| 410 opcode = kCheckedStoreWord8; |
| 411 break; |
| 412 case kRepWord16: |
| 413 opcode = kCheckedStoreWord16; |
| 414 break; |
| 415 case kRepWord32: |
| 416 opcode = kCheckedStoreWord32; |
| 417 break; |
| 418 case kRepFloat32: |
| 419 opcode = kCheckedStoreFloat32; |
| 420 break; |
| 421 case kRepFloat64: |
| 422 opcode = kCheckedStoreFloat64; |
| 423 break; |
| 424 default: |
| 425 UNREACHABLE(); |
| 426 return; |
| 427 } |
| 428 InstructionOperand* offset_operand = g.UseRegister(offset); |
| 429 Emit(opcode | AddressingModeField::encode(kMode_MRR), nullptr, offset_operand, |
| 430 g.UseRegister(length), g.UseRegister(value), g.UseRegister(buffer), |
| 431 offset_operand); |
| 432 } |
| 433 |
| 434 |
365 template <typename Matcher> | 435 template <typename Matcher> |
366 static void VisitLogical(InstructionSelector* selector, Node* node, Matcher* m, | 436 static void VisitLogical(InstructionSelector* selector, Node* node, Matcher* m, |
367 ArchOpcode opcode, bool left_can_cover, | 437 ArchOpcode opcode, bool left_can_cover, |
368 bool right_can_cover, ImmediateMode imm_mode) { | 438 bool right_can_cover, ImmediateMode imm_mode) { |
369 Arm64OperandGenerator g(selector); | 439 Arm64OperandGenerator g(selector); |
370 | 440 |
371 // Map instruction to equivalent operation with inverted right input. | 441 // Map instruction to equivalent operation with inverted right input. |
372 ArchOpcode inv_opcode = opcode; | 442 ArchOpcode inv_opcode = opcode; |
373 switch (opcode) { | 443 switch (opcode) { |
374 case kArm64And32: | 444 case kArm64And32: |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 InstructionSelector::SupportedMachineOperatorFlags() { | 1526 InstructionSelector::SupportedMachineOperatorFlags() { |
1457 return MachineOperatorBuilder::kFloat64Floor | | 1527 return MachineOperatorBuilder::kFloat64Floor | |
1458 MachineOperatorBuilder::kFloat64Ceil | | 1528 MachineOperatorBuilder::kFloat64Ceil | |
1459 MachineOperatorBuilder::kFloat64RoundTruncate | | 1529 MachineOperatorBuilder::kFloat64RoundTruncate | |
1460 MachineOperatorBuilder::kFloat64RoundTiesAway | | 1530 MachineOperatorBuilder::kFloat64RoundTiesAway | |
1461 MachineOperatorBuilder::kWord32ShiftIsSafe; | 1531 MachineOperatorBuilder::kWord32ShiftIsSafe; |
1462 } | 1532 } |
1463 } // namespace compiler | 1533 } // namespace compiler |
1464 } // namespace internal | 1534 } // namespace internal |
1465 } // namespace v8 | 1535 } // namespace v8 |
OLD | NEW |