This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: problem with unaligned access on Alpha
- To: Christian Groessler <cpg at aladdin dot de>
- Subject: Re: problem with unaligned access on Alpha
- From: Richard Henderson <rth at cygnus dot com>
- Date: Wed, 23 Jun 1999 10:35:21 -0700
- Cc: egcs at egcs dot cygnus dot com, axp-list at redhat dot com
- References: <41256798.003CACD0.00@saturn.aladdin.de>
On Tue, Jun 22, 1999 at 11:59:46AM +0100, Christian Groessler wrote:
> #define READ_WORD(a) (*(unsigned short *)(a))
...
> I would expect the "val=READ_WORD()" line to generate an unaligned access
> exception, but this doesn't happen.
You expect incorrectly.
In general you'll only get an unaligned access trap if we'd issued
an `ldwu' instruction, which we can only do when compiling for EV56
or higher.
> I looked at the generated assembler code (with my little only alpha
> assembler knowledge), and it seems that the compiler is generating
> code for unaligned access but somehow forgets to get the byte at (adress+1).
Nope, we're generating code for an _aligned_ word access in
the only way that is possible on EV4. An unaligned word
access doubles the length of the sequence.
If you really want to do unaligned loads, do
typedef struct {
unsigned short __x __attribute__((packed));
} packed_word;
#define READ_WORD(a) (((packed_word *)(a))->__x)
r~