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