[LLVMdev] mapping a virtual register to a specific address

Justin Holewinski justin.holewinski at gmail.com
Fri Jun 22 14:23:38 PDT 2012


On Fri, Jun 22, 2012 at 3:16 PM, amruth.rd <amruth.rd at knights.ucf.edu>wrote:

> Thanks Justin. It was really helpful.
>
> Can i use "alloca" instruction to allocate memory at a particular address
> in the stack? Is it possible to do that? As far as I know, alloca does not
> take any address as an operand.
>

The only control alloca gives you over the address is alignment.    If you
really need an address, you can do as John suggested and write a
MachineFunctionPass that executes towards the end of codegen to see where
in the stack it is allocated.  Also keep in mind that there is not
necessarily a one-to-one mapping from virtual register to physical
register.  An LLVM IR register can hold a complex type that will take
multiple physical registers to hold.

If you want to get the address at run-time, you can also pass the alloca'd
pointer to some user function:

%a = alloca i32
call void @foo(i32* %a)   // Call foo with the stack pointer


>
> Regards,
> Amruth
> ________________________________________
> From: Justin Holewinski [justin.holewinski at gmail.com]
> Sent: Friday, June 22, 2012 3:04 PM
> To: amruth.rd
> Cc: llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] mapping a virtual register to a specific address
>
> On Fri, Jun 22, 2012 at 2:46 PM, amruth.rd <amruth.rd at knights.ucf.edu
> <mailto:amruth.rd at knights.ucf.edu>> wrote:
>
> Does LLVM allow mapping a virtual register to a specific memory location?
> If not, how do we extract information on where the virtual registers are
> mapped to?
>
> In general, you do not know where a virtual register is mapped, and the
> mapping is dependent on the back-end.  It could be allocated or spilled
> onto the stack, or it may live entirely within a physical register (e.g. no
> address).
>
>
> Thanks,
> Amruth
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu<mailto:LLVMdev at cs.uiuc.edu>
> http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
> --
>
> Thanks,
>
> Justin Holewinski
>
>
>


-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120622/ec85ce6d/attachment.html>


More information about the llvm-dev mailing list