[llvm] r361482 - [MCA] Make the bool conversion operator in class InstRef explicit. NFCI
Andrea Di Biagio via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 03:50:01 PDT 2019
Author: adibiagio
Date: Thu May 23 03:50:01 2019
New Revision: 361482
URL: http://llvm.org/viewvc/llvm-project?rev=361482&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/MCA/Instruction.h
llvm/trunk/lib/MCA/Stages/EntryStage.cpp
Modified: llvm/trunk/include/llvm/MCA/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MCA/Instruction.h?rev=361482&r1=361481&r2=361482&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MCA/Instruction.h (original)
+++ llvm/trunk/include/llvm/MCA/Instruction.h Thu May 23 03:50:01 2019
@@ -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; }
Modified: llvm/trunk/lib/MCA/Stages/EntryStage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MCA/Stages/EntryStage.cpp?rev=361482&r1=361481&r2=361482&view=diff
==============================================================================
--- llvm/trunk/lib/MCA/Stages/EntryStage.cpp (original)
+++ llvm/trunk/lib/MCA/Stages/EntryStage.cpp Thu May 23 03:50:01 2019
@@ -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)
More information about the llvm-commits
mailing list