Chromium Code Reviews| 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/machine-operator-reducer.h" | 5 #include "src/compiler/machine-operator-reducer.h" |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
| 9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
| 10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
| 11 #include "src/compiler/node-matchers.h" | 11 #include "src/compiler/node-matchers.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 namespace compiler { | 15 namespace compiler { |
| 16 | 16 |
| 17 MachineOperatorReducer::MachineOperatorReducer(JSGraph* jsgraph) | 17 MachineOperatorReducer::MachineOperatorReducer(JSGraph* jsgraph) |
| 18 : jsgraph_(jsgraph) {} | 18 : jsgraph_(jsgraph) {} |
| 19 | 19 |
| 20 | 20 |
| 21 MachineOperatorReducer::~MachineOperatorReducer() {} | 21 MachineOperatorReducer::~MachineOperatorReducer() {} |
| 22 | 22 |
| 23 | 23 |
| 24 Node* MachineOperatorReducer::Float32Constant(volatile float value) { | |
| 25 return graph()->NewNode(common()->Float32Constant(value)); | |
| 26 } | |
| 27 | |
| 28 | |
| 24 Node* MachineOperatorReducer::Float64Constant(volatile double value) { | 29 Node* MachineOperatorReducer::Float64Constant(volatile double value) { |
| 25 return jsgraph()->Float64Constant(value); | 30 return jsgraph()->Float64Constant(value); |
| 26 } | 31 } |
| 27 | 32 |
| 28 | 33 |
| 29 Node* MachineOperatorReducer::Int32Constant(int32_t value) { | 34 Node* MachineOperatorReducer::Int32Constant(int32_t value) { |
| 30 return jsgraph()->Int32Constant(value); | 35 return jsgraph()->Int32Constant(value); |
| 31 } | 36 } |
| 32 | 37 |
| 33 | 38 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); | 425 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); |
| 421 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); | 426 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0)); |
| 422 break; | 427 break; |
| 423 } | 428 } |
| 424 case IrOpcode::kTruncateInt64ToInt32: { | 429 case IrOpcode::kTruncateInt64ToInt32: { |
| 425 Int64Matcher m(node->InputAt(0)); | 430 Int64Matcher m(node->InputAt(0)); |
| 426 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value())); | 431 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value())); |
| 427 if (m.IsChangeInt32ToInt64()) return Replace(m.node()->InputAt(0)); | 432 if (m.IsChangeInt32ToInt64()) return Replace(m.node()->InputAt(0)); |
| 428 break; | 433 break; |
| 429 } | 434 } |
| 435 case IrOpcode::kTruncateFloat64ToFloat32: { | |
|
titzer
2014/09/22 11:24:54
What about reducing ChangeFloat32ToFloat64 as well
Benedikt Meurer
2014/09/22 11:37:53
Done.
| |
| 436 Float64Matcher m(node->InputAt(0)); | |
| 437 if (m.HasValue()) return ReplaceFloat32(DoubleToFloat32(m.Value())); | |
| 438 if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0)); | |
| 439 break; | |
| 440 } | |
| 430 // TODO(turbofan): strength-reduce and fold floating point operations. | 441 // TODO(turbofan): strength-reduce and fold floating point operations. |
| 431 default: | 442 default: |
| 432 break; | 443 break; |
| 433 } | 444 } |
| 434 return NoChange(); | 445 return NoChange(); |
| 435 } | 446 } |
| 436 | 447 |
| 437 | 448 |
| 438 Reduction MachineOperatorReducer::ReduceProjection(size_t index, Node* node) { | 449 Reduction MachineOperatorReducer::ReduceProjection(size_t index, Node* node) { |
| 439 switch (node->opcode()) { | 450 switch (node->opcode()) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 491 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
| 481 return jsgraph()->machine(); | 492 return jsgraph()->machine(); |
| 482 } | 493 } |
| 483 | 494 |
| 484 | 495 |
| 485 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 496 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
| 486 | 497 |
| 487 } // namespace compiler | 498 } // namespace compiler |
| 488 } // namespace internal | 499 } // namespace internal |
| 489 } // namespace v8 | 500 } // namespace v8 |
| OLD | NEW |