Re: Use of unaligned load/stores by compilers - or doing things by halves

David L Moore <dlmoore@ix.netcom.com>
25 Jan 1998 00:51:29 -0500

          From comp.compilers

Related articles
Use of unaligned load/stores by compilers sazal@aol.com (1998-01-24)
Re: Use of unaligned load/stores by compilers - or doing things by hal dlmoore@ix.netcom.com (David L Moore) (1998-01-25)
Re: Use of unaligned load/stores by compilers - or doing things by hal tmoog@mcs.net (Tom Moog) (1998-01-25)
Re: Use of unaligned load/stores by compilers - or doing things by hal henry@zoo.toronto.edu (Henry Spencer) (1998-01-26)
Re: Use of unaligned load/stores by compilers reid@micro.ti.com (Reid Tatge) (1998-01-30)
Re: Use of unaligned load/stores by compilers tgl@netcom.com (Tom Lane) (1998-02-01)
Re: Use of unaligned load/stores by compilers albaugh@agames.com (1998-02-01)
Re: Use of unaligned load/stores by compilers dlmoore@ix.netcom.com (David L Moore) (1998-02-01)
| List of all articles for this month |

From: David L Moore <dlmoore@ix.netcom.com>
Newsgroups: comp.compilers
Date: 25 Jan 1998 00:51:29 -0500
Organization: Netcom
References: 98-01-099
Keywords: architecture

Sazal wrote:
>
> I was wondering if anyone can point out the different capacities in
> which compilers use unaligned load/store instructions.
>
> [Fortran lets you use equivalence statements to misalign double precision
> floats, other than that I don't know of any languages where misaligned
> data will happen without extraordinary programmer effort. -John]


One of the "interesting" features of Sparc is that floating point
values passed as parameters may not be double word aligned. This is
on a processor that requires doubles to be double word aligned! For
a double which you cannot "prove" is adequately aligned, you have to
load each half separately, otherwise you may get a bus error. In
general, doubles in structures referenced by a pointer have to be loaded
by halves, since you may be handed a pointer to a mis-aligned
parameter structure.


(It also has the interesting feature that a double passed in a certain
place in the parameter list has one half passed in a register and the
other half passed on the stack!)


Some processors have implemented unaligned loads as extra-code traps.
(An extra-code is an instruction that is emulated in software). When I
worked on the 29000, which did this, I put a flag in the kernel to
enable the extra-code. By default you got a bus error. For developers,
this was usually the preferred result, since extra-code runs slowly;
sometimes, it is better that a program not run at all than that it run
slowly.
[The 486 and later Intel chips have an option to trap misaligned mem
refs, but I've never heard of anyone using it. Hmmn. -John]




--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.