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/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/graph-inl.h" | 10 #include "src/compiler/graph-inl.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 Node::Inputs inputs = node->inputs(); | 277 Node::Inputs inputs = node->inputs(); |
278 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); | 278 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); |
279 ++iter, --values) { | 279 ++iter, --values) { |
280 // TODO(titzer): it'd be nice to have distinguished edge kinds here. | 280 // TODO(titzer): it'd be nice to have distinguished edge kinds here. |
281 ProcessInput(node, iter.index(), values > 0 ? use : 0); | 281 ProcessInput(node, iter.index(), values > 0 ? use : 0); |
282 } | 282 } |
283 } | 283 } |
284 // Phis adapt to whatever output representation their uses demand, | 284 // Phis adapt to whatever output representation their uses demand, |
285 // pushing representation changes to their inputs. | 285 // pushing representation changes to their inputs. |
286 MachineTypeUnion use_rep = GetUseInfo(node) & kRepMask; | 286 MachineTypeUnion use_rep = GetUseInfo(node) & kRepMask; |
287 MachineTypeUnion use_type = GetUseInfo(node) & kTypeMask; | 287 Type* upper = NodeProperties::GetBounds(node).upper; |
| 288 MachineTypeUnion phi_type = changer_->TypeFromUpperBound(upper); |
288 MachineTypeUnion rep = 0; | 289 MachineTypeUnion rep = 0; |
289 if (use_rep & kRepTagged) { | 290 if (use_rep & kRepTagged) { |
290 rep = kRepTagged; // Tagged overrides everything. | 291 rep = kRepTagged; // Tagged overrides everything. |
291 } else if (use_rep & kRepFloat32) { | 292 } else if (use_rep & kRepFloat32) { |
292 rep = kRepFloat32; | 293 rep = kRepFloat32; |
293 } else if (use_rep & kRepFloat64) { | 294 } else if (use_rep & kRepFloat64) { |
294 rep = kRepFloat64; | 295 rep = kRepFloat64; |
295 } else if (use_rep & kRepWord64) { | 296 } else if (use_rep & kRepWord64) { |
296 rep = kRepWord64; | 297 rep = kRepWord64; |
297 } else if (use_rep & kRepWord32) { | 298 } else if (use_rep & kRepWord32) { |
298 rep = kRepWord32; | 299 if (phi_type & kTypeNumber) { |
| 300 rep = kRepFloat64; |
| 301 } else { |
| 302 rep = kRepWord32; |
| 303 } |
299 } else if (use_rep & kRepBit) { | 304 } else if (use_rep & kRepBit) { |
300 rep = kRepBit; | 305 rep = kRepBit; |
301 } else { | 306 } else { |
302 // There was no representation associated with any of the uses. | 307 // There was no representation associated with any of the uses. |
303 // TODO(titzer): Select the best rep using phi's type, not the usage type? | 308 if (phi_type & kTypeAny) { |
304 if (use_type & kTypeAny) { | |
305 rep = kRepTagged; | 309 rep = kRepTagged; |
306 } else if (use_type & kTypeNumber) { | 310 } else if (phi_type & kTypeNumber) { |
307 rep = kRepFloat64; | 311 rep = kRepFloat64; |
308 } else if (use_type & kTypeInt64 || use_type & kTypeUint64) { | 312 } else if (phi_type & kTypeInt64 || phi_type & kTypeUint64) { |
309 rep = kRepWord64; | 313 rep = kRepWord64; |
310 } else if (use_type & kTypeInt32 || use_type & kTypeUint32) { | 314 } else if (phi_type & kTypeInt32 || phi_type & kTypeUint32) { |
311 rep = kRepWord32; | 315 rep = kRepWord32; |
312 } else if (use_type & kTypeBool) { | 316 } else if (phi_type & kTypeBool) { |
313 rep = kRepBit; | 317 rep = kRepBit; |
314 } else { | 318 } else { |
315 UNREACHABLE(); // should have at least a usage type! | 319 UNREACHABLE(); // should have at least a usage type! |
316 } | 320 } |
317 } | 321 } |
318 // Preserve the usage type, but set the representation. | 322 // Preserve the usage type, but set the representation. |
319 Type* upper = NodeProperties::GetBounds(node).upper; | 323 MachineTypeUnion output_type = rep | phi_type; |
320 MachineTypeUnion output_type = rep | changer_->TypeFromUpperBound(upper); | |
321 SetOutput(node, output_type); | 324 SetOutput(node, output_type); |
322 | 325 |
323 if (lower()) { | 326 if (lower()) { |
324 int values = OperatorProperties::GetValueInputCount(node->op()); | 327 int values = OperatorProperties::GetValueInputCount(node->op()); |
325 | 328 |
326 // Update the phi operator. | 329 // Update the phi operator. |
327 MachineType type = static_cast<MachineType>(output_type); | 330 MachineType type = static_cast<MachineType>(output_type); |
328 if (type != OpParameter<MachineType>(node)) { | 331 if (type != OpParameter<MachineType>(node)) { |
329 node->set_op(lowering->common()->Phi(type, values)); | 332 node->set_op(lowering->common()->Phi(type, values)); |
330 } | 333 } |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 case IrOpcode::kFloat64Mod: | 730 case IrOpcode::kFloat64Mod: |
728 return VisitFloat64Binop(node); | 731 return VisitFloat64Binop(node); |
729 case IrOpcode::kFloat64Sqrt: | 732 case IrOpcode::kFloat64Sqrt: |
730 return VisitUnop(node, kMachFloat64, kMachFloat64); | 733 return VisitUnop(node, kMachFloat64, kMachFloat64); |
731 case IrOpcode::kFloat64Equal: | 734 case IrOpcode::kFloat64Equal: |
732 case IrOpcode::kFloat64LessThan: | 735 case IrOpcode::kFloat64LessThan: |
733 case IrOpcode::kFloat64LessThanOrEqual: | 736 case IrOpcode::kFloat64LessThanOrEqual: |
734 return VisitFloat64Cmp(node); | 737 return VisitFloat64Cmp(node); |
735 case IrOpcode::kLoadStackPointer: | 738 case IrOpcode::kLoadStackPointer: |
736 return VisitLeaf(node, kMachPtr); | 739 return VisitLeaf(node, kMachPtr); |
| 740 case IrOpcode::kStateValues: |
| 741 for (int i = 0; i < node->InputCount(); i++) { |
| 742 ProcessInput(node, i, kTypeAny); |
| 743 } |
| 744 SetOutput(node, kMachAnyTagged); |
| 745 break; |
737 default: | 746 default: |
738 VisitInputs(node); | 747 VisitInputs(node); |
739 break; | 748 break; |
740 } | 749 } |
741 } | 750 } |
742 | 751 |
743 void DeferReplacement(Node* node, Node* replacement) { | 752 void DeferReplacement(Node* node, Node* replacement) { |
744 if (replacement->id() < count_) { | 753 if (replacement->id() < count_) { |
745 // Replace with a previously existing node eagerly. | 754 // Replace with a previously existing node eagerly. |
746 node->ReplaceUses(replacement); | 755 node->ReplaceUses(replacement); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 979 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
971 node->set_op(machine()->IntLessThanOrEqual()); | 980 node->set_op(machine()->IntLessThanOrEqual()); |
972 node->ReplaceInput(0, StringComparison(node, true)); | 981 node->ReplaceInput(0, StringComparison(node, true)); |
973 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 982 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
974 } | 983 } |
975 | 984 |
976 | 985 |
977 } // namespace compiler | 986 } // namespace compiler |
978 } // namespace internal | 987 } // namespace internal |
979 } // namespace v8 | 988 } // namespace v8 |
OLD | NEW |