| 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 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
| 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
| 7 | 7 |
| 8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
| 9 #include "src/compiler/instruction-selector.h" | 9 #include "src/compiler/instruction-selector.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 int virtual_register = GetVReg(node); | 65 int virtual_register = GetVReg(node); |
| 66 sequence()->AddConstant(virtual_register, ToConstant(node)); | 66 sequence()->AddConstant(virtual_register, ToConstant(node)); |
| 67 return ConstantOperand(virtual_register); | 67 return ConstantOperand(virtual_register); |
| 68 } | 68 } |
| 69 | 69 |
| 70 InstructionOperand DefineAsLocation(Node* node, LinkageLocation location, | 70 InstructionOperand DefineAsLocation(Node* node, LinkageLocation location, |
| 71 MachineType type) { | 71 MachineType type) { |
| 72 return Define(node, ToUnallocatedOperand(location, type, GetVReg(node))); | 72 return Define(node, ToUnallocatedOperand(location, type, GetVReg(node))); |
| 73 } | 73 } |
| 74 | 74 |
| 75 InstructionOperand DefineAsDualLocation(Node* node, |
| 76 LinkageLocation primary_location, |
| 77 LinkageLocation secondary_location) { |
| 78 return Define(node, |
| 79 ToDualLocationUnallocatedOperand( |
| 80 primary_location, secondary_location, GetVReg(node))); |
| 81 } |
| 82 |
| 75 InstructionOperand Use(Node* node) { | 83 InstructionOperand Use(Node* node) { |
| 76 return Use(node, UnallocatedOperand(UnallocatedOperand::NONE, | 84 return Use(node, UnallocatedOperand(UnallocatedOperand::NONE, |
| 77 UnallocatedOperand::USED_AT_START, | 85 UnallocatedOperand::USED_AT_START, |
| 78 GetVReg(node))); | 86 GetVReg(node))); |
| 79 } | 87 } |
| 80 | 88 |
| 81 InstructionOperand UseAny(Node* node) { | 89 InstructionOperand UseAny(Node* node) { |
| 82 return Use(node, UnallocatedOperand(UnallocatedOperand::ANY, | 90 return Use(node, UnallocatedOperand(UnallocatedOperand::ANY, |
| 83 UnallocatedOperand::USED_AT_START, | 91 UnallocatedOperand::USED_AT_START, |
| 84 GetVReg(node))); | 92 GetVReg(node))); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return operand; | 212 return operand; |
| 205 } | 213 } |
| 206 | 214 |
| 207 UnallocatedOperand Use(Node* node, UnallocatedOperand operand) { | 215 UnallocatedOperand Use(Node* node, UnallocatedOperand operand) { |
| 208 DCHECK_NOT_NULL(node); | 216 DCHECK_NOT_NULL(node); |
| 209 DCHECK_EQ(operand.virtual_register(), GetVReg(node)); | 217 DCHECK_EQ(operand.virtual_register(), GetVReg(node)); |
| 210 selector()->MarkAsUsed(node); | 218 selector()->MarkAsUsed(node); |
| 211 return operand; | 219 return operand; |
| 212 } | 220 } |
| 213 | 221 |
| 222 UnallocatedOperand ToDualLocationUnallocatedOperand( |
| 223 LinkageLocation primary_location, LinkageLocation secondary_location, |
| 224 int virtual_register) { |
| 225 // We only support the primary location being a register and the secondary |
| 226 // one a slot. |
| 227 DCHECK(primary_location.IsRegister() && |
| 228 secondary_location.IsCalleeFrameSlot()); |
| 229 int reg_id = primary_location.AsRegister(); |
| 230 int slot_id = secondary_location.AsCalleeFrameSlot(); |
| 231 return UnallocatedOperand(reg_id, slot_id, virtual_register); |
| 232 } |
| 233 |
| 214 UnallocatedOperand ToUnallocatedOperand(LinkageLocation location, | 234 UnallocatedOperand ToUnallocatedOperand(LinkageLocation location, |
| 215 MachineType type, | 235 MachineType type, |
| 216 int virtual_register) { | 236 int virtual_register) { |
| 217 if (location.IsAnyRegister()) { | 237 if (location.IsAnyRegister()) { |
| 218 // any machine register. | 238 // any machine register. |
| 219 return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, | 239 return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, |
| 220 virtual_register); | 240 virtual_register); |
| 221 } | 241 } |
| 222 if (location.IsCallerFrameSlot()) { | 242 if (location.IsCallerFrameSlot()) { |
| 223 // a location on the caller frame. | 243 // a location on the caller frame. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 Node* result_; // Only valid if mode_ == kFlags_set. | 341 Node* result_; // Only valid if mode_ == kFlags_set. |
| 322 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. | 342 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. |
| 323 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. | 343 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. |
| 324 }; | 344 }; |
| 325 | 345 |
| 326 } // namespace compiler | 346 } // namespace compiler |
| 327 } // namespace internal | 347 } // namespace internal |
| 328 } // namespace v8 | 348 } // namespace v8 |
| 329 | 349 |
| 330 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 350 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
| OLD | NEW |