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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 | 685 |
686 | 686 |
687 class Constant FINAL { | 687 class Constant FINAL { |
688 public: | 688 public: |
689 enum Type { | 689 enum Type { |
690 kInt32, | 690 kInt32, |
691 kInt64, | 691 kInt64, |
692 kFloat32, | 692 kFloat32, |
693 kFloat64, | 693 kFloat64, |
694 kExternalReference, | 694 kExternalReference, |
695 kHeapObject | 695 kHeapObject, |
| 696 kRpoNumber |
696 }; | 697 }; |
697 | 698 |
698 explicit Constant(int32_t v) : type_(kInt32), value_(v) {} | 699 explicit Constant(int32_t v) : type_(kInt32), value_(v) {} |
699 explicit Constant(int64_t v) : type_(kInt64), value_(v) {} | 700 explicit Constant(int64_t v) : type_(kInt64), value_(v) {} |
700 explicit Constant(float v) : type_(kFloat32), value_(bit_cast<int32_t>(v)) {} | 701 explicit Constant(float v) : type_(kFloat32), value_(bit_cast<int32_t>(v)) {} |
701 explicit Constant(double v) : type_(kFloat64), value_(bit_cast<int64_t>(v)) {} | 702 explicit Constant(double v) : type_(kFloat64), value_(bit_cast<int64_t>(v)) {} |
702 explicit Constant(ExternalReference ref) | 703 explicit Constant(ExternalReference ref) |
703 : type_(kExternalReference), value_(bit_cast<intptr_t>(ref)) {} | 704 : type_(kExternalReference), value_(bit_cast<intptr_t>(ref)) {} |
704 explicit Constant(Handle<HeapObject> obj) | 705 explicit Constant(Handle<HeapObject> obj) |
705 : type_(kHeapObject), value_(bit_cast<intptr_t>(obj)) {} | 706 : type_(kHeapObject), value_(bit_cast<intptr_t>(obj)) {} |
| 707 explicit Constant(BasicBlock::RpoNumber rpo) |
| 708 : type_(kRpoNumber), value_(rpo.ToInt()) {} |
706 | 709 |
707 Type type() const { return type_; } | 710 Type type() const { return type_; } |
708 | 711 |
709 int32_t ToInt32() const { | 712 int32_t ToInt32() const { |
710 DCHECK(type() == kInt32 || type() == kInt64); | 713 DCHECK(type() == kInt32 || type() == kInt64); |
711 const int32_t value = static_cast<int32_t>(value_); | 714 const int32_t value = static_cast<int32_t>(value_); |
712 DCHECK_EQ(value_, static_cast<int64_t>(value)); | 715 DCHECK_EQ(value_, static_cast<int64_t>(value)); |
713 return value; | 716 return value; |
714 } | 717 } |
715 | 718 |
(...skipping 12 matching lines...) Expand all Loading... |
728 if (type() == kInt32) return ToInt32(); | 731 if (type() == kInt32) return ToInt32(); |
729 DCHECK_EQ(kFloat64, type()); | 732 DCHECK_EQ(kFloat64, type()); |
730 return bit_cast<double>(value_); | 733 return bit_cast<double>(value_); |
731 } | 734 } |
732 | 735 |
733 ExternalReference ToExternalReference() const { | 736 ExternalReference ToExternalReference() const { |
734 DCHECK_EQ(kExternalReference, type()); | 737 DCHECK_EQ(kExternalReference, type()); |
735 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_)); | 738 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_)); |
736 } | 739 } |
737 | 740 |
| 741 BasicBlock::RpoNumber ToRpoNumber() const { |
| 742 DCHECK_EQ(kRpoNumber, type()); |
| 743 return BasicBlock::RpoNumber::FromInt(static_cast<int>(value_)); |
| 744 } |
| 745 |
738 Handle<HeapObject> ToHeapObject() const { | 746 Handle<HeapObject> ToHeapObject() const { |
739 DCHECK_EQ(kHeapObject, type()); | 747 DCHECK_EQ(kHeapObject, type()); |
740 return bit_cast<Handle<HeapObject> >(static_cast<intptr_t>(value_)); | 748 return bit_cast<Handle<HeapObject> >(static_cast<intptr_t>(value_)); |
741 } | 749 } |
742 | 750 |
743 private: | 751 private: |
744 Type type_; | 752 Type type_; |
745 int64_t value_; | 753 int64_t value_; |
746 }; | 754 }; |
747 | 755 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 typedef ZoneVector<PhiInstruction*> PhiInstructions; | 892 typedef ZoneVector<PhiInstruction*> PhiInstructions; |
885 const PhiInstructions& phis() const { return phis_; } | 893 const PhiInstructions& phis() const { return phis_; } |
886 void AddPhi(PhiInstruction* phi) { phis_.push_back(phi); } | 894 void AddPhi(PhiInstruction* phi) { phis_.push_back(phi); } |
887 | 895 |
888 private: | 896 private: |
889 Successors successors_; | 897 Successors successors_; |
890 Predecessors predecessors_; | 898 Predecessors predecessors_; |
891 PhiInstructions phis_; | 899 PhiInstructions phis_; |
892 const BasicBlock::Id id_; | 900 const BasicBlock::Id id_; |
893 const BasicBlock::RpoNumber ao_number_; // Assembly order number. | 901 const BasicBlock::RpoNumber ao_number_; // Assembly order number. |
894 // TODO(dcarney): probably dont't need this. | |
895 const BasicBlock::RpoNumber rpo_number_; | 902 const BasicBlock::RpoNumber rpo_number_; |
896 const BasicBlock::RpoNumber loop_header_; | 903 const BasicBlock::RpoNumber loop_header_; |
897 const BasicBlock::RpoNumber loop_end_; | 904 const BasicBlock::RpoNumber loop_end_; |
898 int32_t code_start_; // start index of arch-specific code. | 905 int32_t code_start_; // start index of arch-specific code. |
899 int32_t code_end_; // end index of arch-specific code. | 906 int32_t code_end_; // end index of arch-specific code. |
900 const bool deferred_; // Block contains deferred code. | 907 const bool deferred_; // Block contains deferred code. |
901 }; | 908 }; |
902 | 909 |
903 typedef ZoneDeque<Constant> ConstantDeque; | 910 typedef ZoneDeque<Constant> ConstantDeque; |
904 typedef std::map<int, Constant, std::less<int>, | 911 typedef std::map<int, Constant, std::less<int>, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1060 |
1054 | 1061 |
1055 std::ostream& operator<<(std::ostream& os, | 1062 std::ostream& operator<<(std::ostream& os, |
1056 const PrintableInstructionSequence& code); | 1063 const PrintableInstructionSequence& code); |
1057 | 1064 |
1058 } // namespace compiler | 1065 } // namespace compiler |
1059 } // namespace internal | 1066 } // namespace internal |
1060 } // namespace v8 | 1067 } // namespace v8 |
1061 | 1068 |
1062 #endif // V8_COMPILER_INSTRUCTION_H_ | 1069 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |