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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 } | 96 } |
97 | 97 |
98 bool EqualsCanonicalized(const InstructionOperand& that) const { | 98 bool EqualsCanonicalized(const InstructionOperand& that) const { |
99 return this->GetCanonicalizedValue() == that.GetCanonicalizedValue(); | 99 return this->GetCanonicalizedValue() == that.GetCanonicalizedValue(); |
100 } | 100 } |
101 | 101 |
102 bool CompareCanonicalized(const InstructionOperand& that) const { | 102 bool CompareCanonicalized(const InstructionOperand& that) const { |
103 return this->GetCanonicalizedValue() < that.GetCanonicalizedValue(); | 103 return this->GetCanonicalizedValue() < that.GetCanonicalizedValue(); |
104 } | 104 } |
105 | 105 |
106 bool InterferesWith(const InstructionOperand& that) const; | |
107 | |
106 void Print(const RegisterConfiguration* config) const; | 108 void Print(const RegisterConfiguration* config) const; |
107 void Print() const; | 109 void Print() const; |
108 | 110 |
109 protected: | 111 protected: |
110 explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {} | 112 explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {} |
111 | 113 |
112 inline uint64_t GetCanonicalizedValue() const; | 114 inline uint64_t GetCanonicalizedValue() const; |
113 | 115 |
114 class KindField : public BitField64<Kind, 0, 3> {}; | 116 class KindField : public BitField64<Kind, 0, 3> {}; |
115 | 117 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 bool InstructionOperand::IsSimd128StackSlot() const { | 597 bool InstructionOperand::IsSimd128StackSlot() const { |
596 return (IsAllocated() || IsExplicit()) && | 598 return (IsAllocated() || IsExplicit()) && |
597 LocationOperand::cast(this)->location_kind() == | 599 LocationOperand::cast(this)->location_kind() == |
598 LocationOperand::STACK_SLOT && | 600 LocationOperand::STACK_SLOT && |
599 LocationOperand::cast(this)->representation() == | 601 LocationOperand::cast(this)->representation() == |
600 MachineRepresentation::kSimd128; | 602 MachineRepresentation::kSimd128; |
601 } | 603 } |
602 | 604 |
603 uint64_t InstructionOperand::GetCanonicalizedValue() const { | 605 uint64_t InstructionOperand::GetCanonicalizedValue() const { |
604 if (IsAllocated() || IsExplicit()) { | 606 if (IsAllocated() || IsExplicit()) { |
605 // TODO(dcarney): put machine type last and mask. | 607 MachineRepresentation rep = LocationOperand::cast(this)->representation(); |
bbudge
2016/06/14 23:34:24
I removed this because I don't understand what it
| |
606 MachineRepresentation canonicalized_representation = | 608 // Preserve FP representation so we can check for interference on |
607 IsFloatingPoint(LocationOperand::cast(this)->representation()) | 609 // architectures with complex register aliasing. |
608 ? MachineRepresentation::kFloat64 | 610 MachineRepresentation canonical = |
609 : MachineRepresentation::kNone; | 611 IsFPRegister() ? rep : MachineRepresentation::kNone; |
610 return InstructionOperand::KindField::update( | 612 return InstructionOperand::KindField::update( |
611 LocationOperand::RepresentationField::update( | 613 LocationOperand::RepresentationField::update(this->value_, canonical), |
612 this->value_, canonicalized_representation), | |
613 LocationOperand::EXPLICIT); | 614 LocationOperand::EXPLICIT); |
614 } | 615 } |
615 return this->value_; | 616 return this->value_; |
616 } | 617 } |
617 | 618 |
618 | 619 |
619 // Required for maps that don't care about machine type. | 620 // Required for maps that don't care about machine type. |
620 struct CompareOperandModuloType { | 621 struct CompareOperandModuloType { |
621 bool operator()(const InstructionOperand& a, | 622 bool operator()(const InstructionOperand& a, |
622 const InstructionOperand& b) const { | 623 const InstructionOperand& b) const { |
(...skipping 20 matching lines...) Expand all Loading... | |
643 destination_ = operand; | 644 destination_ = operand; |
644 } | 645 } |
645 | 646 |
646 // The gap resolver marks moves as "in-progress" by clearing the | 647 // The gap resolver marks moves as "in-progress" by clearing the |
647 // destination (but not the source). | 648 // destination (but not the source). |
648 bool IsPending() const { | 649 bool IsPending() const { |
649 return destination_.IsInvalid() && !source_.IsInvalid(); | 650 return destination_.IsInvalid() && !source_.IsInvalid(); |
650 } | 651 } |
651 void SetPending() { destination_ = InstructionOperand(); } | 652 void SetPending() { destination_ = InstructionOperand(); } |
652 | 653 |
653 // True if this move a move into the given destination operand. | 654 // True if this move is a move into the given destination operand. |
654 bool Blocks(const InstructionOperand& operand) const { | 655 bool Blocks(const InstructionOperand& destination) const { |
655 return !IsEliminated() && source().EqualsCanonicalized(operand); | 656 return !IsEliminated() && source().InterferesWith(destination); |
656 } | 657 } |
657 | 658 |
658 // A move is redundant if it's been eliminated or if its source and | 659 // A move is redundant if it's been eliminated or if its source and |
659 // destination are the same. | 660 // destination are the same. |
660 bool IsRedundant() const { | 661 bool IsRedundant() const { |
661 DCHECK_IMPLIES(!destination_.IsInvalid(), !destination_.IsConstant()); | 662 DCHECK_IMPLIES(!destination_.IsInvalid(), !destination_.IsConstant()); |
662 return IsEliminated() || source_.EqualsCanonicalized(destination_); | 663 return IsEliminated() || source_.EqualsCanonicalized(destination_); |
663 } | 664 } |
664 | 665 |
665 // We clear both operands to indicate move that's been eliminated. | 666 // We clear both operands to indicate move that's been eliminated. |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1479 | 1480 |
1480 | 1481 |
1481 std::ostream& operator<<(std::ostream& os, | 1482 std::ostream& operator<<(std::ostream& os, |
1482 const PrintableInstructionSequence& code); | 1483 const PrintableInstructionSequence& code); |
1483 | 1484 |
1484 } // namespace compiler | 1485 } // namespace compiler |
1485 } // namespace internal | 1486 } // namespace internal |
1486 } // namespace v8 | 1487 } // namespace v8 |
1487 | 1488 |
1488 #endif // V8_COMPILER_INSTRUCTION_H_ | 1489 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |