Index: src/compiler/type-hints.h |
diff --git a/src/compiler/type-hints.h b/src/compiler/type-hints.h |
index 6971960153f5c1d84b24ff2f33dba3b719ddc92d..731be7a7c6dd6f6d81d78ed29ee2b7ed9afb50b8 100644 |
--- a/src/compiler/type-hints.h |
+++ b/src/compiler/type-hints.h |
@@ -64,6 +64,52 @@ class BinaryOperationHints final { |
std::ostream& operator<<(std::ostream&, BinaryOperationHints::Hint); |
std::ostream& operator<<(std::ostream&, BinaryOperationHints); |
+// Type hints for an binary operation. |
+class CompareOperationHints final { |
+ public: |
+ enum Hint { |
+ kNone, |
+ kSignedSmall, |
+ kSigned32, |
+ kNumberOrUndefined, |
+ kString, |
+ kAny |
+ }; |
+ |
+ CompareOperationHints() : CompareOperationHints(kNone, kNone, kNone) {} |
+ CompareOperationHints(Hint left, Hint right, Hint combined) |
+ : bit_field_(LeftField::encode(left) | RightField::encode(right) | |
+ CombinedField::encode(combined)) {} |
+ |
+ static CompareOperationHints Any() { |
+ return CompareOperationHints(kAny, kAny, kAny); |
+ } |
+ |
+ Hint left() const { return LeftField::decode(bit_field_); } |
+ Hint right() const { return RightField::decode(bit_field_); } |
+ Hint combined() const { return CombinedField::decode(bit_field_); } |
+ |
+ bool operator==(CompareOperationHints const& that) const { |
+ return this->bit_field_ == that.bit_field_; |
+ } |
+ bool operator!=(CompareOperationHints const& that) const { |
+ return !(*this == that); |
+ } |
+ |
+ friend size_t hash_value(CompareOperationHints const& hints) { |
+ return hints.bit_field_; |
+ } |
+ |
+ private: |
+ typedef BitField<Hint, 0, 3> LeftField; |
+ typedef BitField<Hint, 3, 3> RightField; |
+ typedef BitField<Hint, 6, 3> CombinedField; |
+ |
+ uint32_t bit_field_; |
+}; |
+ |
+std::ostream& operator<<(std::ostream&, CompareOperationHints::Hint); |
+std::ostream& operator<<(std::ostream&, CompareOperationHints); |
// Type hints for the ToBoolean type conversion. |
enum class ToBooleanHint : uint16_t { |