[llvm] r342480 - [llvm-mca] Slightly refactor class InstRef. NFC.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 18 07:03:47 PDT 2018


Author: adibiagio
Date: Tue Sep 18 07:03:46 2018
New Revision: 342480

URL: http://llvm.org/viewvc/llvm-project?rev=342480&view=rev
Log:
[llvm-mca] Slightly refactor class InstRef. NFC.

Modified:
    llvm/trunk/tools/llvm-mca/include/Instruction.h
    llvm/trunk/tools/llvm-mca/lib/Stages/DispatchStage.cpp

Modified: llvm/trunk/tools/llvm-mca/include/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/include/Instruction.h?rev=342480&r1=342479&r2=342480&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/include/Instruction.h (original)
+++ llvm/trunk/tools/llvm-mca/include/Instruction.h Tue Sep 18 07:03:46 2018
@@ -389,21 +389,24 @@ public:
 /// An InstRef contains both a SourceMgr index and Instruction pair.  The index
 /// is used as a unique identifier for the instruction.  MCA will make use of
 /// this index as a key throughout MCA.
-class InstRef : public std::pair<unsigned, Instruction *> {
+class InstRef {
+  std::pair<unsigned, Instruction *> Data;
+
 public:
-  InstRef() : std::pair<unsigned, Instruction *>(0, nullptr) {}
-  InstRef(unsigned Index, Instruction *I)
-      : std::pair<unsigned, Instruction *>(Index, I) {}
-
-  unsigned getSourceIndex() const { return first; }
-  Instruction *getInstruction() { return second; }
-  const Instruction *getInstruction() const { return second; }
+  InstRef() : Data(std::make_pair(0, nullptr)) {}
+  InstRef(unsigned Index, Instruction *I) : Data(std::make_pair(Index, I)) {}
+
+  bool operator==(const InstRef &Other) const { return Data == Other.Data; }
+
+  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.
-  bool isValid() const { return second != nullptr; }
+  bool isValid() const { return Data.second; }
 
   /// Invalidate this reference.
-  void invalidate() { second = nullptr; }
+  void invalidate() { Data.second = nullptr; }
 
 #ifndef NDEBUG
   void print(llvm::raw_ostream &OS) const { OS << getSourceIndex(); }

Modified: llvm/trunk/tools/llvm-mca/lib/Stages/DispatchStage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/lib/Stages/DispatchStage.cpp?rev=342480&r1=342479&r2=342480&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/lib/Stages/DispatchStage.cpp (original)
+++ llvm/trunk/tools/llvm-mca/lib/Stages/DispatchStage.cpp Tue Sep 18 07:03:46 2018
@@ -118,7 +118,7 @@ llvm::Error DispatchStage::dispatch(Inst
       !(Desc.isZeroLatency() && IsDependencyBreaking);
   SmallVector<unsigned, 4> RegisterFiles(PRF.getNumRegisterFiles());
   for (std::unique_ptr<WriteState> &WS : IS.getDefs()) {
-    PRF.addRegisterWrite(WriteRef(IR.first, WS.get()), RegisterFiles,
+    PRF.addRegisterWrite(WriteRef(IR.getSourceIndex(), WS.get()), RegisterFiles,
                          ShouldAllocateRegisters);
   }
 




More information about the llvm-commits mailing list