Because an assignment of a constant to a variable isn't an instruction. Or more to the point, the right-hand-side of "%var2 = 12" isn't an instruction.
What is the simplest way to make %var2 = 12 ?
I think that this should work:
define i32 @test() {
%v = bitcast i32 42 to i32
ret i32 %v
}
There is no LLVM instruction for an assignment, since it's superfluous in an SSA environment.
What are you using to create the IR? In the above example, there's no need for var2; just "ret i32 12" will suffice if you're hand-coding it. If you're generating the IR programmatically, you would normally use ConstantInt::get() with appropriate parameters to create a Value object that can be used wherever needed.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
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