21#define DEBUG_TYPE "llvm-mca-riscv-custombehaviour"
31 .
Cases(
"M1",
"M2",
"M4",
"M8",
"MF2",
"MF4",
"MF8",
true)
39 "Cannot get LMUL because invalid Data value");
56 .
Cases(
"E8",
"E16",
"E32",
"E64",
true)
87 return std::make_unique<RISCVLMULInstrument>(
Data);
96 return std::make_unique<RISCVSEWInstrument>(
Data);
105 if (Inst.
getOpcode() == RISCV::VSETVLI ||
107 LLVM_DEBUG(
dbgs() <<
"RVCB: Found VSETVLI and creating instrument for it: "
168static std::pair<uint8_t, uint8_t>
182 case RISCV::VLSE16_V:
183 case RISCV::VSSE16_V:
188 case RISCV::VLSE32_V:
189 case RISCV::VSSE32_V:
194 case RISCV::VLSE64_V:
195 case RISCV::VSSE64_V:
205 return std::make_pair(EEW, *EMUL);
209 return Opcode == RISCV::VLM_V || Opcode == RISCV::VSM_V ||
210 Opcode == RISCV::VLE8_V || Opcode == RISCV::VSE8_V ||
211 Opcode == RISCV::VLE16_V || Opcode == RISCV::VSE16_V ||
212 Opcode == RISCV::VLE32_V || Opcode == RISCV::VSE32_V ||
213 Opcode == RISCV::VLE64_V || Opcode == RISCV::VSE64_V ||
214 Opcode == RISCV::VLSE8_V || Opcode == RISCV::VSSE8_V ||
215 Opcode == RISCV::VLSE16_V || Opcode == RISCV::VSSE16_V ||
216 Opcode == RISCV::VLSE32_V || Opcode == RISCV::VSSE32_V ||
217 Opcode == RISCV::VLSE64_V || Opcode == RISCV::VSSE64_V;
229 for (
auto &
I : IVec) {
240 dbgs() <<
"RVCB: Did not use instrumentation to override Opcode.\n");
248 uint8_t SEW = SI ? SI->getSEW() : 0;
254 RVV = RISCVVInversePseudosTable::getBaseInfo(Opcode, EMUL, EEW);
257 RVV = RISCVVInversePseudosTable::getBaseInfo(Opcode, LMUL, SEW);
260 RVV = RISCVVInversePseudosTable::getBaseInfo(Opcode, LMUL, 0);
266 dbgs() <<
"RVCB: Could not find PseudoInstruction for Opcode "
268 <<
", LMUL=" << (LI ? LI->
getData() :
"Unspecified")
269 <<
", SEW=" << (SI ? SI->getData() :
"Unspecified")
270 <<
". Ignoring instrumentation and using original SchedClassID="
271 << SchedClassID <<
'\n');
278 <<
", SEW=" << (SI ? SI->getData() :
"Unspecified")
279 <<
". Overriding original SchedClassID=" << SchedClassID
#define LLVM_EXTERNAL_VISIBILITY
static InstrumentManager * createRISCVInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTargetMCA()
Extern function to initialize the targets for the RISC-V backend.
This file defines the RISCVCustomBehaviour class which inherits from CustomBehaviour.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
static RISCVII::VLMUL getVLMUL(unsigned VType)
static unsigned getSEW(unsigned VType)
std::optional< RISCVII::VLMUL > getSameRatioLMUL(unsigned SEW, RISCVII::VLMUL VLMUL, unsigned EEW)
bool opcodeHasEEWAndEMULInfo(unsigned short Opcode)
static std::pair< uint8_t, uint8_t > getEEWAndEMUL(unsigned Opcode, RISCVII::VLMUL LMUL, uint8_t SEW)
std::unique_ptr< Instrument > UniqueInstrument
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheRISCV32Target()
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.