LLVM  10.0.0svn
RetireStage.cpp
Go to the documentation of this file.
1 //===---------------------- RetireStage.cpp ---------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 ///
10 /// This file defines the retire stage of an instruction pipeline.
11 /// The RetireStage represents the process logic that interacts with the
12 /// simulated RetireControlUnit hardware.
13 ///
14 //===----------------------------------------------------------------------===//
15 
18 #include "llvm/Support/Debug.h"
19 
20 #define DEBUG_TYPE "llvm-mca"
21 
22 namespace llvm {
23 namespace mca {
24 
26  if (RCU.isEmpty())
27  return llvm::ErrorSuccess();
28 
29  const unsigned MaxRetirePerCycle = RCU.getMaxRetirePerCycle();
30  unsigned NumRetired = 0;
31  while (!RCU.isEmpty()) {
32  if (MaxRetirePerCycle != 0 && NumRetired == MaxRetirePerCycle)
33  break;
34  const RetireControlUnit::RUToken &Current = RCU.getCurrentToken();
35  if (!Current.Executed)
36  break;
38  RCU.consumeCurrentToken();
39  NumRetired++;
40  }
41 
42  return llvm::ErrorSuccess();
43 }
44 
47  return llvm::ErrorSuccess();
48 }
49 
51  LLVM_DEBUG(llvm::dbgs() << "[E] Instruction Retired: #" << IR << '\n');
53  const Instruction &Inst = *IR.getInstruction();
54 
55  // Release the load/store queue entries.
56  if (Inst.isMemOp())
57  LSU.onInstructionRetired(IR);
58 
59  for (const WriteState &WS : Inst.getDefs())
60  PRF.removeRegisterWrite(WS, FreedRegs);
61  notifyEvent<HWInstructionEvent>(HWInstructionRetiredEvent(IR, FreedRegs));
62 }
63 
64 } // namespace mca
65 } // namespace llvm
Instruction * getInstruction()
Definition: Instruction.h:576
This file defines the retire stage of a default instruction pipeline.
An instruction propagated through the simulated instruction pipeline.
Definition: Instruction.h:445
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Subclass of Error for the sole purpose of identifying the success path in the type system...
Definition: Error.h:324
unsigned getNumRegisterFiles() const
Definition: RegisterFile.h:226
void notifyInstructionRetired(const InstRef &IR) const
Definition: RetireStage.cpp:50
An InstRef contains both a SourceMgr index and Instruction pair.
Definition: Instruction.h:562
void onInstructionExecuted(unsigned TokenID)
unsigned getRCUTokenID() const
Definition: Instruction.h:498
void removeRegisterWrite(const WriteState &WS, MutableArrayRef< unsigned > FreedPhysRegs)
This file defines the main interface for hardware event listeners.
Error cycleStart() override
Called once at the start of each cycle.
Definition: RetireStage.cpp:25
Tracks uses of a register definition (e.g.
Definition: Instruction.h:99
unsigned getMaxRetirePerCycle() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
Definition: RetireStage.cpp:45
virtual void onInstructionRetired(const InstRef &IR)
Definition: LSUnit.cpp:171
const RUToken & getCurrentToken() const
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
#define LLVM_DEBUG(X)
Definition: Debug.h:122
Statically lint checks LLVM IR
Definition: Lint.cpp:192