1bdd1243dSDimitry Andric //===-------------------- RISCVCustomBehaviour.h -----------------*-C++ -*-===// 2bdd1243dSDimitry Andric // 3bdd1243dSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4bdd1243dSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5bdd1243dSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6bdd1243dSDimitry Andric // 7bdd1243dSDimitry Andric //===----------------------------------------------------------------------===// 8bdd1243dSDimitry Andric /// \file 9bdd1243dSDimitry Andric /// 10bdd1243dSDimitry Andric /// This file defines the RISCVCustomBehaviour class which inherits from 11bdd1243dSDimitry Andric /// CustomBehaviour. This class is used by the tool llvm-mca to enforce 12bdd1243dSDimitry Andric /// target specific behaviour that is not expressed well enough in the 13bdd1243dSDimitry Andric /// scheduling model for mca to enforce it automatically. 14bdd1243dSDimitry Andric /// 15bdd1243dSDimitry Andric //===----------------------------------------------------------------------===// 16bdd1243dSDimitry Andric 17bdd1243dSDimitry Andric #ifndef LLVM_LIB_TARGET_RISCV_MCA_RISCVCUSTOMBEHAVIOUR_H 18bdd1243dSDimitry Andric #define LLVM_LIB_TARGET_RISCV_MCA_RISCVCUSTOMBEHAVIOUR_H 19bdd1243dSDimitry Andric 20bdd1243dSDimitry Andric #include "llvm/ADT/SmallVector.h" 21bdd1243dSDimitry Andric #include "llvm/MC/MCInst.h" 22bdd1243dSDimitry Andric #include "llvm/MC/MCInstrDesc.h" 23bdd1243dSDimitry Andric #include "llvm/MC/MCInstrInfo.h" 24bdd1243dSDimitry Andric #include "llvm/MCA/CustomBehaviour.h" 25bdd1243dSDimitry Andric 26bdd1243dSDimitry Andric namespace llvm { 27bdd1243dSDimitry Andric namespace mca { 28bdd1243dSDimitry Andric 29bdd1243dSDimitry Andric class RISCVLMULInstrument : public Instrument { 30bdd1243dSDimitry Andric public: 31bdd1243dSDimitry Andric static const StringRef DESC_NAME; 32bdd1243dSDimitry Andric static bool isDataValid(StringRef Data); 33bdd1243dSDimitry Andric RISCVLMULInstrument(StringRef Data)34*06c3fb27SDimitry Andric explicit RISCVLMULInstrument(StringRef Data) : Instrument(DESC_NAME, Data) {} 35bdd1243dSDimitry Andric 36bdd1243dSDimitry Andric ~RISCVLMULInstrument() = default; 37bdd1243dSDimitry Andric 38bdd1243dSDimitry Andric uint8_t getLMUL() const; 39bdd1243dSDimitry Andric }; 40bdd1243dSDimitry Andric 41*06c3fb27SDimitry Andric class RISCVSEWInstrument : public Instrument { 42*06c3fb27SDimitry Andric public: 43*06c3fb27SDimitry Andric static const StringRef DESC_NAME; 44*06c3fb27SDimitry Andric static bool isDataValid(StringRef Data); 45*06c3fb27SDimitry Andric RISCVSEWInstrument(StringRef Data)46*06c3fb27SDimitry Andric explicit RISCVSEWInstrument(StringRef Data) : Instrument(DESC_NAME, Data) {} 47*06c3fb27SDimitry Andric 48*06c3fb27SDimitry Andric ~RISCVSEWInstrument() = default; 49*06c3fb27SDimitry Andric 50*06c3fb27SDimitry Andric uint8_t getSEW() const; 51*06c3fb27SDimitry Andric }; 52*06c3fb27SDimitry Andric 53bdd1243dSDimitry Andric class RISCVInstrumentManager : public InstrumentManager { 54bdd1243dSDimitry Andric public: RISCVInstrumentManager(const MCSubtargetInfo & STI,const MCInstrInfo & MCII)55bdd1243dSDimitry Andric RISCVInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) 56bdd1243dSDimitry Andric : InstrumentManager(STI, MCII) {} 57bdd1243dSDimitry Andric shouldIgnoreInstruments()58bdd1243dSDimitry Andric bool shouldIgnoreInstruments() const override { return false; } 59bdd1243dSDimitry Andric bool supportsInstrumentType(StringRef Type) const override; 60bdd1243dSDimitry Andric 61*06c3fb27SDimitry Andric /// Create a Instrument for RISC-V target 62*06c3fb27SDimitry Andric UniqueInstrument createInstrument(StringRef Desc, StringRef Data) override; 63*06c3fb27SDimitry Andric 64*06c3fb27SDimitry Andric SmallVector<UniqueInstrument> createInstruments(const MCInst &Inst) override; 65bdd1243dSDimitry Andric 66bdd1243dSDimitry Andric /// Using the Instrument, returns a SchedClassID to use instead of 67bdd1243dSDimitry Andric /// the SchedClassID that belongs to the MCI or the original SchedClassID. 68bdd1243dSDimitry Andric unsigned 69bdd1243dSDimitry Andric getSchedClassID(const MCInstrInfo &MCII, const MCInst &MCI, 70*06c3fb27SDimitry Andric const SmallVector<Instrument *> &IVec) const override; 71bdd1243dSDimitry Andric }; 72bdd1243dSDimitry Andric 73bdd1243dSDimitry Andric } // namespace mca 74bdd1243dSDimitry Andric } // namespace llvm 75bdd1243dSDimitry Andric 76bdd1243dSDimitry Andric #endif 77