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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 size_t locals_count_; | 780 size_t locals_count_; |
781 size_t stack_count_; | 781 size_t stack_count_; |
782 ZoneVector<MachineType> types_; | 782 ZoneVector<MachineType> types_; |
783 FrameStateDescriptor* outer_state_; | 783 FrameStateDescriptor* outer_state_; |
784 MaybeHandle<JSFunction> jsfunction_; | 784 MaybeHandle<JSFunction> jsfunction_; |
785 }; | 785 }; |
786 | 786 |
787 std::ostream& operator<<(std::ostream& os, const Constant& constant); | 787 std::ostream& operator<<(std::ostream& os, const Constant& constant); |
788 | 788 |
789 | 789 |
790 // TODO(dcarney): this is a temporary hack. turn into an actual instruction. | |
791 class PhiInstruction FINAL : public ZoneObject { | 790 class PhiInstruction FINAL : public ZoneObject { |
792 public: | 791 public: |
793 PhiInstruction(Zone* zone, int virtual_register) | 792 typedef ZoneVector<InstructionOperand*> Inputs; |
794 : virtual_register_(virtual_register), operands_(zone) {} | 793 |
| 794 PhiInstruction(Zone* zone, int virtual_register, size_t reserved_input_count) |
| 795 : virtual_register_(virtual_register), |
| 796 operands_(zone), |
| 797 output_(nullptr), |
| 798 inputs_(zone) { |
| 799 UnallocatedOperand* output = |
| 800 new (zone) UnallocatedOperand(UnallocatedOperand::NONE); |
| 801 output->set_virtual_register(virtual_register); |
| 802 output_ = output; |
| 803 inputs_.reserve(reserved_input_count); |
| 804 operands_.reserve(reserved_input_count); |
| 805 } |
795 | 806 |
796 int virtual_register() const { return virtual_register_; } | 807 int virtual_register() const { return virtual_register_; } |
797 const IntVector& operands() const { return operands_; } | 808 const IntVector& operands() const { return operands_; } |
798 IntVector& operands() { return operands_; } | 809 |
| 810 void Extend(Zone* zone, int virtual_register) { |
| 811 UnallocatedOperand* input = |
| 812 new (zone) UnallocatedOperand(UnallocatedOperand::ANY); |
| 813 input->set_virtual_register(virtual_register); |
| 814 operands_.push_back(virtual_register); |
| 815 inputs_.push_back(input); |
| 816 } |
| 817 |
| 818 InstructionOperand* output() const { return output_; } |
| 819 const Inputs& inputs() const { return inputs_; } |
| 820 Inputs& inputs() { return inputs_; } |
799 | 821 |
800 private: | 822 private: |
| 823 // TODO(dcarney): some of these fields are only for verification, move them to |
| 824 // verifier. |
801 const int virtual_register_; | 825 const int virtual_register_; |
802 IntVector operands_; | 826 IntVector operands_; |
| 827 InstructionOperand* output_; |
| 828 Inputs inputs_; |
803 }; | 829 }; |
804 | 830 |
805 | 831 |
806 // Analogue of BasicBlock for Instructions instead of Nodes. | 832 // Analogue of BasicBlock for Instructions instead of Nodes. |
807 class InstructionBlock FINAL : public ZoneObject { | 833 class InstructionBlock FINAL : public ZoneObject { |
808 public: | 834 public: |
809 InstructionBlock(Zone* zone, BasicBlock::Id id, | 835 InstructionBlock(Zone* zone, BasicBlock::Id id, |
810 BasicBlock::RpoNumber ao_number, | 836 BasicBlock::RpoNumber ao_number, |
811 BasicBlock::RpoNumber rpo_number, | 837 BasicBlock::RpoNumber rpo_number, |
812 BasicBlock::RpoNumber loop_header, | 838 BasicBlock::RpoNumber loop_header, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 | 1053 |
1028 | 1054 |
1029 std::ostream& operator<<(std::ostream& os, | 1055 std::ostream& operator<<(std::ostream& os, |
1030 const PrintableInstructionSequence& code); | 1056 const PrintableInstructionSequence& code); |
1031 | 1057 |
1032 } // namespace compiler | 1058 } // namespace compiler |
1033 } // namespace internal | 1059 } // namespace internal |
1034 } // namespace v8 | 1060 } // namespace v8 |
1035 | 1061 |
1036 #endif // V8_COMPILER_INSTRUCTION_H_ | 1062 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |