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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; | 106 bool InterferesWith(const InstructionOperand& that) const; |
107 | 107 |
108 void Print(const RegisterConfiguration* config) const; | 108 void Print(std::ostream& os, const RegisterConfiguration* config) const; |
109 void Print() const; | 109 void Print(std::ostream& os) const; |
110 | 110 |
111 protected: | 111 protected: |
112 explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {} | 112 explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {} |
113 | 113 |
114 inline uint64_t GetCanonicalizedValue() const; | 114 inline uint64_t GetCanonicalizedValue() const; |
115 | 115 |
116 class KindField : public BitField64<Kind, 0, 3> {}; | 116 class KindField : public BitField64<Kind, 0, 3> {}; |
117 | 117 |
118 uint64_t value_; | 118 uint64_t value_; |
119 }; | 119 }; |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 return IsEliminated() || source_.EqualsCanonicalized(destination_); | 665 return IsEliminated() || source_.EqualsCanonicalized(destination_); |
666 } | 666 } |
667 | 667 |
668 // We clear both operands to indicate move that's been eliminated. | 668 // We clear both operands to indicate move that's been eliminated. |
669 void Eliminate() { source_ = destination_ = InstructionOperand(); } | 669 void Eliminate() { source_ = destination_ = InstructionOperand(); } |
670 bool IsEliminated() const { | 670 bool IsEliminated() const { |
671 DCHECK_IMPLIES(source_.IsInvalid(), destination_.IsInvalid()); | 671 DCHECK_IMPLIES(source_.IsInvalid(), destination_.IsInvalid()); |
672 return source_.IsInvalid(); | 672 return source_.IsInvalid(); |
673 } | 673 } |
674 | 674 |
675 void Print(const RegisterConfiguration* config) const; | 675 void Print(std::ostream& os, const RegisterConfiguration* config) const; |
676 void Print() const; | 676 void Print(std::ostream& os) const; |
677 | 677 |
678 private: | 678 private: |
679 InstructionOperand source_; | 679 InstructionOperand source_; |
680 InstructionOperand destination_; | 680 InstructionOperand destination_; |
681 | 681 |
682 DISALLOW_COPY_AND_ASSIGN(MoveOperands); | 682 DISALLOW_COPY_AND_ASSIGN(MoveOperands); |
683 }; | 683 }; |
684 | 684 |
685 | 685 |
686 struct PrintableMoveOperands { | 686 struct PrintableMoveOperands { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 | 905 |
906 // The block_id may be invalidated in JumpThreading. It is only important for | 906 // The block_id may be invalidated in JumpThreading. It is only important for |
907 // register allocation, to avoid searching for blocks from instruction | 907 // register allocation, to avoid searching for blocks from instruction |
908 // indexes. | 908 // indexes. |
909 InstructionBlock* block() const { return block_; } | 909 InstructionBlock* block() const { return block_; } |
910 void set_block(InstructionBlock* block) { | 910 void set_block(InstructionBlock* block) { |
911 DCHECK_NOT_NULL(block); | 911 DCHECK_NOT_NULL(block); |
912 block_ = block; | 912 block_ = block; |
913 } | 913 } |
914 | 914 |
915 void Print(const RegisterConfiguration* config) const; | 915 void Print(std::ostream& os, const RegisterConfiguration* config) const; |
916 void Print() const; | 916 void Print(std::ostream& os) const; |
917 | 917 |
918 private: | 918 private: |
919 explicit Instruction(InstructionCode opcode); | 919 explicit Instruction(InstructionCode opcode); |
920 | 920 |
921 Instruction(InstructionCode opcode, size_t output_count, | 921 Instruction(InstructionCode opcode, size_t output_count, |
922 InstructionOperand* outputs, size_t input_count, | 922 InstructionOperand* outputs, size_t input_count, |
923 InstructionOperand* inputs, size_t temp_count, | 923 InstructionOperand* inputs, size_t temp_count, |
924 InstructionOperand* temps); | 924 InstructionOperand* temps); |
925 | 925 |
926 typedef BitField<size_t, 0, 8> OutputCountField; | 926 typedef BitField<size_t, 0, 8> OutputCountField; |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 bool GetSourcePosition(const Instruction* instr, | 1434 bool GetSourcePosition(const Instruction* instr, |
1435 SourcePosition* result) const; | 1435 SourcePosition* result) const; |
1436 void SetSourcePosition(const Instruction* instr, SourcePosition value); | 1436 void SetSourcePosition(const Instruction* instr, SourcePosition value); |
1437 | 1437 |
1438 bool ContainsCall() const { | 1438 bool ContainsCall() const { |
1439 for (Instruction* instr : instructions_) { | 1439 for (Instruction* instr : instructions_) { |
1440 if (instr->IsCall()) return true; | 1440 if (instr->IsCall()) return true; |
1441 } | 1441 } |
1442 return false; | 1442 return false; |
1443 } | 1443 } |
1444 void Print(const RegisterConfiguration* config) const; | 1444 void Print(std::ostream& os, const RegisterConfiguration* config) const; |
1445 void Print() const; | 1445 void Print(std::ostream& os) const; |
1446 | 1446 |
1447 void PrintBlock(const RegisterConfiguration* config, int block_id) const; | 1447 void PrintBlock(std::ostream& os, const RegisterConfiguration* config, |
1448 void PrintBlock(int block_id) const; | 1448 int block_id) const; |
| 1449 void PrintBlock(std::ostream& os, int block_id) const; |
1449 | 1450 |
1450 void ValidateEdgeSplitForm() const; | 1451 void ValidateEdgeSplitForm() const; |
1451 void ValidateDeferredBlockExitPaths() const; | 1452 void ValidateDeferredBlockExitPaths() const; |
1452 void ValidateDeferredBlockEntryPaths() const; | 1453 void ValidateDeferredBlockEntryPaths() const; |
1453 void ValidateSSA() const; | 1454 void ValidateSSA() const; |
1454 | 1455 |
1455 private: | 1456 private: |
1456 friend std::ostream& operator<<(std::ostream& os, | 1457 friend std::ostream& operator<<(std::ostream& os, |
1457 const PrintableInstructionSequence& code); | 1458 const PrintableInstructionSequence& code); |
1458 | 1459 |
(...skipping 25 matching lines...) Expand all Loading... |
1484 | 1485 |
1485 | 1486 |
1486 std::ostream& operator<<(std::ostream& os, | 1487 std::ostream& operator<<(std::ostream& os, |
1487 const PrintableInstructionSequence& code); | 1488 const PrintableInstructionSequence& code); |
1488 | 1489 |
1489 } // namespace compiler | 1490 } // namespace compiler |
1490 } // namespace internal | 1491 } // namespace internal |
1491 } // namespace v8 | 1492 } // namespace v8 |
1492 | 1493 |
1493 #endif // V8_COMPILER_INSTRUCTION_H_ | 1494 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |