22#define DEBUG_TYPE "llvm-mca-riscv-custombehaviour"
33#define GET_RISCVBaseVXMemOpTable_IMPL
34#include "RISCVGenSearchableTables.inc"
45 .
Cases(
"M1",
"M2",
"M4",
"M8",
"MF2",
"MF4",
"MF8",
true)
53 "Cannot get LMUL because invalid Data value");
70 .
Cases(
"E8",
"E16",
"E32",
"E64",
true)
101 return std::make_unique<RISCVLMULInstrument>(
Data);
110 return std::make_unique<RISCVSEWInstrument>(
Data);
119 if (Inst.
getOpcode() == RISCV::VSETVLI ||
121 LLVM_DEBUG(
dbgs() <<
"RVCB: Found VSETVLI and creating instrument for it: "
182static std::pair<uint8_t, uint8_t>
196 case RISCV::VLSE16_V:
197 case RISCV::VSSE16_V:
202 case RISCV::VLSE32_V:
203 case RISCV::VSSE32_V:
208 case RISCV::VLSE64_V:
209 case RISCV::VSSE64_V:
219 return std::make_pair(EEW, *EMUL);
223 return Opcode == RISCV::VLM_V || Opcode == RISCV::VSM_V ||
224 Opcode == RISCV::VLE8_V || Opcode == RISCV::VSE8_V ||
225 Opcode == RISCV::VLE16_V || Opcode == RISCV::VSE16_V ||
226 Opcode == RISCV::VLE32_V || Opcode == RISCV::VSE32_V ||
227 Opcode == RISCV::VLE64_V || Opcode == RISCV::VSE64_V ||
228 Opcode == RISCV::VLSE8_V || Opcode == RISCV::VSSE8_V ||
229 Opcode == RISCV::VLSE16_V || Opcode == RISCV::VSSE16_V ||
230 Opcode == RISCV::VLSE32_V || Opcode == RISCV::VSSE32_V ||
231 Opcode == RISCV::VLSE64_V || Opcode == RISCV::VSSE64_V;
243 for (
auto &
I : IVec) {
254 dbgs() <<
"RVCB: Did not use instrumentation to override Opcode.\n");
262 uint8_t SEW = SI ? SI->getSEW() : 0;
264 std::optional<unsigned> VPOpcode;
265 if (
const auto *VXMO = RISCV::getVXMemOpInfo(Opcode)) {
268 unsigned IndexEMUL = ((1 << VXMO->Log2IdxEEW) * LMUL) / SEW;
273 if (
const auto *VXP = RISCV::getVSXPseudo(
274 0, VXMO->IsOrdered, VXMO->Log2IdxEEW, LMUL,
276 VPOpcode = VXP->Pseudo;
278 if (
const auto *VXP = RISCV::getVLXPseudo(
279 0, VXMO->IsOrdered, VXMO->Log2IdxEEW, LMUL,
281 VPOpcode = VXP->Pseudo;
286 if (
const auto *VXP =
287 RISCV::getVSXSEGPseudo(VXMO->NF, 0, VXMO->IsOrdered,
288 VXMO->Log2IdxEEW, LMUL, IndexEMUL))
289 VPOpcode = VXP->Pseudo;
291 if (
const auto *VXP =
292 RISCV::getVLXSEGPseudo(VXMO->NF, 0, VXMO->IsOrdered,
293 VXMO->Log2IdxEEW, LMUL, IndexEMUL))
294 VPOpcode = VXP->Pseudo;
300 if (
const auto *
RVV =
301 RISCVVInversePseudosTable::getBaseInfo(Opcode, EMUL, EEW))
302 VPOpcode =
RVV->Pseudo;
305 const auto *
RVV = RISCVVInversePseudosTable::getBaseInfo(Opcode, LMUL, SEW);
308 RVV = RISCVVInversePseudosTable::getBaseInfo(Opcode, LMUL, 0);
311 VPOpcode =
RVV->Pseudo;
317 dbgs() <<
"RVCB: Could not find PseudoInstruction for Opcode "
319 <<
", LMUL=" << (LI ? LI->
getData() :
"Unspecified")
320 <<
", SEW=" << (SI ? SI->getData() :
"Unspecified")
321 <<
". Ignoring instrumentation and using original SchedClassID="
322 << SchedClassID <<
'\n');
329 <<
", SEW=" << (SI ? SI->getData() :
"Unspecified")
330 <<
". Overriding original SchedClassID=" << SchedClassID
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_EXTERNAL_VISIBILITY
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTargetMCA()
Extern function to initialize the targets for the RISC-V backend.
static InstrumentManager * createRISCVInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
This file defines the RISCVCustomBehaviour class which inherits from CustomBehaviour.
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
const MCOperand & getOperand(unsigned i) const
unsigned getSchedClass() const
Return the scheduling class for this instruction.
Interface to description of machine instruction set.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
Generic base class for all target subtargets.
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
The instances of the Type class are immutable: once they are created, they are never changed.
This class allows targets to optionally customize the logic that resolves scheduling class IDs.
StringRef getData() const
bool supportsInstrumentType(StringRef Type) const override
unsigned getSchedClassID(const MCInstrInfo &MCII, const MCInst &MCI, const SmallVector< Instrument * > &IVec) const override
Using the Instrument, returns a SchedClassID to use instead of the SchedClassID that belongs to the M...
UniqueInstrument createInstrument(StringRef Desc, StringRef Data) override
Create a Instrument for RISC-V target.
SmallVector< UniqueInstrument > createInstruments(const MCInst &Inst) override
Return a list of unique pointers to Instruments, where each Instrument is allocated by this function.
static bool isDataValid(StringRef Data)
static const StringRef DESC_NAME
static bool isDataValid(StringRef Data)
static const StringRef DESC_NAME
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI std::optional< VLMUL > getSameRatioLMUL(unsigned SEW, VLMUL VLMUL, unsigned EEW)
static unsigned getSEW(unsigned VType)
static VLMUL getVLMUL(unsigned VType)
static bool opcodeHasEEWAndEMULInfo(unsigned short Opcode)
static std::pair< uint8_t, uint8_t > getEEWAndEMUL(unsigned Opcode, RISCVVType::VLMUL LMUL, uint8_t SEW)
std::unique_ptr< Instrument > UniqueInstrument
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheRISCV32Target()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target & getTheRISCV64Target()
Description of the encoding of one expression Op.
static void RegisterInstrumentManager(Target &T, Target::InstrumentManagerCtorTy Fn)
RegisterInstrumentManager - Register an InstrumentManager implementation for the given target.