Also, removed a couple of unused methods from class Instruction.
llvm-svn: 328198
Stage = IS_EXECUTING;
// Set the cycles left before the write-back stage.
- setCyclesLeft(Desc.MaxLatency);
+ CyclesLeft = Desc.MaxLatency;
for (UniqueDef &Def : Defs)
Def->onInstructionIssued();
VecUses &getUses() { return Uses; }
const VecUses &getUses() const { return Uses; }
const InstrDesc &getDesc() const { return Desc; }
-
unsigned getRCUTokenID() const { return RCUTokenID; }
- int getCyclesLeft() const { return CyclesLeft; }
- void setCyclesLeft(int Cycles) { CyclesLeft = Cycles; }
// Transition to the dispatch stage, and assign a RCUToken to this
// instruction. The RCUToken is used to track the completion of every
///
//===----------------------------------------------------------------------===//
+#include "Instruction.h"
#include "LSUnit.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
StoreQueue.insert(Index);
}
+bool LSUnit::reserve(unsigned Index, const InstrDesc &Desc) {
+ unsigned MayLoad = Desc.MayLoad;
+ unsigned MayStore = Desc.MayStore;
+ unsigned IsMemBarrier = Desc.HasSideEffects;
+ if (!MayLoad && !MayStore)
+ return false;
+
+ if (MayLoad) {
+ if (IsMemBarrier)
+ LoadBarriers.insert(Index);
+ assignLQSlot(Index);
+ }
+ if (MayStore) {
+ if (IsMemBarrier)
+ StoreBarriers.insert(Index);
+ assignSQSlot(Index);
+ }
+ return true;
+}
+
bool LSUnit::isReady(unsigned Index) const {
bool IsALoad = LoadQueue.count(Index) != 0;
bool IsAStore = StoreQueue.count(Index) != 0;
+ assert((IsALoad || IsAStore) && "Instruction is not in queue!");
+
unsigned LoadBarrierIndex = LoadBarriers.empty() ? 0 : *LoadBarriers.begin();
unsigned StoreBarrierIndex = StoreBarriers.empty() ? 0 : *StoreBarriers.begin();
namespace mca {
+struct InstrDesc;
+
/// \brief A Load/Store Unit implementing a load and store queues.
///
/// This class implements a load queue and a store queue to emulate the
bool isSQFull() const { return SQ_Size != 0 && StoreQueue.size() == SQ_Size; }
bool isLQFull() const { return LQ_Size != 0 && LoadQueue.size() == LQ_Size; }
- void reserve(unsigned Index, bool MayLoad, bool MayStore, bool IsMemBarrier) {
- if (!MayLoad && !MayStore)
- return;
- if (MayLoad) {
- if (IsMemBarrier)
- LoadBarriers.insert(Index);
- assignLQSlot(Index);
- }
- if (MayStore) {
- if (IsMemBarrier)
- StoreBarriers.insert(Index);
- assignSQSlot(Index);
- }
- }
+ // Returns true if this instruction has been successfully enqueued.
+ bool reserve(unsigned Index, const InstrDesc &Desc);
// The rules are:
// 1. A store may not pass a previous store.
notifyReservedBuffers(Desc.Buffers);
}
- bool MayLoad = Desc.MayLoad;
- bool MayStore = Desc.MayStore;
- if (MayLoad || MayStore)
- LSU->reserve(Idx, MayLoad, MayStore, Desc.HasSideEffects);
-
- bool IsReady = MCIS.isReady();
- if (IsReady && (MayLoad || MayStore))
- IsReady &= LSU->isReady(Idx);
-
- if (!IsReady) {
+ // If necessary, reserve queue entries in the load-store unit (LSU).
+ bool Reserved = LSU->reserve(Idx, Desc);
+ if (!MCIS.isReady() || (Reserved && !LSU->isReady(Idx))) {
DEBUG(dbgs() << "[SCHEDULER] Adding " << Idx << " to the Wait Queue\n");
WaitQueue[Idx] = &MCIS;
return;