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

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

Issue 1050803002: [turbofan] cleanup InstructionOperand a little (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 8 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') | src/compiler/x64/code-generator-x64.cc » ('j') | 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 #include "src/bit-vector.h" 5 #include "src/bit-vector.h"
6 #include "src/compiler/instruction.h" 6 #include "src/compiler/instruction.h"
7 #include "src/compiler/register-allocator-verifier.h" 7 #include "src/compiler/register-allocator-verifier.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 } 113 }
114 114
115 115
116 void RegisterAllocatorVerifier::BuildConstraint(const InstructionOperand* op, 116 void RegisterAllocatorVerifier::BuildConstraint(const InstructionOperand* op,
117 OperandConstraint* constraint) { 117 OperandConstraint* constraint) {
118 constraint->value_ = kMinInt; 118 constraint->value_ = kMinInt;
119 constraint->virtual_register_ = InstructionOperand::kInvalidVirtualRegister; 119 constraint->virtual_register_ = InstructionOperand::kInvalidVirtualRegister;
120 if (op->IsConstant()) { 120 if (op->IsConstant()) {
121 constraint->type_ = kConstant; 121 constraint->type_ = kConstant;
122 constraint->value_ = ConstantOperand::cast(op)->index(); 122 constraint->value_ = ConstantOperand::cast(op)->virtual_register();
123 constraint->virtual_register_ = constraint->value_; 123 constraint->virtual_register_ = constraint->value_;
124 } else if (op->IsImmediate()) { 124 } else if (op->IsImmediate()) {
125 constraint->type_ = kImmediate; 125 constraint->type_ = kImmediate;
126 constraint->value_ = ImmediateOperand::cast(op)->index(); 126 constraint->value_ = ImmediateOperand::cast(op)->index();
127 } else { 127 } else {
128 CHECK(op->IsUnallocated()); 128 CHECK(op->IsUnallocated());
129 const auto* unallocated = UnallocatedOperand::cast(op); 129 const auto* unallocated = UnallocatedOperand::cast(op);
130 int vreg = unallocated->virtual_register(); 130 int vreg = unallocated->virtual_register();
131 constraint->virtual_register_ = vreg; 131 constraint->virtual_register_ = vreg;
132 if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) { 132 if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 177
178 void RegisterAllocatorVerifier::CheckConstraint( 178 void RegisterAllocatorVerifier::CheckConstraint(
179 const InstructionOperand* op, const OperandConstraint* constraint) { 179 const InstructionOperand* op, const OperandConstraint* constraint) {
180 switch (constraint->type_) { 180 switch (constraint->type_) {
181 case kConstant: 181 case kConstant:
182 CHECK(op->IsConstant()); 182 CHECK(op->IsConstant());
183 CHECK_EQ(op->index(), constraint->value_); 183 CHECK_EQ(ConstantOperand::cast(op)->virtual_register(),
184 constraint->value_);
184 return; 185 return;
185 case kImmediate: 186 case kImmediate:
186 CHECK(op->IsImmediate()); 187 CHECK(op->IsImmediate());
187 CHECK_EQ(op->index(), constraint->value_); 188 CHECK_EQ(ImmediateOperand::cast(op)->index(), constraint->value_);
188 return; 189 return;
189 case kRegister: 190 case kRegister:
190 CHECK(op->IsRegister()); 191 CHECK(op->IsRegister());
191 return; 192 return;
192 case kFixedRegister: 193 case kFixedRegister:
193 CHECK(op->IsRegister()); 194 CHECK(op->IsRegister());
194 CHECK_EQ(op->index(), constraint->value_); 195 CHECK_EQ(RegisterOperand::cast(op)->index(), constraint->value_);
195 return; 196 return;
196 case kDoubleRegister: 197 case kDoubleRegister:
197 CHECK(op->IsDoubleRegister()); 198 CHECK(op->IsDoubleRegister());
198 return; 199 return;
199 case kFixedDoubleRegister: 200 case kFixedDoubleRegister:
200 CHECK(op->IsDoubleRegister()); 201 CHECK(op->IsDoubleRegister());
201 CHECK_EQ(op->index(), constraint->value_); 202 CHECK_EQ(DoubleRegisterOperand::cast(op)->index(), constraint->value_);
202 return; 203 return;
203 case kFixedSlot: 204 case kFixedSlot:
204 CHECK(op->IsStackSlot()); 205 CHECK(op->IsStackSlot());
205 CHECK_EQ(op->index(), constraint->value_); 206 CHECK_EQ(StackSlotOperand::cast(op)->index(), constraint->value_);
206 return; 207 return;
207 case kSlot: 208 case kSlot:
208 CHECK(op->IsStackSlot()); 209 CHECK(op->IsStackSlot());
209 return; 210 return;
210 case kDoubleSlot: 211 case kDoubleSlot:
211 CHECK(op->IsDoubleStackSlot()); 212 CHECK(op->IsDoubleStackSlot());
212 return; 213 return;
213 case kNone: 214 case kNone:
214 CHECK(op->IsRegister() || op->IsStackSlot()); 215 CHECK(op->IsRegister() || op->IsStackSlot());
215 return; 216 return;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 337 }
337 } 338 }
338 339
339 void Drop(const InstructionOperand* op) { 340 void Drop(const InstructionOperand* op) {
340 auto it = map().find(op); 341 auto it = map().find(op);
341 if (it != map().end()) map().erase(it); 342 if (it != map().end()) map().erase(it);
342 } 343 }
343 344
344 void DropRegisters(const RegisterConfiguration* config) { 345 void DropRegisters(const RegisterConfiguration* config) {
345 for (int i = 0; i < config->num_general_registers(); ++i) { 346 for (int i = 0; i < config->num_general_registers(); ++i) {
346 InstructionOperand op(InstructionOperand::REGISTER, i); 347 RegisterOperand op(i);
347 Drop(&op); 348 Drop(&op);
348 } 349 }
349 for (int i = 0; i < config->num_double_registers(); ++i) { 350 for (int i = 0; i < config->num_double_registers(); ++i) {
350 InstructionOperand op(InstructionOperand::DOUBLE_REGISTER, i); 351 DoubleRegisterOperand op(i);
351 Drop(&op); 352 Drop(&op);
352 } 353 }
353 } 354 }
354 355
355 void Define(Zone* zone, const InstructionOperand* op, int virtual_register) { 356 void Define(Zone* zone, const InstructionOperand* op, int virtual_register) {
356 auto value = new (zone) MapValue(); 357 auto value = new (zone) MapValue();
357 value->define_vreg = virtual_register; 358 value->define_vreg = virtual_register;
358 auto res = map().insert(std::make_pair(op, value)); 359 auto res = map().insert(std::make_pair(op, value));
359 if (!res.second) res.first->second = value; 360 if (!res.second) res.first->second = value;
360 } 361 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 int virtual_register = op_constraints[count].virtual_register_; 670 int virtual_register = op_constraints[count].virtual_register_;
670 current->Define(zone(), instr->OutputAt(i), virtual_register); 671 current->Define(zone(), instr->OutputAt(i), virtual_register);
671 } 672 }
672 } 673 }
673 } 674 }
674 } 675 }
675 676
676 } // namespace compiler 677 } // namespace compiler
677 } // namespace internal 678 } // namespace internal
678 } // namespace v8 679 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | src/compiler/x64/code-generator-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698