xref: /titanic_51/usr/src/lib/libbc/libc/crt/sparc/misalign.s (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate!	.text
2*7c478bd9Sstevel@tonic-gate!	.asciz ident	"%Z%%M%	%I%	%E% SMI"
3*7c478bd9Sstevel@tonic-gate!	.align	4
4*7c478bd9Sstevel@tonic-gate!	.seg	"text"
5*7c478bd9Sstevel@tonic-gate
6*7c478bd9Sstevel@tonic-gate!	 Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
7*7c478bd9Sstevel@tonic-gate!	 Use is subject to license terms.
8*7c478bd9Sstevel@tonic-gate!
9*7c478bd9Sstevel@tonic-gate!	 CDDL HEADER START
10*7c478bd9Sstevel@tonic-gate!
11*7c478bd9Sstevel@tonic-gate!	 The contents of this file are subject to the terms of the
12*7c478bd9Sstevel@tonic-gate!	 Common Development and Distribution License, Version 1.0 only
13*7c478bd9Sstevel@tonic-gate!	 (the "License").  You may not use this file except in compliance
14*7c478bd9Sstevel@tonic-gate!	 with the License.
15*7c478bd9Sstevel@tonic-gate!
16*7c478bd9Sstevel@tonic-gate!	 You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
17*7c478bd9Sstevel@tonic-gate!	 or http://www.opensolaris.org/os/licensing.
18*7c478bd9Sstevel@tonic-gate!	 See the License for the specific language governing permissions
19*7c478bd9Sstevel@tonic-gate!	 and limitations under the License.
20*7c478bd9Sstevel@tonic-gate!
21*7c478bd9Sstevel@tonic-gate!	 When distributing Covered Code, include this CDDL HEADER in each
22*7c478bd9Sstevel@tonic-gate!	 file and include the License file at usr/src/OPENSOLARIS.LICENSE.
23*7c478bd9Sstevel@tonic-gate!	 If applicable, add the following below this CDDL HEADER, with the
24*7c478bd9Sstevel@tonic-gate!	 fields enclosed by brackets "[]" replaced with your own identifying
25*7c478bd9Sstevel@tonic-gate!	 information: Portions Copyright [yyyy] [name of copyright owner]
26*7c478bd9Sstevel@tonic-gate!
27*7c478bd9Sstevel@tonic-gate!	 CDDL HEADER END
28*7c478bd9Sstevel@tonic-gate!
29*7c478bd9Sstevel@tonic-gate
30*7c478bd9Sstevel@tonic-gate!
31*7c478bd9Sstevel@tonic-gate! C library routines for compiler support of misaligned memory
32*7c478bd9Sstevel@tonic-gate! references.  These are called when an in-line test reveals a
33*7c478bd9Sstevel@tonic-gate! misaligned address.
34*7c478bd9Sstevel@tonic-gate!
35*7c478bd9Sstevel@tonic-gate
36*7c478bd9Sstevel@tonic-gate	.file	"misalign.s"
37*7c478bd9Sstevel@tonic-gate
38*7c478bd9Sstevel@tonic-gate#include <SYS.h>
39*7c478bd9Sstevel@tonic-gate
40*7c478bd9Sstevel@tonic-gate!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41*7c478bd9Sstevel@tonic-gate
42*7c478bd9Sstevel@tonic-gate!
43*7c478bd9Sstevel@tonic-gate! int ld_int(p)
44*7c478bd9Sstevel@tonic-gate! char *p;
45*7c478bd9Sstevel@tonic-gate! {
46*7c478bd9Sstevel@tonic-gate!	/*
47*7c478bd9Sstevel@tonic-gate!	 * load 32-bit int from misaligned address
48*7c478bd9Sstevel@tonic-gate!	 * cost(16-bit aligned case): 9 cycles
49*7c478bd9Sstevel@tonic-gate!	 * cost(8-bit aligned case): 18 cycles
50*7c478bd9Sstevel@tonic-gate!	 */
51*7c478bd9Sstevel@tonic-gate! }
52*7c478bd9Sstevel@tonic-gate!
53*7c478bd9Sstevel@tonic-gate	RTENTRY(.ld_int)
54*7c478bd9Sstevel@tonic-gate	andcc	%o0,1,%g0	! test 16-bit alignment
55*7c478bd9Sstevel@tonic-gate	be,a	1f		! fast case: two loads;
56*7c478bd9Sstevel@tonic-gate	lduh	[%o0+2],%o1	! do first one in delay slot
57*7c478bd9Sstevel@tonic-gate!
58*7c478bd9Sstevel@tonic-gate	ldub	[%o0+3],%o3	! slow case: load 4 bytes in <o0,o1,o2,o3>
59*7c478bd9Sstevel@tonic-gate	ldub	[%o0+2],%o2
60*7c478bd9Sstevel@tonic-gate	ldub	[%o0+1],%o1
61*7c478bd9Sstevel@tonic-gate	ldub	[%o0],%o0	! note this has to be done last.
62*7c478bd9Sstevel@tonic-gate	sll	%o2,8,%o2
63*7c478bd9Sstevel@tonic-gate	sll	%o1,16,%o1
64*7c478bd9Sstevel@tonic-gate	sll	%o0,24,%o0
65*7c478bd9Sstevel@tonic-gate	or	%o1,%o0,%o0	! put the pieces together.
66*7c478bd9Sstevel@tonic-gate	or	%o2,%o0,%o0
67*7c478bd9Sstevel@tonic-gate	retl
68*7c478bd9Sstevel@tonic-gate	or	%o3,%o0,%o0
69*7c478bd9Sstevel@tonic-gate1:
70*7c478bd9Sstevel@tonic-gate	lduh	[%o0],%o0	! 2nd half of fast case
71*7c478bd9Sstevel@tonic-gate	sll	%o0,16,%o0	! shift, concat, done.
72*7c478bd9Sstevel@tonic-gate	retl
73*7c478bd9Sstevel@tonic-gate	or	%o0,%o1,%o0
74*7c478bd9Sstevel@tonic-gate	SET_SIZE(.ld_int)
75*7c478bd9Sstevel@tonic-gate
76*7c478bd9Sstevel@tonic-gate!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
77*7c478bd9Sstevel@tonic-gate
78*7c478bd9Sstevel@tonic-gate!
79*7c478bd9Sstevel@tonic-gate! float ld_float(p)
80*7c478bd9Sstevel@tonic-gate! char *p;
81*7c478bd9Sstevel@tonic-gate! {
82*7c478bd9Sstevel@tonic-gate!	/* load 32-bit float (not double!) from misaligned address */
83*7c478bd9Sstevel@tonic-gate! }
84*7c478bd9Sstevel@tonic-gate!
85*7c478bd9Sstevel@tonic-gate	RTENTRY(.ld_float)
86*7c478bd9Sstevel@tonic-gate	save	%sp,-SA(MINFRAME+8),%sp
87*7c478bd9Sstevel@tonic-gate	andcc	%i0,1,%g0	! test for short alignment
88*7c478bd9Sstevel@tonic-gate	be,a	1f
89*7c478bd9Sstevel@tonic-gate	lduh	[%i0],%o0	! short aligned case: 2 loads, 2 stores
90*7c478bd9Sstevel@tonic-gate!
91*7c478bd9Sstevel@tonic-gate	ldub	[%i0],%o0	! byte aligned case: 4 loads, 4 stores
92*7c478bd9Sstevel@tonic-gate	ldub	[%i0+1],%o1
93*7c478bd9Sstevel@tonic-gate	ldub	[%i0+2],%o2
94*7c478bd9Sstevel@tonic-gate	ldub	[%i0+3],%o3
95*7c478bd9Sstevel@tonic-gate	stb	%o0,[%fp-4]
96*7c478bd9Sstevel@tonic-gate	stb	%o1,[%fp-3]
97*7c478bd9Sstevel@tonic-gate	stb	%o2,[%fp-2]
98*7c478bd9Sstevel@tonic-gate	b	2f
99*7c478bd9Sstevel@tonic-gate	stb	%o3,[%fp-1]
100*7c478bd9Sstevel@tonic-gate1:
101*7c478bd9Sstevel@tonic-gate	lduh	[%i0+2],%o1	! rest of short aligned case
102*7c478bd9Sstevel@tonic-gate	sth	%o0,[%fp-4]
103*7c478bd9Sstevel@tonic-gate	sth	%o1,[%fp-2]
104*7c478bd9Sstevel@tonic-gate2:
105*7c478bd9Sstevel@tonic-gate	ld	[%fp-4],%f0	! load FPU reg, done
106*7c478bd9Sstevel@tonic-gate	ret
107*7c478bd9Sstevel@tonic-gate	restore
108*7c478bd9Sstevel@tonic-gate	SET_SIZE(.ld_float)
109*7c478bd9Sstevel@tonic-gate
110*7c478bd9Sstevel@tonic-gate!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111*7c478bd9Sstevel@tonic-gate
112*7c478bd9Sstevel@tonic-gate!
113*7c478bd9Sstevel@tonic-gate! double ld_double(p)
114*7c478bd9Sstevel@tonic-gate! char *p;
115*7c478bd9Sstevel@tonic-gate! {
116*7c478bd9Sstevel@tonic-gate!	/* load 64-bit float from misaligned address */
117*7c478bd9Sstevel@tonic-gate! }
118*7c478bd9Sstevel@tonic-gate!
119*7c478bd9Sstevel@tonic-gate	RTENTRY(.ld_double)
120*7c478bd9Sstevel@tonic-gate	save	%sp,-SA(MINFRAME+8),%sp
121*7c478bd9Sstevel@tonic-gate	andcc	%i0,3,%g0	! test for long alignment
122*7c478bd9Sstevel@tonic-gate	be,a	1f		! long aligned case: 2 loads, no stores
123*7c478bd9Sstevel@tonic-gate	ld	[%i0],%f0
124*7c478bd9Sstevel@tonic-gate!
125*7c478bd9Sstevel@tonic-gate	andcc	%i0,1,%g0	! test for short alignment
126*7c478bd9Sstevel@tonic-gate	be,a	2f		! short aligned case: 4 loads, 4 stores
127*7c478bd9Sstevel@tonic-gate	lduh	[%i0],%o0
128*7c478bd9Sstevel@tonic-gate!
129*7c478bd9Sstevel@tonic-gate	ldub	[%i0],%o0	! worst case: byte alignment
130*7c478bd9Sstevel@tonic-gate	ldub	[%i0+1],%o1	! 8 loads, 8 stores
131*7c478bd9Sstevel@tonic-gate	ldub	[%i0+2],%o2
132*7c478bd9Sstevel@tonic-gate	ldub	[%i0+3],%o3
133*7c478bd9Sstevel@tonic-gate	stb	%o0,[%fp-8]
134*7c478bd9Sstevel@tonic-gate	stb	%o1,[%fp-7]
135*7c478bd9Sstevel@tonic-gate	stb	%o2,[%fp-6]
136*7c478bd9Sstevel@tonic-gate	stb	%o3,[%fp-5]
137*7c478bd9Sstevel@tonic-gate	ldub	[%i0+4],%o0
138*7c478bd9Sstevel@tonic-gate	ldub	[%i0+5],%o1
139*7c478bd9Sstevel@tonic-gate	ldub	[%i0+6],%o2
140*7c478bd9Sstevel@tonic-gate	ldub	[%i0+7],%o3
141*7c478bd9Sstevel@tonic-gate	stb	%o0,[%fp-4]
142*7c478bd9Sstevel@tonic-gate	stb	%o1,[%fp-3]
143*7c478bd9Sstevel@tonic-gate	stb	%o2,[%fp-2]
144*7c478bd9Sstevel@tonic-gate	stb	%o3,[%fp-1]
145*7c478bd9Sstevel@tonic-gate	ldd	[%fp-8],%f0	! load f0-f1, done
146*7c478bd9Sstevel@tonic-gate	ret
147*7c478bd9Sstevel@tonic-gate	restore
148*7c478bd9Sstevel@tonic-gate2:
149*7c478bd9Sstevel@tonic-gate	lduh	[%i0+2],%o1	! rest of short aligned case
150*7c478bd9Sstevel@tonic-gate	lduh	[%i0+4],%o2
151*7c478bd9Sstevel@tonic-gate	lduh	[%i0+6],%o3
152*7c478bd9Sstevel@tonic-gate	sth	%o0,[%fp-8]
153*7c478bd9Sstevel@tonic-gate	sth	%o1,[%fp-6]
154*7c478bd9Sstevel@tonic-gate	sth	%o2,[%fp-4]
155*7c478bd9Sstevel@tonic-gate	sth	%o3,[%fp-2]
156*7c478bd9Sstevel@tonic-gate	ldd	[%fp-8],%f0	! load f0-f1, done
157*7c478bd9Sstevel@tonic-gate	ret
158*7c478bd9Sstevel@tonic-gate	restore
159*7c478bd9Sstevel@tonic-gate1:
160*7c478bd9Sstevel@tonic-gate	ld	[%i0+4],%f1	! rest of long aligned case
161*7c478bd9Sstevel@tonic-gate	ret
162*7c478bd9Sstevel@tonic-gate	restore
163*7c478bd9Sstevel@tonic-gate	SET_SIZE(.ld_double)
164*7c478bd9Sstevel@tonic-gate
165*7c478bd9Sstevel@tonic-gate!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
166*7c478bd9Sstevel@tonic-gate
167*7c478bd9Sstevel@tonic-gate!
168*7c478bd9Sstevel@tonic-gate! int st_int(x,p)
169*7c478bd9Sstevel@tonic-gate! int x;
170*7c478bd9Sstevel@tonic-gate! char *p;
171*7c478bd9Sstevel@tonic-gate! {
172*7c478bd9Sstevel@tonic-gate!	/* store 32-bit int from misaligned address;
173*7c478bd9Sstevel@tonic-gate!	   return stored value */
174*7c478bd9Sstevel@tonic-gate! }
175*7c478bd9Sstevel@tonic-gate!
176*7c478bd9Sstevel@tonic-gate	RTENTRY(.st_int)
177*7c478bd9Sstevel@tonic-gate	andcc	%o1,1,%g0	! test for short alignment
178*7c478bd9Sstevel@tonic-gate	be,a	1f
179*7c478bd9Sstevel@tonic-gate	srl	%o0,16,%o4
180*7c478bd9Sstevel@tonic-gate!
181*7c478bd9Sstevel@tonic-gate	srl	%o0,24,%o5	! byte aligned case
182*7c478bd9Sstevel@tonic-gate	stb	%o5,[%o1]
183*7c478bd9Sstevel@tonic-gate	srl	%o0,16,%o2
184*7c478bd9Sstevel@tonic-gate	stb	%o2,[%o1+1]
185*7c478bd9Sstevel@tonic-gate	srl	%o0,8,%o3
186*7c478bd9Sstevel@tonic-gate	stb	%o3,[%o1+2]
187*7c478bd9Sstevel@tonic-gate	retl
188*7c478bd9Sstevel@tonic-gate	stb	%o0,[%o1+3]
189*7c478bd9Sstevel@tonic-gate1:
190*7c478bd9Sstevel@tonic-gate	sth	%o4,[%o1]	! rest of short aligned case
191*7c478bd9Sstevel@tonic-gate	retl
192*7c478bd9Sstevel@tonic-gate	sth	%o0,[%o1+2]
193*7c478bd9Sstevel@tonic-gate	SET_SIZE(.st_int)
194*7c478bd9Sstevel@tonic-gate
195*7c478bd9Sstevel@tonic-gate!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
196*7c478bd9Sstevel@tonic-gate
197*7c478bd9Sstevel@tonic-gate!
198*7c478bd9Sstevel@tonic-gate! float st_float(x,p)
199*7c478bd9Sstevel@tonic-gate! float x;
200*7c478bd9Sstevel@tonic-gate! char *p;
201*7c478bd9Sstevel@tonic-gate! {
202*7c478bd9Sstevel@tonic-gate!	/* store 32-bit float from misaligned address;
203*7c478bd9Sstevel@tonic-gate!	   return stored value */
204*7c478bd9Sstevel@tonic-gate! }
205*7c478bd9Sstevel@tonic-gate!
206*7c478bd9Sstevel@tonic-gate	RTENTRY(.st_float)
207*7c478bd9Sstevel@tonic-gate	save	%sp,-SA(MINFRAME+8),%sp
208*7c478bd9Sstevel@tonic-gate	andcc	%i1,1,%g0	! test for short alignment
209*7c478bd9Sstevel@tonic-gate	be,a	1f		! short aligned case
210*7c478bd9Sstevel@tonic-gate	srl	%i0,16,%o0
211*7c478bd9Sstevel@tonic-gate!
212*7c478bd9Sstevel@tonic-gate	srl	%i0,24,%o0	! byte aligned case
213*7c478bd9Sstevel@tonic-gate	srl	%i0,16,%o1
214*7c478bd9Sstevel@tonic-gate	srl	%i0,8,%o2
215*7c478bd9Sstevel@tonic-gate	stb	%o0,[%i1]
216*7c478bd9Sstevel@tonic-gate	stb	%o1,[%i1+1]
217*7c478bd9Sstevel@tonic-gate	stb	%o2,[%i1+2]
218*7c478bd9Sstevel@tonic-gate	stb	%i0,[%i1+3]
219*7c478bd9Sstevel@tonic-gate	st	%i0,[%fp-4]	! store temp, load f0, done
220*7c478bd9Sstevel@tonic-gate	ld	[%fp-4],%f0
221*7c478bd9Sstevel@tonic-gate	ret
222*7c478bd9Sstevel@tonic-gate	restore
223*7c478bd9Sstevel@tonic-gate1:
224*7c478bd9Sstevel@tonic-gate	sth	%o0,[%i1]	! rest of short aligned case
225*7c478bd9Sstevel@tonic-gate	sth	%i0,[%i1+2]
226*7c478bd9Sstevel@tonic-gate	st	%i0,[%fp-4]
227*7c478bd9Sstevel@tonic-gate	ld	[%fp-4],%f0
228*7c478bd9Sstevel@tonic-gate	ret
229*7c478bd9Sstevel@tonic-gate	restore
230*7c478bd9Sstevel@tonic-gate	SET_SIZE(.st_float)
231*7c478bd9Sstevel@tonic-gate
232*7c478bd9Sstevel@tonic-gate!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
233*7c478bd9Sstevel@tonic-gate
234*7c478bd9Sstevel@tonic-gate!
235*7c478bd9Sstevel@tonic-gate! double st_double(x,p)
236*7c478bd9Sstevel@tonic-gate! double x;
237*7c478bd9Sstevel@tonic-gate! char *p;
238*7c478bd9Sstevel@tonic-gate! {
239*7c478bd9Sstevel@tonic-gate!	/* store 64-bit float from misaligned address;
240*7c478bd9Sstevel@tonic-gate!	   return stored value */
241*7c478bd9Sstevel@tonic-gate! }
242*7c478bd9Sstevel@tonic-gate!
243*7c478bd9Sstevel@tonic-gate	RTENTRY(.st_double)
244*7c478bd9Sstevel@tonic-gate	save	%sp,-SA(MINFRAME+8),%sp
245*7c478bd9Sstevel@tonic-gate	andcc	%i2,3,%g0	! test for long alignment
246*7c478bd9Sstevel@tonic-gate	be,a	1f		! long aligned case: 2 stores, 2 loads
247*7c478bd9Sstevel@tonic-gate	st	%i0,[%i2]
248*7c478bd9Sstevel@tonic-gate!
249*7c478bd9Sstevel@tonic-gate	andcc	%i2,1,%g0	! test for short alignment
250*7c478bd9Sstevel@tonic-gate	be,a	2f		! short aligned case: 4 stores, 4 loads
251*7c478bd9Sstevel@tonic-gate	srl	%i0,16,%o0
252*7c478bd9Sstevel@tonic-gate!				! byte aligned case: the pits
253*7c478bd9Sstevel@tonic-gate	srl	%i0,24,%o0
254*7c478bd9Sstevel@tonic-gate	srl	%i0,16,%o1
255*7c478bd9Sstevel@tonic-gate	srl	%i0,8,%o2
256*7c478bd9Sstevel@tonic-gate	stb	%o0,[%i2]	! store first word, a byte at a time
257*7c478bd9Sstevel@tonic-gate	stb	%o1,[%i2+1]
258*7c478bd9Sstevel@tonic-gate	stb	%o2,[%i2+2]
259*7c478bd9Sstevel@tonic-gate	stb	%i0,[%i2+3]
260*7c478bd9Sstevel@tonic-gate	srl	%i1,24,%o0
261*7c478bd9Sstevel@tonic-gate	srl	%i1,16,%o1
262*7c478bd9Sstevel@tonic-gate	srl	%i1,8,%o2
263*7c478bd9Sstevel@tonic-gate	stb	%o0,[%i2+4]	! store second word, a byte at a time
264*7c478bd9Sstevel@tonic-gate	stb	%o1,[%i2+5]
265*7c478bd9Sstevel@tonic-gate	stb	%o2,[%i2+6]
266*7c478bd9Sstevel@tonic-gate	stb	%i1,[%i2+7]
267*7c478bd9Sstevel@tonic-gate	std	%i0,[%fp-8]	! since dest is misaligned, must use temp
268*7c478bd9Sstevel@tonic-gate	ldd	[%fp-8],%f0	! load f0,f1 from double-aligned temp, done
269*7c478bd9Sstevel@tonic-gate	ret
270*7c478bd9Sstevel@tonic-gate	restore
271*7c478bd9Sstevel@tonic-gate2:				! rest of short aligned case
272*7c478bd9Sstevel@tonic-gate	srl	%i1,16,%o1
273*7c478bd9Sstevel@tonic-gate	sth	%o0,[%i2]	! store two words, a half word at a time
274*7c478bd9Sstevel@tonic-gate	sth	%i0,[%i2+2]
275*7c478bd9Sstevel@tonic-gate	sth	%o1,[%i2+4]
276*7c478bd9Sstevel@tonic-gate	sth	%i1,[%i2+6]
277*7c478bd9Sstevel@tonic-gate	std	%i0,[%fp-8]	! since dest is misaligned, must use temp
278*7c478bd9Sstevel@tonic-gate	ldd	[%fp-8],%f0	! load f0,f1 from double-aligned temp, done
279*7c478bd9Sstevel@tonic-gate	ret
280*7c478bd9Sstevel@tonic-gate	restore
281*7c478bd9Sstevel@tonic-gate1:				! rest of long aligned case
282*7c478bd9Sstevel@tonic-gate	st	%i1,[%i2+4]
283*7c478bd9Sstevel@tonic-gate	ld	[%i2],%f0	! load f0,f1 from long-aligned memory, done
284*7c478bd9Sstevel@tonic-gate	ld	[%i2+4],%f1
285*7c478bd9Sstevel@tonic-gate	ret
286*7c478bd9Sstevel@tonic-gate	restore
287*7c478bd9Sstevel@tonic-gate	SET_SIZE(.st_double)
288*7c478bd9Sstevel@tonic-gate
289*7c478bd9Sstevel@tonic-gate!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
290*7c478bd9Sstevel@tonic-gate
291*7c478bd9Sstevel@tonic-gate!
292*7c478bd9Sstevel@tonic-gate! void st_float_foreff(x,p)
293*7c478bd9Sstevel@tonic-gate! float x;
294*7c478bd9Sstevel@tonic-gate! char *p;
295*7c478bd9Sstevel@tonic-gate! {
296*7c478bd9Sstevel@tonic-gate!	/* store 32-bit float from misaligned address */
297*7c478bd9Sstevel@tonic-gate! }
298*7c478bd9Sstevel@tonic-gate!
299*7c478bd9Sstevel@tonic-gate	RTENTRY(.st_float_foreff)
300*7c478bd9Sstevel@tonic-gate	andcc	%o1,1,%g0	! test for short alignment
301*7c478bd9Sstevel@tonic-gate	be,a	1f
302*7c478bd9Sstevel@tonic-gate	srl	%o0,16,%o2
303*7c478bd9Sstevel@tonic-gate!
304*7c478bd9Sstevel@tonic-gate	srl	%o0,24,%o2	! byte aligned case
305*7c478bd9Sstevel@tonic-gate	srl	%o0,16,%o3
306*7c478bd9Sstevel@tonic-gate	srl	%o0,8,%o4
307*7c478bd9Sstevel@tonic-gate	stb	%o2,[%o1]
308*7c478bd9Sstevel@tonic-gate	stb	%o3,[%o1+1]
309*7c478bd9Sstevel@tonic-gate	stb	%o4,[%o1+2]
310*7c478bd9Sstevel@tonic-gate	retl
311*7c478bd9Sstevel@tonic-gate	stb	%o0,[%o1+3]
312*7c478bd9Sstevel@tonic-gate1:				! rest of short aligned case
313*7c478bd9Sstevel@tonic-gate	sth	%o2,[%o1]
314*7c478bd9Sstevel@tonic-gate	retl
315*7c478bd9Sstevel@tonic-gate	sth	%o0,[%o1+2]
316*7c478bd9Sstevel@tonic-gate	SET_SIZE(.st_float_foreff)
317*7c478bd9Sstevel@tonic-gate
318*7c478bd9Sstevel@tonic-gate!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
319*7c478bd9Sstevel@tonic-gate
320*7c478bd9Sstevel@tonic-gate!
321*7c478bd9Sstevel@tonic-gate! void st_double_foreff(x,p)
322*7c478bd9Sstevel@tonic-gate! double x;
323*7c478bd9Sstevel@tonic-gate! char *p;
324*7c478bd9Sstevel@tonic-gate! {
325*7c478bd9Sstevel@tonic-gate!	/* store 64-bit float from misaligned address;
326*7c478bd9Sstevel@tonic-gate!	   return stored value */
327*7c478bd9Sstevel@tonic-gate! }
328*7c478bd9Sstevel@tonic-gate!
329*7c478bd9Sstevel@tonic-gate	RTENTRY(.st_double_foreff)
330*7c478bd9Sstevel@tonic-gate	andcc	%o2,3,%g0	! test for long alignment
331*7c478bd9Sstevel@tonic-gate	be,a	1f		! long aligned case: 2 stores
332*7c478bd9Sstevel@tonic-gate	st	%o0,[%o2]
333*7c478bd9Sstevel@tonic-gate!
334*7c478bd9Sstevel@tonic-gate	andcc	%o2,1,%g0	! test for short alignment
335*7c478bd9Sstevel@tonic-gate	be,a	2f		! short aligned case: 4 stores
336*7c478bd9Sstevel@tonic-gate	srl	%o0,16,%o3
337*7c478bd9Sstevel@tonic-gate!
338*7c478bd9Sstevel@tonic-gate	srl	%o0,24,%o3	! byte aligned case: 8 stores
339*7c478bd9Sstevel@tonic-gate	srl	%o0,16,%o4
340*7c478bd9Sstevel@tonic-gate	srl	%o0,8,%o5
341*7c478bd9Sstevel@tonic-gate	stb	%o3,[%o2]
342*7c478bd9Sstevel@tonic-gate	stb	%o4,[%o2+1]
343*7c478bd9Sstevel@tonic-gate	stb	%o5,[%o2+2]
344*7c478bd9Sstevel@tonic-gate	stb	%o0,[%o2+3]
345*7c478bd9Sstevel@tonic-gate	srl	%o1,24,%o3
346*7c478bd9Sstevel@tonic-gate	srl	%o1,16,%o4
347*7c478bd9Sstevel@tonic-gate	srl	%o1,8,%o5
348*7c478bd9Sstevel@tonic-gate	stb	%o3,[%o2+4]
349*7c478bd9Sstevel@tonic-gate	stb	%o4,[%o2+5]
350*7c478bd9Sstevel@tonic-gate	stb	%o5,[%o2+6]
351*7c478bd9Sstevel@tonic-gate	retl
352*7c478bd9Sstevel@tonic-gate	stb	%o1,[%o2+7]
353*7c478bd9Sstevel@tonic-gate2:				! rest of short aligned case
354*7c478bd9Sstevel@tonic-gate	srl	%o1,16,%o4
355*7c478bd9Sstevel@tonic-gate	sth	%o3,[%o2]
356*7c478bd9Sstevel@tonic-gate	sth	%o0,[%o2+2]
357*7c478bd9Sstevel@tonic-gate	sth	%o4,[%o2+4]
358*7c478bd9Sstevel@tonic-gate	retl
359*7c478bd9Sstevel@tonic-gate	sth	%o1,[%o2+6]
360*7c478bd9Sstevel@tonic-gate1:				! rest of long aligned case
361*7c478bd9Sstevel@tonic-gate	retl
362*7c478bd9Sstevel@tonic-gate	st	%o1,[%o2+4]
363*7c478bd9Sstevel@tonic-gate	SET_SIZE(.st_double_foreff)
364