| 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/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler/diamond.h" | 8 #include "src/compiler/diamond.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| 11 #include "src/compiler/machine-operator.h" | 11 #include "src/compiler/machine-operator.h" |
| 12 #include "src/compiler/node-properties-inl.h" | 12 #include "src/compiler/node-properties-inl.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 namespace compiler { | 16 namespace compiler { |
| 17 | 17 |
| 18 ChangeLowering::~ChangeLowering() {} | 18 ChangeLowering::~ChangeLowering() {} |
| 19 | 19 |
| 20 | 20 |
| 21 Reduction ChangeLowering::Reduce(Node* node) { | 21 Reduction ChangeLowering::Reduce(Node* node) { |
| 22 Node* control = graph()->start(); | 22 Node* control = graph()->start(); |
| 23 switch (node->opcode()) { | 23 switch (node->opcode()) { |
| 24 case IrOpcode::kChangeBitToBool: | 24 case IrOpcode::kChangeBitToBool: |
| 25 return ChangeBitToBool(node->InputAt(0)); | 25 return ChangeBitToBool(node->InputAt(0), control); |
| 26 case IrOpcode::kChangeBoolToBit: | 26 case IrOpcode::kChangeBoolToBit: |
| 27 return ChangeBoolToBit(node->InputAt(0)); | 27 return ChangeBoolToBit(node->InputAt(0)); |
| 28 case IrOpcode::kChangeWord32ToBit: | |
| 29 return ChangeWord32ToBit(node->InputAt(0)); | |
| 30 case IrOpcode::kChangeWord64ToBit: | |
| 31 return ChangeWord64ToBit(node->InputAt(0)); | |
| 32 case IrOpcode::kChangeFloat64ToTagged: | 28 case IrOpcode::kChangeFloat64ToTagged: |
| 33 return ChangeFloat64ToTagged(node->InputAt(0), control); | 29 return ChangeFloat64ToTagged(node->InputAt(0), control); |
| 34 case IrOpcode::kChangeInt32ToTagged: | 30 case IrOpcode::kChangeInt32ToTagged: |
| 35 return ChangeInt32ToTagged(node->InputAt(0), control); | 31 return ChangeInt32ToTagged(node->InputAt(0), control); |
| 36 case IrOpcode::kChangeTaggedToFloat64: | 32 case IrOpcode::kChangeTaggedToFloat64: |
| 37 return ChangeTaggedToFloat64(node->InputAt(0), control); | 33 return ChangeTaggedToFloat64(node->InputAt(0), control); |
| 38 case IrOpcode::kChangeTaggedToInt32: | 34 case IrOpcode::kChangeTaggedToInt32: |
| 39 return ChangeTaggedToUI32(node->InputAt(0), control, kSigned); | 35 return ChangeTaggedToUI32(node->InputAt(0), control, kSigned); |
| 40 case IrOpcode::kChangeTaggedToUint32: | 36 case IrOpcode::kChangeTaggedToUint32: |
| 41 return ChangeTaggedToUI32(node->InputAt(0), control, kUnsigned); | 37 return ChangeTaggedToUI32(node->InputAt(0), control, kUnsigned); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return graph()->NewNode(machine()->WordAnd(), value, | 131 return graph()->NewNode(machine()->WordAnd(), value, |
| 136 jsgraph()->IntPtrConstant(kSmiTagMask)); | 132 jsgraph()->IntPtrConstant(kSmiTagMask)); |
| 137 } | 133 } |
| 138 | 134 |
| 139 | 135 |
| 140 Node* ChangeLowering::Uint32LessThanOrEqual(Node* lhs, Node* rhs) { | 136 Node* ChangeLowering::Uint32LessThanOrEqual(Node* lhs, Node* rhs) { |
| 141 return graph()->NewNode(machine()->Uint32LessThanOrEqual(), lhs, rhs); | 137 return graph()->NewNode(machine()->Uint32LessThanOrEqual(), lhs, rhs); |
| 142 } | 138 } |
| 143 | 139 |
| 144 | 140 |
| 145 Reduction ChangeLowering::ChangeBitToBool(Node* value) { | 141 Reduction ChangeLowering::ChangeBitToBool(Node* val, Node* control) { |
| 146 MachineType const type = static_cast<MachineType>(kTypeBool | kRepTagged); | 142 MachineType const type = static_cast<MachineType>(kTypeBool | kRepTagged); |
| 147 return Replace(graph()->NewNode(common()->Select(type), value, | 143 return Replace(graph()->NewNode(common()->Select(type), val, |
| 148 jsgraph()->TrueConstant(), | 144 jsgraph()->TrueConstant(), |
| 149 jsgraph()->FalseConstant())); | 145 jsgraph()->FalseConstant())); |
| 150 } | 146 } |
| 151 | 147 |
| 152 | 148 |
| 153 Reduction ChangeLowering::ChangeBoolToBit(Node* value) { | 149 Reduction ChangeLowering::ChangeBoolToBit(Node* val) { |
| 154 return Replace(graph()->NewNode(machine()->WordEqual(), value, | 150 return Replace( |
| 155 jsgraph()->TrueConstant())); | 151 graph()->NewNode(machine()->WordEqual(), val, jsgraph()->TrueConstant())); |
| 156 } | 152 } |
| 157 | 153 |
| 158 | 154 |
| 159 Reduction ChangeLowering::ChangeWord32ToBit(Node* value) { | |
| 160 return Replace( | |
| 161 graph()->NewNode(machine()->Word32Equal(), | |
| 162 graph()->NewNode(machine()->Word32Equal(), value, | |
| 163 jsgraph()->Int32Constant(0)), | |
| 164 jsgraph()->Int32Constant(0))); | |
| 165 } | |
| 166 | |
| 167 | |
| 168 Reduction ChangeLowering::ChangeWord64ToBit(Node* value) { | |
| 169 return Replace( | |
| 170 graph()->NewNode(machine()->Word32Equal(), | |
| 171 graph()->NewNode(machine()->Word64Equal(), value, | |
| 172 jsgraph()->Int64Constant(0)), | |
| 173 jsgraph()->Int32Constant(0))); | |
| 174 } | |
| 175 | |
| 176 | |
| 177 Reduction ChangeLowering::ChangeFloat64ToTagged(Node* val, Node* control) { | 155 Reduction ChangeLowering::ChangeFloat64ToTagged(Node* val, Node* control) { |
| 178 return Replace(AllocateHeapNumberWithValue(val, control)); | 156 return Replace(AllocateHeapNumberWithValue(val, control)); |
| 179 } | 157 } |
| 180 | 158 |
| 181 | 159 |
| 182 Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) { | 160 Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) { |
| 183 if (machine()->Is64()) { | 161 if (machine()->Is64()) { |
| 184 return Replace(graph()->NewNode( | 162 return Replace(graph()->NewNode( |
| 185 machine()->Word64Shl(), | 163 machine()->Word64Shl(), |
| 186 graph()->NewNode(machine()->ChangeInt32ToInt64(), value), | 164 graph()->NewNode(machine()->ChangeInt32ToInt64(), value), |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 274 } |
| 297 | 275 |
| 298 | 276 |
| 299 MachineOperatorBuilder* ChangeLowering::machine() const { | 277 MachineOperatorBuilder* ChangeLowering::machine() const { |
| 300 return jsgraph()->machine(); | 278 return jsgraph()->machine(); |
| 301 } | 279 } |
| 302 | 280 |
| 303 } // namespace compiler | 281 } // namespace compiler |
| 304 } // namespace internal | 282 } // namespace internal |
| 305 } // namespace v8 | 283 } // namespace v8 |
| OLD | NEW |