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