OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/representation-change.h" | 5 #include "src/compiler/representation-change.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 case IrOpcode::kFloat64Constant: | 181 case IrOpcode::kFloat64Constant: |
182 return jsgraph()->Constant(OpParameter<double>(node)); | 182 return jsgraph()->Constant(OpParameter<double>(node)); |
183 case IrOpcode::kFloat32Constant: | 183 case IrOpcode::kFloat32Constant: |
184 return jsgraph()->Constant(OpParameter<float>(node)); | 184 return jsgraph()->Constant(OpParameter<float>(node)); |
185 default: | 185 default: |
186 break; | 186 break; |
187 } | 187 } |
188 // Select the correct X -> Tagged operator. | 188 // Select the correct X -> Tagged operator. |
189 const Operator* op; | 189 const Operator* op; |
190 if (output_rep == MachineRepresentation::kBit) { | 190 if (output_rep == MachineRepresentation::kBit) { |
191 op = simplified()->ChangeBitToTagged(); | 191 op = simplified()->ChangeBitToBool(); |
192 } else if (IsWord(output_rep)) { | 192 } else if (IsWord(output_rep)) { |
193 if (output_type->Is(Type::Signed31())) { | 193 if (output_type->Is(Type::Signed31())) { |
194 op = simplified()->ChangeInt31ToTaggedSigned(); | 194 op = simplified()->ChangeInt31ToTagged(); |
195 } else if (output_type->Is(Type::Signed32())) { | 195 } else if (output_type->Is(Type::Signed32())) { |
196 op = simplified()->ChangeInt32ToTagged(); | 196 op = simplified()->ChangeInt32ToTagged(); |
197 } else if (output_type->Is(Type::Unsigned32())) { | 197 } else if (output_type->Is(Type::Unsigned32())) { |
198 op = simplified()->ChangeUint32ToTagged(); | 198 op = simplified()->ChangeUint32ToTagged(); |
199 } else { | 199 } else { |
200 return TypeError(node, output_rep, output_type, | 200 return TypeError(node, output_rep, output_type, |
201 MachineRepresentation::kTagged); | 201 MachineRepresentation::kTagged); |
202 } | 202 } |
203 } else if (output_rep == | 203 } else if (output_rep == |
204 MachineRepresentation::kFloat32) { // float32 -> float64 -> tagged | 204 MachineRepresentation::kFloat32) { // float32 -> float64 -> tagged |
205 node = InsertChangeFloat32ToFloat64(node); | 205 node = InsertChangeFloat32ToFloat64(node); |
206 // TODO(bmeurer): Pass -0 hint to ChangeFloat64ToTagged. | 206 // TODO(bmeurer): Pass -0 hint to ChangeFloat64ToTagged. |
207 op = simplified()->ChangeFloat64ToTagged(); | 207 op = simplified()->ChangeFloat64ToTagged(); |
208 } else if (output_rep == MachineRepresentation::kFloat64) { | 208 } else if (output_rep == MachineRepresentation::kFloat64) { |
209 if (output_type->Is(Type::Signed31())) { // float64 -> int32 -> tagged | 209 if (output_type->Is(Type::Signed31())) { // float64 -> int32 -> tagged |
210 node = InsertChangeFloat64ToInt32(node); | 210 node = InsertChangeFloat64ToInt32(node); |
211 op = simplified()->ChangeInt31ToTaggedSigned(); | 211 op = simplified()->ChangeInt31ToTagged(); |
212 } else if (output_type->Is( | 212 } else if (output_type->Is( |
213 Type::Signed32())) { // float64 -> int32 -> tagged | 213 Type::Signed32())) { // float64 -> int32 -> tagged |
214 node = InsertChangeFloat64ToInt32(node); | 214 node = InsertChangeFloat64ToInt32(node); |
215 op = simplified()->ChangeInt32ToTagged(); | 215 op = simplified()->ChangeInt32ToTagged(); |
216 } else if (output_type->Is( | 216 } else if (output_type->Is( |
217 Type::Unsigned32())) { // float64 -> uint32 -> tagged | 217 Type::Unsigned32())) { // float64 -> uint32 -> tagged |
218 node = InsertChangeFloat64ToUint32(node); | 218 node = InsertChangeFloat64ToUint32(node); |
219 op = simplified()->ChangeUint32ToTagged(); | 219 op = simplified()->ChangeUint32ToTagged(); |
220 } else { | 220 } else { |
221 // TODO(bmeurer): Pass -0 hint to ChangeFloat64ToTagged. | 221 // TODO(bmeurer): Pass -0 hint to ChangeFloat64ToTagged. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 value.is_identical_to(factory()->false_value())); | 411 value.is_identical_to(factory()->false_value())); |
412 return jsgraph()->Int32Constant( | 412 return jsgraph()->Int32Constant( |
413 value.is_identical_to(factory()->true_value()) ? 1 : 0); | 413 value.is_identical_to(factory()->true_value()) ? 1 : 0); |
414 } | 414 } |
415 default: | 415 default: |
416 break; | 416 break; |
417 } | 417 } |
418 // Select the correct X -> Bit operator. | 418 // Select the correct X -> Bit operator. |
419 const Operator* op; | 419 const Operator* op; |
420 if (output_rep == MachineRepresentation::kTagged) { | 420 if (output_rep == MachineRepresentation::kTagged) { |
421 op = simplified()->ChangeTaggedToBit(); | 421 op = simplified()->ChangeBoolToBit(); |
422 } else { | 422 } else { |
423 return TypeError(node, output_rep, output_type, | 423 return TypeError(node, output_rep, output_type, |
424 MachineRepresentation::kBit); | 424 MachineRepresentation::kBit); |
425 } | 425 } |
426 return jsgraph()->graph()->NewNode(op, node); | 426 return jsgraph()->graph()->NewNode(op, node); |
427 } | 427 } |
428 | 428 |
429 | 429 |
430 Node* RepresentationChanger::GetWord64RepresentationFor( | 430 Node* RepresentationChanger::GetWord64RepresentationFor( |
431 Node* node, MachineRepresentation output_rep, Type* output_type) { | 431 Node* node, MachineRepresentation output_rep, Type* output_type) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 } | 566 } |
567 | 567 |
568 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { | 568 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { |
569 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), | 569 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), |
570 node); | 570 node); |
571 } | 571 } |
572 | 572 |
573 } // namespace compiler | 573 } // namespace compiler |
574 } // namespace internal | 574 } // namespace internal |
575 } // namespace v8 | 575 } // namespace v8 |
OLD | NEW |