Skip to content

Commit 28afd8d

Browse files
committed
[MCA] Make the bool conversion operator in class InstRef explicit. NFCI
This patch makes the bool conversion operator in InstRef explicit. It also adds a operator< to hel comparing InstRef objects in sets. llvm-svn: 361482
1 parent f95b05c commit 28afd8d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

llvm/include/llvm/MCA/Instruction.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,17 @@ class InstRef {
526526
InstRef(unsigned Index, Instruction *I) : Data(std::make_pair(Index, I)) {}
527527

528528
bool operator==(const InstRef &Other) const { return Data == Other.Data; }
529+
bool operator!=(const InstRef &Other) const { return Data != Other.Data; }
530+
bool operator<(const InstRef &Other) const {
531+
return Data.first < Other.Data.first;
532+
}
529533

530534
unsigned getSourceIndex() const { return Data.first; }
531535
Instruction *getInstruction() { return Data.second; }
532536
const Instruction *getInstruction() const { return Data.second; }
533537

534538
/// Returns true if this references a valid instruction.
535-
operator bool() const { return Data.second != nullptr; }
539+
explicit operator bool() const { return Data.second != nullptr; }
536540

537541
/// Invalidate this reference.
538542
void invalidate() { Data.second = nullptr; }

llvm/lib/MCA/Stages/EntryStage.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
namespace llvm {
1919
namespace mca {
2020

21-
bool EntryStage::hasWorkToComplete() const { return CurrentInstruction; }
21+
bool EntryStage::hasWorkToComplete() const {
22+
return static_cast<bool>(CurrentInstruction);
23+
}
2224

2325
bool EntryStage::isAvailable(const InstRef & /* unused */) const {
2426
if (CurrentInstruction)

0 commit comments

Comments
 (0)