LLVM  8.0.1
RetireStage.cpp
Go to the documentation of this file.
1 //===---------------------- RetireStage.cpp ---------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
11 /// This file defines the retire stage of an instruction pipeline.
12 /// The RetireStage represents the process logic that interacts with the
13 /// simulated RetireControlUnit hardware.
14 ///
15 //===----------------------------------------------------------------------===//
16 
19 #include "llvm/Support/Debug.h"
20 
21 #define DEBUG_TYPE "llvm-mca"
22 
23 namespace llvm {
24 namespace mca {
25 
27  if (RCU.isEmpty())
28  return llvm::ErrorSuccess();
29 
30  const unsigned MaxRetirePerCycle = RCU.getMaxRetirePerCycle();
31  unsigned NumRetired = 0;
32  while (!RCU.isEmpty()) {
33  if (MaxRetirePerCycle != 0 && NumRetired == MaxRetirePerCycle)
34  break;
35  const RetireControlUnit::RUToken &Current = RCU.peekCurrentToken();
36  if (!Current.Executed)
37  break;
38  RCU.consumeCurrentToken();
40  NumRetired++;
41  }
42 
43  return llvm::ErrorSuccess();
44 }
45 
48  return llvm::ErrorSuccess();
49 }
50 
52  LLVM_DEBUG(llvm::dbgs() << "[E] Instruction Retired: #" << IR << '\n');
54  const Instruction &Inst = *IR.getInstruction();
55 
56  for (const WriteState &WS : Inst.getDefs())
57  PRF.removeRegisterWrite(WS, FreedRegs);
58  notifyEvent<HWInstructionEvent>(HWInstructionRetiredEvent(IR, FreedRegs));
59 }
60 
61 } // namespace mca
62 } // namespace llvm
Instruction * getInstruction()
Definition: Instruction.h:488
This file defines the retire stage of a default instruction pipeline.
An instruction propagated through the simulated instruction pipeline.
Definition: Instruction.h:407
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Subclass of Error for the sole purpose of identifying the success path in the type system...
Definition: Error.h:325
unsigned getNumRegisterFiles() const
Definition: RegisterFile.h:226
void notifyInstructionRetired(const InstRef &IR) const
Definition: RetireStage.cpp:51
An InstRef contains both a SourceMgr index and Instruction pair.
Definition: Instruction.h:478
const RUToken & peekCurrentToken() const
void onInstructionExecuted(unsigned TokenID)
unsigned getRCUTokenID() const
Definition: Instruction.h:432
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:26
Tracks uses of a register definition (e.g.
Definition: Instruction.h:90
unsigned getMaxRetirePerCycle() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:133
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
Definition: RetireStage.cpp:46
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
#define LLVM_DEBUG(X)
Definition: Debug.h:123
Statically lint checks LLVM IR
Definition: Lint.cpp:193