aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
diff options
context:
space:
mode:
authorRoman Belenov <rbelenov@gmail.com>2025-09-23 19:50:34 +0300
committerGitHub <noreply@github.com>2025-09-23 09:50:34 -0700
commit51a86e75ddf3eac3057c901bbe5e750dea62c7c1 (patch)
tree9490f57029ecb4bea0c407ad2958e5a70862874b /llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
parentf3762b7b7155a51a249dccb48fa414876222c7ed (diff)
downloadllvm-51a86e75ddf3eac3057c901bbe5e750dea62c7c1.zip
llvm-51a86e75ddf3eac3057c901bbe5e750dea62c7c1.tar.gz
llvm-51a86e75ddf3eac3057c901bbe5e750dea62c7c1.tar.bz2
[MCA][RISCV]Enable latency instrument on RISCV (#160063)
Recently added latency customization ([PR](https://github.com/llvm/llvm-project/pull/155420)) does not work on RISCV since it has target-specific InstrumentManager that overrides default functionality. Added calls to base class to ensure that common instruments (including latency customizer) are available.
Diffstat (limited to 'llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp')
-rw-r--r--llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp b/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
index ae44306..50730c6 100644
--- a/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
+++ b/llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp
@@ -18,6 +18,7 @@
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/DebugLog.h"
#define DEBUG_TYPE "llvm-mca-riscv-custombehaviour"
@@ -86,7 +87,8 @@ uint8_t RISCVSEWInstrument::getSEW() const {
bool RISCVInstrumentManager::supportsInstrumentType(
llvm::StringRef Type) const {
return Type == RISCVLMULInstrument::DESC_NAME ||
- Type == RISCVSEWInstrument::DESC_NAME;
+ Type == RISCVSEWInstrument::DESC_NAME ||
+ InstrumentManager::supportsInstrumentType(Type);
}
UniqueInstrument
@@ -94,8 +96,8 @@ RISCVInstrumentManager::createInstrument(llvm::StringRef Desc,
llvm::StringRef Data) {
if (Desc == RISCVLMULInstrument::DESC_NAME) {
if (!RISCVLMULInstrument::isDataValid(Data)) {
- LLVM_DEBUG(dbgs() << "RVCB: Bad data for instrument kind " << Desc << ": "
- << Data << '\n');
+ LDBG() << "RVCB: Bad data for instrument kind " << Desc << ": " << Data
+ << '\n';
return nullptr;
}
return std::make_unique<RISCVLMULInstrument>(Data);
@@ -103,23 +105,23 @@ RISCVInstrumentManager::createInstrument(llvm::StringRef Desc,
if (Desc == RISCVSEWInstrument::DESC_NAME) {
if (!RISCVSEWInstrument::isDataValid(Data)) {
- LLVM_DEBUG(dbgs() << "RVCB: Bad data for instrument kind " << Desc << ": "
- << Data << '\n');
+ LDBG() << "RVCB: Bad data for instrument kind " << Desc << ": " << Data
+ << '\n';
return nullptr;
}
return std::make_unique<RISCVSEWInstrument>(Data);
}
- LLVM_DEBUG(dbgs() << "RVCB: Unknown instrumentation Desc: " << Desc << '\n');
- return nullptr;
+ LDBG() << "RVCB: Creating default instrument for Desc: " << Desc << '\n';
+ return InstrumentManager::createInstrument(Desc, Data);
}
SmallVector<UniqueInstrument>
RISCVInstrumentManager::createInstruments(const MCInst &Inst) {
if (Inst.getOpcode() == RISCV::VSETVLI ||
Inst.getOpcode() == RISCV::VSETIVLI) {
- LLVM_DEBUG(dbgs() << "RVCB: Found VSETVLI and creating instrument for it: "
- << Inst << "\n");
+ LDBG() << "RVCB: Found VSETVLI and creating instrument for it: " << Inst
+ << "\n";
unsigned VTypeI = Inst.getOperand(2).getImm();
RISCVVType::VLMUL VLMUL = RISCVVType::getVLMUL(VTypeI);
@@ -250,8 +252,7 @@ unsigned RISCVInstrumentManager::getSchedClassID(
// Need LMUL or LMUL, SEW in order to override opcode. If no LMUL is provided,
// then no option to override.
if (!LI) {
- LLVM_DEBUG(
- dbgs() << "RVCB: Did not use instrumentation to override Opcode.\n");
+ LDBG() << "RVCB: Did not use instrumentation to override Opcode.\n";
return SchedClassID;
}
uint8_t LMUL = LI->getLMUL();
@@ -313,22 +314,21 @@ unsigned RISCVInstrumentManager::getSchedClassID(
// Not a RVV instr
if (!VPOpcode) {
- LLVM_DEBUG(
- dbgs() << "RVCB: Could not find PseudoInstruction for Opcode "
- << MCII.getName(Opcode)
- << ", LMUL=" << (LI ? LI->getData() : "Unspecified")
- << ", SEW=" << (SI ? SI->getData() : "Unspecified")
- << ". Ignoring instrumentation and using original SchedClassID="
- << SchedClassID << '\n');
+ LDBG() << "RVCB: Could not find PseudoInstruction for Opcode "
+ << MCII.getName(Opcode)
+ << ", LMUL=" << (LI ? LI->getData() : "Unspecified")
+ << ", SEW=" << (SI ? SI->getData() : "Unspecified")
+ << ". Ignoring instrumentation and using original SchedClassID="
+ << SchedClassID << '\n';
return SchedClassID;
}
// Override using pseudo
- LLVM_DEBUG(dbgs() << "RVCB: Found Pseudo Instruction for Opcode "
- << MCII.getName(Opcode) << ", LMUL=" << LI->getData()
- << ", SEW=" << (SI ? SI->getData() : "Unspecified")
- << ". Overriding original SchedClassID=" << SchedClassID
- << " with " << MCII.getName(*VPOpcode) << '\n');
+ LDBG() << "RVCB: Found Pseudo Instruction for Opcode " << MCII.getName(Opcode)
+ << ", LMUL=" << LI->getData()
+ << ", SEW=" << (SI ? SI->getData() : "Unspecified")
+ << ". Overriding original SchedClassID=" << SchedClassID << " with "
+ << MCII.getName(*VPOpcode) << '\n';
return MCII.get(*VPOpcode).getSchedClass();
}