[LLVMdev] create load from a register in LLVM IR

Tim Northover t.p.northover at gmail.com
Fri Dec 13 23:42:19 PST 2013


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