1 //===-------------------- RISCVCustomBehaviour.h -----------------*-C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_LIB_TARGET_RISCV_MCA_RISCVCUSTOMBEHAVIOUR_H
18 #define LLVM_LIB_TARGET_RISCV_MCA_RISCVCUSTOMBEHAVIOUR_H
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"
29 class RISCVLMULInstrument
: public Instrument
{
31 static const StringRef DESC_NAME
;
32 static bool isDataValid(StringRef Data
);
34 explicit RISCVLMULInstrument(StringRef Data
) : Instrument(DESC_NAME
, Data
) {}
36 ~RISCVLMULInstrument() = default;
38 uint8_t getLMUL() const;
41 class RISCVSEWInstrument
: public Instrument
{
43 static const StringRef DESC_NAME
;
44 static bool isDataValid(StringRef Data
);
46 explicit RISCVSEWInstrument(StringRef Data
) : Instrument(DESC_NAME
, Data
) {}
48 ~RISCVSEWInstrument() = default;
50 uint8_t getSEW() const;
53 class RISCVInstrumentManager
: public InstrumentManager
{
55 RISCVInstrumentManager(const MCSubtargetInfo
&STI
, const MCInstrInfo
&MCII
)
56 : InstrumentManager(STI
, MCII
) {}
58 bool shouldIgnoreInstruments() const override
{ return false; }
59 bool supportsInstrumentType(StringRef Type
) const override
;
61 /// Create a Instrument for RISC-V target
62 UniqueInstrument
createInstrument(StringRef Desc
, StringRef Data
) override
;
64 SmallVector
<UniqueInstrument
> createInstruments(const MCInst
&Inst
) override
;
66 /// Using the Instrument, returns a SchedClassID to use instead of
67 /// the SchedClassID that belongs to the MCI or the original SchedClassID.
69 getSchedClassID(const MCInstrInfo
&MCII
, const MCInst
&MCI
,
70 const SmallVector
<Instrument
*> &IVec
) const override
;