[LLVMdev] How to bind a register variable with a given general purpose register?

Kenneth Uildriks kennethuil at gmail.com
Mon Jan 4 05:44:55 PST 2010

On Sun, Jan 3, 2010 at 8:59 PM, Heyu Zhu <zhu.heyu at gmail.com> wrote:
> Hi everyone,
> There are 16 GPRs in my RISC, but in fact GPR13 is read-only and connected
> to output of an A/D converter.
> It would be very convenient if i could bind a register variable with GPR13.
> Because i am a newbie i don't know how my llvm backend can support that.
> I plan to implement it as below.
> A.  first declare a global variable in c-code
>      int  ADC  asm("GPR13");
> B.  If backend finds a variable is loaded from "GPR13"  use GPR13 instead.
> C.  backend can't allocate GPR13 to other variable
> Is it a foolish method? Is there a better one? Please give me some guidance
> Thanks
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

If your end goal is to allow programs to use the output of the A/D
converter, my recommendation would be to create a platform-specific
intrinsic function that returns the output of the A/D converter, and
have your back-end refuse to allocate GPR13 as a register.  The
intrinsic function would of course simply cough up the value of GPR13,
which would then be available for use in the program.

More information about the llvm-dev mailing list