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-exception 6// 7//===----------------------------------------------------------------------===// 8/// \file 9/// 10/// This file defines the RISCVCustomBehaviour class which inherits from 11/// CustomBehaviour. This class is used by the tool llvm-mca to enforce 12/// target specific behaviour that is not expressed well enough in the 13/// scheduling model for mca to enforce it automatically. 14/// 15//===----------------------------------------------------------------------===// 16 17#ifndef LLVM_LIB_TARGET_RISCV_MCA_RISCVCUSTOMBEHAVIOUR_H 18#define LLVM_LIB_TARGET_RISCV_MCA_RISCVCUSTOMBEHAVIOUR_H 19 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 RISCVLMULInstrument(StringRef Data) : Instrument(DESC_NAME, Data) {} 35 36 ~RISCVLMULInstrument() = default; 37 38 uint8_t getLMUL() const; 39}; 40 41class RISCVInstrumentManager : public InstrumentManager { 42public: 43 RISCVInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) 44 : InstrumentManager(STI, MCII) {} 45 46 bool shouldIgnoreInstruments() const override { return false; } 47 bool supportsInstrumentType(StringRef Type) const override; 48 49 /// Create a Instrument for RISCV target 50 SharedInstrument createInstrument(StringRef Desc, StringRef Data) override; 51 52 /// Using the Instrument, returns a SchedClassID to use instead of 53 /// the SchedClassID that belongs to the MCI or the original SchedClassID. 54 unsigned 55 getSchedClassID(const MCInstrInfo &MCII, const MCInst &MCI, 56 const SmallVector<SharedInstrument> &IVec) const override; 57}; 58 59} // namespace mca 60} // namespace llvm 61 62#endif 63