2 ! .asciz ident "%Z%%M% %I% %E% SMI"
6 ! Copyright
2005 Sun Microsystems
, Inc. All rights reserved.
7 ! Use is subject to license terms.
11 ! The contents of this file are subject to the terms of the
12 ! Common Development
and Distribution License
, Version
1.0 only
13 ! (the
"License"). You may not use this file except in compliance
16 ! You can obtain
a copy of the license at usr
/src
/OPENSOLARIS.LICENSE
17 ! or http
://www.opensolaris.org
/os
/licensing.
18 ! See the License for the specific language governing permissions
19 ! and limitations under the License.
21 ! When distributing Covered Code
, include this CDDL HEADER in each
22 ! file
and include the License file at usr
/src
/OPENSOLARIS.LICENSE.
23 ! If applicable
, add the following below this CDDL HEADER
, with the
24 ! fields enclosed by brackets
"[]" replaced with your own identifying
25 ! information
: Portions Copyright
[yyyy
] [name of copyright owner
]
31 ! C library routines for compiler support of misaligned memory
32 ! references. These are called when an in-line test reveals
a
40 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
47 ! * load 32-bit int from misaligned address
48 ! * cost(16-bit aligned case): 9 cycles
49 ! * cost(8-bit aligned case): 18 cycles
54 andcc
%o0
,1,%g0
! test
16-bit alignment
55 be,a 1f
! fast case
: two loads;
56 lduh
[%o0+
2],%o1
! do first one in delay slot
58 ldub
[%o0+
3],%o3
! slow case
: load
4 bytes in
<o0
,o1
,o2
,o3
>
61 ldub
[%o0
],%o0
! note this has to
be done last.
65 or %o1
,%o0
,%o0
! put the pieces together.
70 lduh
[%o0
],%o0
! 2nd half of fast case
71 sll
%o0
,16,%o0
! shift
, concat
, done.
76 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
82 ! /* load 32-bit float (not double!) from misaligned address */
86 save
%sp
,-SA
(MINFRAME+
8),%sp
87 andcc
%i0
,1,%g0
! test for short alignment
89 lduh
[%i0
],%o0
! short aligned case
: 2 loads
, 2 stores
91 ldub
[%i0
],%o0
! byte aligned case
: 4 loads
, 4 stores
101 lduh
[%i0+
2],%o1
! rest of short aligned case
105 ld [%fp-
4],%f0 ! load FPU reg
, done
110 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
113 ! double ld_double
(p
)
116 ! /* load 64-bit float from misaligned address */
120 save
%sp
,-SA
(MINFRAME+
8),%sp
121 andcc
%i0
,3,%g0
! test for long alignment
122 be,a 1f
! long aligned case
: 2 loads
, no stores
125 andcc
%i0
,1,%g0
! test for short alignment
126 be,a 2f
! short aligned case
: 4 loads
, 4 stores
129 ldub
[%i0
],%o0
! worst case
: byte alignment
130 ldub
[%i0+
1],%o1
! 8 loads
, 8 stores
145 ldd
[%fp-
8],%f0 ! load f0-
f1, done
149 lduh
[%i0+
2],%o1
! rest of short aligned case
156 ldd
[%fp-
8],%f0 ! load f0-
f1, done
160 ld [%i0+
4],%f1 ! rest of long aligned case
165 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
172 ! /* store 32-bit int from misaligned address;
173 ! return stored value */
177 andcc
%o1
,1,%g0
! test for short alignment
181 srl
%o0
,24,%o5
! byte aligned case
190 sth %o4
,[%o1
] ! rest of short aligned case
195 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
198 ! float st_float
(x
,p
)
202 ! /* store 32-bit float from misaligned address;
203 ! return stored value */
207 save
%sp
,-SA
(MINFRAME+
8),%sp
208 andcc
%i1
,1,%g0
! test for short alignment
209 be,a 1f
! short aligned case
212 srl
%i0
,24,%o0
! byte aligned case
219 st %i0
,[%fp-
4] ! store temp
, load
f0, done
224 sth %o0
,[%i1
] ! rest of short aligned case
232 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
235 ! double st_double
(x
,p
)
239 ! /* store 64-bit float from misaligned address;
240 ! return stored value */
244 save
%sp
,-SA
(MINFRAME+
8),%sp
245 andcc
%i2
,3,%g0
! test for long alignment
246 be,a 1f
! long aligned case
: 2 stores
, 2 loads
249 andcc
%i2
,1,%g0
! test for short alignment
250 be,a 2f
! short aligned case
: 4 stores
, 4 loads
252 ! ! byte aligned case
: the pits
256 stb %o0
,[%i2
] ! store first word
, a byte at
a time
263 stb %o0
,[%i2+
4] ! store second word
, a byte at
a time
267 std %i0
,[%fp-
8] ! since dest is misaligned
, must use temp
268 ldd
[%fp-
8],%f0 ! load
f0,f1 from double-aligned temp
, done
271 2: ! rest of short aligned case
273 sth %o0
,[%i2
] ! store two words
, a half word at
a time
277 std %i0
,[%fp-
8] ! since dest is misaligned
, must use temp
278 ldd
[%fp-
8],%f0 ! load
f0,f1 from double-aligned temp
, done
281 1: ! rest of long aligned case
283 ld [%i2
],%f0 ! load
f0,f1 from long-aligned memory
, done
289 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
292 ! void st_float_foreff
(x
,p
)
296 ! /* store 32-bit float from misaligned address */
299 RTENTRY
(.st_float_foreff)
300 andcc
%o1
,1,%g0
! test for short alignment
304 srl
%o0
,24,%o2
! byte aligned case
312 1: ! rest of short aligned case
316 SET_SIZE
(.st_float_foreff)
318 !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
321 ! void st_double_foreff
(x
,p
)
325 ! /* store 64-bit float from misaligned address;
326 ! return stored value */
329 RTENTRY
(.st_double_foreff)
330 andcc
%o2
,3,%g0
! test for long alignment
331 be,a 1f
! long aligned case
: 2 stores
334 andcc
%o2
,1,%g0
! test for short alignment
335 be,a 2f
! short aligned case
: 4 stores
338 srl
%o0
,24,%o3
! byte aligned case
: 8 stores
353 2: ! rest of short aligned case
360 1: ! rest of long aligned case
363 SET_SIZE
(.st_double_foreff)