Hello everyone ! In my LLVM pass, there is `Intruction* I1`. All the used "I1"s are ICMP instructions. *I1->getOperand(0) returns a `Value*` type. From errs()<<"\n"<<*I1->getOperand(0)<<"\n"; //printed : %3 = load i32* %c, align 4 Printed as expected. But I want to use %c. Do you know how I can get %c ? I need to use the value %c in some computations. First, I tried for (llvm::Value::use_iterator VI=(*I1->getOperand(0)).use_begin(), VE=(*I1->getOperand(0)).use_end(); VI != VE ; ++VI) { errs()<<"\n "<<**VI<<" \n"; //printed : %cmp3 = icmp ne i32 %3, 0 } But it is not getting Value* fields. Also, it is printing only one VI per for, so VI cannot increment. Second, it is a solution of taking the output of errs() in a string and parse the string for %c ? If so, how I can do it? I have problems while trying to declare `static raw_ostream S` in order to take somehow the errs() output. Thank you for any help ! -- Best regards, Alexandru Ionut Diaconescu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130111/44fdccac/attachment.html>
If I1->getOperand(0) is the load, then %c is its pointer argument available with: LoadInst *LD = cast<LoadInst>(I1->getOperand(0)); Value *C = LD->getPointerOperand(); On Fri, Jan 11, 2013 at 7:19 AM, Alexandru Ionut Diaconescu < alexandruionutdiaconescu at gmail.com> wrote:> Hello everyone ! > > In my LLVM pass, there is `Intruction* I1`. All the used "I1"s are ICMP > instructions. *I1->getOperand(0) returns a `Value*` type. From > > errs()<<"\n"<<*I1->getOperand(0)<<"\n"; > //printed : %3 = load i32* %c, align 4 > Printed as expected. But I want to use %c. Do you know how I can get %c ? > I need to use the value %c in some computations. > > First, I tried > > for (llvm::Value::use_iterator VI=(*I1->getOperand(0)).use_begin(), > VE=(*I1->getOperand(0)).use_end(); VI != VE ; ++VI) > { > errs()<<"\n "<<**VI<<" \n"; > //printed : %cmp3 = icmp ne i32 %3, 0 > } > But it is not getting Value* fields. Also, it is printing only one VI per > for, so VI cannot increment. > > Second, it is a solution of taking the output of errs() in a string and > parse the string for %c ? If so, how I can do it? I have problems while > trying to declare `static raw_ostream S` in order to take somehow the > errs() output. > > Thank you for any help ! > > > -- > Best regards, > Alexandru Ionut Diaconescu > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130111/73080e30/attachment.html>
Also, I just saw your other thread. Please refrain from double-posting these questions. On Fri, Jan 11, 2013 at 7:43 AM, Justin Holewinski < justin.holewinski at gmail.com> wrote:> If I1->getOperand(0) is the load, then %c is its pointer argument > available with: > > LoadInst *LD = cast<LoadInst>(I1->getOperand(0)); > Value *C = LD->getPointerOperand(); > > > > On Fri, Jan 11, 2013 at 7:19 AM, Alexandru Ionut Diaconescu < > alexandruionutdiaconescu at gmail.com> wrote: > >> Hello everyone ! >> >> In my LLVM pass, there is `Intruction* I1`. All the used "I1"s are ICMP >> instructions. *I1->getOperand(0) returns a `Value*` type. From >> >> errs()<<"\n"<<*I1->getOperand(0)<<"\n"; >> //printed : %3 = load i32* %c, align 4 >> Printed as expected. But I want to use %c. Do you know how I can get %c ? >> I need to use the value %c in some computations. >> >> First, I tried >> >> for (llvm::Value::use_iterator VI=(*I1->getOperand(0)).use_begin(), >> VE=(*I1->getOperand(0)).use_end(); VI != VE ; ++VI) >> { >> errs()<<"\n "<<**VI<<" \n"; >> //printed : %cmp3 = icmp ne i32 %3, 0 >> } >> But it is not getting Value* fields. Also, it is printing only one VI per >> for, so VI cannot increment. >> >> Second, it is a solution of taking the output of errs() in a string and >> parse the string for %c ? If so, how I can do it? I have problems while >> trying to declare `static raw_ostream S` in order to take somehow the >> errs() output. >> >> Thank you for any help ! >> >> >> -- >> Best regards, >> Alexandru Ionut Diaconescu >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > > > -- > > Thanks, > > Justin Holewinski >-- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130111/8c24a0b1/attachment.html>
Hi, On 11/01/13 13:19, Alexandru Ionut Diaconescu wrote:> Hello everyone ! > > In my LLVM pass, there is `Intruction* I1`. All the used "I1"s are ICMP > instructions. *I1->getOperand(0) returns a `Value*` type. From > > errs()<<"\n"<<*I1->getOperand(0)<<"\n"; > //printed : %3 = load i32* %c, align 4 > Printed as expected. But I want to use %c. Do you know how I can get %c ? I need > to use the value %c in some computations.I1->getOperand(0)->getOperand(0) Ciao, Duncan.> > First, I tried > > for (llvm::Value::use_iterator VI=(*I1->getOperand(0)).use_begin(), > VE=(*I1->getOperand(0)).use_end(); VI != VE ; ++VI) > { > errs()<<"\n "<<**VI<<" \n"; > //printed : %cmp3 = icmp ne i32 %3, 0 > } > But it is not getting Value* fields. Also, it is printing only one VI per for, > so VI cannot increment. > > Second, it is a solution of taking the output of errs() in a string and parse > the string for %c ? If so, how I can do it? I have problems while trying to > declare `static raw_ostream S` in order to take somehow the errs() output. > > Thank you for any help ! > > > -- > Best regards, > Alexandru Ionut Diaconescu > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Reasonably Related Threads
- [LLVMdev] llvm get Value* iterators
- [LLVMdev] LLVM Instruction*->getOperand() not working properly for ICMP
- [LLVMdev] LLVM Instruction*->getOperand() not working properly for ICMP
- [LLVMdev] LLVM Instruction*->getOperand() not working properly for ICMP
- [LLVMdev] LLVM Instruction*->getOperand() not working properly for ICMP