Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 176148f

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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361482 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a1dbeea commit 176148f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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; }

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)