<p><br>
On Mar 15, 2013 10:53 PM, "Óscar Fuentes" <<a href="mailto:ofv@wanadoo.es">ofv@wanadoo.es</a>> wrote:<br>
><br>
> James Courtier-Dutton <<a href="mailto:james.dutton@gmail.com">james.dutton@gmail.com</a>> writes:<br>
><br>
> > I think this is a very simple question, and it must just be missing something.<br>
> ><br>
> > I am looking for find out how to assign a constant integer value to<br>
> > the variable in llvm ir.<br>
> ><br>
> > The following returns 12, and %var2 = 12.<br>
> > ; ModuleID = 't.c'<br>
> > target datalayout =<br>
> > "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"<br>
> > target triple = "x86_64-pc-linux-gnu"<br>
> ><br>
> > define i32 @test() nounwind readnone {<br>
> >   %var1 = xor i32 0, 0<br>
> >   %var2 = add i32 %var1, 12<br>
> >   ret i32 %var2<br>
> > }<br>
> ><br>
> > Why can't I do?:<br>
> > ; ModuleID = 't.c'<br>
> > target datalayout =<br>
> > "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"<br>
> > target triple = "x86_64-pc-linux-gnu"<br>
> ><br>
> > define i32 @test() nounwind readnone {<br>
> >   %var2 = 12<br>
> >   ret i32 %var2<br>
> > }<br>
> ><br>
> > What is the simplest way to make %var2 = 12   ?<br>
><br>
> To add to the other response, it is important to note that your %var1,<br>
> %var2 above are not variables at all, because they can't be reassigned<br>
> (i.e. they can't appear again on the left hand of a %varX = ...<br>
> expression.) They are just names for the values corresponding to the<br>
> instructions.<br>
></p>
<p>Ok, maybe i asked the wrong question.<br>
Instead of using the value 12 all the way through the llvm ir text file. How do i use %friendlyName instead?<br>
I.e. The equivalent of something like<br>
#define FriendlyName  12<br>
in C<br>
</p>