amruth.rd
2012-Jun-22 18:46 UTC
[LLVMdev] mapping a virtual register to a specific address
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? Thanks, Amruth
Justin Holewinski
2012-Jun-22 19:04 UTC
[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>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 http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120622/4c7b6756/attachment.html>
John Criswell
2012-Jun-22 19:14 UTC
[LLVMdev] mapping a virtual register to a specific address
On 6/22/12 2:04 PM, Justin Holewinski wrote:> 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).To elaborate on what Justin said, at the LLVM IR level, you don't know where a virtual register will live after code generation (or even if it will live in the same "place;" the code generator is free to allocate it to a register for part of its life and a stack spill slot for another part of its life). You may be able to get this information if you write a MachineFunction pass or some other code that is run by LLVM after code generation and register allocation (because you can see the generated code). However, I don't know enough about MachineFunction passes to be sure that it's possible; that's just where I'd look if I were you. -- John T.> > 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 > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120622/9f96c415/attachment.html>
Justin Holewinski
2012-Jun-22 21:23 UTC
[LLVMdev] mapping a virtual register to a specific address
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>