| OLD | NEW |
| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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)->virtual_register(); | 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 auto imm = ImmediateOperand::cast(op); |
| 126 int value = imm->type() == ImmediateOperand::INLINE ? imm->inline_value() |
| 127 : imm->indexed_value(); |
| 125 constraint->type_ = kImmediate; | 128 constraint->type_ = kImmediate; |
| 126 constraint->value_ = ImmediateOperand::cast(op)->index(); | 129 constraint->value_ = value; |
| 127 } else { | 130 } else { |
| 128 CHECK(op->IsUnallocated()); | 131 CHECK(op->IsUnallocated()); |
| 129 const auto* unallocated = UnallocatedOperand::cast(op); | 132 const auto* unallocated = UnallocatedOperand::cast(op); |
| 130 int vreg = unallocated->virtual_register(); | 133 int vreg = unallocated->virtual_register(); |
| 131 constraint->virtual_register_ = vreg; | 134 constraint->virtual_register_ = vreg; |
| 132 if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) { | 135 if (unallocated->basic_policy() == UnallocatedOperand::FIXED_SLOT) { |
| 133 constraint->type_ = kFixedSlot; | 136 constraint->type_ = kFixedSlot; |
| 134 constraint->value_ = unallocated->fixed_slot_index(); | 137 constraint->value_ = unallocated->fixed_slot_index(); |
| 135 } else { | 138 } else { |
| 136 switch (unallocated->extended_policy()) { | 139 switch (unallocated->extended_policy()) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 179 |
| 177 | 180 |
| 178 void RegisterAllocatorVerifier::CheckConstraint( | 181 void RegisterAllocatorVerifier::CheckConstraint( |
| 179 const InstructionOperand* op, const OperandConstraint* constraint) { | 182 const InstructionOperand* op, const OperandConstraint* constraint) { |
| 180 switch (constraint->type_) { | 183 switch (constraint->type_) { |
| 181 case kConstant: | 184 case kConstant: |
| 182 CHECK(op->IsConstant()); | 185 CHECK(op->IsConstant()); |
| 183 CHECK_EQ(ConstantOperand::cast(op)->virtual_register(), | 186 CHECK_EQ(ConstantOperand::cast(op)->virtual_register(), |
| 184 constraint->value_); | 187 constraint->value_); |
| 185 return; | 188 return; |
| 186 case kImmediate: | 189 case kImmediate: { |
| 187 CHECK(op->IsImmediate()); | 190 CHECK(op->IsImmediate()); |
| 188 CHECK_EQ(ImmediateOperand::cast(op)->index(), constraint->value_); | 191 auto imm = ImmediateOperand::cast(op); |
| 192 int value = imm->type() == ImmediateOperand::INLINE |
| 193 ? imm->inline_value() |
| 194 : imm->indexed_value(); |
| 195 CHECK_EQ(value, constraint->value_); |
| 189 return; | 196 return; |
| 197 } |
| 190 case kRegister: | 198 case kRegister: |
| 191 CHECK(op->IsRegister()); | 199 CHECK(op->IsRegister()); |
| 192 return; | 200 return; |
| 193 case kFixedRegister: | 201 case kFixedRegister: |
| 194 CHECK(op->IsRegister()); | 202 CHECK(op->IsRegister()); |
| 195 CHECK_EQ(RegisterOperand::cast(op)->index(), constraint->value_); | 203 CHECK_EQ(RegisterOperand::cast(op)->index(), constraint->value_); |
| 196 return; | 204 return; |
| 197 case kDoubleRegister: | 205 case kDoubleRegister: |
| 198 CHECK(op->IsDoubleRegister()); | 206 CHECK(op->IsDoubleRegister()); |
| 199 return; | 207 return; |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 int virtual_register = op_constraints[count].virtual_register_; | 678 int virtual_register = op_constraints[count].virtual_register_; |
| 671 current->Define(zone(), instr->OutputAt(i), virtual_register); | 679 current->Define(zone(), instr->OutputAt(i), virtual_register); |
| 672 } | 680 } |
| 673 } | 681 } |
| 674 } | 682 } |
| 675 } | 683 } |
| 676 | 684 |
| 677 } // namespace compiler | 685 } // namespace compiler |
| 678 } // namespace internal | 686 } // namespace internal |
| 679 } // namespace v8 | 687 } // namespace v8 |
| OLD | NEW |