This is the mail archive of the ecos-discuss@sourceware.cygnus.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to create a new platform?



> > Grant> Do you prefer the "declare a pointer and then type-cast a
> > Grant> hard-wired constant value" method?
> > 
> > Grant>    const UartType Uart0Ptr = (UartType*) 0x3604000;
> > 
> > This is the method I'm familiar with. But I'm just a dumb kid :)
> 
> If this is actually a define, ie. #define UARTBASE ((UartType *)0x3604000)
> then it would be very bad if gcc could not optimize "UARTBASE->foo" to be a
> direct access to a single memory address, rather than having to do the
> addition.

Most compilers will do that (and I'm pretty sure gcc does).
But since the ARM can't directly access memory in a general
way, the code generated ends up being pointer operations
anyway, so for me I think it turns out to be a moot point.

> I'm not sure I could guarantee that for "const"s though.

IIRC, the code generate for the ARM for the following cases is
pretty much identical

  x = *((int*)(0x123456));

  const int *p = (int*)0x123456;
  x = *p;

Since there is no direct memory addressing in the ARM, the
former case has to generate a const pointer and put it in
memory somewhere close to the instruction which needs it (where
it can be read using an offset from either the frame pointer or
the program counter), and then generates code to read and
dereference the pointer.

-- 
Grant Edwards
grante@visi.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]