Hi. I want to detect whether there is certain riscv vector(rvv) instruction in the input executable file, so I write a BOLT pass. I did it in the same way as BOLT detect whether there’s a call instruction isRISCVCall
. However, I found that RISCV::VSETIVLI
returns the opcode for MachineInstr, while others like RISCV::JAL
returns the opcode for MCInst.
I added a helper function in RISCVMCPlusBuilder
bool isRISCVVsetivli(const MachineInstr &Inst) const {
if(Inst.getOpcode() != RISCV::VSETIVLI || Inst.getOpcode() != RISCV::VSETVLI)
{
outs() << Inst.getOpcode() << " " << RISCV::VSETIVLI;
return false;
}
return true;
}
and my pass looks like this
if (!BC.isRISCV())
return;
for (auto &BFI : BC.getBinaryFunctions())
{
for (BinaryBasicBlock &BB : BFI.second)
{
for (auto II = BB.begin(); II != BB.end(); ++II)
{
MCInst &Inst = *II;
outs() << Inst;
if(BC.MIB->isRISCVVsetivli(Inst))
outs() << "yes\n";
else
outs() << "no\n";
}
}
}
and the result is there is no yes in the commandline even though the input file contains vsetivli instruction.
So how can i detect whether there’s an rvv instruction using BOLT pass?