xref: /titanic_41/usr/src/lib/libc/sparc/threads/sparc.il (revision 41efec2219526a9b3ecce26f97aba761ef1e1d0d)
17c478bd9Sstevel@tonic-gate/*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5ae115bc7Smrj * Common Development and Distribution License (the "License").
6ae115bc7Smrj * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate/*
22ae115bc7Smrj * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate	.inline	_curthread, 0
297c478bd9Sstevel@tonic-gate	.register %g7, #scratch
307c478bd9Sstevel@tonic-gate	mov	%g7, %o0
317c478bd9Sstevel@tonic-gate	.end
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate	.inline	__curthread, 0
347c478bd9Sstevel@tonic-gate	.register %g7, #scratch
357c478bd9Sstevel@tonic-gate	ld	[%g7 + 80], %o0		! ul_self
367c478bd9Sstevel@tonic-gate	.end
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate	.inline	stkptr, 0
397c478bd9Sstevel@tonic-gate	mov	%sp, %o0
407c478bd9Sstevel@tonic-gate	.end
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate	.inline	gethrtime, 0
437c478bd9Sstevel@tonic-gate	ta	0x24
447c478bd9Sstevel@tonic-gate	.end
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate	.inline	set_lock_byte, 0
477c478bd9Sstevel@tonic-gate	ldstub	[%o0], %o0
487c478bd9Sstevel@tonic-gate	.end
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate	/*
517c478bd9Sstevel@tonic-gate	 * When compiling with -xarch=v8, the compiler refuses to
527c478bd9Sstevel@tonic-gate	 * accept the 'cas' instruction, so we encode it in hex below.
537c478bd9Sstevel@tonic-gate	 * We can't compile the 32-bit libc with -xarch=v8plus because
547c478bd9Sstevel@tonic-gate	 * then %g5 would become a scratch register and we would break
557c478bd9Sstevel@tonic-gate	 * 32-bit applications that use %g5 as an invariant register.
567c478bd9Sstevel@tonic-gate	 */
577c478bd9Sstevel@tonic-gate
58*41efec22Sraf	.inline	atomic_cas_32, 0
597c478bd9Sstevel@tonic-gate	.word	0xd5e21009	! cas [%o0], %o1, %o2
607c478bd9Sstevel@tonic-gate	mov	%o2, %o0
617c478bd9Sstevel@tonic-gate	.end
627c478bd9Sstevel@tonic-gate
63*41efec22Sraf	.inline	atomic_swap_32, 0
647c478bd9Sstevel@tonic-gate	ld	[%o0], %o2
657c478bd9Sstevel@tonic-gate1:
667c478bd9Sstevel@tonic-gate	mov	%o1, %o3
677c478bd9Sstevel@tonic-gate	.word	0xd7e2100a	! cas [%o0], %o2, %o3
687c478bd9Sstevel@tonic-gate	cmp	%o2, %o3
697c478bd9Sstevel@tonic-gate	bne,a	1b
707c478bd9Sstevel@tonic-gate	  mov	%o3, %o2
717c478bd9Sstevel@tonic-gate	mov	%o3, %o0
727c478bd9Sstevel@tonic-gate	.end
737c478bd9Sstevel@tonic-gate
74*41efec22Sraf	.inline	atomic_inc_32, 0
757c478bd9Sstevel@tonic-gate	ld	[%o0], %o2
767c478bd9Sstevel@tonic-gate1:
777c478bd9Sstevel@tonic-gate	add	%o2, 1, %o3
787c478bd9Sstevel@tonic-gate	.word	0xd7e2100a	! cas [%o0], %o2, %o3
797c478bd9Sstevel@tonic-gate	cmp	%o2, %o3
807c478bd9Sstevel@tonic-gate	bne,a	1b
817c478bd9Sstevel@tonic-gate	  mov	%o3, %o2
827c478bd9Sstevel@tonic-gate	.end
837c478bd9Sstevel@tonic-gate
84*41efec22Sraf	.inline	atomic_dec_32, 0
857c478bd9Sstevel@tonic-gate	ld	[%o0], %o2
867c478bd9Sstevel@tonic-gate1:
877c478bd9Sstevel@tonic-gate	sub	%o2, 1, %o3
887c478bd9Sstevel@tonic-gate	.word	0xd7e2100a	! cas [%o0], %o2, %o3
897c478bd9Sstevel@tonic-gate	cmp	%o2, %o3
907c478bd9Sstevel@tonic-gate	bne,a	1b
917c478bd9Sstevel@tonic-gate	  mov	%o3, %o2
927c478bd9Sstevel@tonic-gate	.end
937c478bd9Sstevel@tonic-gate
94*41efec22Sraf	.inline	atomic_and_32, 0
95*41efec22Sraf	ld	[%o0], %o2
96*41efec22Sraf1:
97*41efec22Sraf	and	%o2, %o1, %o3
98*41efec22Sraf	.word	0xd7e2100a	! cas [%o0], %o2, %o3
99*41efec22Sraf	cmp	%o2, %o3
100*41efec22Sraf	bne,a	1b
101*41efec22Sraf	  mov	%o3, %o2
102*41efec22Sraf	.end
103*41efec22Sraf
104*41efec22Sraf	.inline	atomic_or_32, 0
105*41efec22Sraf	ld	[%o0], %o2
106*41efec22Sraf1:
107*41efec22Sraf	or	%o2, %o1, %o3
108*41efec22Sraf	.word	0xd7e2100a	! cas [%o0], %o2, %o3
109*41efec22Sraf	cmp	%o2, %o3
110*41efec22Sraf	bne,a	1b
111*41efec22Sraf	  mov	%o3, %o2
112*41efec22Sraf	.end
113*41efec22Sraf
1147c478bd9Sstevel@tonic-gate	.inline	caller, 0
1157c478bd9Sstevel@tonic-gate	mov	%i7, %o0
1167c478bd9Sstevel@tonic-gate	.end
1177c478bd9Sstevel@tonic-gate
1187c478bd9Sstevel@tonic-gate	.inline	getfp, 0
1197c478bd9Sstevel@tonic-gate	mov	%fp, %o0
1207c478bd9Sstevel@tonic-gate	.end
121