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/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // This should only be used by the Enqueue method. | 123 // This should only be used by the Enqueue method. |
124 MachineTypeUnion machine_type() const { return type_; } | 124 MachineTypeUnion machine_type() const { return type_; } |
125 | 125 |
126 private: | 126 private: |
127 explicit UseInfo(MachineTypeUnion type) : type_(type) {} | 127 explicit UseInfo(MachineTypeUnion type) : type_(type) {} |
128 | 128 |
129 MachineTypeUnion type_; | 129 MachineTypeUnion type_; |
130 }; | 130 }; |
131 | 131 |
132 | 132 |
133 UseInfo UseInfoFromRepresentation(MachineTypeUnion rep) { | 133 UseInfo UseInfoFromMachineType(MachineType type) { |
| 134 MachineTypeUnion rep = RepresentationOf(type); |
134 DCHECK((rep & kTypeMask) == 0); | 135 DCHECK((rep & kTypeMask) == 0); |
135 if (rep & kRepTagged) return UseInfo::AnyTagged(); | 136 if (rep & kRepTagged) return UseInfo::AnyTagged(); |
136 if (rep & kRepFloat64) { | 137 if (rep & kRepFloat64) { |
137 DCHECK((rep & kRepWord64) == 0); | 138 DCHECK((rep & kRepWord64) == 0); |
138 return UseInfo::Float64(); | 139 return UseInfo::Float64(); |
139 } | 140 } |
140 if (rep & kRepFloat32) { | 141 if (rep & kRepFloat32) { |
141 if (rep == kRepFloat32) return UseInfo::Float32(); | 142 if (rep == kRepFloat32) return UseInfo::Float32(); |
142 return UseInfo::AnyTagged(); | 143 return UseInfo::AnyTagged(); |
143 } | 144 } |
144 if (rep & kRepWord64) { | 145 if (rep & kRepWord64) { |
145 return UseInfo::TruncatingWord64(); | 146 return UseInfo::TruncatingWord64(); |
146 } | 147 } |
147 if (rep & (kRepWord32 | kRepWord16 | kRepWord8)) { | 148 if (rep & (kRepWord32 | kRepWord16 | kRepWord8)) { |
148 CHECK(!(rep & kRepBit)); | 149 CHECK(!(rep & kRepBit)); |
149 return UseInfo::TruncatingWord32(); | 150 return UseInfo::TruncatingWord32(); |
150 } | 151 } |
151 DCHECK(rep & kRepBit); | 152 DCHECK(rep & kRepBit); |
152 return UseInfo::Bool(); | 153 return UseInfo::Bool(); |
153 } | 154 } |
154 | 155 |
155 | 156 |
156 UseInfo UseInfoFromMachineType(MachineType type) { | |
157 return UseInfoFromRepresentation(RepresentationOf(type)); | |
158 } | |
159 | |
160 | |
161 UseInfo UseInfoForBasePointer(const FieldAccess& access) { | 157 UseInfo UseInfoForBasePointer(const FieldAccess& access) { |
162 return access.tag() != 0 ? UseInfo::AnyTagged() : UseInfo::PointerInt(); | 158 return access.tag() != 0 ? UseInfo::AnyTagged() : UseInfo::PointerInt(); |
163 } | 159 } |
164 | 160 |
165 | 161 |
166 UseInfo UseInfoForBasePointer(const ElementAccess& access) { | 162 UseInfo UseInfoForBasePointer(const ElementAccess& access) { |
167 return access.tag() != 0 ? UseInfo::AnyTagged() : UseInfo::PointerInt(); | 163 return access.tag() != 0 ? UseInfo::AnyTagged() : UseInfo::PointerInt(); |
168 } | 164 } |
169 | 165 |
170 } // namespace | 166 } // namespace |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Sar()); | 816 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Sar()); |
821 break; | 817 break; |
822 } | 818 } |
823 case IrOpcode::kNumberShiftRightLogical: { | 819 case IrOpcode::kNumberShiftRightLogical: { |
824 VisitBinop(node, UseInfo::TruncatingWord32(), | 820 VisitBinop(node, UseInfo::TruncatingWord32(), |
825 UseInfo::TruncatingWord32(), kMachUint32); | 821 UseInfo::TruncatingWord32(), kMachUint32); |
826 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shr()); | 822 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shr()); |
827 break; | 823 break; |
828 } | 824 } |
829 case IrOpcode::kNumberToInt32: { | 825 case IrOpcode::kNumberToInt32: { |
830 MachineTypeUnion use_rep = use & kRepMask; | 826 // Just change representation if necessary. |
831 Node* input = node->InputAt(0); | 827 VisitUnop(node, UseInfo::TruncatingWord32(), kMachInt32); |
832 Type* in_upper = NodeProperties::GetType(input); | 828 if (lower()) DeferReplacement(node, node->InputAt(0)); |
833 if (in_upper->Is(Type::Signed32())) { | |
834 // If the input has type int32, pass through representation. | |
835 VisitUnop(node, UseInfoFromRepresentation(use_rep), | |
836 kTypeInt32 | use_rep); | |
837 if (lower()) DeferReplacement(node, node->InputAt(0)); | |
838 } else { | |
839 // Just change representation if necessary. | |
840 VisitUnop(node, UseInfo::TruncatingWord32(), kMachInt32); | |
841 if (lower()) DeferReplacement(node, node->InputAt(0)); | |
842 } | |
843 break; | 829 break; |
844 } | 830 } |
845 case IrOpcode::kNumberToUint32: { | 831 case IrOpcode::kNumberToUint32: { |
846 MachineTypeUnion use_rep = use & kRepMask; | 832 // Just change representation if necessary. |
847 Node* input = node->InputAt(0); | 833 VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32); |
848 Type* in_upper = NodeProperties::GetType(input); | 834 if (lower()) DeferReplacement(node, node->InputAt(0)); |
849 if (in_upper->Is(Type::Unsigned32())) { | |
850 // If the input has type uint32, pass through representation. | |
851 VisitUnop(node, UseInfoFromRepresentation(use_rep), | |
852 kTypeUint32 | use_rep); | |
853 if (lower()) DeferReplacement(node, node->InputAt(0)); | |
854 } else { | |
855 // Just change representation if necessary. | |
856 VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32); | |
857 if (lower()) DeferReplacement(node, node->InputAt(0)); | |
858 } | |
859 break; | 835 break; |
860 } | 836 } |
861 case IrOpcode::kNumberIsHoleNaN: { | 837 case IrOpcode::kNumberIsHoleNaN: { |
862 VisitUnop(node, UseInfo::Float64(), kMachBool); | 838 VisitUnop(node, UseInfo::Float64(), kMachBool); |
863 if (lower()) { | 839 if (lower()) { |
864 // NumberIsHoleNaN(x) => Word32Equal(Float64ExtractLowWord32(x), | 840 // NumberIsHoleNaN(x) => Word32Equal(Float64ExtractLowWord32(x), |
865 // #HoleNaNLower32) | 841 // #HoleNaNLower32) |
866 node->ReplaceInput(0, | 842 node->ReplaceInput(0, |
867 jsgraph_->graph()->NewNode( | 843 jsgraph_->graph()->NewNode( |
868 lowering->machine()->Float64ExtractLowWord32(), | 844 lowering->machine()->Float64ExtractLowWord32(), |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 ReplaceEffectUses(node, comparison); | 1635 ReplaceEffectUses(node, comparison); |
1660 node->ReplaceInput(0, comparison); | 1636 node->ReplaceInput(0, comparison); |
1661 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1637 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1662 node->TrimInputCount(2); | 1638 node->TrimInputCount(2); |
1663 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1639 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
1664 } | 1640 } |
1665 | 1641 |
1666 } // namespace compiler | 1642 } // namespace compiler |
1667 } // namespace internal | 1643 } // namespace internal |
1668 } // namespace v8 | 1644 } // namespace v8 |
OLD | NEW |