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