[LLVMdev] Simple question

James Courtier-Dutton james.dutton at gmail.com
Fri Mar 15 17:18:33 PDT 2013


On Mar 15, 2013 10:53 PM, "Óscar Fuentes" <ofv at wanadoo.es> wrote:
>
> James Courtier-Dutton <james.dutton at gmail.com> writes:
>
> > I think this is a very simple question, and it must just be missing
something.
> >
> > I am looking for find out how to assign a constant integer value to
> > the variable in llvm ir.
> >
> > The following returns 12, and %var2 = 12.
> > ; ModuleID = 't.c'
> > target datalayout =
> >
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> > target triple = "x86_64-pc-linux-gnu"
> >
> > define i32 @test() nounwind readnone {
> >   %var1 = xor i32 0, 0
> >   %var2 = add i32 %var1, 12
> >   ret i32 %var2
> > }
> >
> > Why can't I do?:
> > ; ModuleID = 't.c'
> > target datalayout =
> >
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
> > target triple = "x86_64-pc-linux-gnu"
> >
> > define i32 @test() nounwind readnone {
> >   %var2 = 12
> >   ret i32 %var2
> > }
> >
> > What is the simplest way to make %var2 = 12   ?
>
> To add to the other response, it is important to note that your %var1,
> %var2 above are not variables at all, because they can't be reassigned
> (i.e. they can't appear again on the left hand of a %varX = ...
> expression.) They are just names for the values corresponding to the
> instructions.
>

Ok, maybe i asked the wrong question.
Instead of using the value 12 all the way through the llvm ir text file.
How do i use %friendlyName instead?
I.e. The equivalent of something like
#define FriendlyName  12
in C
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130316/ac535085/attachment.html>


More information about the llvm-dev mailing list