This is the mail archive of the
mailing list for the GCC project.
Re: PATCH:[darwin] fix load of a misaligned double word
- From: Paul Koning <pkoning at equallogic dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Jan 2004 14:38:43 -0500
- Subject: Re: PATCH:[darwin] fix load of a misaligned double word
- References: <6F551554-3BBA-11D8-9393-000A958F150A@math.purdue.edu><200312311910.hBVJA2T34064@makai.watson.ibm.com><05096D5C-3BCB-11D8-9393-000A958F150A@math.purdue.edu><200312311959.hBVJxsT27684@makai.watson.ibm.com><0F1F3F63-3BE0-11D8-9393-000A958F150A@math.purdue.edu>
I was getting positively baffled by the track this discussion was
taking, but after some off-line mail I think I understand the
underlying issue. Since it seems to be a bit obscured at this point,
let me post what I believe I heard. I'll do that at the risk of
belaboring the obvious for at least some of the audience.
1. We're dealing with a properly aligned variable.
2. gcc is trying to generate the storage reference to that variable by
taking a base register plus offset. That's perfectly ok in
3. gcc happens to pick a base register value that's not a multiple of
4. That too is ok given that it's using the right offset to
4. However... the machine instruction set support arbitrary byte
offsets ONLY if the load/store target is an FP register, NOT if
it's a GPR. For (64 bit) GPR load/stores the machine encoding
restricts offsets to multiples of 4.
5. So the problem is that the gcc backend doesn't correctly honor this
restriction. If it needs an odd offset, it can't use GPRs. If it
wants to use GPRs for 64-bit data, it can't use odd offsets.
The assembler is complaining about illegal instructions, which isn't
good. You should see assembler error messages ONLY for asm
statements, never for anything gcc generated. Gcc is welcome to use
any base register it wants, so long as it generates the right offsets
to go with it AND honors any machine restrictions on what offsets can
Come to think of it, that's no different from the far more common
restriction that offsets are 16-bit values, or 12 bit values, or
The only escape I can see is that gcc can refuse to handle user code
that is "undefined" -- but if so it should generate a meaningful error
message, not strange stuff that the assembler objects to.