Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 2096403002: [turbofan] Introduce simplified operator NumberAbs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: This time fix the compile error for realz Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 } 1480 }
1481 case IrOpcode::kNumberShiftRightLogical: { 1481 case IrOpcode::kNumberShiftRightLogical: {
1482 Type* rhs_type = GetUpperBound(node->InputAt(1)); 1482 Type* rhs_type = GetUpperBound(node->InputAt(1));
1483 VisitBinop(node, UseInfo::TruncatingWord32(), 1483 VisitBinop(node, UseInfo::TruncatingWord32(),
1484 UseInfo::TruncatingWord32(), MachineRepresentation::kWord32); 1484 UseInfo::TruncatingWord32(), MachineRepresentation::kWord32);
1485 if (lower()) { 1485 if (lower()) {
1486 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); 1486 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type);
1487 } 1487 }
1488 return; 1488 return;
1489 } 1489 }
1490 case IrOpcode::kNumberAbs: {
1491 if (InputIs(node, Type::Unsigned32())) {
1492 VisitUnop(node, UseInfo::TruncatingWord32(),
1493 MachineRepresentation::kWord32);
1494 if (lower()) DeferReplacement(node, node->InputAt(0));
1495 } else if (InputIs(node, type_cache_.kSafeSigned32)) {
1496 VisitUnop(node, UseInfo::TruncatingWord32(),
1497 MachineRepresentation::kWord32);
1498 if (lower()) DeferReplacement(node, lowering->Int32Abs(node));
1499 } else if (InputIs(node,
1500 type_cache_.kPositiveIntegerOrMinusZeroOrNaN)) {
1501 VisitUnop(node, UseInfo::TruncatingFloat64(),
1502 MachineRepresentation::kFloat64);
1503 if (lower()) DeferReplacement(node, node->InputAt(0));
1504 } else {
1505 VisitUnop(node, UseInfo::TruncatingFloat64(),
1506 MachineRepresentation::kFloat64);
1507 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
1508 }
1509 return;
1510 }
1490 case IrOpcode::kNumberClz32: { 1511 case IrOpcode::kNumberClz32: {
1491 VisitUnop(node, UseInfo::TruncatingWord32(), 1512 VisitUnop(node, UseInfo::TruncatingWord32(),
1492 MachineRepresentation::kWord32); 1513 MachineRepresentation::kWord32);
1493 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); 1514 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
1494 return; 1515 return;
1495 } 1516 }
1496 case IrOpcode::kNumberImul: { 1517 case IrOpcode::kNumberImul: {
1497 VisitBinop(node, UseInfo::TruncatingWord32(), 1518 VisitBinop(node, UseInfo::TruncatingWord32(),
1498 UseInfo::TruncatingWord32(), MachineRepresentation::kWord32); 1519 UseInfo::TruncatingWord32(), MachineRepresentation::kWord32);
1499 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); 1520 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 vfalse0 = 2796 vfalse0 =
2776 graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), 2797 graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2),
2777 vtrue1, vfalse1, if_false0); 2798 vtrue1, vfalse1, if_false0);
2778 } 2799 }
2779 2800
2780 Node* merge0 = graph()->NewNode(common()->Merge(2), if_true0, if_false0); 2801 Node* merge0 = graph()->NewNode(common()->Merge(2), if_true0, if_false0);
2781 return graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), 2802 return graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2),
2782 vtrue0, vfalse0, merge0); 2803 vtrue0, vfalse0, merge0);
2783 } 2804 }
2784 2805
2806 Node* SimplifiedLowering::Int32Abs(Node* const node) {
2807 Node* const zero = jsgraph()->Int32Constant(0);
2808 Node* const input = node->InputAt(0);
2809
2810 // if 0 < input then input else 0 - input
2811 return graph()->NewNode(
2812 common()->Select(MachineRepresentation::kWord32, BranchHint::kTrue),
2813 graph()->NewNode(machine()->Int32LessThan(), zero, input), input,
2814 graph()->NewNode(machine()->Int32Sub(), zero, input));
2815 }
2816
2785 Node* SimplifiedLowering::Int32Div(Node* const node) { 2817 Node* SimplifiedLowering::Int32Div(Node* const node) {
2786 Int32BinopMatcher m(node); 2818 Int32BinopMatcher m(node);
2787 Node* const zero = jsgraph()->Int32Constant(0); 2819 Node* const zero = jsgraph()->Int32Constant(0);
2788 Node* const minus_one = jsgraph()->Int32Constant(-1); 2820 Node* const minus_one = jsgraph()->Int32Constant(-1);
2789 Node* const lhs = m.left().node(); 2821 Node* const lhs = m.left().node();
2790 Node* const rhs = m.right().node(); 2822 Node* const rhs = m.right().node();
2791 2823
2792 if (m.right().Is(-1)) { 2824 if (m.right().Is(-1)) {
2793 return graph()->NewNode(machine()->Int32Sub(), zero, lhs); 2825 return graph()->NewNode(machine()->Int32Sub(), zero, lhs);
2794 } else if (m.right().Is(0)) { 2826 } else if (m.right().Is(0)) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3060 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 3092 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
3061 Operator::kNoProperties); 3093 Operator::kNoProperties);
3062 to_number_operator_.set(common()->Call(desc)); 3094 to_number_operator_.set(common()->Call(desc));
3063 } 3095 }
3064 return to_number_operator_.get(); 3096 return to_number_operator_.get();
3065 } 3097 }
3066 3098
3067 } // namespace compiler 3099 } // namespace compiler
3068 } // namespace internal 3100 } // namespace internal
3069 } // namespace v8 3101 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.h ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698