[llvm-mca] Avoid exposing index values in the MCA interfaces.
Summary:
This patch eliminates many places where we originally needed to pass index
values to represent an instruction. The index is still used as a key, in various parts of
MCA. I'm not comfortable eliminating the index just yet. By burying the index in
the instruction, we can avoid exposing that value in many places.
Eventually, we should consider removing the Instructions list in the Backend
all together, it's only used to hold and reclaim the memory for the allocated
Instruction instances. Instead we could pass around a smart pointer. But that's
a separate discussion/patch.
Reviewers: andreadb, courbet, RKSimon
Reviewed By: andreadb
Subscribers: javed.absar, tschuett, gbedwell, llvm-commits
Differential Revision: https://reviews.llvm.org/D46367
llvm-svn: 331660
diff --git a/llvm/tools/llvm-mca/LSUnit.h b/llvm/tools/llvm-mca/LSUnit.h
index d291a09..8591107 100644
--- a/llvm/tools/llvm-mca/LSUnit.h
+++ b/llvm/tools/llvm-mca/LSUnit.h
@@ -24,6 +24,7 @@
namespace mca {
+class InstRef;
struct InstrDesc;
/// A Load/Store Unit implementing a load and store queues.
@@ -132,7 +133,7 @@
bool isLQFull() const { return LQ_Size != 0 && LoadQueue.size() == LQ_Size; }
// Returns true if this instruction has been successfully enqueued.
- bool reserve(unsigned Index, const InstrDesc &Desc);
+ bool reserve(const InstRef &IR);
// The rules are:
// 1. A store may not pass a previous store.
@@ -141,8 +142,8 @@
// 4. A store may not pass a previous load (regardless of flag 'NoAlias').
// 5. A load has to wait until an older load barrier is fully executed.
// 6. A store has to wait until an older store barrier is fully executed.
- bool isReady(unsigned Index) const;
- void onInstructionExecuted(unsigned Index);
+ bool isReady(const InstRef &IR) const;
+ void onInstructionExecuted(const InstRef &IR);
};
} // namespace mca