156893Sfenner//===---------------------- EntryStage.h ------------------------*- C++ -*-===//
256893Sfenner//
356893Sfenner// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
456893Sfenner// See https://llvm.org/LICENSE.txt for license information.
556893Sfenner// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
656893Sfenner//
756893Sfenner//===----------------------------------------------------------------------===//
856893Sfenner/// \file
956893Sfenner///
1056893Sfenner/// This file defines the Entry stage of an instruction pipeline.  Its sole
1156893Sfenner/// purpose in life is to pick instructions in sequence and move them to the
1256893Sfenner/// next pipeline stage.
1356893Sfenner///
1456893Sfenner//===----------------------------------------------------------------------===//
1556893Sfenner
1656893Sfenner#ifndef LLVM_MCA_STAGES_ENTRYSTAGE_H
1756893Sfenner#define LLVM_MCA_STAGES_ENTRYSTAGE_H
1856893Sfenner
1956893Sfenner#include "llvm/ADT/SmallVector.h"
2056893Sfenner#include "llvm/MCA/SourceMgr.h"
2156893Sfenner#include "llvm/MCA/Stages/Stage.h"
2256893Sfenner
2356893Sfennernamespace llvm {
24111726Sfennernamespace mca {
2556893Sfenner
2656893Sfennerclass EntryStage final : public Stage {
2756893Sfenner  InstRef CurrentInstruction;
2856893Sfenner  SmallVector<std::unique_ptr<Instruction>, 16> Instructions;
2956893Sfenner  SourceMgr &SM;
3056893Sfenner  unsigned NumRetired;
3156893Sfenner
3256893Sfenner  // Updates the program counter, and sets 'CurrentInstruction'.
3356893Sfenner  Error getNextInstruction();
3456893Sfenner
3556893Sfenner  EntryStage(const EntryStage &Other) = delete;
3656893Sfenner  EntryStage &operator=(const EntryStage &Other) = delete;
3756893Sfenner
3856893Sfennerpublic:
3956893Sfenner  EntryStage(SourceMgr &SM) : SM(SM), NumRetired(0) {}
4056893Sfenner
4156893Sfenner  bool isAvailable(const InstRef &IR) const override;
4256893Sfenner  bool hasWorkToComplete() const override;
4356893Sfenner  Error execute(InstRef &IR) override;
4456893Sfenner  Error cycleStart() override;
4556893Sfenner  Error cycleResume() override;
4698524Sfenner  Error cycleEnd() override;
4775115Sfenner};
4856893Sfenner
4975115Sfenner} // namespace mca
5075115Sfenner} // namespace llvm
5156893Sfenner
5256893Sfenner#endif // LLVM_MCA_STAGES_ENTRYSTAGE_H
5356893Sfenner