[llvm-mca] Simplify (and better standardize) the Instruction interface.
llvm-svn: 328190
diff --git a/llvm/tools/llvm-mca/Instruction.cpp b/llvm/tools/llvm-mca/Instruction.cpp
index e3b26bd..edf321a 100644
--- a/llvm/tools/llvm-mca/Instruction.cpp
+++ b/llvm/tools/llvm-mca/Instruction.cpp
@@ -92,10 +92,12 @@
}
#endif
-void Instruction::dispatch() {
+void Instruction::dispatch(unsigned RCUToken) {
assert(Stage == IS_INVALID);
Stage = IS_AVAILABLE;
+ RCUTokenID = RCUToken;
+ // Check if input operands are already available.
if (std::all_of(Uses.begin(), Uses.end(),
[](const UniqueUse &Use) { return Use->isReady(); }))
Stage = IS_READY;
@@ -104,8 +106,14 @@
void Instruction::execute() {
assert(Stage == IS_READY);
Stage = IS_EXECUTING;
+
+ // Set the cycles left before the write-back stage.
+ setCyclesLeft(Desc.MaxLatency);
+
for (UniqueDef &Def : Defs)
Def->onInstructionIssued();
+
+ // Transition to the "executed" stage if this is a zero-latency instruction.
if (!CyclesLeft)
Stage = IS_EXECUTED;
}