| 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_REGISTER_ALLOCATOR_VERIFIER_H_ | 5 #ifndef V8_REGISTER_ALLOCATOR_VERIFIER_H_ |
| 6 #define V8_REGISTER_ALLOCATOR_VERIFIER_H_ | 6 #define V8_REGISTER_ALLOCATOR_VERIFIER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 class InstructionOperand; | 15 class InstructionOperand; |
| 16 class InstructionSequence; | 16 class InstructionSequence; |
| 17 | 17 |
| 18 class RegisterAllocatorVerifier FINAL : public ZoneObject { | 18 class RegisterAllocatorVerifier FINAL : public ZoneObject { |
| 19 public: | 19 public: |
| 20 RegisterAllocatorVerifier(Zone* zone, const InstructionSequence* sequence); | 20 RegisterAllocatorVerifier(Zone* zone, const RegisterConfiguration* config, |
| 21 const InstructionSequence* sequence); |
| 21 | 22 |
| 22 void VerifyAssignment(); | 23 void VerifyAssignment(); |
| 24 void VerifyGapMoves(); |
| 23 | 25 |
| 24 private: | 26 private: |
| 25 enum ConstraintType { | 27 enum ConstraintType { |
| 26 kConstant, | 28 kConstant, |
| 27 kImmediate, | 29 kImmediate, |
| 28 kRegister, | 30 kRegister, |
| 29 kFixedRegister, | 31 kFixedRegister, |
| 30 kDoubleRegister, | 32 kDoubleRegister, |
| 31 kFixedDoubleRegister, | 33 kFixedDoubleRegister, |
| 32 kFixedSlot, | 34 kFixedSlot, |
| 33 kNone, | 35 kNone, |
| 34 kNoneDouble, | 36 kNoneDouble, |
| 35 kSameAsFirst | 37 kSameAsFirst |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 struct OperandConstraint { | 40 struct OperandConstraint { |
| 39 ConstraintType type_; | 41 ConstraintType type_; |
| 40 int value_; // subkind index when relevant | 42 int value_; // subkind index when relevant |
| 43 int virtual_register_; |
| 41 }; | 44 }; |
| 42 | 45 |
| 43 struct InstructionConstraint { | 46 struct InstructionConstraint { |
| 44 const Instruction* instruction_; | 47 const Instruction* instruction_; |
| 45 size_t operand_constaints_size_; | 48 size_t operand_constaints_size_; |
| 46 OperandConstraint* operand_constraints_; | 49 OperandConstraint* operand_constraints_; |
| 47 }; | 50 }; |
| 48 | 51 |
| 52 class OutgoingMapping; |
| 53 |
| 49 typedef ZoneVector<InstructionConstraint> Constraints; | 54 typedef ZoneVector<InstructionConstraint> Constraints; |
| 55 typedef ZoneVector<OutgoingMapping*> OutgoingMappings; |
| 50 | 56 |
| 57 Zone* zone() const { return zone_; } |
| 58 const RegisterConfiguration* config() { return config_; } |
| 51 const InstructionSequence* sequence() const { return sequence_; } | 59 const InstructionSequence* sequence() const { return sequence_; } |
| 52 Constraints* constraints() { return &constraints_; } | 60 Constraints* constraints() { return &constraints_; } |
| 61 |
| 62 static void VerifyInput(const OperandConstraint& constraint); |
| 63 static void VerifyTemp(const OperandConstraint& constraint); |
| 64 static void VerifyOutput(const OperandConstraint& constraint); |
| 65 |
| 53 void BuildConstraint(const InstructionOperand* op, | 66 void BuildConstraint(const InstructionOperand* op, |
| 54 OperandConstraint* constraint); | 67 OperandConstraint* constraint); |
| 55 void CheckConstraint(const InstructionOperand* op, | 68 void CheckConstraint(const InstructionOperand* op, |
| 56 const OperandConstraint* constraint); | 69 const OperandConstraint* constraint); |
| 57 | 70 |
| 71 void ConstructOutgoingMappings(OutgoingMappings* outgoing_mappings, |
| 72 bool initial_pass); |
| 73 |
| 74 Zone* const zone_; |
| 75 const RegisterConfiguration* config_; |
| 58 const InstructionSequence* const sequence_; | 76 const InstructionSequence* const sequence_; |
| 59 Constraints constraints_; | 77 Constraints constraints_; |
| 60 | 78 |
| 61 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier); | 79 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier); |
| 62 }; | 80 }; |
| 63 | 81 |
| 64 } // namespace compiler | 82 } // namespace compiler |
| 65 } // namespace internal | 83 } // namespace internal |
| 66 } // namespace v8 | 84 } // namespace v8 |
| 67 | 85 |
| 68 #endif | 86 #endif |
| OLD | NEW |