<br clear="all"><br>Hello !<br><br>I want some piece of advice regarding a LLVM pass. My particular problem is:<br><br>There is a method<br><br>bool patternDC::runOnFunction(Function &F) {<br>...<br> if ( CC->operEquiv(icmpInstrArray[i], icmpInstrArray[j]) ) {...}<br>
...<br>}<br><br>having the array elements of type Instruction* : <a href="http://llvm.org/doxygen/classllvm_1_1Instruction.html">http://llvm.org/doxygen/classllvm_1_1Instruction.html</a><br><br>The called method is <br><br>
bool ifChecker::operEquiv(Instruction *I1, Instruction *I2)<br>{<br>...<br>}<br><br>BUT I want to use the methods from class ICmpInst : clasa <a href="http://llvm.org/doxygen/classllvm_1_1ICmpInst.html">http://llvm.org/doxygen/classllvm_1_1ICmpInst.html</a> inside operEquiv. I cannot do something like <br>
<br>ICmpInst** II1 = dyn_cast<ICmpInst*>(I1); <br><br>(a kind of instanceOf() from Java), having casting compilation problems.<br><br>The ICmpInst class is defined at line 913 from <a href="http://llvm.org/doxygen/Instructions_8h_source.html">http://llvm.org/doxygen/Instructions_8h_source.html</a> <br>
The inheritance diagram is at <a href="http://llvm.org/doxygen/classllvm_1_1ICmpInst.html">http://llvm.org/doxygen/classllvm_1_1ICmpInst.html</a><br><br>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) ?<br>
<br>Thank you for any suggestion !<br><br><br><br> <br>