|
18 | 18 | #include "llvm/MC/TargetRegistry.h" |
19 | 19 | #include "llvm/Support/Compiler.h" |
20 | 20 | #include "llvm/Support/Debug.h" |
| 21 | +#include "llvm/Support/DebugLog.h" |
21 | 22 |
|
22 | 23 | #define DEBUG_TYPE "llvm-mca-riscv-custombehaviour" |
23 | 24 |
|
@@ -86,40 +87,41 @@ uint8_t RISCVSEWInstrument::getSEW() const { |
86 | 87 | bool RISCVInstrumentManager::supportsInstrumentType( |
87 | 88 | llvm::StringRef Type) const { |
88 | 89 | return Type == RISCVLMULInstrument::DESC_NAME || |
89 | | - Type == RISCVSEWInstrument::DESC_NAME; |
| 90 | + Type == RISCVSEWInstrument::DESC_NAME || |
| 91 | + InstrumentManager::supportsInstrumentType(Type); |
90 | 92 | } |
91 | 93 |
|
92 | 94 | UniqueInstrument |
93 | 95 | RISCVInstrumentManager::createInstrument(llvm::StringRef Desc, |
94 | 96 | llvm::StringRef Data) { |
95 | 97 | if (Desc == RISCVLMULInstrument::DESC_NAME) { |
96 | 98 | if (!RISCVLMULInstrument::isDataValid(Data)) { |
97 | | - LLVM_DEBUG(dbgs() << "RVCB: Bad data for instrument kind " << Desc << ": " |
98 | | - << Data << '\n'); |
| 99 | + LDBG() << "RVCB: Bad data for instrument kind " << Desc << ": " << Data |
| 100 | + << '\n'; |
99 | 101 | return nullptr; |
100 | 102 | } |
101 | 103 | return std::make_unique<RISCVLMULInstrument>(Data); |
102 | 104 | } |
103 | 105 |
|
104 | 106 | if (Desc == RISCVSEWInstrument::DESC_NAME) { |
105 | 107 | if (!RISCVSEWInstrument::isDataValid(Data)) { |
106 | | - LLVM_DEBUG(dbgs() << "RVCB: Bad data for instrument kind " << Desc << ": " |
107 | | - << Data << '\n'); |
| 108 | + LDBG() << "RVCB: Bad data for instrument kind " << Desc << ": " << Data |
| 109 | + << '\n'; |
108 | 110 | return nullptr; |
109 | 111 | } |
110 | 112 | return std::make_unique<RISCVSEWInstrument>(Data); |
111 | 113 | } |
112 | 114 |
|
113 | | - LLVM_DEBUG(dbgs() << "RVCB: Unknown instrumentation Desc: " << Desc << '\n'); |
114 | | - return nullptr; |
| 115 | + LDBG() << "RVCB: Creating default instrument for Desc: " << Desc << '\n'; |
| 116 | + return InstrumentManager::createInstrument(Desc, Data); |
115 | 117 | } |
116 | 118 |
|
117 | 119 | SmallVector<UniqueInstrument> |
118 | 120 | RISCVInstrumentManager::createInstruments(const MCInst &Inst) { |
119 | 121 | if (Inst.getOpcode() == RISCV::VSETVLI || |
120 | 122 | Inst.getOpcode() == RISCV::VSETIVLI) { |
121 | | - LLVM_DEBUG(dbgs() << "RVCB: Found VSETVLI and creating instrument for it: " |
122 | | - << Inst << "\n"); |
| 123 | + LDBG() << "RVCB: Found VSETVLI and creating instrument for it: " << Inst |
| 124 | + << "\n"; |
123 | 125 | unsigned VTypeI = Inst.getOperand(2).getImm(); |
124 | 126 | RISCVVType::VLMUL VLMUL = RISCVVType::getVLMUL(VTypeI); |
125 | 127 |
|
@@ -250,8 +252,7 @@ unsigned RISCVInstrumentManager::getSchedClassID( |
250 | 252 | // Need LMUL or LMUL, SEW in order to override opcode. If no LMUL is provided, |
251 | 253 | // then no option to override. |
252 | 254 | if (!LI) { |
253 | | - LLVM_DEBUG( |
254 | | - dbgs() << "RVCB: Did not use instrumentation to override Opcode.\n"); |
| 255 | + LDBG() << "RVCB: Did not use instrumentation to override Opcode.\n"; |
255 | 256 | return SchedClassID; |
256 | 257 | } |
257 | 258 | uint8_t LMUL = LI->getLMUL(); |
@@ -313,22 +314,21 @@ unsigned RISCVInstrumentManager::getSchedClassID( |
313 | 314 |
|
314 | 315 | // Not a RVV instr |
315 | 316 | if (!VPOpcode) { |
316 | | - LLVM_DEBUG( |
317 | | - dbgs() << "RVCB: Could not find PseudoInstruction for Opcode " |
318 | | - << MCII.getName(Opcode) |
319 | | - << ", LMUL=" << (LI ? LI->getData() : "Unspecified") |
320 | | - << ", SEW=" << (SI ? SI->getData() : "Unspecified") |
321 | | - << ". Ignoring instrumentation and using original SchedClassID=" |
322 | | - << SchedClassID << '\n'); |
| 317 | + LDBG() << "RVCB: Could not find PseudoInstruction for Opcode " |
| 318 | + << MCII.getName(Opcode) |
| 319 | + << ", LMUL=" << (LI ? LI->getData() : "Unspecified") |
| 320 | + << ", SEW=" << (SI ? SI->getData() : "Unspecified") |
| 321 | + << ". Ignoring instrumentation and using original SchedClassID=" |
| 322 | + << SchedClassID << '\n'; |
323 | 323 | return SchedClassID; |
324 | 324 | } |
325 | 325 |
|
326 | 326 | // Override using pseudo |
327 | | - LLVM_DEBUG(dbgs() << "RVCB: Found Pseudo Instruction for Opcode " |
328 | | - << MCII.getName(Opcode) << ", LMUL=" << LI->getData() |
329 | | - << ", SEW=" << (SI ? SI->getData() : "Unspecified") |
330 | | - << ". Overriding original SchedClassID=" << SchedClassID |
331 | | - << " with " << MCII.getName(*VPOpcode) << '\n'); |
| 327 | + LDBG() << "RVCB: Found Pseudo Instruction for Opcode " << MCII.getName(Opcode) |
| 328 | + << ", LMUL=" << LI->getData() |
| 329 | + << ", SEW=" << (SI ? SI->getData() : "Unspecified") |
| 330 | + << ". Overriding original SchedClassID=" << SchedClassID << " with " |
| 331 | + << MCII.getName(*VPOpcode) << '\n'; |
332 | 332 | return MCII.get(*VPOpcode).getSchedClass(); |
333 | 333 | } |
334 | 334 |
|
|
0 commit comments