[LLVMdev] Defining a pointer to a specific memory address?

Jeffrey Yasskin jyasskin at google.com
Mon Apr 12 10:01:43 PDT 2010


Try compiling the following C code:

typedef volatile unsigned int AT91_REG;// Hardware register definition
#define AT91_CAST(a) (a)
#define AT91C_BASE_SYS       (AT91_CAST(AT91_REG*)      0xFFFFF000) //
(SYS) Base Address

AT91_REG* global = AT91C_BASE_SYS;



On Fri, Apr 9, 2010 at 9:17 PM, Rick Mann <rmann at latencyzero.com> wrote:
> I've been working through the getting started and language reference docs. One thing that's not immediately clear if it's possible is to define a global pointer to a specific memory address.
>
> I'm looking at ways to use LLVM to target a small ARM embedded processor, and there are a great many hardware registers mapped into the address space. I tried making a little sample C program to see how llvm-gcc generated the access, and it used this:
>
>  volatile store i32 -1430532899, i32* inttoptr (i64 4294963200 to i32*), align 4
>
> for this C code:
>
> typedef volatile unsigned int AT91_REG;// Hardware register definition
> #define AT91_CAST(a) (a)
> #define AT91C_BASE_SYS       (AT91_CAST(AT91_REG*)      0xFFFFF000) // (SYS) Base Address
>
> void
> main()
> {
>        *AT91C_BASE_SYS = 0xaabbccdd;
> }
>
>
> Is there any way to do the equivalent with a global?
>
> Thanks,
> Rick
>
>
> _______________________________________________
> 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