brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 4ccd3cf Raw
77 lines · c
1//===-------------------- RISCVCustomBehaviour.h -----------------*-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-exception6//7//===----------------------------------------------------------------------===//8/// \file9///10/// This file defines the RISCVCustomBehaviour class which inherits from11/// CustomBehaviour. This class is used by the tool llvm-mca to enforce12/// target specific behaviour that is not expressed well enough in the13/// scheduling model for mca to enforce it automatically.14///15//===----------------------------------------------------------------------===//16 17#ifndef LLVM_LIB_TARGET_RISCV_MCA_RISCVCUSTOMBEHAVIOUR_H18#define LLVM_LIB_TARGET_RISCV_MCA_RISCVCUSTOMBEHAVIOUR_H19 20#include "llvm/ADT/SmallVector.h"21#include "llvm/MC/MCInst.h"22#include "llvm/MC/MCInstrDesc.h"23#include "llvm/MC/MCInstrInfo.h"24#include "llvm/MCA/CustomBehaviour.h"25 26namespace llvm {27namespace mca {28 29class RISCVLMULInstrument : public Instrument {30public:31  static const StringRef DESC_NAME;32  static bool isDataValid(StringRef Data);33 34  explicit RISCVLMULInstrument(StringRef Data) : Instrument(DESC_NAME, Data) {}35 36  ~RISCVLMULInstrument() override = default;37 38  uint8_t getLMUL() const;39};40 41class RISCVSEWInstrument : public Instrument {42public:43  static const StringRef DESC_NAME;44  static bool isDataValid(StringRef Data);45 46  explicit RISCVSEWInstrument(StringRef Data) : Instrument(DESC_NAME, Data) {}47 48  ~RISCVSEWInstrument() override = default;49 50  uint8_t getSEW() const;51};52 53class RISCVInstrumentManager : public InstrumentManager {54public:55  RISCVInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)56      : InstrumentManager(STI, MCII) {}57 58  bool shouldIgnoreInstruments() const override { return false; }59  bool supportsInstrumentType(StringRef Type) const override;60 61  /// Create a Instrument for RISC-V target62  UniqueInstrument createInstrument(StringRef Desc, StringRef Data) override;63 64  SmallVector<UniqueInstrument> createInstruments(const MCInst &Inst) override;65 66  /// Using the Instrument, returns a SchedClassID to use instead of67  /// the SchedClassID that belongs to the MCI or the original SchedClassID.68  unsigned69  getSchedClassID(const MCInstrInfo &MCII, const MCInst &MCI,70                  const SmallVector<Instrument *> &IVec) const override;71};72 73} // namespace mca74} // namespace llvm75 76#endif77