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

Rick Mann rmann at latencyzero.com
Fri Apr 9 21:17:23 PDT 2010

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

	*AT91C_BASE_SYS = 0xaabbccdd;

Is there any way to do the equivalent with a global?


More information about the llvm-dev mailing list