public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Daney <ddaney@avtrex.com>
To: Roberto Barbieri Carrera <rbarbiericarrera@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Byte-reverse instructions in PowerPC Processors
Date: Wed, 27 Aug 2008 13:51:00 -0000	[thread overview]
Message-ID: <48B47337.9030300@avtrex.com> (raw)
In-Reply-To: <238980730808252303g676883e7ja2751d7f9ffe20cd@mail.gmail.com>

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

      reply	other threads:[~2008-08-26 21:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-26  6:19 Roberto Barbieri Carrera
2008-08-27 13:51 ` David Daney [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48B47337.9030300@avtrex.com \
    --to=ddaney@avtrex.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=rbarbiericarrera@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).