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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } else { | 136 } else { |
137 return ExplicitOperand(LocationOperand::STACK_SLOT, rep, | 137 return ExplicitOperand(LocationOperand::STACK_SLOT, rep, |
138 location.GetLocation()); | 138 location.GetLocation()); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 InstructionOperand UseImmediate(Node* node) { | 142 InstructionOperand UseImmediate(Node* node) { |
143 return sequence()->AddImmediate(ToConstant(node)); | 143 return sequence()->AddImmediate(ToConstant(node)); |
144 } | 144 } |
145 | 145 |
| 146 InstructionOperand UseNegatedImmediate(Node* node) { |
| 147 return sequence()->AddImmediate(ToNegatedConstant(node)); |
| 148 } |
| 149 |
146 InstructionOperand UseLocation(Node* node, LinkageLocation location) { | 150 InstructionOperand UseLocation(Node* node, LinkageLocation location) { |
147 return Use(node, ToUnallocatedOperand(location, GetVReg(node))); | 151 return Use(node, ToUnallocatedOperand(location, GetVReg(node))); |
148 } | 152 } |
149 | 153 |
150 // Used to force gap moves from the from_location to the to_location | 154 // Used to force gap moves from the from_location to the to_location |
151 // immediately before an instruction. | 155 // immediately before an instruction. |
152 InstructionOperand UsePointerLocation(LinkageLocation to_location, | 156 InstructionOperand UsePointerLocation(LinkageLocation to_location, |
153 LinkageLocation from_location) { | 157 LinkageLocation from_location) { |
154 UnallocatedOperand casted_from_operand = | 158 UnallocatedOperand casted_from_operand = |
155 UnallocatedOperand::cast(TempLocation(from_location)); | 159 UnallocatedOperand::cast(TempLocation(from_location)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return Constant(OpParameter<ExternalReference>(node)); | 222 return Constant(OpParameter<ExternalReference>(node)); |
219 case IrOpcode::kHeapConstant: | 223 case IrOpcode::kHeapConstant: |
220 return Constant(OpParameter<Handle<HeapObject>>(node)); | 224 return Constant(OpParameter<Handle<HeapObject>>(node)); |
221 default: | 225 default: |
222 break; | 226 break; |
223 } | 227 } |
224 UNREACHABLE(); | 228 UNREACHABLE(); |
225 return Constant(static_cast<int32_t>(0)); | 229 return Constant(static_cast<int32_t>(0)); |
226 } | 230 } |
227 | 231 |
| 232 static Constant ToNegatedConstant(const Node* node) { |
| 233 switch (node->opcode()) { |
| 234 case IrOpcode::kInt32Constant: |
| 235 return Constant(-OpParameter<int32_t>(node)); |
| 236 case IrOpcode::kInt64Constant: |
| 237 return Constant(-OpParameter<int64_t>(node)); |
| 238 default: |
| 239 break; |
| 240 } |
| 241 UNREACHABLE(); |
| 242 return Constant(static_cast<int32_t>(0)); |
| 243 } |
| 244 |
228 UnallocatedOperand Define(Node* node, UnallocatedOperand operand) { | 245 UnallocatedOperand Define(Node* node, UnallocatedOperand operand) { |
229 DCHECK_NOT_NULL(node); | 246 DCHECK_NOT_NULL(node); |
230 DCHECK_EQ(operand.virtual_register(), GetVReg(node)); | 247 DCHECK_EQ(operand.virtual_register(), GetVReg(node)); |
231 selector()->MarkAsDefined(node); | 248 selector()->MarkAsDefined(node); |
232 return operand; | 249 return operand; |
233 } | 250 } |
234 | 251 |
235 UnallocatedOperand Use(Node* node, UnallocatedOperand operand) { | 252 UnallocatedOperand Use(Node* node, UnallocatedOperand operand) { |
236 DCHECK_NOT_NULL(node); | 253 DCHECK_NOT_NULL(node); |
237 DCHECK_EQ(operand.virtual_register(), GetVReg(node)); | 254 DCHECK_EQ(operand.virtual_register(), GetVReg(node)); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // or mode_ == kFlags_set. | 397 // or mode_ == kFlags_set. |
381 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. | 398 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. |
382 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. | 399 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. |
383 }; | 400 }; |
384 | 401 |
385 } // namespace compiler | 402 } // namespace compiler |
386 } // namespace internal | 403 } // namespace internal |
387 } // namespace v8 | 404 } // namespace v8 |
388 | 405 |
389 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 406 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
OLD | NEW |