1343171Sdim//===---------------------- EntryStage.h ------------------------*- C++ -*-===//
2343171Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6343171Sdim//
7343171Sdim//===----------------------------------------------------------------------===//
8343171Sdim/// \file
9343171Sdim///
10343171Sdim/// This file defines the Entry stage of an instruction pipeline.  Its sole
11343171Sdim/// purpose in life is to pick instructions in sequence and move them to the
12343171Sdim/// next pipeline stage.
13343171Sdim///
14343171Sdim//===----------------------------------------------------------------------===//
15343171Sdim
16343171Sdim#ifndef LLVM_MCA_ENTRY_STAGE_H
17343171Sdim#define LLVM_MCA_ENTRY_STAGE_H
18343171Sdim
19343171Sdim#include "llvm/ADT/SmallVector.h"
20343171Sdim#include "llvm/MCA/SourceMgr.h"
21343171Sdim#include "llvm/MCA/Stages/Stage.h"
22343171Sdim
23343171Sdimnamespace llvm {
24343171Sdimnamespace mca {
25343171Sdim
26343171Sdimclass EntryStage final : public Stage {
27343171Sdim  InstRef CurrentInstruction;
28343171Sdim  SmallVector<std::unique_ptr<Instruction>, 16> Instructions;
29343171Sdim  SourceMgr &SM;
30343171Sdim  unsigned NumRetired;
31343171Sdim
32343171Sdim  // Updates the program counter, and sets 'CurrentInstruction'.
33343171Sdim  void getNextInstruction();
34343171Sdim
35343171Sdim  EntryStage(const EntryStage &Other) = delete;
36343171Sdim  EntryStage &operator=(const EntryStage &Other) = delete;
37343171Sdim
38343171Sdimpublic:
39343171Sdim  EntryStage(SourceMgr &SM) : CurrentInstruction(), SM(SM), NumRetired(0) { }
40343171Sdim
41343171Sdim  bool isAvailable(const InstRef &IR) const override;
42343171Sdim  bool hasWorkToComplete() const override;
43343171Sdim  Error execute(InstRef &IR) override;
44343171Sdim  Error cycleStart() override;
45343171Sdim  Error cycleEnd() override;
46343171Sdim};
47343171Sdim
48343171Sdim} // namespace mca
49343171Sdim} // namespace llvm
50343171Sdim
51343171Sdim#endif // LLVM_MCA_FETCH_STAGE_H
52