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. | |
1071 DCHECK_EQ(kFloat32, type()); | 1068 DCHECK_EQ(kFloat32, type()); |
1072 return bit_cast<float>(static_cast<int32_t>(value_)); | 1069 return bit_cast<float>(static_cast<int32_t>(value_)); |
1073 } | 1070 } |
1074 | 1071 |
1075 uint32_t ToFloat32AsInt() const { | |
1076 DCHECK_EQ(kFloat32, type()); | |
1077 return bit_cast<uint32_t>(static_cast<int32_t>(value_)); | |
1078 } | |
1079 | |
1080 double ToFloat64() const { | 1072 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. | |
1084 if (type() == kInt32) return ToInt32(); | 1073 if (type() == kInt32) return ToInt32(); |
1085 DCHECK_EQ(kFloat64, type()); | 1074 DCHECK_EQ(kFloat64, type()); |
1086 return bit_cast<double>(value_); | 1075 return bit_cast<double>(value_); |
1087 } | 1076 } |
1088 | 1077 |
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 | |
1095 ExternalReference ToExternalReference() const { | 1078 ExternalReference ToExternalReference() const { |
1096 DCHECK_EQ(kExternalReference, type()); | 1079 DCHECK_EQ(kExternalReference, type()); |
1097 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_)); | 1080 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_)); |
1098 } | 1081 } |
1099 | 1082 |
1100 RpoNumber ToRpoNumber() const { | 1083 RpoNumber ToRpoNumber() const { |
1101 DCHECK_EQ(kRpoNumber, type()); | 1084 DCHECK_EQ(kRpoNumber, type()); |
1102 return RpoNumber::FromInt(static_cast<int>(value_)); | 1085 return RpoNumber::FromInt(static_cast<int>(value_)); |
1103 } | 1086 } |
1104 | 1087 |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 }; | 1609 }; |
1627 | 1610 |
1628 V8_EXPORT_PRIVATE std::ostream& operator<<( | 1611 V8_EXPORT_PRIVATE std::ostream& operator<<( |
1629 std::ostream& os, const PrintableInstructionSequence& code); | 1612 std::ostream& os, const PrintableInstructionSequence& code); |
1630 | 1613 |
1631 } // namespace compiler | 1614 } // namespace compiler |
1632 } // namespace internal | 1615 } // namespace internal |
1633 } // namespace v8 | 1616 } // namespace v8 |
1634 | 1617 |
1635 #endif // V8_COMPILER_INSTRUCTION_H_ | 1618 #endif // V8_COMPILER_INSTRUCTION_H_ |
OLD | NEW |