Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: src/compiler/register-allocator-verifier.h

Issue 2081443002: [Turbofan] Clean up register allocator and verifier code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/zone-containers.h" 8 #include "src/zone-containers.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // FinalAssessmens are associated to operands that we know to be a certain 92 // FinalAssessmens are associated to operands that we know to be a certain
93 // virtual register. 93 // virtual register.
94 class FinalAssessment final : public Assessment { 94 class FinalAssessment final : public Assessment {
95 public: 95 public:
96 explicit FinalAssessment(int virtual_register, 96 explicit FinalAssessment(int virtual_register,
97 const PendingAssessment* original_pending = nullptr) 97 const PendingAssessment* original_pending = nullptr)
98 : Assessment(Final), 98 : Assessment(Final),
99 virtual_register_(virtual_register), 99 virtual_register_(virtual_register),
100 original_pending_assessment_(original_pending) {} 100 original_pending_assessment_(original_pending) {}
101 101
102 int virtual_register() const { return virtual_register_; }
103 static const FinalAssessment* cast(const Assessment* assessment) { 102 static const FinalAssessment* cast(const Assessment* assessment) {
104 CHECK(assessment->kind() == Final); 103 CHECK(assessment->kind() == Final);
105 return static_cast<const FinalAssessment*>(assessment); 104 return static_cast<const FinalAssessment*>(assessment);
106 } 105 }
107 106
107 int virtual_register() const { return virtual_register_; }
108 const PendingAssessment* original_pending_assessment() const { 108 const PendingAssessment* original_pending_assessment() const {
Mircea Trofin 2016/06/18 00:39:32 Can you move this line back to where it was, since
bbudge 2016/06/18 22:15:51 I moved it so it would be near the other getter, a
109 return original_pending_assessment_; 109 return original_pending_assessment_;
110 } 110 }
111 111
112 private: 112 private:
113 int virtual_register_; 113 int virtual_register_;
114 const PendingAssessment* original_pending_assessment_; 114 const PendingAssessment* original_pending_assessment_;
115 115
116 DISALLOW_COPY_AND_ASSIGN(FinalAssessment); 116 DISALLOW_COPY_AND_ASSIGN(FinalAssessment);
117 }; 117 };
118 118
119 struct OperandAsKeyLess {
120 bool operator()(const InstructionOperand& a,
121 const InstructionOperand& b) const {
122 return a.CompareCanonicalized(b);
123 }
124 };
125
126 // Assessments associated with a basic block. 119 // Assessments associated with a basic block.
127 class BlockAssessments : public ZoneObject { 120 class BlockAssessments : public ZoneObject {
128 public: 121 public:
129 typedef ZoneMap<InstructionOperand, Assessment*, OperandAsKeyLess> OperandMap; 122 typedef ZoneMap<InstructionOperand, Assessment*, CompareOperandModuloType>
123 OperandMap;
130 explicit BlockAssessments(Zone* zone) 124 explicit BlockAssessments(Zone* zone)
131 : map_(zone), map_for_moves_(zone), zone_(zone) {} 125 : map_(zone), map_for_moves_(zone), zone_(zone) {}
132 void Drop(InstructionOperand operand) { map_.erase(operand); } 126 void Drop(InstructionOperand operand) { map_.erase(operand); }
133 void DropRegisters(); 127 void DropRegisters();
134 void AddDefinition(InstructionOperand operand, int virtual_register) { 128 void AddDefinition(InstructionOperand operand, int virtual_register) {
135 auto existent = map_.find(operand); 129 auto existent = map_.find(operand);
136 if (existent != map_.end()) { 130 if (existent != map_.end()) {
137 // Drop the assignment 131 // Drop the assignment
138 map_.erase(existent); 132 map_.erase(existent);
139 } 133 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 struct InstructionConstraint { 191 struct InstructionConstraint {
198 const Instruction* instruction_; 192 const Instruction* instruction_;
199 size_t operand_constaints_size_; 193 size_t operand_constaints_size_;
200 OperandConstraint* operand_constraints_; 194 OperandConstraint* operand_constraints_;
201 }; 195 };
202 196
203 typedef ZoneVector<InstructionConstraint> Constraints; 197 typedef ZoneVector<InstructionConstraint> Constraints;
204 198
205 class DelayedAssessments : public ZoneObject { 199 class DelayedAssessments : public ZoneObject {
206 public: 200 public:
201 typedef ZoneMap<InstructionOperand, int, CompareOperandModuloType>
202 OperandMap;
207 explicit DelayedAssessments(Zone* zone) : map_(zone) {} 203 explicit DelayedAssessments(Zone* zone) : map_(zone) {}
208 204
209 const ZoneMap<InstructionOperand, int, OperandAsKeyLess>& map() const { 205 const OperandMap& map() const { return map_; }
210 return map_;
211 }
212 206
213 void AddDelayedAssessment(InstructionOperand op, int vreg) { 207 void AddDelayedAssessment(InstructionOperand op, int vreg) {
214 auto it = map_.find(op); 208 auto it = map_.find(op);
215 if (it == map_.end()) { 209 if (it == map_.end()) {
216 map_.insert(std::make_pair(op, vreg)); 210 map_.insert(std::make_pair(op, vreg));
217 } else { 211 } else {
218 CHECK_EQ(it->second, vreg); 212 CHECK_EQ(it->second, vreg);
219 } 213 }
220 } 214 }
221 215
222 private: 216 private:
223 ZoneMap<InstructionOperand, int, OperandAsKeyLess> map_; 217 OperandMap map_;
224 }; 218 };
225 219
226 Zone* zone() const { return zone_; } 220 Zone* zone() const { return zone_; }
227 const RegisterConfiguration* config() { return config_; } 221 const RegisterConfiguration* config() { return config_; }
228 const InstructionSequence* sequence() const { return sequence_; } 222 const InstructionSequence* sequence() const { return sequence_; }
229 Constraints* constraints() { return &constraints_; } 223 Constraints* constraints() { return &constraints_; }
230 224
231 static void VerifyInput(const OperandConstraint& constraint); 225 static void VerifyInput(const OperandConstraint& constraint);
232 static void VerifyTemp(const OperandConstraint& constraint); 226 static void VerifyTemp(const OperandConstraint& constraint);
233 static void VerifyOutput(const OperandConstraint& constraint); 227 static void VerifyOutput(const OperandConstraint& constraint);
(...skipping 23 matching lines...) Expand all
257 ZoneMap<RpoNumber, DelayedAssessments*> outstanding_assessments_; 251 ZoneMap<RpoNumber, DelayedAssessments*> outstanding_assessments_;
258 252
259 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier); 253 DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorVerifier);
260 }; 254 };
261 255
262 } // namespace compiler 256 } // namespace compiler
263 } // namespace internal 257 } // namespace internal
264 } // namespace v8 258 } // namespace v8
265 259
266 #endif 260 #endif
OLDNEW
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698