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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 switch (use_rep) { | 131 switch (use_rep) { |
132 case MachineRepresentation::kTagged: | 132 case MachineRepresentation::kTagged: |
133 return GetTaggedRepresentationFor(node, output_rep, output_type); | 133 return GetTaggedRepresentationFor(node, output_rep, output_type); |
134 case MachineRepresentation::kFloat32: | 134 case MachineRepresentation::kFloat32: |
135 return GetFloat32RepresentationFor(node, output_rep, output_type, | 135 return GetFloat32RepresentationFor(node, output_rep, output_type, |
136 truncation); | 136 truncation); |
137 case MachineRepresentation::kFloat64: | 137 case MachineRepresentation::kFloat64: |
138 return GetFloat64RepresentationFor(node, output_rep, output_type, | 138 return GetFloat64RepresentationFor(node, output_rep, output_type, |
139 truncation); | 139 truncation); |
| 140 case MachineRepresentation::kSimd128: |
| 141 return GetSimd128RepresentationFor(node, output_rep, output_type); |
140 case MachineRepresentation::kBit: | 142 case MachineRepresentation::kBit: |
141 return GetBitRepresentationFor(node, output_rep, output_type); | 143 return GetBitRepresentationFor(node, output_rep, output_type); |
142 case MachineRepresentation::kWord8: | 144 case MachineRepresentation::kWord8: |
143 case MachineRepresentation::kWord16: | 145 case MachineRepresentation::kWord16: |
144 case MachineRepresentation::kWord32: | 146 case MachineRepresentation::kWord32: |
145 return GetWord32RepresentationFor(node, output_rep, output_type); | 147 return GetWord32RepresentationFor(node, output_rep, output_type); |
146 case MachineRepresentation::kWord64: | 148 case MachineRepresentation::kWord64: |
147 return GetWord64RepresentationFor(node, output_rep, output_type); | 149 return GetWord64RepresentationFor(node, output_rep, output_type); |
148 case MachineRepresentation::kSimd128: // Fall through. | |
149 // TODO(bbudge) Handle conversions between tagged and untagged. | |
150 break; | |
151 case MachineRepresentation::kNone: | 150 case MachineRepresentation::kNone: |
152 return node; | 151 return node; |
153 } | 152 } |
154 UNREACHABLE(); | 153 UNREACHABLE(); |
155 return nullptr; | 154 return nullptr; |
156 } | 155 } |
157 | 156 |
158 | 157 |
159 Node* RepresentationChanger::GetTaggedRepresentationFor( | 158 Node* RepresentationChanger::GetTaggedRepresentationFor( |
160 Node* node, MachineRepresentation output_rep, Type* output_type) { | 159 Node* node, MachineRepresentation output_rep, Type* output_type) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 op = simplified()->ChangeTaggedToFloat64(); | 306 op = simplified()->ChangeTaggedToFloat64(); |
308 } else if (output_rep == MachineRepresentation::kFloat32) { | 307 } else if (output_rep == MachineRepresentation::kFloat32) { |
309 op = machine()->ChangeFloat32ToFloat64(); | 308 op = machine()->ChangeFloat32ToFloat64(); |
310 } else { | 309 } else { |
311 return TypeError(node, output_rep, output_type, | 310 return TypeError(node, output_rep, output_type, |
312 MachineRepresentation::kFloat64); | 311 MachineRepresentation::kFloat64); |
313 } | 312 } |
314 return jsgraph()->graph()->NewNode(op, node); | 313 return jsgraph()->graph()->NewNode(op, node); |
315 } | 314 } |
316 | 315 |
| 316 Node* RepresentationChanger::GetSimd128RepresentationFor( |
| 317 Node* node, MachineRepresentation output_rep, Type* output_type) { |
| 318 // Select the correct X -> Simd128 operator. |
| 319 const Operator* op; |
| 320 if (output_rep == MachineRepresentation::kTagged) { |
| 321 op = nullptr; |
| 322 } else { |
| 323 return TypeError(node, output_rep, output_type, |
| 324 MachineRepresentation::kFloat64); |
| 325 } |
| 326 return jsgraph()->graph()->NewNode(op, node); |
| 327 } |
317 | 328 |
318 Node* RepresentationChanger::MakeTruncatedInt32Constant(double value) { | 329 Node* RepresentationChanger::MakeTruncatedInt32Constant(double value) { |
319 return jsgraph()->Int32Constant(DoubleToInt32(value)); | 330 return jsgraph()->Int32Constant(DoubleToInt32(value)); |
320 } | 331 } |
321 | 332 |
322 | |
323 Node* RepresentationChanger::GetWord32RepresentationFor( | 333 Node* RepresentationChanger::GetWord32RepresentationFor( |
324 Node* node, MachineRepresentation output_rep, Type* output_type) { | 334 Node* node, MachineRepresentation output_rep, Type* output_type) { |
325 // Eagerly fold representation changes for constants. | 335 // Eagerly fold representation changes for constants. |
326 switch (node->opcode()) { | 336 switch (node->opcode()) { |
327 case IrOpcode::kInt32Constant: | 337 case IrOpcode::kInt32Constant: |
328 return node; // No change necessary. | 338 return node; // No change necessary. |
329 case IrOpcode::kFloat32Constant: | 339 case IrOpcode::kFloat32Constant: |
330 return MakeTruncatedInt32Constant(OpParameter<float>(node)); | 340 return MakeTruncatedInt32Constant(OpParameter<float>(node)); |
331 case IrOpcode::kNumberConstant: | 341 case IrOpcode::kNumberConstant: |
332 case IrOpcode::kFloat64Constant: | 342 case IrOpcode::kFloat64Constant: |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 540 |
531 | 541 |
532 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { | 542 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { |
533 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), | 543 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), |
534 node); | 544 node); |
535 } | 545 } |
536 | 546 |
537 } // namespace compiler | 547 } // namespace compiler |
538 } // namespace internal | 548 } // namespace internal |
539 } // namespace v8 | 549 } // namespace v8 |
OLD | NEW |