This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH:[darwin] fix load of a misaligned double word

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
be encoded.

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.


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