From 2730df2e164b9a1f98cebd2dd51f059650fcec27 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Mon, 30 Sep 2019 17:24:25 +0000 Subject: [PATCH] [MCA] Use references to LSUnitBase in class Scheduler and add helper methods to acquire/release LS queue entries. NFCI llvm-svn: 373236 --- llvm/include/llvm/MCA/HardwareUnits/LSUnit.h | 6 ++++-- llvm/include/llvm/MCA/HardwareUnits/Scheduler.h | 8 ++++---- llvm/lib/MCA/HardwareUnits/LSUnit.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/llvm/include/llvm/MCA/HardwareUnits/LSUnit.h b/llvm/include/llvm/MCA/HardwareUnits/LSUnit.h index 6ca103808aa8..0dd5d3322aa1 100644 --- a/llvm/include/llvm/MCA/HardwareUnits/LSUnit.h +++ b/llvm/include/llvm/MCA/HardwareUnits/LSUnit.h @@ -209,8 +209,10 @@ public: unsigned getUsedLQEntries() const { return UsedLQEntries; } unsigned getUsedSQEntries() const { return UsedSQEntries; } - unsigned assignLQSlot() { return UsedLQEntries++; } - unsigned assignSQSlot() { return UsedSQEntries++; } + void acquireLQSlot() { ++UsedLQEntries; } + void acquireSQSlot() { ++UsedSQEntries; } + void releaseLQSlot() { --UsedLQEntries; } + void releaseSQSlot() { --UsedSQEntries; } bool assumeNoAlias() const { return NoAlias; } diff --git a/llvm/include/llvm/MCA/HardwareUnits/Scheduler.h b/llvm/include/llvm/MCA/HardwareUnits/Scheduler.h index 74c71a73dffd..6c196757e571 100644 --- a/llvm/include/llvm/MCA/HardwareUnits/Scheduler.h +++ b/llvm/include/llvm/MCA/HardwareUnits/Scheduler.h @@ -68,7 +68,7 @@ public: /// instructions from the dispatch stage, until the write-back stage. /// class Scheduler : public HardwareUnit { - LSUnit &LSU; + LSUnitBase &LSU; // Instruction selection strategy for this Scheduler. std::unique_ptr Strategy; @@ -154,15 +154,15 @@ class Scheduler : public HardwareUnit { bool promoteToPendingSet(SmallVectorImpl &Pending); public: - Scheduler(const MCSchedModel &Model, LSUnit &Lsu) + Scheduler(const MCSchedModel &Model, LSUnitBase &Lsu) : Scheduler(Model, Lsu, nullptr) {} - Scheduler(const MCSchedModel &Model, LSUnit &Lsu, + Scheduler(const MCSchedModel &Model, LSUnitBase &Lsu, std::unique_ptr SelectStrategy) : Scheduler(std::make_unique(Model), Lsu, std::move(SelectStrategy)) {} - Scheduler(std::unique_ptr RM, LSUnit &Lsu, + Scheduler(std::unique_ptr RM, LSUnitBase &Lsu, std::unique_ptr SelectStrategy) : LSU(Lsu), Resources(std::move(RM)), BusyResourceUnits(0), NumDispatchedToThePendingSet(0), HadTokenStall(false) { diff --git a/llvm/lib/MCA/HardwareUnits/LSUnit.cpp b/llvm/lib/MCA/HardwareUnits/LSUnit.cpp index 0465f53ed36e..973bb908e41a 100644 --- a/llvm/lib/MCA/HardwareUnits/LSUnit.cpp +++ b/llvm/lib/MCA/HardwareUnits/LSUnit.cpp @@ -72,9 +72,9 @@ unsigned LSUnit::dispatch(const InstRef &IR) { assert((Desc.MayLoad || Desc.MayStore) && "Not a memory operation!"); if (Desc.MayLoad) - assignLQSlot(); + acquireLQSlot(); if (Desc.MayStore) - assignSQSlot(); + acquireSQSlot(); if (Desc.MayStore) { // Always create a new group for store operations. @@ -173,13 +173,13 @@ void LSUnitBase::onInstructionExecuted(const InstRef &IR) { } if (IsALoad) { - UsedLQEntries--; + releaseLQSlot(); LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << IR.getSourceIndex() << " has been removed from the load queue.\n"); } if (IsAStore) { - UsedSQEntries--; + releaseSQSlot(); LLVM_DEBUG(dbgs() << "[LSUnit]: Instruction idx=" << IR.getSourceIndex() << " has been removed from the store queue.\n"); }