[LLVMdev] LLVM Instruction to ICmpInst conversion

Alexandru Ionut Diaconescu alexandruionutdiaconescu at gmail.com
Thu Jan 10 05:29:34 PST 2013

Hello !

I want some piece of advice regarding a LLVM pass. My particular problem is:

There is a method

bool patternDC::runOnFunction(Function &F) {
    if ( CC->operEquiv(icmpInstrArray[i], icmpInstrArray[j]) ) {...}

having the array elements of type Instruction* :

The called method is

bool ifChecker::operEquiv(Instruction *I1, Instruction *I2)

BUT I want to use the methods from class ICmpInst : clasa
http://llvm.org/doxygen/classllvm_1_1ICmpInst.html  inside operEquiv. I
cannot do something like

ICmpInst** II1 = dyn_cast<ICmpInst*>(I1);

(a kind of instanceOf() from Java), having casting compilation problems.

The ICmpInst class is defined at line 913 from
The inheritance diagram is at

I want to use the ICmpInst methods for objects of type Instruction. The
methods are hard to copy/replicate. What solution I better to use to solve
this problem? Should I use visitor pattern (about which I don't know much) ?

Thank you for any suggestion !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130110/faedb643/attachment.html>

More information about the llvm-dev mailing list