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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 850 |
851 const ParallelMove* GetParallelMove(GapPosition pos) const { | 851 const ParallelMove* GetParallelMove(GapPosition pos) const { |
852 return parallel_moves_[pos]; | 852 return parallel_moves_[pos]; |
853 } | 853 } |
854 | 854 |
855 bool AreMovesRedundant() const; | 855 bool AreMovesRedundant() const; |
856 | 856 |
857 ParallelMove* const* parallel_moves() const { return ¶llel_moves_[0]; } | 857 ParallelMove* const* parallel_moves() const { return ¶llel_moves_[0]; } |
858 ParallelMove** parallel_moves() { return ¶llel_moves_[0]; } | 858 ParallelMove** parallel_moves() { return ¶llel_moves_[0]; } |
859 | 859 |
| 860 int block_id() const { return block_id_; } |
| 861 void set_block_id(int id) { |
| 862 DCHECK(id >= 0); |
| 863 block_id_ = id; |
| 864 } |
| 865 |
860 void Print(const RegisterConfiguration* config) const; | 866 void Print(const RegisterConfiguration* config) const; |
861 void Print() const; | 867 void Print() const; |
862 | 868 |
863 private: | 869 private: |
864 explicit Instruction(InstructionCode opcode); | 870 explicit Instruction(InstructionCode opcode); |
865 | 871 |
866 Instruction(InstructionCode opcode, size_t output_count, | 872 Instruction(InstructionCode opcode, size_t output_count, |
867 InstructionOperand* outputs, size_t input_count, | 873 InstructionOperand* outputs, size_t input_count, |
868 InstructionOperand* inputs, size_t temp_count, | 874 InstructionOperand* inputs, size_t temp_count, |
869 InstructionOperand* temps); | 875 InstructionOperand* temps); |
870 | 876 |
871 typedef BitField<size_t, 0, 8> OutputCountField; | 877 typedef BitField<size_t, 0, 8> OutputCountField; |
872 typedef BitField<size_t, 8, 16> InputCountField; | 878 typedef BitField<size_t, 8, 16> InputCountField; |
873 typedef BitField<size_t, 24, 6> TempCountField; | 879 typedef BitField<size_t, 24, 6> TempCountField; |
874 typedef BitField<bool, 30, 1> IsCallField; | 880 typedef BitField<bool, 30, 1> IsCallField; |
875 | 881 |
876 InstructionCode opcode_; | 882 InstructionCode opcode_; |
877 uint32_t bit_field_; | 883 uint32_t bit_field_; |
878 ParallelMove* parallel_moves_[2]; | 884 ParallelMove* parallel_moves_[2]; |
879 ReferenceMap* reference_map_; | 885 ReferenceMap* reference_map_; |
| 886 int block_id_; |
880 InstructionOperand operands_[1]; | 887 InstructionOperand operands_[1]; |
881 | 888 |
882 DISALLOW_COPY_AND_ASSIGN(Instruction); | 889 DISALLOW_COPY_AND_ASSIGN(Instruction); |
883 }; | 890 }; |
884 | 891 |
885 | 892 |
886 struct PrintableInstruction { | 893 struct PrintableInstruction { |
887 const RegisterConfiguration* register_configuration_; | 894 const RegisterConfiguration* register_configuration_; |
888 const Instruction* instr_; | 895 const Instruction* instr_; |
889 }; | 896 }; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 | 1303 |
1297 Isolate* isolate() const { return isolate_; } | 1304 Isolate* isolate() const { return isolate_; } |
1298 const ReferenceMapDeque* reference_maps() const { return &reference_maps_; } | 1305 const ReferenceMapDeque* reference_maps() const { return &reference_maps_; } |
1299 Zone* zone() const { return zone_; } | 1306 Zone* zone() const { return zone_; } |
1300 | 1307 |
1301 // Used by the instruction selector while adding instructions. | 1308 // Used by the instruction selector while adding instructions. |
1302 int AddInstruction(Instruction* instr); | 1309 int AddInstruction(Instruction* instr); |
1303 void StartBlock(RpoNumber rpo); | 1310 void StartBlock(RpoNumber rpo); |
1304 void EndBlock(RpoNumber rpo); | 1311 void EndBlock(RpoNumber rpo); |
1305 | 1312 |
| 1313 void FinishInstructionMap(); |
| 1314 |
1306 int AddConstant(int virtual_register, Constant constant) { | 1315 int AddConstant(int virtual_register, Constant constant) { |
1307 // TODO(titzer): allow RPO numbers as constants? | 1316 // TODO(titzer): allow RPO numbers as constants? |
1308 DCHECK(constant.type() != Constant::kRpoNumber); | 1317 DCHECK(constant.type() != Constant::kRpoNumber); |
1309 DCHECK(virtual_register >= 0 && virtual_register < next_virtual_register_); | 1318 DCHECK(virtual_register >= 0 && virtual_register < next_virtual_register_); |
1310 DCHECK(constants_.find(virtual_register) == constants_.end()); | 1319 DCHECK(constants_.find(virtual_register) == constants_.end()); |
1311 constants_.insert(std::make_pair(virtual_register, constant)); | 1320 constants_.insert(std::make_pair(virtual_register, constant)); |
1312 return virtual_register; | 1321 return virtual_register; |
1313 } | 1322 } |
1314 Constant GetConstant(int virtual_register) const { | 1323 Constant GetConstant(int virtual_register) const { |
1315 ConstantMap::const_iterator it = constants_.find(virtual_register); | 1324 ConstantMap::const_iterator it = constants_.find(virtual_register); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 private: | 1396 private: |
1388 friend std::ostream& operator<<(std::ostream& os, | 1397 friend std::ostream& operator<<(std::ostream& os, |
1389 const PrintableInstructionSequence& code); | 1398 const PrintableInstructionSequence& code); |
1390 | 1399 |
1391 typedef ZoneMap<const Instruction*, SourcePosition> SourcePositionMap; | 1400 typedef ZoneMap<const Instruction*, SourcePosition> SourcePositionMap; |
1392 | 1401 |
1393 Isolate* isolate_; | 1402 Isolate* isolate_; |
1394 Zone* const zone_; | 1403 Zone* const zone_; |
1395 InstructionBlocks* const instruction_blocks_; | 1404 InstructionBlocks* const instruction_blocks_; |
1396 SourcePositionMap source_positions_; | 1405 SourcePositionMap source_positions_; |
1397 IntVector block_starts_; | |
1398 ConstantMap constants_; | 1406 ConstantMap constants_; |
1399 Immediates immediates_; | 1407 Immediates immediates_; |
1400 InstructionDeque instructions_; | 1408 InstructionDeque instructions_; |
1401 int next_virtual_register_; | 1409 int next_virtual_register_; |
1402 ReferenceMapDeque reference_maps_; | 1410 ReferenceMapDeque reference_maps_; |
1403 ZoneVector<MachineRepresentation> representations_; | 1411 ZoneVector<MachineRepresentation> representations_; |
1404 DeoptimizationVector deoptimization_entries_; | 1412 DeoptimizationVector deoptimization_entries_; |
1405 | 1413 |
1406 DISALLOW_COPY_AND_ASSIGN(InstructionSequence); | 1414 DISALLOW_COPY_AND_ASSIGN(InstructionSequence); |
1407 }; | 1415 }; |
1408 | 1416 |
1409 | 1417 |
1410 struct PrintableInstructionSequence { | 1418 struct PrintableInstructionSequence { |
1411 const RegisterConfiguration* register_configuration_; | 1419 const RegisterConfiguration* register_configuration_; |
1412 const InstructionSequence* sequence_; | 1420 const InstructionSequence* sequence_; |
1413 }; | 1421 }; |
1414 | 1422 |
1415 | 1423 |
1416 std::ostream& operator<<(std::ostream& os, | 1424 std::ostream& operator<<(std::ostream& os, |
1417 const PrintableInstructionSequence& code); | 1425 const PrintableInstructionSequence& code); |
1418 | 1426 |
1419 } // namespace compiler | 1427 } // namespace compiler |
1420 } // namespace internal | 1428 } // namespace internal |
1421 } // namespace v8 | 1429 } // namespace v8 |
1422 | 1430 |
1423 #endif // V8_COMPILER_INSTRUCTION_H_ | 1431 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |