home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc B) / Acorn User China CD-ROM (UK) (Disc B).bin / BARNET / ARMLINUX / MAIL / 9801 / text0025.txt < prev    next >
Encoding:
Text File  |  1998-01-31  |  1.4 KB  |  41 lines

  1. >> EG, to access bytes
  2. >>  12 and 13 only of a structure, GCC will use by default:
  3. >>    ldr r0, [r1, #14]
  4. >>    mov r0, r0, lsr #16
  5. > >Does anyone know if this is a legal optimisation that the compiler is making?
  6. > The consensus among the gcc people is that it is, because the ARM ABI is 
  7. > allowed to define a minimum alignment (and has done so, to 32).  The 
  8. > optimisation does produce noticeably better code in the vast majority of cases.
  9. > A way to signal to gcc that a structure is unaligned in this way is on the 
  10. > cards in the future, but we don't have it yet.  In the short term we need to 
  11. > find a workaround such as using -mshort-load-bytes on the offending source 
  12. > files, or fixing them to use explicit byte ops.
  13.  
  14. Can I ask for a specific example here?  Are we talking about something along
  15. the lines of:
  16.  
  17. struct foo
  18. {
  19.   int a;
  20.   short b;
  21.   short c;
  22.   char d;
  23.   short e;
  24.   short f;
  25. }
  26.  
  27. ie which of these will be wrongly accessed?  And what alignment will GCC
  28. give them?
  29.  
  30. I don't think that -mshort-load-bytes is the correct way to differentiate
  31. the two cases, I think -munaligned-loads versus -mno-unaligned-loads is the
  32. correct name for the switch - simply because I don't think shorts should
  33. be loaded as bytes!  It's /at least/ as efficient to load them as words
  34. and then shift them twice as it is to load as bytes and orr them together.
  35.  
  36. unsubscribe: body of `unsubscribe linux-arm' to majordomo@vger.rutgers.edu
  37.  
  38.