[LLVMdev] Stack implementation

Piotr Kaleta piotrek.kaleta at gmail.com
Mon Jul 25 09:15:39 PDT 2011


I'm translating the source of stack-based virtual machine into LLVM IR and
my plan is to implement  the stack in LLVM IR (using alloca/load/store) in
order to emulate the VM's stack and then use the optimization phase
"mem2reg". Therefore I'm going to have a stack pointer that points to the
top of my stack. I'm curious whether I will have to implement that in a
linked-list fashion, i.e. each stack node would contain the pointer to the
previous node as well as the current value of the top of the stack or maybe
alloca instruction works in a way that the subsequent calls to it allocates
the contiguous memory area and I could get rid of the "pointer to previous
thing" and only count the number of calls to alloca instruction.

Another thing is that there might be a better (less expensive or easier) way
of doing the whole stack -> SSA transformation which I didn't came up with,
but someone else did?

Kind regards
-- 
Piotr Kaleta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110725/657e3e46/attachment.html>


More information about the llvm-dev mailing list