[LLVMdev] Value* to Instruction*/LoadInst* casting
Alexandru Ionut Diaconescu
alexandruionutdiaconescu at gmail.com
Mon Jan 28 02:31:15 PST 2013
Hello everyone,
Can you please tell me if it is possible in LLVM to cast a `Value*` to an
`Instruction*/LoadInst*` if for example `isa<LoadInst>(MyValue)` is true?
In my particular piece of code:
Value* V1 = icmpInstrArray[i]->getOperand(0);
Value* V2 = icmpInstrArray[i]->getOperand(1);
if (isa<LoadInst>(V1) || isa<LoadInst>(V2)){
...
if(isa<LoadInst>(icmpInstrArray[i]->getOperand(0)))
LoadInst *LD100 = cast<LoadInst>(icmpInstrArray[i]->getOperand(0));
Value *C100 = LD100->getPointerOperand(); //HERE COMPILATION
ERROR
Further, I just need to make `C100->getName()` and I will get the loaded
variable.
I don't think that I can use cast like that. Can you tell me a method to
obtain the loaded variable from a Load instruction correspondent to my ICMP
instructions? Or better how I can extract the Load instruction from
`icmpInstrArray[i]->getOperand(0)`?
Thank you a lot !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130128/b7e75875/attachment.html>
More information about the llvm-dev
mailing list