<div class="gmail_quote">On Fri, Jun 22, 2012 at 3:16 PM, amruth.rd <span dir="ltr"><<a href="mailto:amruth.rd@knights.ucf.edu" target="_blank">amruth.rd@knights.ucf.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks Justin. It was really helpful.<br>
<br>
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.<br></blockquote><div><br></div>
<div>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.</div>
<div><br></div><div>If you want to get the address at run-time, you can also pass the alloca'd pointer to some user function:</div><div><br></div><div>%a = alloca i32</div><div>call void @foo(i32* %a)   // Call foo with the stack pointer</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Regards,<br>
Amruth<br>
________________________________________<br>
From: Justin Holewinski [<a href="mailto:justin.holewinski@gmail.com">justin.holewinski@gmail.com</a>]<br>
Sent: Friday, June 22, 2012 3:04 PM<br>
To: amruth.rd<br>
Cc: <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
Subject: Re: [LLVMdev] mapping a virtual register to a specific address<br>
<div class="im"><br>
On Fri, Jun 22, 2012 at 2:46 PM, amruth.rd <<a href="mailto:amruth.rd@knights.ucf.edu">amruth.rd@knights.ucf.edu</a><mailto:<a href="mailto:amruth.rd@knights.ucf.edu">amruth.rd@knights.ucf.edu</a>>> wrote:<br>

<br>
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?<br>
<br>
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).<br>

<br>
<br>
Thanks,<br>
Amruth<br>
<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
</div><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a><mailto:<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>

<div class="HOEnZb"><div class="h5"><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
<br>
<br>
--<br>
<br>
Thanks,<br>
<br>
Justin Holewinski<br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div><br>