| 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 #ifndef V8_COMPILER_INSTRUCTION_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_H_ |
| 6 #define V8_COMPILER_INSTRUCTION_H_ | 6 #define V8_COMPILER_INSTRUCTION_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // stack slots, completely bypassing the register allocator. They are never | 59 // stack slots, completely bypassing the register allocator. They are never |
| 60 // associated with a virtual register | 60 // associated with a virtual register |
| 61 INSTRUCTION_OPERAND_PREDICATE(Explicit, EXPLICIT) | 61 INSTRUCTION_OPERAND_PREDICATE(Explicit, EXPLICIT) |
| 62 // AllocatedOperands are registers or stack slots that are assigned by the | 62 // AllocatedOperands are registers or stack slots that are assigned by the |
| 63 // register allocator and are always associated with a virtual register. | 63 // register allocator and are always associated with a virtual register. |
| 64 INSTRUCTION_OPERAND_PREDICATE(Allocated, ALLOCATED) | 64 INSTRUCTION_OPERAND_PREDICATE(Allocated, ALLOCATED) |
| 65 #undef INSTRUCTION_OPERAND_PREDICATE | 65 #undef INSTRUCTION_OPERAND_PREDICATE |
| 66 | 66 |
| 67 inline bool IsAnyRegister() const; | 67 inline bool IsAnyRegister() const; |
| 68 inline bool IsRegister() const; | 68 inline bool IsRegister() const; |
| 69 inline bool IsFPRegister() const; |
| 70 inline bool IsFloatRegister() const; |
| 69 inline bool IsDoubleRegister() const; | 71 inline bool IsDoubleRegister() const; |
| 70 inline bool IsSimd128Register() const; | 72 inline bool IsSimd128Register() const; |
| 71 inline bool IsStackSlot() const; | 73 inline bool IsStackSlot() const; |
| 74 inline bool IsFPStackSlot() const; |
| 75 inline bool IsFloatStackSlot() const; |
| 72 inline bool IsDoubleStackSlot() const; | 76 inline bool IsDoubleStackSlot() const; |
| 73 inline bool IsSimd128StackSlot() const; | 77 inline bool IsSimd128StackSlot() const; |
| 74 | 78 |
| 75 template <typename SubKindOperand> | 79 template <typename SubKindOperand> |
| 76 static SubKindOperand* New(Zone* zone, const SubKindOperand& op) { | 80 static SubKindOperand* New(Zone* zone, const SubKindOperand& op) { |
| 77 void* buffer = zone->New(sizeof(op)); | 81 void* buffer = zone->New(sizeof(op)); |
| 78 return new (buffer) SubKindOperand(op); | 82 return new (buffer) SubKindOperand(op); |
| 79 } | 83 } |
| 80 | 84 |
| 81 static void ReplaceWith(InstructionOperand* dest, | 85 static void ReplaceWith(InstructionOperand* dest, |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 MachineRepresentation rep, int index) | 410 MachineRepresentation rep, int index) |
| 407 : InstructionOperand(operand_kind) { | 411 : InstructionOperand(operand_kind) { |
| 408 DCHECK_IMPLIES(location_kind == REGISTER, index >= 0); | 412 DCHECK_IMPLIES(location_kind == REGISTER, index >= 0); |
| 409 DCHECK(IsSupportedRepresentation(rep)); | 413 DCHECK(IsSupportedRepresentation(rep)); |
| 410 value_ |= LocationKindField::encode(location_kind); | 414 value_ |= LocationKindField::encode(location_kind); |
| 411 value_ |= RepresentationField::encode(rep); | 415 value_ |= RepresentationField::encode(rep); |
| 412 value_ |= static_cast<int64_t>(index) << IndexField::kShift; | 416 value_ |= static_cast<int64_t>(index) << IndexField::kShift; |
| 413 } | 417 } |
| 414 | 418 |
| 415 int index() const { | 419 int index() const { |
| 416 DCHECK(IsStackSlot() || IsDoubleStackSlot() || IsSimd128StackSlot()); | 420 DCHECK(IsStackSlot() || IsFPStackSlot()); |
| 417 return static_cast<int64_t>(value_) >> IndexField::kShift; | 421 return static_cast<int64_t>(value_) >> IndexField::kShift; |
| 418 } | 422 } |
| 419 | 423 |
| 420 Register GetRegister() const { | 424 Register GetRegister() const { |
| 421 DCHECK(IsRegister()); | 425 DCHECK(IsRegister()); |
| 422 return Register::from_code(static_cast<int64_t>(value_) >> | 426 return Register::from_code(static_cast<int64_t>(value_) >> |
| 423 IndexField::kShift); | 427 IndexField::kShift); |
| 424 } | 428 } |
| 425 | 429 |
| 430 FloatRegister GetFloatRegister() const { |
| 431 DCHECK(IsFloatRegister()); |
| 432 return FloatRegister::from_code(static_cast<int64_t>(value_) >> |
| 433 IndexField::kShift); |
| 434 } |
| 435 |
| 426 DoubleRegister GetDoubleRegister() const { | 436 DoubleRegister GetDoubleRegister() const { |
| 427 DCHECK(IsDoubleRegister()); | 437 // TODO(bbudge) Tighten this test to IsDoubleRegister when all code |
| 438 // generators are changed to use the correct Get*Register method. |
| 439 DCHECK(IsFPRegister()); |
| 428 return DoubleRegister::from_code(static_cast<int64_t>(value_) >> | 440 return DoubleRegister::from_code(static_cast<int64_t>(value_) >> |
| 429 IndexField::kShift); | 441 IndexField::kShift); |
| 430 } | 442 } |
| 431 | 443 |
| 432 Simd128Register GetSimd128Register() const { | 444 Simd128Register GetSimd128Register() const { |
| 433 DCHECK(IsSimd128Register()); | 445 DCHECK(IsSimd128Register()); |
| 434 return Simd128Register::from_code(static_cast<int64_t>(value_) >> | 446 return Simd128Register::from_code(static_cast<int64_t>(value_) >> |
| 435 IndexField::kShift); | 447 IndexField::kShift); |
| 436 } | 448 } |
| 437 | 449 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 LocationOperand::cast(this)->location_kind() == | 531 LocationOperand::cast(this)->location_kind() == |
| 520 LocationOperand::REGISTER; | 532 LocationOperand::REGISTER; |
| 521 } | 533 } |
| 522 | 534 |
| 523 | 535 |
| 524 bool InstructionOperand::IsRegister() const { | 536 bool InstructionOperand::IsRegister() const { |
| 525 return IsAnyRegister() && | 537 return IsAnyRegister() && |
| 526 !IsFloatingPoint(LocationOperand::cast(this)->representation()); | 538 !IsFloatingPoint(LocationOperand::cast(this)->representation()); |
| 527 } | 539 } |
| 528 | 540 |
| 541 bool InstructionOperand::IsFPRegister() const { |
| 542 return IsAnyRegister() && |
| 543 IsFloatingPoint(LocationOperand::cast(this)->representation()); |
| 544 } |
| 545 |
| 546 bool InstructionOperand::IsFloatRegister() const { |
| 547 return IsAnyRegister() && |
| 548 LocationOperand::cast(this)->representation() == |
| 549 MachineRepresentation::kFloat32; |
| 550 } |
| 551 |
| 529 bool InstructionOperand::IsDoubleRegister() const { | 552 bool InstructionOperand::IsDoubleRegister() const { |
| 530 return IsAnyRegister() && | 553 return IsAnyRegister() && |
| 531 IsFloatingPoint(LocationOperand::cast(this)->representation()); | 554 LocationOperand::cast(this)->representation() == |
| 555 MachineRepresentation::kFloat64; |
| 532 } | 556 } |
| 533 | 557 |
| 534 bool InstructionOperand::IsSimd128Register() const { | 558 bool InstructionOperand::IsSimd128Register() const { |
| 535 return IsAnyRegister() && | 559 return IsAnyRegister() && |
| 536 LocationOperand::cast(this)->representation() == | 560 LocationOperand::cast(this)->representation() == |
| 537 MachineRepresentation::kSimd128; | 561 MachineRepresentation::kSimd128; |
| 538 } | 562 } |
| 539 | 563 |
| 540 bool InstructionOperand::IsStackSlot() const { | 564 bool InstructionOperand::IsStackSlot() const { |
| 541 return (IsAllocated() || IsExplicit()) && | 565 return (IsAllocated() || IsExplicit()) && |
| 542 LocationOperand::cast(this)->location_kind() == | 566 LocationOperand::cast(this)->location_kind() == |
| 543 LocationOperand::STACK_SLOT && | 567 LocationOperand::STACK_SLOT && |
| 544 !IsFloatingPoint(LocationOperand::cast(this)->representation()); | 568 !IsFloatingPoint(LocationOperand::cast(this)->representation()); |
| 545 } | 569 } |
| 546 | 570 |
| 571 bool InstructionOperand::IsFPStackSlot() const { |
| 572 return (IsAllocated() || IsExplicit()) && |
| 573 LocationOperand::cast(this)->location_kind() == |
| 574 LocationOperand::STACK_SLOT && |
| 575 IsFloatingPoint(LocationOperand::cast(this)->representation()); |
| 576 } |
| 577 |
| 578 bool InstructionOperand::IsFloatStackSlot() const { |
| 579 return (IsAllocated() || IsExplicit()) && |
| 580 LocationOperand::cast(this)->location_kind() == |
| 581 LocationOperand::STACK_SLOT && |
| 582 LocationOperand::cast(this)->representation() == |
| 583 MachineRepresentation::kFloat32; |
| 584 } |
| 585 |
| 547 bool InstructionOperand::IsDoubleStackSlot() const { | 586 bool InstructionOperand::IsDoubleStackSlot() const { |
| 548 return (IsAllocated() || IsExplicit()) && | 587 return (IsAllocated() || IsExplicit()) && |
| 549 LocationOperand::cast(this)->location_kind() == | 588 LocationOperand::cast(this)->location_kind() == |
| 550 LocationOperand::STACK_SLOT && | 589 LocationOperand::STACK_SLOT && |
| 551 IsFloatingPoint(LocationOperand::cast(this)->representation()); | 590 LocationOperand::cast(this)->representation() == |
| 591 MachineRepresentation::kFloat64; |
| 552 } | 592 } |
| 553 | 593 |
| 554 bool InstructionOperand::IsSimd128StackSlot() const { | 594 bool InstructionOperand::IsSimd128StackSlot() const { |
| 555 return (IsAllocated() || IsExplicit()) && | 595 return (IsAllocated() || IsExplicit()) && |
| 556 LocationOperand::cast(this)->location_kind() == | 596 LocationOperand::cast(this)->location_kind() == |
| 557 LocationOperand::STACK_SLOT && | 597 LocationOperand::STACK_SLOT && |
| 558 LocationOperand::cast(this)->representation() == | 598 LocationOperand::cast(this)->representation() == |
| 559 MachineRepresentation::kSimd128; | 599 MachineRepresentation::kSimd128; |
| 560 } | 600 } |
| 561 | 601 |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 | 1467 |
| 1428 | 1468 |
| 1429 std::ostream& operator<<(std::ostream& os, | 1469 std::ostream& operator<<(std::ostream& os, |
| 1430 const PrintableInstructionSequence& code); | 1470 const PrintableInstructionSequence& code); |
| 1431 | 1471 |
| 1432 } // namespace compiler | 1472 } // namespace compiler |
| 1433 } // namespace internal | 1473 } // namespace internal |
| 1434 } // namespace v8 | 1474 } // namespace v8 |
| 1435 | 1475 |
| 1436 #endif // V8_COMPILER_INSTRUCTION_H_ | 1476 #endif // V8_COMPILER_INSTRUCTION_H_ |
| OLD | NEW |