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 #ifndef V8_COMPILER_INSTRUCTION_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_H_ |
6 #define V8_COMPILER_INSTRUCTION_H_ | 6 #define V8_COMPILER_INSTRUCTION_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <map> | 10 #include <map> |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 return value; | 1058 return value; |
1059 } | 1059 } |
1060 | 1060 |
1061 int64_t ToInt64() const { | 1061 int64_t ToInt64() const { |
1062 if (type() == kInt32) return ToInt32(); | 1062 if (type() == kInt32) return ToInt32(); |
1063 DCHECK_EQ(kInt64, type()); | 1063 DCHECK_EQ(kInt64, type()); |
1064 return value_; | 1064 return value_; |
1065 } | 1065 } |
1066 | 1066 |
1067 float ToFloat32() const { | 1067 float ToFloat32() const { |
| 1068 // TODO(ahaas): We should remove this function. If value_ has the bit |
| 1069 // representation of a signalling NaN, then returning it as float can cause |
| 1070 // the signalling bit to flip, and value_ is returned as a quiet NaN. |
1068 DCHECK_EQ(kFloat32, type()); | 1071 DCHECK_EQ(kFloat32, type()); |
1069 return bit_cast<float>(static_cast<int32_t>(value_)); | 1072 return bit_cast<float>(static_cast<int32_t>(value_)); |
1070 } | 1073 } |
1071 | 1074 |
| 1075 uint32_t ToFloat32AsInt() const { |
| 1076 DCHECK_EQ(kFloat32, type()); |
| 1077 return bit_cast<uint32_t>(static_cast<int32_t>(value_)); |
| 1078 } |
| 1079 |
1072 double ToFloat64() const { | 1080 double ToFloat64() const { |
| 1081 // TODO(ahaas): We should remove this function. If value_ has the bit |
| 1082 // representation of a signalling NaN, then returning it as float can cause |
| 1083 // the signalling bit to flip, and value_ is returned as a quiet NaN. |
1073 if (type() == kInt32) return ToInt32(); | 1084 if (type() == kInt32) return ToInt32(); |
1074 DCHECK_EQ(kFloat64, type()); | 1085 DCHECK_EQ(kFloat64, type()); |
1075 return bit_cast<double>(value_); | 1086 return bit_cast<double>(value_); |
1076 } | 1087 } |
1077 | 1088 |
| 1089 uint64_t ToFloat64AsInt() const { |
| 1090 if (type() == kInt32) return ToInt32(); |
| 1091 DCHECK_EQ(kFloat64, type()); |
| 1092 return bit_cast<uint64_t>(value_); |
| 1093 } |
| 1094 |
1078 ExternalReference ToExternalReference() const { | 1095 ExternalReference ToExternalReference() const { |
1079 DCHECK_EQ(kExternalReference, type()); | 1096 DCHECK_EQ(kExternalReference, type()); |
1080 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_)); | 1097 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_)); |
1081 } | 1098 } |
1082 | 1099 |
1083 RpoNumber ToRpoNumber() const { | 1100 RpoNumber ToRpoNumber() const { |
1084 DCHECK_EQ(kRpoNumber, type()); | 1101 DCHECK_EQ(kRpoNumber, type()); |
1085 return RpoNumber::FromInt(static_cast<int>(value_)); | 1102 return RpoNumber::FromInt(static_cast<int>(value_)); |
1086 } | 1103 } |
1087 | 1104 |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 }; | 1626 }; |
1610 | 1627 |
1611 V8_EXPORT_PRIVATE std::ostream& operator<<( | 1628 V8_EXPORT_PRIVATE std::ostream& operator<<( |
1612 std::ostream& os, const PrintableInstructionSequence& code); | 1629 std::ostream& os, const PrintableInstructionSequence& code); |
1613 | 1630 |
1614 } // namespace compiler | 1631 } // namespace compiler |
1615 } // namespace internal | 1632 } // namespace internal |
1616 } // namespace v8 | 1633 } // namespace v8 |
1617 | 1634 |
1618 #endif // V8_COMPILER_INSTRUCTION_H_ | 1635 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |