Shen Liu via llvm-dev
2016-Dec-15 20:10 UTC
[llvm-dev] How to get the value for casting in a bitcast instruction more efficiently?
Hi Ryan, Thanks for your reply! Yes i can use llvm::Use.get() API to do this, i just want to know whether there's a better way(e.g. an existed API like getValue()) to make my code look more professional. On Thu, Dec 15, 2016 at 2:58 PM, Ryan Taylor via llvm-dev < llvm-dev at lists.llvm.org> wrote:> This might help: > > http://llvm.org/docs/ProgrammersManual.html#the-value-class > > Or maybe I'm misunderstanding what you mean by "efficient way to get the > value". When you say 'value', I'm assuming you mean the class. In your > case, AllocaInst inherits from value. > > -Ryan > > On Thu, Dec 15, 2016 at 10:24 AM, Shen Liu via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hi everyone, >> >> This is a simple question but is there an efficient way to get the *value for casting* directly from a bitcast instruction? >> >> bitcast format :<result> = bitcast <ty> <*value*> to <ty2> >> >> For example, if i have >> >> MemAddr >> ... >> 0x3d61238 %key = alloca [16 x i8], align 16 >> 0x3d612a8 %plain_text = alloca [64 x i8], align 16 >> 0x3d61318 %key1 = bitcast [16 x i8]* %key to i8* >> ... >> >> The way i am using is processing all opcodes in %key1, and go back to find %key along the def-use chain. But is there a better way for doing this? >> >> Thanks very much! >> >> Best >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161215/c7b34671/attachment.html>
Ryan Taylor via llvm-dev
2016-Dec-15 20:11 UTC
[llvm-dev] How to get the value for casting in a bitcast instruction more efficiently?
I guess I didn't understand your question, my point was that the operand, in your example, inherits from value class, it already is a value, most everything in IR is a value. -Ryan On Thu, Dec 15, 2016 at 3:10 PM, Shen Liu <sxl463 at cse.psu.edu> wrote:> Hi Ryan, > > Thanks for your reply! Yes i can use llvm::Use.get() API to do this, i > just want to know whether there's a better way(e.g. an existed API like > getValue()) to make my code look more professional. > > On Thu, Dec 15, 2016 at 2:58 PM, Ryan Taylor via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> This might help: >> >> http://llvm.org/docs/ProgrammersManual.html#the-value-class >> >> Or maybe I'm misunderstanding what you mean by "efficient way to get the >> value". When you say 'value', I'm assuming you mean the class. In your >> case, AllocaInst inherits from value. >> >> -Ryan >> >> On Thu, Dec 15, 2016 at 10:24 AM, Shen Liu via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >>> Hi everyone, >>> >>> This is a simple question but is there an efficient way to get the *value for casting* directly from a bitcast instruction? >>> >>> bitcast format :<result> = bitcast <ty> <*value*> to <ty2> >>> >>> For example, if i have >>> >>> MemAddr >>> ... >>> 0x3d61238 %key = alloca [16 x i8], align 16 >>> 0x3d612a8 %plain_text = alloca [64 x i8], align 16 >>> 0x3d61318 %key1 = bitcast [16 x i8]* %key to i8* >>> ... >>> >>> The way i am using is processing all opcodes in %key1, and go back to find %key along the def-use chain. But is there a better way for doing this? >>> >>> Thanks very much! >>> >>> Best >>> >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> llvm-dev at lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>> >>> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161215/a809496c/attachment.html>
Shen Liu via llvm-dev
2016-Dec-15 20:15 UTC
[llvm-dev] How to get the value for casting in a bitcast instruction more efficiently?
I see, thank you! ^_^ On Thu, Dec 15, 2016 at 3:11 PM, Ryan Taylor via llvm-dev < llvm-dev at lists.llvm.org> wrote:> I guess I didn't understand your question, my point was that the operand, > in your example, inherits from value class, it already is a value, most > everything in IR is a value. > > -Ryan > > On Thu, Dec 15, 2016 at 3:10 PM, Shen Liu <sxl463 at cse.psu.edu> wrote: > >> Hi Ryan, >> >> Thanks for your reply! Yes i can use llvm::Use.get() API to do this, i >> just want to know whether there's a better way(e.g. an existed API like >> getValue()) to make my code look more professional. >> >> On Thu, Dec 15, 2016 at 2:58 PM, Ryan Taylor via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >>> This might help: >>> >>> http://llvm.org/docs/ProgrammersManual.html#the-value-class >>> >>> Or maybe I'm misunderstanding what you mean by "efficient way to get the >>> value". When you say 'value', I'm assuming you mean the class. In your >>> case, AllocaInst inherits from value. >>> >>> -Ryan >>> >>> On Thu, Dec 15, 2016 at 10:24 AM, Shen Liu via llvm-dev < >>> llvm-dev at lists.llvm.org> wrote: >>> >>>> Hi everyone, >>>> >>>> This is a simple question but is there an efficient way to get the *value for casting* directly from a bitcast instruction? >>>> >>>> bitcast format :<result> = bitcast <ty> <*value*> to <ty2> >>>> >>>> For example, if i have >>>> >>>> MemAddr >>>> ... >>>> 0x3d61238 %key = alloca [16 x i8], align 16 >>>> 0x3d612a8 %plain_text = alloca [64 x i8], align 16 >>>> 0x3d61318 %key1 = bitcast [16 x i8]* %key to i8* >>>> ... >>>> >>>> The way i am using is processing all opcodes in %key1, and go back to find %key along the def-use chain. But is there a better way for doing this? >>>> >>>> Thanks very much! >>>> >>>> Best >>>> >>>> >>>> _______________________________________________ >>>> LLVM Developers mailing list >>>> llvm-dev at lists.llvm.org >>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>>> >>>> >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> llvm-dev at lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>> >>> >> > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161215/f6f0069a/attachment.html>
Mehdi Amini via llvm-dev
2016-Dec-15 21:31 UTC
[llvm-dev] How to get the value for casting in a bitcast instruction more efficiently?
> On Dec 15, 2016, at 12:10 PM, Shen Liu via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi Ryan, > > Thanks for your reply! Yes i can use llvm::Use.get() API to do this, i just want to know whether there's a better way(e.g. an existed API like getValue()) to make my code look more professional.CastInst->getOperand(0) ? — Mehdi> > On Thu, Dec 15, 2016 at 2:58 PM, Ryan Taylor via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: > This might help: > > http://llvm.org/docs/ProgrammersManual.html#the-value-class <http://llvm.org/docs/ProgrammersManual.html#the-value-class> > > Or maybe I'm misunderstanding what you mean by "efficient way to get the value". When you say 'value', I'm assuming you mean the class. In your case, AllocaInst inherits from value. > > -Ryan > > On Thu, Dec 15, 2016 at 10:24 AM, Shen Liu via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: > Hi everyone, > > This is a simple question but is there an efficient way to get the value for casting directly from a bitcast instruction? > > bitcast format :<result> = bitcast <ty> <value> to <ty2> > > For example, if i have > > MemAddr > ... > 0x3d61238 %key = alloca [16 x i8], align 16 > 0x3d612a8 %plain_text = alloca [64 x i8], align 16 > 0x3d61318 %key1 = bitcast [16 x i8]* %key to i8* > ... > The way i am using is processing all opcodes in %key1, and go back to find %key along the def-use chain. But is there a better way for doing this? > Thanks very much! > > Best > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev> > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev> > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161215/ea9d40b5/attachment.html>
Shen Liu via llvm-dev
2016-Dec-15 21:37 UTC
[llvm-dev] How to get the value for casting in a bitcast instruction more efficiently?
Better than my way, thank you Mehdi! On Thu, Dec 15, 2016 at 4:31 PM, Mehdi Amini via llvm-dev < llvm-dev at lists.llvm.org> wrote:> > On Dec 15, 2016, at 12:10 PM, Shen Liu via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > Hi Ryan, > > Thanks for your reply! Yes i can use llvm::Use.get() API to do this, i > just want to know whether there's a better way(e.g. an existed API like > getValue()) to make my code look more professional. > > > CastInst->getOperand(0) ? > > — > Mehdi > > > > > > On Thu, Dec 15, 2016 at 2:58 PM, Ryan Taylor via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> This might help: >> >> http://llvm.org/docs/ProgrammersManual.html#the-value-class >> >> Or maybe I'm misunderstanding what you mean by "efficient way to get the >> value". When you say 'value', I'm assuming you mean the class. In your >> case, AllocaInst inherits from value. >> >> -Ryan >> >> On Thu, Dec 15, 2016 at 10:24 AM, Shen Liu via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >>> Hi everyone, >>> >>> This is a simple question but is there an efficient way to get the *value for casting* directly from a bitcast instruction? >>> >>> bitcast format :<result> = bitcast <ty> <*value*> to <ty2> >>> >>> For example, if i have >>> >>> MemAddr >>> ... >>> 0x3d61238 %key = alloca [16 x i8], align 16 >>> 0x3d612a8 %plain_text = alloca [64 x i8], align 16 >>> 0x3d61318 %key1 = bitcast [16 x i8]* %key to i8* >>> ... >>> >>> The way i am using is processing all opcodes in %key1, and go back to find %key along the def-use chain. But is there a better way for doing this? >>> >>> Thanks very much! >>> >>> Best >>> >>> >>> _______________________________________________ >>> LLVM Developers mailing list >>> llvm-dev at lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>> >>> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161215/62f1ec98/attachment.html>
Apparently Analagous Threads
- How to get the value for casting in a bitcast instruction more efficiently?
- How to get the value for casting in a bitcast instruction more efficiently?
- How to get the value for casting in a bitcast instruction more efficiently?
- How to get the value for casting in a bitcast instruction more efficiently?
- How to get the value for casting in a bitcast instruction more efficiently?