[LLVMdev] how to code a loop in llvm assembly

Patrick Meredith pmeredit at uiuc.edu
Sat Apr 15 12:34:13 PDT 2006

Using an alloca'd variable with loads and stores would work well  
too.  To date this
is how every llvm language front end works.  You would want to avoid  
malloc for
such a purpose generally.  mem2reg is nice enough to take your local  
and stores and promote them to registers with PHINodes :-)

On Apr 15, 2006, at 4:43 AM, Ralph Corderoy wrote:

> Hi Simon,
>> I've read over the "LLVM Language Reference Manual" a few times, and
>> writing some ll code, but i'm stuck at a very basic point. How to
>> decrement a counter variable ?
> As Oscar pointed out, you need a phi-node.  I read some of the  
> published
> papers on LLVM before the Language Reference Manual and found them  
> to be
> of use.  You may also find Wikipedia's explanation of SSA useful,
> especially the key paragraph
>     http://en.wikipedia.org/wiki/Static_single_assignment_form
>     "Note: the phi functions are not actually implemented; instead,
>     they're just markers for the compiler to place the value of all  
> the
>     variables grouped together by the phi function, in the same  
> location
>     in memory (or same register)."
> Cheers,
> Ralph.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list