public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc Sparc alignment problems
@ 2004-04-19 20:50 Phil Prentice
  2004-04-19 21:03 ` Dale Johannesen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Phil Prentice @ 2004-04-19 20:50 UTC (permalink / raw)
  To: gcc-help, gcc

Hi

 Does anyone know of a gcc compiler flag or option that would enable us to 
compile and successfully run 'C' code that will access mis-aligned integers 
or dioubles which runs on a SPARC workstation running Solaris.

  The Sun compiler achieves this by means of the -misalign flag

   If you are able to help, I would be grateful to hear from you

Many thanks.

Regards

Phil 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc Sparc alignment problems
  2004-04-19 20:50 gcc Sparc alignment problems Phil Prentice
@ 2004-04-19 21:03 ` Dale Johannesen
  2004-04-19 23:13   ` Jim Wilson
  2004-04-19 21:43 ` Mike Stump
  2004-04-19 23:20 ` Jim Wilson
  2 siblings, 1 reply; 5+ messages in thread
From: Dale Johannesen @ 2004-04-19 21:03 UTC (permalink / raw)
  To: Phil Prentice; +Cc: gcc-help, gcc, Dale Johannesen

On Apr 19, 2004, at 12:38 PM, Phil Prentice wrote:
>  Does anyone know of a gcc compiler flag or option that would enable 
> us to
> compile and successfully run 'C' code that will access mis-aligned 
> integers
> or dioubles which runs on a SPARC workstation running Solaris.
>
>   The Sun compiler achieves this by means of the -misalign flag
>
>    If you are able to help, I would be grateful to hear from you
>
> Many thanks.

The documentation lists -munaligned-doubles .  I don't know how well it 
works.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc Sparc alignment problems
  2004-04-19 20:50 gcc Sparc alignment problems Phil Prentice
  2004-04-19 21:03 ` Dale Johannesen
@ 2004-04-19 21:43 ` Mike Stump
  2004-04-19 23:20 ` Jim Wilson
  2 siblings, 0 replies; 5+ messages in thread
From: Mike Stump @ 2004-04-19 21:43 UTC (permalink / raw)
  To: Phil Prentice; +Cc: gcc-help, gcc

On Monday, April 19, 2004, at 12:38  PM, Phil Prentice wrote:
>  Does anyone know of a gcc compiler flag or option that would enable 
> us to
> compile and successfully run 'C' code that will access mis-aligned 
> integers
> or dioubles which runs on a SPARC workstation running Solaris.

A trap handler that does the unaligned load might be best, gcc 
generally doesn't support doing this without typing information, and 
even when that is used, you cannot violate the type system and expect 
it to work.

This could be done be changing your port to generate the unaligned 
loads and store all the time instead of the aligned versions, but, this 
would cause generated code to suffer significant performance 
degradation, which is why in general, people don't do this.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc Sparc alignment problems
  2004-04-19 21:03 ` Dale Johannesen
@ 2004-04-19 23:13   ` Jim Wilson
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Wilson @ 2004-04-19 23:13 UTC (permalink / raw)
  To: Dale Johannesen; +Cc: gcc-help, gcc

Dale Johannesen wrote:
> The documentation lists -munaligned-doubles .  I don't know how well it 
> works.

This is something completely different.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc Sparc alignment problems
  2004-04-19 20:50 gcc Sparc alignment problems Phil Prentice
  2004-04-19 21:03 ` Dale Johannesen
  2004-04-19 21:43 ` Mike Stump
@ 2004-04-19 23:20 ` Jim Wilson
  2 siblings, 0 replies; 5+ messages in thread
From: Jim Wilson @ 2004-04-19 23:20 UTC (permalink / raw)
  To: Phil Prentice; +Cc: gcc, gcc-help

Phil Prentice wrote:
>  Does anyone know of a gcc compiler flag or option that would enable us to 
> compile and successfully run 'C' code that will access mis-aligned integers 
> or dioubles which runs on a SPARC workstation running Solaris.
>   The Sun compiler achieves this by means of the -misalign flag

The Sun -misalign flag was originally added for people migrating from 
Sun3 (m68k) systems to Sun4 (sparc) systems.  m68k systems only align 
data to 2 bytes, whereas sparc systems align data to 4 bytes.  So if you 
have existing data created on a m68k system, you might not be able to 
read it on a sparc system.  -misalign adds the assumption that all 
pointers point to unaligned data, and thus we use byte loads and shift 
to access all data.  This allows use of m68k created data on a sparc system.

The m68k to sparc switchover happened so long ago that people really 
shouldn't need the -misalign flag anymore.  Use of this option will 
seriously hurt performance.  You would be much better off if you use 
attribute packed and/or attribute aligned to make your data structures 
match your data.

I did once add an equivalent option to gcc at Cygnus a long time ago, 
but I never cleaned it up to the point where I felt confident that it 
would be accepted into the FSF gcc sources.  It wasn't hard to add it. 
You just add another flags to MEM to indicate that they are unaligned. 
You set this flag when expanding an INDIRECT_REF in expand_expr.  In 
emit_move_insn, if the source is a MEM with this flag set, then you call 
extract_bitfield.  If the dest is a MEM with this flag set, then you 
call store_bitfield.

As a bonus, one can use this to implement unaligned pointers.  Just add 
an attribute unaligned, and when we deference a pointer with this 
attribute set, we set the MEM unaligned flag.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-04-19 23:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-19 20:50 gcc Sparc alignment problems Phil Prentice
2004-04-19 21:03 ` Dale Johannesen
2004-04-19 23:13   ` Jim Wilson
2004-04-19 21:43 ` Mike Stump
2004-04-19 23:20 ` Jim Wilson

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).