summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/RetireControlUnit.cpp
diff options
context:
space:
mode:
authorMatt Davis <Matthew.Davis@sony.com>2018-05-07 18:29:15 +0000
committerMatt Davis <Matthew.Davis@sony.com>2018-05-07 18:29:15 +0000
commit21a8d3230736346611992ecca6e15718ed0368fc (patch)
tree2debf253269ca0e90a4cee2f684a264a4e86dddd /llvm/tools/llvm-mca/RetireControlUnit.cpp
parente480ed0b9f3b86c77efbf84505baf92cd95554ed (diff)
downloadbcm5719-llvm-21a8d3230736346611992ecca6e15718ed0368fc.tar.gz
bcm5719-llvm-21a8d3230736346611992ecca6e15718ed0368fc.zip
[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
Diffstat (limited to 'llvm/tools/llvm-mca/RetireControlUnit.cpp')
-rw-r--r--llvm/tools/llvm-mca/RetireControlUnit.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/tools/llvm-mca/RetireControlUnit.cpp b/llvm/tools/llvm-mca/RetireControlUnit.cpp
index bd0fc28c6ba..da93c2c11c1 100644
--- a/llvm/tools/llvm-mca/RetireControlUnit.cpp
+++ b/llvm/tools/llvm-mca/RetireControlUnit.cpp
@@ -28,7 +28,7 @@ RetireControlUnit::RetireControlUnit(const llvm::MCSchedModel &SM,
}
// Reserves a number of slots, and returns a new token.
-unsigned RetireControlUnit::reserveSlot(unsigned Index, unsigned NumMicroOps) {
+unsigned RetireControlUnit::reserveSlot(const InstRef &IR, unsigned NumMicroOps) {
assert(isAvailable(NumMicroOps));
unsigned NormalizedQuantity =
std::min(NumMicroOps, static_cast<unsigned>(Queue.size()));
@@ -37,7 +37,7 @@ unsigned RetireControlUnit::reserveSlot(unsigned Index, unsigned NumMicroOps) {
// resources, they still consume one slot in the retire queue.
NormalizedQuantity = std::max(NormalizedQuantity, 1U);
unsigned TokenID = NextAvailableSlotIdx;
- Queue[NextAvailableSlotIdx] = {Index, NormalizedQuantity, false};
+ Queue[NextAvailableSlotIdx] = {IR, NormalizedQuantity, false};
NextAvailableSlotIdx += NormalizedQuantity;
NextAvailableSlotIdx %= Queue.size();
AvailableSlots -= NormalizedQuantity;
@@ -54,9 +54,10 @@ void RetireControlUnit::cycleEvent() {
break;
RUToken &Current = Queue[CurrentInstructionSlotIdx];
assert(Current.NumSlots && "Reserved zero slots?");
+ assert(Current.IR.isValid() && "Invalid RUToken in the RCU queue.");
if (!Current.Executed)
break;
- Owner->notifyInstructionRetired(Current.Index);
+ Owner->notifyInstructionRetired(Current.IR);
CurrentInstructionSlotIdx += Current.NumSlots;
CurrentInstructionSlotIdx %= Queue.size();
AvailableSlots += Current.NumSlots;
@@ -66,7 +67,7 @@ void RetireControlUnit::cycleEvent() {
void RetireControlUnit::onInstructionExecuted(unsigned TokenID) {
assert(Queue.size() > TokenID);
- assert(Queue[TokenID].Executed == false && Queue[TokenID].Index != ~0U);
+ assert(Queue[TokenID].Executed == false && Queue[TokenID].IR.isValid());
Queue[TokenID].Executed = true;
}
OpenPOWER on IntegriCloud