summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca
diff options
context:
space:
mode:
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-04-05 15:41:41 +0000
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>2018-04-05 15:41:41 +0000
commitc74ad502cecf221e2cbfed86f79a93155247760a (patch)
treea8803caa215d0107dad7d27842c2fe9d6b4709a3 /llvm/tools/llvm-mca
parent2204520e49581352227091f9f052ff708ae1398b (diff)
downloadbcm5719-llvm-c74ad502cecf221e2cbfed86f79a93155247760a.tar.gz
bcm5719-llvm-c74ad502cecf221e2cbfed86f79a93155247760a.zip
[MC][Tablegen] Allow models to describe the retire control unit for llvm-mca.
This patch adds the ability to describe properties of the hardware retire control unit. Tablegen class RetireControlUnit has been added for this purpose (see TargetSchedule.td). A RetireControlUnit specifies the size of the reorder buffer, as well as the maximum number of opcodes that can be retired every cycle. A zero (or negative) value for the reorder buffer size means: "the size is unknown". If the size is unknown, then llvm-mca defaults it to the value of field SchedMachineModel::MicroOpBufferSize. A zero or negative number of opcodes retired per cycle means: "there is no restriction on the number of instructions that can be retired every cycle". Models can optionally specify an instance of RetireControlUnit. There can only be up-to one RetireControlUnit definition per scheduling model. Information related to the RCU (RetireControlUnit) is stored in (two new fields of) MCExtraProcessorInfo. llvm-mca loads that information when it initializes the DispatchUnit / RetireControlUnit (see Dispatch.h/Dispatch.cpp). This patch fixes PR36661. Differential Revision: https://reviews.llvm.org/D45259 llvm-svn: 329304
Diffstat (limited to 'llvm/tools/llvm-mca')
-rw-r--r--llvm/tools/llvm-mca/Backend.h6
-rw-r--r--llvm/tools/llvm-mca/Dispatch.cpp18
-rw-r--r--llvm/tools/llvm-mca/Dispatch.h20
3 files changed, 27 insertions, 17 deletions
diff --git a/llvm/tools/llvm-mca/Backend.h b/llvm/tools/llvm-mca/Backend.h
index 12e80777c77..c21da1f23af 100644
--- a/llvm/tools/llvm-mca/Backend.h
+++ b/llvm/tools/llvm-mca/Backend.h
@@ -68,9 +68,9 @@ public:
HWS(llvm::make_unique<Scheduler>(this, Subtarget.getSchedModel(),
LoadQueueSize, StoreQueueSize,
AssumeNoAlias)),
- DU(llvm::make_unique<DispatchUnit>(
- this, STI, MRI, Subtarget.getSchedModel().MicroOpBufferSize,
- RegisterFileSize, DispatchWidth, HWS.get())),
+ DU(llvm::make_unique<DispatchUnit>(this, Subtarget.getSchedModel(), MRI,
+ RegisterFileSize, DispatchWidth,
+ HWS.get())),
SM(Source), Cycles(0) {
HWS->setDispatchUnit(DU.get());
}
diff --git a/llvm/tools/llvm-mca/Dispatch.cpp b/llvm/tools/llvm-mca/Dispatch.cpp
index 383737a41ca..ce329b4a00d 100644
--- a/llvm/tools/llvm-mca/Dispatch.cpp
+++ b/llvm/tools/llvm-mca/Dispatch.cpp
@@ -251,6 +251,24 @@ void RegisterFile::dump() const {
}
#endif
+RetireControlUnit::RetireControlUnit(const llvm::MCSchedModel &SM,
+ DispatchUnit *DU)
+ : NextAvailableSlotIdx(0), CurrentInstructionSlotIdx(0),
+ AvailableSlots(SM.MicroOpBufferSize), MaxRetirePerCycle(0), Owner(DU) {
+ // Check if the scheduling model provides extra information about the machine
+ // processor. If so, then use that information to set the reorder buffer size
+ // and the maximum number of instructions retired per cycle.
+ if (SM.hasExtraProcessorInfo()) {
+ const MCExtraProcessorInfo &EPI = SM.getExtraProcessorInfo();
+ if (EPI.ReorderBufferSize)
+ AvailableSlots = EPI.ReorderBufferSize;
+ MaxRetirePerCycle = EPI.MaxRetirePerCycle;
+ }
+
+ assert(AvailableSlots && "Invalid reorder buffer size!");
+ Queue.resize(AvailableSlots);
+}
+
// Reserves a number of slots, and returns a new token.
unsigned RetireControlUnit::reserveSlot(unsigned Index, unsigned NumMicroOps) {
assert(isAvailable(NumMicroOps));
diff --git a/llvm/tools/llvm-mca/Dispatch.h b/llvm/tools/llvm-mca/Dispatch.h
index 979e2a370dd..3f09ab78611 100644
--- a/llvm/tools/llvm-mca/Dispatch.h
+++ b/llvm/tools/llvm-mca/Dispatch.h
@@ -192,12 +192,7 @@ private:
DispatchUnit *Owner;
public:
- RetireControlUnit(unsigned NumSlots, DispatchUnit *DU)
- : NextAvailableSlotIdx(0), CurrentInstructionSlotIdx(0),
- AvailableSlots(NumSlots), MaxRetirePerCycle(0), Owner(DU) {
- assert(NumSlots && "Expected at least one slot!");
- Queue.resize(NumSlots);
- }
+ RetireControlUnit(const llvm::MCSchedModel &SM, DispatchUnit *DU);
bool isFull() const { return !AvailableSlots; }
bool isEmpty() const { return AvailableSlots == Queue.size(); }
@@ -264,16 +259,13 @@ class DispatchUnit {
llvm::ArrayRef<unsigned> UsedPhysRegs);
public:
- DispatchUnit(Backend *B, const llvm::MCSubtargetInfo &STI,
- const llvm::MCRegisterInfo &MRI, unsigned MicroOpBufferSize,
- unsigned RegisterFileSize, unsigned MaxDispatchWidth,
- Scheduler *Sched)
+ DispatchUnit(Backend *B, const llvm::MCSchedModel &SM,
+ const llvm::MCRegisterInfo &MRI, unsigned RegisterFileSize,
+ unsigned MaxDispatchWidth, Scheduler *Sched)
: DispatchWidth(MaxDispatchWidth), AvailableEntries(MaxDispatchWidth),
CarryOver(0U), SC(Sched),
- RAT(llvm::make_unique<RegisterFile>(STI.getSchedModel(), MRI,
- RegisterFileSize)),
- RCU(llvm::make_unique<RetireControlUnit>(MicroOpBufferSize, this)),
- Owner(B) {}
+ RAT(llvm::make_unique<RegisterFile>(SM, MRI, RegisterFileSize)),
+ RCU(llvm::make_unique<RetireControlUnit>(SM, this)), Owner(B) {}
unsigned getDispatchWidth() const { return DispatchWidth; }
OpenPOWER on IntegriCloud