llvm - How to check the opcode of an instruction? -
in fact have found 2 solutions, , want know if there difference :
- using isa,
isa<loadinst>(i). - using getopcode (
i.getopcode()method , comparing load
which 1 use ?
isa used check existing dirived instruction class. class i.getopcode() operations information.
according the inheritance diagram llvm::instruction,llvm internally divide instruction several different classes, llvm::binaryoperator, llvm::callinst, llvm::cmpinst, etc. there no exact operation information these classes.
however, instruction::getopcode(), directly operation llvm::instruction object. refer instruction.def idea defination of each instruction. basically, opcode exact operations instruction intends to.
say, llvm ir add. can use isa<llvm::binaryoperator>, know binaryoperator. instruction class is. if want know whether add or sub. i.getopcode() should used here.
Comments
Post a Comment