blob: f3ab54f01818788ae70fb2a6aa59714aefd9e776 [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
Emily Bernierd0a1eb72015-03-24 16:35:39 -04008#include "src/zone-containers.h"
9
10namespace v8 {
11namespace internal {
12namespace compiler {
13
14class InstructionOperand;
15class InstructionSequence;
16
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000017class RegisterAllocatorVerifier final : public ZoneObject {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040018 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 Murdoch4a90d5f2016-03-22 12:00:34 +000033 kSlot,
34 kDoubleSlot,
Emily Bernierd0a1eb72015-03-24 16:35:39 -040035 kFixedSlot,
36 kNone,
37 kNoneDouble,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000038 kExplicit,
39 kSameAsFirst,
40 kRegisterAndSlot
Emily Bernierd0a1eb72015-03-24 16:35:39 -040041 };
42
43 struct OperandConstraint {
44 ConstraintType type_;
45 int value_; // subkind index when relevant
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000046 int spilled_slot_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040047 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 Murdoch4a90d5f2016-03-22 12:00:34 +000056 class BlockMaps;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040057
58 typedef ZoneVector<InstructionConstraint> Constraints;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040059
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 Murdoch4a90d5f2016-03-22 12:00:34 +000074 void VerifyGapMoves(BlockMaps* outgoing_mappings, bool initial_pass);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040075
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