OSDN Git Service

[MCA] Make the bool conversion operator in class InstRef explicit. NFCI
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Thu, 23 May 2019 10:50:01 +0000 (10:50 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Thu, 23 May 2019 10:50:01 +0000 (10:50 +0000)
This patch makes the bool conversion operator in InstRef explicit.
It also adds a operator< to hel comparing InstRef objects in sets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361482 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MCA/Instruction.h
lib/MCA/Stages/EntryStage.cpp

index 0cb6f6c..a7a47fd 100644 (file)
@@ -526,13 +526,17 @@ public:
   InstRef(unsigned Index, Instruction *I) : Data(std::make_pair(Index, I)) {}
 
   bool operator==(const InstRef &Other) const { return Data == Other.Data; }
+  bool operator!=(const InstRef &Other) const { return Data != Other.Data; }
+  bool operator<(const InstRef &Other) const {
+    return Data.first < Other.Data.first;
+  }
 
   unsigned getSourceIndex() const { return Data.first; }
   Instruction *getInstruction() { return Data.second; }
   const Instruction *getInstruction() const { return Data.second; }
 
   /// Returns true if this references a valid instruction.
-  operator bool() const { return Data.second != nullptr; }
+  explicit operator bool() const { return Data.second != nullptr; }
 
   /// Invalidate this reference.
   void invalidate() { Data.second = nullptr; }
index 2028b9e..d2f5613 100644 (file)
@@ -18,7 +18,9 @@
 namespace llvm {
 namespace mca {
 
-bool EntryStage::hasWorkToComplete() const { return CurrentInstruction; }
+bool EntryStage::hasWorkToComplete() const {
+  return static_cast<bool>(CurrentInstruction);
+}
 
 bool EntryStage::isAvailable(const InstRef & /* unused */) const {
   if (CurrentInstruction)