Hi Cristianno, Thank you, it works :) with an extra cast: Value *v ...... ConstantInt* RR = (ConstantInt *)v; uint64_t VV = (RR->getValue()).getLimitedValue(); errs()<<"\nRR "<<VV<<"\n"; ________________________________ From: Cristianno Martins <cristiannomartins at gmail.com> To: Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> Cc: "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu> Sent: Tuesday, June 25, 2013 12:27 PM Subject: Re: [LLVMdev] get value Hi Alexandru, if you have a Value pointer named v, you could use the method v->getValue().getLimitedValue(), which returns uint64_t, that can be casted as int. Hope I could help, -- Cristianno Martins PhD Student of Computer Science University of Campinas cmartins at ic.unicamp.br On Tue, Jun 25, 2013 at 4:05 AM, Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> wrote: Hello !> > >This may be a trivial question, but I cannot get fields from a Value type. > > >If my Value is i32 1, how can I store 1 in a different structure (an integer) ? For the type, I have getType(). For the value, I see no method in Value.h. > > > >I tried to cast to ConstantExpr and then to get operands, or cast to ConstantDataArray and then use getAsString(), but is not working. How should I get the value? > > >Thank you ! > > > >_______________________________________________ >LLVM Developers mailing list >LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130625/de4e0b94/attachment.html>
Oops, that's true: I forgot about that XD sorry =) Glad I could help, -- Cristianno Martins PhD Student of Computer Science University of Campinas cmartins at ic.unicamp.br <cristiannomartins at hotmail.com> On Tue, Jun 25, 2013 at 4:38 AM, Alexandru Ionut Diaconescu < cyrusthevirus001x at yahoo.com> wrote:> Hi Cristianno, > > Thank you, it works :) > > with an extra cast: > Value *v ...... > ConstantInt* RR = (ConstantInt *)v; > uint64_t VV > (RR->getValue()).getLimitedValue(); > errs()<<"\nRR "<<VV<<"\n"; > > > ------------------------------ > *From:* Cristianno Martins <cristiannomartins at gmail.com> > *To:* Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> > *Cc:* "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu> > *Sent:* Tuesday, June 25, 2013 12:27 PM > *Subject:* Re: [LLVMdev] get value > > Hi Alexandru, > > if you have a Value pointer named v, you could use the method v->getValue > ().getLimitedValue(), which returns uint64_t, that can be casted as int. > > Hope I could help, > > > -- > Cristianno Martins > PhD Student of Computer Science > University of Campinas > cmartins at ic.unicamp.br > <cristiannomartins at hotmail.com> > > > On Tue, Jun 25, 2013 at 4:05 AM, Alexandru Ionut Diaconescu < > cyrusthevirus001x at yahoo.com> wrote: > > Hello ! > > This may be a trivial question, but I cannot get fields from a Value type. > > If my Value is i32 1, how can I store 1 in a different structure (an > integer) ? For the type, I have getType(). For the value, I see no method > in Value.h. > > I tried to cast to ConstantExpr and then to get operands, or cast to > ConstantDataArray and then use getAsString(), but is not working. How > should I get the value? > > Thank you ! > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130625/8b1ea251/attachment.html>
Thank you for the help :D ________________________________ From: Cristianno Martins <cristiannomartins at gmail.com> To: Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> Cc: "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu> Sent: Tuesday, June 25, 2013 2:11 PM Subject: Re: [LLVMdev] get value Oops, that's true: I forgot about that XD sorry =) Glad I could help, -- Cristianno Martins PhD Student of Computer Science University of Campinas cmartins at ic.unicamp.br On Tue, Jun 25, 2013 at 4:38 AM, Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> wrote: Hi Cristianno,> >Thank you, it works :) > >with an extra cast: > Value *v ...... > ConstantInt* RR = (ConstantInt *)v; > uint64_t VV = (RR->getValue()).getLimitedValue(); >errs()<<"\nRR "<<VV<<"\n";> > > > > > >________________________________ > From: Cristianno Martins <cristiannomartins at gmail.com> >To: Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> >Cc: "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu> >Sent: Tuesday, June 25, 2013 12:27 PM >Subject: Re: [LLVMdev] get value > > > >Hi Alexandru, > > >if you have a Value pointer named v, you could use the method v->getValue().getLimitedValue(), which returns uint64_t, that can be casted as int. > > >Hope I could help, > > > >-- >Cristianno Martins >PhD Student of Computer Science >University of Campinas >cmartins at ic.unicamp.br > > > >On Tue, Jun 25, 2013 at 4:05 AM, Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> wrote: > >Hello ! >> >> >>This may be a trivial question, but I cannot get fields from a Value type. >> >> >>If my Value is i32 1, how can I store 1 in a different structure (an integer) ? For the type, I have getType(). For the value, I see no method in Value.h. >> >> >> >>I tried to cast to ConstantExpr and then to get operands, or cast to ConstantDataArray and then use getAsString(), but is not working. How should I get the value? >> >> >>Thank you ! >> >> >> >>_______________________________________________ >>LLVM Developers mailing list >>LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu/ >>http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130625/86edd34c/attachment.html>
Alexandru Ionut Diaconescu wrote:> Hi Cristianno, > > Thank you, it works :) > > with an extra cast: > Value *v ...... > ConstantInt* RR = (ConstantInt *)v;Please use "cast<ConstantInt>(v)" instead. See http://llvm.org/docs/ProgrammersManual.html#the-isa-cast-and-dyn-cast-templates . Nick> uint64_t VV = (RR->getValue()).getLimitedValue(); > errs()<<"\nRR "<<VV<<"\n"; > > > *From:* Cristianno Martins <cristiannomartins at gmail.com> > *To:* Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> > *Cc:* "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu> > *Sent:* Tuesday, June 25, 2013 12:27 PM > *Subject:* Re: [LLVMdev] get value > > Hi Alexandru, > > if you have a Value pointer named v, you could use the method > v->getValue().getLimitedValue(), which returns uint64_t, that can be > casted as int. > > Hope I could help, > > > -- > Cristianno Martins > PhD Student of Computer Science > University of Campinas > cmartins at ic.unicamp.br <mailto:cmartins at ic.unicamp.br> > <mailto:cristiannomartins at hotmail.com> > > > On Tue, Jun 25, 2013 at 4:05 AM, Alexandru Ionut Diaconescu > <cyrusthevirus001x at yahoo.com <mailto:cyrusthevirus001x at yahoo.com>> wrote: > > Hello ! > > This may be a trivial question, but I cannot get fields from a Value > type. > > If my Value is i32 1, how can I store 1 in a different structure (an > integer) ? For the type, I have getType(). For the value, I see no > method in Value.h. > > I tried to cast to ConstantExpr and then to get operands, or cast to > ConstantDataArray and then use getAsString(), but is not working. > How should I get the value? > > Thank you ! > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu <http://llvm.cs.uiuc.edu/> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Thank you ! ________________________________ From: Nick Lewycky <nicholas at mxc.ca> To: Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> Cc: Cristianno Martins <cristiannomartins at gmail.com>; "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu> Sent: Wednesday, June 26, 2013 8:54 AM Subject: Re: [LLVMdev] get value Alexandru Ionut Diaconescu wrote:> Hi Cristianno, > > Thank you, it works :) > > with an extra cast: > Value *v ...... > ConstantInt* RR = (ConstantInt *)v;Please use "cast<ConstantInt>(v)" instead. See http://llvm.org/docs/ProgrammersManual.html#the-isa-cast-and-dyn-cast-templates . Nick> uint64_t VV = (RR->getValue()).getLimitedValue(); > errs()<<"\nRR "<<VV<<"\n"; > > > *From:* Cristianno Martins <cristiannomartins at gmail.com> > *To:* Alexandru Ionut Diaconescu <cyrusthevirus001x at yahoo.com> > *Cc:* "llvmdev at cs.uiuc.edu" <llvmdev at cs.uiuc.edu> > *Sent:* Tuesday, June 25, 2013 12:27 PM > *Subject:* Re: [LLVMdev] get value > > Hi Alexandru, > > if you have a Value pointer named v, you could use the method > v->getValue().getLimitedValue(), which returns uint64_t, that can be > casted as int. > > Hope I could help, > > > -- > Cristianno Martins > PhD Student of Computer Science > University of Campinas > cmartins at ic.unicamp.br <mailto:cmartins at ic.unicamp.br> > <mailto:cristiannomartins at hotmail.com> > > > On Tue, Jun 25, 2013 at 4:05 AM, Alexandru Ionut Diaconescu > <cyrusthevirus001x at yahoo.com <mailto:cyrusthevirus001x at yahoo.com>> wrote: > > Hello ! > > This may be a trivial question, but I cannot get fields from a Value > type. > > If my Value is i32 1, how can I store 1 in a different structure (an > integer) ? For the type, I have getType(). For the value, I see no > method in Value.h. > > I tried to cast to ConstantExpr and then to get operands, or cast to > ConstantDataArray and then use getAsString(), but is not working. > How should I get the value? > > Thank you ! > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu> > http://llvm.cs.uiuc.edu <http://llvm.cs.uiuc.edu/> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130625/cceedc1d/attachment.html>