I’m writing my own algorithms by myself and it applies on specific instructions.
So, I have to get the operator of instruction and check what the operator is.
I’m doing like this: (for example)
if ( I->getOpcode() == 13) // if the instruction is a Add operator
{
.
.
}
But I don’t think it’s a good way to check. Because I was searching the history of instruction.def which define the opcode num, sometimes the opcode will change, and it means my algorithm need to rewrite due to the change of instruction.def.
I also do like this:
if ( ! strncmp( i->getOpcodeName(), "add", 4))
{
.
.
}
But I don’t think this is a good way.
It must have another ways better than above two examples but I don’t know how to do.
Thanks!