public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Byte-reverse instructions in PowerPC Processors
@ 2008-08-26  6:19 Roberto Barbieri Carrera
  2008-08-27 13:51 ` David Daney
  0 siblings, 1 reply; 2+ messages in thread
From: Roberto Barbieri Carrera @ 2008-08-26  6:19 UTC (permalink / raw)
  To: gcc-help

Hello,

I don´t actually know if this is the proper place for asking this.
Please excuse me if I´m wrong.

I´m developing a system that works in two stages: configuration time
and run time.

Configuration processing is performed in a little endian machine, with
code compiled with gcc.

Run time processing is performed in a ´603´ PowerPC processor, namely,
an MPC8248. Also compiled with gcc.

The output of the configuration stage is a binary file containing
several struct´s. This means that the endianness of the data has to be
converted somewhere.

Of course I can do this with some software, but this brings a
maintainability issue, i.e., if a struct changes in the future, the
conversion software will have to be changed also. This usually brings
bugs.

I though that, as the PowerPC processor has byte-reverse instructions,
one could declare, for example, a big struct containing all the file´s
structs, as byte-order reversed, so that the compiler could use the
byte-reversed instructions each time it accesses something within this
struct. Declaring my struct like this in the PowerPC code could make
my binary file little endian, as well as its memory image in the
PowerPC processor, and no conversions would be necessary.

Is it possible to do something like this with gcc? If not, would it be
too hard to implement?

Thank you in advance for your answer.

Kind regards,
Roberto Barbieri Carrera

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Byte-reverse instructions in PowerPC Processors
  2008-08-26  6:19 Byte-reverse instructions in PowerPC Processors Roberto Barbieri Carrera
@ 2008-08-27 13:51 ` David Daney
  0 siblings, 0 replies; 2+ messages in thread
From: David Daney @ 2008-08-27 13:51 UTC (permalink / raw)
  To: Roberto Barbieri Carrera; +Cc: gcc-help

Roberto Barbieri Carrera wrote:
> Hello,
> 
> I don´t actually know if this is the proper place for asking this.
> Please excuse me if I´m wrong.
> 
> I´m developing a system that works in two stages: configuration time
> and run time.
> 
> Configuration processing is performed in a little endian machine, with
> code compiled with gcc.
> 
> Run time processing is performed in a ´603´ PowerPC processor, namely,
> an MPC8248. Also compiled with gcc.
> 
> The output of the configuration stage is a binary file containing
> several struct´s. This means that the endianness of the data has to be
> converted somewhere.
> 
> Of course I can do this with some software, but this brings a
> maintainability issue, i.e., if a struct changes in the future, the
> conversion software will have to be changed also. This usually brings
> bugs.
> 
> I though that, as the PowerPC processor has byte-reverse instructions,
> one could declare, for example, a big struct containing all the file´s
> structs, as byte-order reversed, so that the compiler could use the
> byte-reversed instructions each time it accesses something within this
> struct. Declaring my struct like this in the PowerPC code could make
> my binary file little endian, as well as its memory image in the
> PowerPC processor, and no conversions would be necessary.
> 
> Is it possible to do something like this with gcc? If not, would it be
> too hard to implement?
> 
> Thank you in advance for your answer.

Portable device drivers often have similar issues.

One I have recently seen is in the Linux kernel: drivers/net/e100.c  You 
may be able to borrow the techniques used there.

David Daney

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-26 21:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-26  6:19 Byte-reverse instructions in PowerPC Processors Roberto Barbieri Carrera
2008-08-27 13:51 ` David Daney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).