1343171Sdim//===--------------------- InstructionTables.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 implements a custom stage to generate instruction tables.
11343171Sdim/// See the description of command-line flag -instruction-tables in
12343171Sdim/// docs/CommandGuide/lvm-mca.rst
13343171Sdim///
14343171Sdim//===----------------------------------------------------------------------===//
15343171Sdim
16343171Sdim#ifndef LLVM_MCA_INSTRUCTIONTABLES_H
17343171Sdim#define LLVM_MCA_INSTRUCTIONTABLES_H
18343171Sdim
19343171Sdim#include "llvm/ADT/SmallVector.h"
20343171Sdim#include "llvm/MC/MCSchedule.h"
21343171Sdim#include "llvm/MCA/HardwareUnits/Scheduler.h"
22343171Sdim#include "llvm/MCA/Stages/Stage.h"
23343171Sdim#include "llvm/MCA/Support.h"
24343171Sdim
25343171Sdimnamespace llvm {
26343171Sdimnamespace mca {
27343171Sdim
28343171Sdimclass InstructionTables final : public Stage {
29343171Sdim  const MCSchedModel &SM;
30343171Sdim  SmallVector<std::pair<ResourceRef, ResourceCycles>, 4> UsedResources;
31343171Sdim  SmallVector<uint64_t, 8> Masks;
32343171Sdim
33343171Sdimpublic:
34343171Sdim  InstructionTables(const MCSchedModel &Model)
35343171Sdim      : Stage(), SM(Model), Masks(Model.getNumProcResourceKinds()) {
36343171Sdim    computeProcResourceMasks(Model, Masks);
37343171Sdim  }
38343171Sdim
39343171Sdim  bool hasWorkToComplete() const override { return false; }
40343171Sdim  Error execute(InstRef &IR) override;
41343171Sdim};
42343171Sdim} // namespace mca
43343171Sdim} // namespace llvm
44343171Sdim
45343171Sdim#endif // LLVM_MCA_INSTRUCTIONTABLES_H
46