[LLVMdev] create load from a register in LLVM IR

Chen Li meloli87 at gmail.com
Sat Dec 14 16:33:00 PST 2013


Hi Tim,

Thanks for the reply. All I need right now are %rbp and %rsp, in other words are frame pointer and stack pointer. I guess @llvm.frameaddress intrinsic work for %rbp in this case, and does @llvm.stacksave return the stack pointer? 

Thanks,
Chen 




On Dec 13, 2013, at 11:42 PM, Tim Northover <t.p.northover at gmail.com> wrote:

> Hi Chen,
> 
>> I have recently encountered a problem when creating LLVM IRs. I am wondering
>> if there is a standard or easy way to create a load from a certain register?
>> For example, CreateLoad(rbp, NAME).
> 
> LLVM doesn't directly provide access to any machine registers. If you
> want %rbp because it's the frame pointer then for that one case there
> is actually an @llvm.frameaddress intrinsic you can call to get it.
> But if you want other registers as well, the only way I can think of
> is through inline assembly.
> 
> This is roughly the line clang produces, and should be sufficient:
> 
>    %my_value = call i64 asm "movq $0, %rbp", "=r"()
> 
> Cheers.
> 
> Tim.





More information about the llvm-dev mailing list