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/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/graph-inl.h" | 9 #include "src/compiler/graph-inl.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 void VisitUint64Binop(Node* node) { | 260 void VisitUint64Binop(Node* node) { |
261 VisitBinop(node, kMachUint64, kMachUint64); | 261 VisitBinop(node, kMachUint64, kMachUint64); |
262 } | 262 } |
263 void VisitFloat64Cmp(Node* node) { VisitBinop(node, kMachFloat64, kRepBit); } | 263 void VisitFloat64Cmp(Node* node) { VisitBinop(node, kMachFloat64, kRepBit); } |
264 void VisitInt32Cmp(Node* node) { VisitBinop(node, kMachInt32, kRepBit); } | 264 void VisitInt32Cmp(Node* node) { VisitBinop(node, kMachInt32, kRepBit); } |
265 void VisitUint32Cmp(Node* node) { VisitBinop(node, kMachUint32, kRepBit); } | 265 void VisitUint32Cmp(Node* node) { VisitBinop(node, kMachUint32, kRepBit); } |
266 void VisitInt64Cmp(Node* node) { VisitBinop(node, kMachInt64, kRepBit); } | 266 void VisitInt64Cmp(Node* node) { VisitBinop(node, kMachInt64, kRepBit); } |
267 void VisitUint64Cmp(Node* node) { VisitBinop(node, kMachUint64, kRepBit); } | 267 void VisitUint64Cmp(Node* node) { VisitBinop(node, kMachUint64, kRepBit); } |
268 | 268 |
269 // Helper for handling phis. | 269 // Helper for handling phis. |
270 void VisitPhi(Node* node, MachineTypeUnion use) { | 270 void VisitPhi(Node* node, MachineTypeUnion use, |
| 271 SimplifiedLowering* lowering) { |
271 // First, propagate the usage information to inputs of the phi. | 272 // First, propagate the usage information to inputs of the phi. |
272 if (!lower()) { | 273 if (!lower()) { |
273 int values = OperatorProperties::GetValueInputCount(node->op()); | 274 int values = OperatorProperties::GetValueInputCount(node->op()); |
274 // Propagate {use} of the phi to value inputs, and 0 to control. | 275 // Propagate {use} of the phi to value inputs, and 0 to control. |
275 Node::Inputs inputs = node->inputs(); | 276 Node::Inputs inputs = node->inputs(); |
276 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); | 277 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); |
277 ++iter, --values) { | 278 ++iter, --values) { |
278 // TODO(titzer): it'd be nice to have distinguished edge kinds here. | 279 // TODO(titzer): it'd be nice to have distinguished edge kinds here. |
279 ProcessInput(node, iter.index(), values > 0 ? use : 0); | 280 ProcessInput(node, iter.index(), values > 0 ? use : 0); |
280 } | 281 } |
(...skipping 30 matching lines...) Expand all Loading... |
311 UNREACHABLE(); // should have at least a usage type! | 312 UNREACHABLE(); // should have at least a usage type! |
312 } | 313 } |
313 } | 314 } |
314 // Preserve the usage type, but set the representation. | 315 // Preserve the usage type, but set the representation. |
315 Type* upper = NodeProperties::GetBounds(node).upper; | 316 Type* upper = NodeProperties::GetBounds(node).upper; |
316 MachineTypeUnion output_type = rep | changer_->TypeFromUpperBound(upper); | 317 MachineTypeUnion output_type = rep | changer_->TypeFromUpperBound(upper); |
317 SetOutput(node, output_type); | 318 SetOutput(node, output_type); |
318 | 319 |
319 if (lower()) { | 320 if (lower()) { |
320 int values = OperatorProperties::GetValueInputCount(node->op()); | 321 int values = OperatorProperties::GetValueInputCount(node->op()); |
| 322 |
| 323 // Update the phi operator. |
| 324 MachineType type = static_cast<MachineType>(output_type); |
| 325 if (type != OpParameter<MachineType>(node)) { |
| 326 node->set_op(lowering->common()->Phi(type, values)); |
| 327 } |
| 328 |
321 // Convert inputs to the output representation of this phi. | 329 // Convert inputs to the output representation of this phi. |
322 Node::Inputs inputs = node->inputs(); | 330 Node::Inputs inputs = node->inputs(); |
323 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); | 331 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); |
324 ++iter, --values) { | 332 ++iter, --values) { |
325 // TODO(titzer): it'd be nice to have distinguished edge kinds here. | 333 // TODO(titzer): it'd be nice to have distinguished edge kinds here. |
326 ProcessInput(node, iter.index(), values > 0 ? output_type : 0); | 334 ProcessInput(node, iter.index(), values > 0 ? output_type : 0); |
327 } | 335 } |
328 } | 336 } |
329 } | 337 } |
330 | 338 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 case IrOpcode::kReturn: | 385 case IrOpcode::kReturn: |
378 case IrOpcode::kMerge: | 386 case IrOpcode::kMerge: |
379 case IrOpcode::kThrow: | 387 case IrOpcode::kThrow: |
380 return VisitInputs(node); // default visit for all node inputs. | 388 return VisitInputs(node); // default visit for all node inputs. |
381 | 389 |
382 case IrOpcode::kBranch: | 390 case IrOpcode::kBranch: |
383 ProcessInput(node, 0, kRepBit); | 391 ProcessInput(node, 0, kRepBit); |
384 Enqueue(NodeProperties::GetControlInput(node, 0)); | 392 Enqueue(NodeProperties::GetControlInput(node, 0)); |
385 break; | 393 break; |
386 case IrOpcode::kPhi: | 394 case IrOpcode::kPhi: |
387 return VisitPhi(node, use); | 395 return VisitPhi(node, use, lowering); |
388 | 396 |
389 //------------------------------------------------------------------ | 397 //------------------------------------------------------------------ |
390 // JavaScript operators. | 398 // JavaScript operators. |
391 //------------------------------------------------------------------ | 399 //------------------------------------------------------------------ |
392 // For now, we assume that all JS operators were too complex to lower | 400 // For now, we assume that all JS operators were too complex to lower |
393 // to Simplified and that they will always require tagged value inputs | 401 // to Simplified and that they will always require tagged value inputs |
394 // and produce tagged value outputs. | 402 // and produce tagged value outputs. |
395 // TODO(turbofan): it might be possible to lower some JSOperators here, | 403 // TODO(turbofan): it might be possible to lower some JSOperators here, |
396 // but that responsibility really lies in the typed lowering phase. | 404 // but that responsibility really lies in the typed lowering phase. |
397 #define DEFINE_JS_CASE(x) case IrOpcode::k##x: | 405 #define DEFINE_JS_CASE(x) case IrOpcode::k##x: |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 899 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
892 node->set_op(machine()->IntLessThanOrEqual()); | 900 node->set_op(machine()->IntLessThanOrEqual()); |
893 node->ReplaceInput(0, StringComparison(node, true)); | 901 node->ReplaceInput(0, StringComparison(node, true)); |
894 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 902 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
895 } | 903 } |
896 | 904 |
897 | 905 |
898 } // namespace compiler | 906 } // namespace compiler |
899 } // namespace internal | 907 } // namespace internal |
900 } // namespace v8 | 908 } // namespace v8 |
OLD | NEW |