86fda1670ddb89ee52dd988f423624b3720f8e2a
[platform/upstream/nodejs.git] / deps / v8 / src / compiler / register-allocator-verifier.h
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
8 #include "src/zone-containers.h"
9
10 namespace v8 {
11 namespace internal {
12 namespace compiler {
13
14 class InstructionOperand;
15 class InstructionSequence;
16
17 class RegisterAllocatorVerifier FINAL : public ZoneObject {
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,
33     kFixedSlot,
34     kNone,
35     kNoneDouble,
36     kSameAsFirst
37   };
38
39   struct OperandConstraint {
40     ConstraintType type_;
41     int value_;  // subkind index when relevant
42     int virtual_register_;
43   };
44
45   struct InstructionConstraint {
46     const Instruction* instruction_;
47     size_t operand_constaints_size_;
48     OperandConstraint* operand_constraints_;
49   };
50
51   class BlockMaps;
52
53   typedef ZoneVector<InstructionConstraint> Constraints;
54
55   Zone* zone() const { return zone_; }
56   const RegisterConfiguration* config() { return config_; }
57   const InstructionSequence* sequence() const { return sequence_; }
58   Constraints* constraints() { return &constraints_; }
59
60   static void VerifyInput(const OperandConstraint& constraint);
61   static void VerifyTemp(const OperandConstraint& constraint);
62   static void VerifyOutput(const OperandConstraint& constraint);
63
64   void BuildConstraint(const InstructionOperand* op,
65                        OperandConstraint* constraint);
66   void CheckConstraint(const InstructionOperand* op,
67                        const OperandConstraint* constraint);
68
69   void VerifyGapMoves(BlockMaps* outgoing_mappings, bool initial_pass);
70
71   Zone* const zone_;
72   const RegisterConfiguration* config_;
73   const InstructionSequence* const sequence_;
74   Constraints constraints_;
75
76   DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier);
77 };
78
79 }  // namespace compiler
80 }  // namespace internal
81 }  // namespace v8
82
83 #endif