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

ether etherzhhb at gmail.com
Mon Jan 4 00:36:15 PST 2010


hi zhu,

i think you should map the peripheral registers to data memory space 
instead of register file, then mark that memory address as "volatile".
like said the adc register was mapped to address 0xc0000, and then the 
corresponding c source will goes like this:
//define the register
#define ADCREG (*((volatile unsigned int *)0xc0000))
//read the register
a = ADCREG

--ether

On 2010-1-4 10:59, Heyu Zhu 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
>    



More information about the llvm-dev mailing list