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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 1543 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
1544 return; | 1544 return; |
1545 } | 1545 } |
1546 case IrOpcode::kNumberAtan2: | 1546 case IrOpcode::kNumberAtan2: |
1547 case IrOpcode::kNumberPow: { | 1547 case IrOpcode::kNumberPow: { |
1548 VisitBinop(node, UseInfo::TruncatingFloat64(), | 1548 VisitBinop(node, UseInfo::TruncatingFloat64(), |
1549 MachineRepresentation::kFloat64); | 1549 MachineRepresentation::kFloat64); |
1550 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 1550 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
1551 return; | 1551 return; |
1552 } | 1552 } |
| 1553 case IrOpcode::kNumberAcos: |
| 1554 case IrOpcode::kNumberAcosh: |
| 1555 case IrOpcode::kNumberAsin: |
| 1556 case IrOpcode::kNumberAsinh: |
1553 case IrOpcode::kNumberAtan: | 1557 case IrOpcode::kNumberAtan: |
1554 case IrOpcode::kNumberAtanh: | 1558 case IrOpcode::kNumberAtanh: |
1555 case IrOpcode::kNumberCos: | 1559 case IrOpcode::kNumberCos: |
1556 case IrOpcode::kNumberExp: | 1560 case IrOpcode::kNumberExp: |
1557 case IrOpcode::kNumberExpm1: | 1561 case IrOpcode::kNumberExpm1: |
1558 case IrOpcode::kNumberLog: | 1562 case IrOpcode::kNumberLog: |
1559 case IrOpcode::kNumberLog1p: | 1563 case IrOpcode::kNumberLog1p: |
1560 case IrOpcode::kNumberLog2: | 1564 case IrOpcode::kNumberLog2: |
1561 case IrOpcode::kNumberLog10: | 1565 case IrOpcode::kNumberLog10: |
1562 case IrOpcode::kNumberCbrt: | 1566 case IrOpcode::kNumberCbrt: |
1563 case IrOpcode::kNumberSin: | 1567 case IrOpcode::kNumberSin: |
1564 case IrOpcode::kNumberTan: { | 1568 case IrOpcode::kNumberTan: { |
1565 VisitUnop(node, UseInfo::TruncatingFloat64(), | 1569 VisitUnop(node, UseInfo::TruncatingFloat64(), |
1566 MachineRepresentation::kFloat64); | 1570 MachineRepresentation::kFloat64); |
1567 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 1571 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
1568 return; | 1572 return; |
1569 } | 1573 } |
1570 case IrOpcode::kNumberRound: { | 1574 case IrOpcode::kNumberRound: { |
1571 VisitUnop(node, UseInfo::TruncatingFloat64(), | 1575 VisitUnop(node, UseInfo::TruncatingFloat64(), |
1572 MachineRepresentation::kFloat64); | 1576 MachineRepresentation::kFloat64); |
1573 if (lower()) DeferReplacement(node, lowering->Float64Round(node)); | 1577 if (lower()) DeferReplacement(node, lowering->Float64Round(node)); |
1574 return; | 1578 return; |
1575 } | 1579 } |
| 1580 case IrOpcode::kNumberSign: { |
| 1581 if (InputIs(node, Type::Signed32())) { |
| 1582 VisitUnop(node, UseInfo::TruncatingWord32(), |
| 1583 MachineRepresentation::kWord32); |
| 1584 if (lower()) DeferReplacement(node, lowering->Int32Sign(node)); |
| 1585 } else { |
| 1586 VisitUnop(node, UseInfo::TruncatingFloat64(), |
| 1587 MachineRepresentation::kFloat64); |
| 1588 if (lower()) DeferReplacement(node, lowering->Float64Sign(node)); |
| 1589 } |
| 1590 return; |
| 1591 } |
1576 case IrOpcode::kNumberSqrt: { | 1592 case IrOpcode::kNumberSqrt: { |
1577 VisitUnop(node, UseInfo::TruncatingFloat64(), | 1593 VisitUnop(node, UseInfo::TruncatingFloat64(), |
1578 MachineRepresentation::kFloat64); | 1594 MachineRepresentation::kFloat64); |
1579 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); | 1595 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); |
1580 return; | 1596 return; |
1581 } | 1597 } |
1582 case IrOpcode::kNumberTrunc: { | 1598 case IrOpcode::kNumberTrunc: { |
1583 VisitUnop(node, UseInfo::TruncatingFloat64(), | 1599 VisitUnop(node, UseInfo::TruncatingFloat64(), |
1584 MachineRepresentation::kFloat64); | 1600 MachineRepresentation::kFloat64); |
1585 if (lower()) DeferReplacement(node, lowering->Float64Trunc(node)); | 1601 if (lower()) DeferReplacement(node, lowering->Float64Trunc(node)); |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2688 // Round up towards Infinity, and adjust if the difference exceeds 0.5. | 2704 // Round up towards Infinity, and adjust if the difference exceeds 0.5. |
2689 Node* result = Float64Ceil(node); | 2705 Node* result = Float64Ceil(node); |
2690 return graph()->NewNode( | 2706 return graph()->NewNode( |
2691 common()->Select(MachineRepresentation::kFloat64), | 2707 common()->Select(MachineRepresentation::kFloat64), |
2692 graph()->NewNode( | 2708 graph()->NewNode( |
2693 machine()->Float64LessThanOrEqual(), | 2709 machine()->Float64LessThanOrEqual(), |
2694 graph()->NewNode(machine()->Float64Sub(), result, one_half), input), | 2710 graph()->NewNode(machine()->Float64Sub(), result, one_half), input), |
2695 result, graph()->NewNode(machine()->Float64Sub(), result, one)); | 2711 result, graph()->NewNode(machine()->Float64Sub(), result, one)); |
2696 } | 2712 } |
2697 | 2713 |
| 2714 Node* SimplifiedLowering::Float64Sign(Node* const node) { |
| 2715 Node* const minus_one = jsgraph()->Float64Constant(-1.0); |
| 2716 Node* const zero = jsgraph()->Float64Constant(0.0); |
| 2717 Node* const one = jsgraph()->Float64Constant(1.0); |
| 2718 |
| 2719 Node* const input = node->InputAt(0); |
| 2720 |
| 2721 return graph()->NewNode( |
| 2722 common()->Select(MachineRepresentation::kFloat64), |
| 2723 graph()->NewNode(machine()->Float64LessThan(), input, zero), minus_one, |
| 2724 graph()->NewNode( |
| 2725 common()->Select(MachineRepresentation::kFloat64), |
| 2726 graph()->NewNode(machine()->Float64LessThan(), zero, input), one, |
| 2727 zero)); |
| 2728 } |
| 2729 |
2698 Node* SimplifiedLowering::Float64Trunc(Node* const node) { | 2730 Node* SimplifiedLowering::Float64Trunc(Node* const node) { |
2699 Node* const one = jsgraph()->Float64Constant(1.0); | 2731 Node* const one = jsgraph()->Float64Constant(1.0); |
2700 Node* const zero = jsgraph()->Float64Constant(0.0); | 2732 Node* const zero = jsgraph()->Float64Constant(0.0); |
2701 Node* const minus_zero = jsgraph()->Float64Constant(-0.0); | 2733 Node* const minus_zero = jsgraph()->Float64Constant(-0.0); |
2702 Node* const two_52 = jsgraph()->Float64Constant(4503599627370496.0E0); | 2734 Node* const two_52 = jsgraph()->Float64Constant(4503599627370496.0E0); |
2703 Node* const minus_two_52 = jsgraph()->Float64Constant(-4503599627370496.0E0); | 2735 Node* const minus_two_52 = jsgraph()->Float64Constant(-4503599627370496.0E0); |
2704 Node* const input = node->InputAt(0); | 2736 Node* const input = node->InputAt(0); |
2705 | 2737 |
2706 // Use fast hardware instruction if available. | 2738 // Use fast hardware instruction if available. |
2707 if (machine()->Float64RoundTruncate().IsSupported()) { | 2739 if (machine()->Float64RoundTruncate().IsSupported()) { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2994 Node* false1 = zero; | 3026 Node* false1 = zero; |
2995 | 3027 |
2996 if_false0 = graph()->NewNode(merge_op, if_true1, if_false1); | 3028 if_false0 = graph()->NewNode(merge_op, if_true1, if_false1); |
2997 false0 = graph()->NewNode(phi_op, true1, false1, if_false0); | 3029 false0 = graph()->NewNode(phi_op, true1, false1, if_false0); |
2998 } | 3030 } |
2999 | 3031 |
3000 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0); | 3032 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0); |
3001 return graph()->NewNode(phi_op, true0, false0, merge0); | 3033 return graph()->NewNode(phi_op, true0, false0, merge0); |
3002 } | 3034 } |
3003 | 3035 |
| 3036 Node* SimplifiedLowering::Int32Sign(Node* const node) { |
| 3037 Node* const minus_one = jsgraph()->Int32Constant(-1); |
| 3038 Node* const zero = jsgraph()->Int32Constant(0); |
| 3039 Node* const one = jsgraph()->Int32Constant(1); |
| 3040 |
| 3041 Node* const input = node->InputAt(0); |
| 3042 |
| 3043 return graph()->NewNode( |
| 3044 common()->Select(MachineRepresentation::kWord32), |
| 3045 graph()->NewNode(machine()->Int32LessThan(), input, zero), minus_one, |
| 3046 graph()->NewNode( |
| 3047 common()->Select(MachineRepresentation::kWord32), |
| 3048 graph()->NewNode(machine()->Int32LessThan(), zero, input), one, |
| 3049 zero)); |
| 3050 } |
3004 | 3051 |
3005 Node* SimplifiedLowering::Uint32Div(Node* const node) { | 3052 Node* SimplifiedLowering::Uint32Div(Node* const node) { |
3006 Uint32BinopMatcher m(node); | 3053 Uint32BinopMatcher m(node); |
3007 Node* const zero = jsgraph()->Uint32Constant(0); | 3054 Node* const zero = jsgraph()->Uint32Constant(0); |
3008 Node* const lhs = m.left().node(); | 3055 Node* const lhs = m.left().node(); |
3009 Node* const rhs = m.right().node(); | 3056 Node* const rhs = m.right().node(); |
3010 | 3057 |
3011 if (m.right().Is(0)) { | 3058 if (m.right().Is(0)) { |
3012 return zero; | 3059 return zero; |
3013 } else if (machine()->Uint32DivIsSafe() || m.right().HasValue()) { | 3060 } else if (machine()->Uint32DivIsSafe() || m.right().HasValue()) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3107 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3154 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3108 Operator::kNoProperties); | 3155 Operator::kNoProperties); |
3109 to_number_operator_.set(common()->Call(desc)); | 3156 to_number_operator_.set(common()->Call(desc)); |
3110 } | 3157 } |
3111 return to_number_operator_.get(); | 3158 return to_number_operator_.get(); |
3112 } | 3159 } |
3113 | 3160 |
3114 } // namespace compiler | 3161 } // namespace compiler |
3115 } // namespace internal | 3162 } // namespace internal |
3116 } // namespace v8 | 3163 } // namespace v8 |
OLD | NEW |