diff options
author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-22 10:19:20 +0000 |
---|---|---|
committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-03-22 10:19:20 +0000 |
commit | 35622488258b6224a152ec7b310714d5a490af42 (patch) | |
tree | 65ce7d905d553f56cfad72ff2162711cb03d7c6c /llvm/tools/llvm-mca/Instruction.cpp | |
parent | 843a3caa71ca94ec7fd857ce7b4276a37d5de4ca (diff) | |
download | bcm5719-llvm-35622488258b6224a152ec7b310714d5a490af42.tar.gz bcm5719-llvm-35622488258b6224a152ec7b310714d5a490af42.zip |
[llvm-mca] Simplify code. NFC
llvm-svn: 328187
Diffstat (limited to 'llvm/tools/llvm-mca/Instruction.cpp')
-rw-r--r-- | llvm/tools/llvm-mca/Instruction.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/llvm/tools/llvm-mca/Instruction.cpp b/llvm/tools/llvm-mca/Instruction.cpp index e7f9916cae2..e3b26bd9609 100644 --- a/llvm/tools/llvm-mca/Instruction.cpp +++ b/llvm/tools/llvm-mca/Instruction.cpp @@ -92,17 +92,13 @@ void WriteState::dump() const { } #endif -bool Instruction::isReady() { - if (Stage == IS_READY) - return true; +void Instruction::dispatch() { + assert(Stage == IS_INVALID); + Stage = IS_AVAILABLE; - assert(Stage == IS_AVAILABLE); - for (const UniqueUse &Use : Uses) - if (!Use.get()->isReady()) - return false; - - setReady(); - return true; + if (std::all_of(Uses.begin(), Uses.end(), + [](const UniqueUse &Use) { return Use->isReady(); })) + Stage = IS_READY; } void Instruction::execute() { @@ -110,6 +106,8 @@ void Instruction::execute() { Stage = IS_EXECUTING; for (UniqueDef &Def : Defs) Def->onInstructionIssued(); + if (!CyclesLeft) + Stage = IS_EXECUTED; } bool Instruction::isZeroLatency() const { @@ -117,18 +115,27 @@ bool Instruction::isZeroLatency() const { } void Instruction::cycleEvent() { + if (isReady()) + return; + if (isDispatched()) { - for (UniqueUse &Use : Uses) + bool IsReady = true; + for (UniqueUse &Use : Uses) { Use->cycleEvent(); + IsReady &= Use->isReady(); + } + + if (IsReady) + Stage = IS_READY; return; } - if (isExecuting()) { - for (UniqueDef &Def : Defs) - Def->cycleEvent(); - CyclesLeft--; - } + + assert(isExecuting() && "Instruction not in-flight?"); + assert(CyclesLeft && "Instruction already executed?"); + for (UniqueDef &Def : Defs) + Def->cycleEvent(); + CyclesLeft--; if (!CyclesLeft) Stage = IS_EXECUTED; } - } // namespace mca |