diff options
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/Clustering.h')
-rw-r--r-- | llvm/tools/llvm-exegesis/lib/Clustering.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Clustering.h b/llvm/tools/llvm-exegesis/lib/Clustering.h index 6b8f5a654d9..3d6413d2256 100644 --- a/llvm/tools/llvm-exegesis/lib/Clustering.h +++ b/llvm/tools/llvm-exegesis/lib/Clustering.h @@ -33,14 +33,14 @@ public: public: static ClusterId noise() { return ClusterId(kNoise); } static ClusterId error() { return ClusterId(kError); } - static ClusterId makeValid(int Id) { - assert(Id >= 0); + static ClusterId makeValid(size_t Id) { return ClusterId(Id); } ClusterId() : Id_(kUndef) {} bool operator==(const ClusterId &O) const { return Id_ == O.Id_; } + bool operator<(const ClusterId &O) const {return Id_ < O.Id_; } - bool isValid() const { return Id_ >= 0; } + bool isValid() const { return Id_ <= kMaxValid; } bool isUndef() const { return Id_ == kUndef; } bool isNoise() const { return Id_ == kNoise; } bool isError() const { return Id_ == kError; } @@ -48,15 +48,16 @@ public: // Precondition: isValid(). size_t getId() const { assert(isValid()); - return static_cast<size_t>(Id_); + return Id_; } private: - explicit ClusterId(int Id) : Id_(Id) {} - static constexpr const int kUndef = -1; - static constexpr const int kNoise = -2; - static constexpr const int kError = -3; - int Id_; + explicit ClusterId(size_t Id) : Id_(Id) {} + static constexpr const size_t kMaxValid = std::numeric_limits<size_t>::max() - 4; + static constexpr const size_t kNoise = kMaxValid + 1; + static constexpr const size_t kError = kMaxValid + 2; + static constexpr const size_t kUndef = kMaxValid + 3; + size_t Id_; }; struct Cluster { |