xref: /titanic_41/usr/src/lib/libc/sparc/threads/sparc.il (revision 948f2876ce2a3010558f4f6937e16086ebcd36f2)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#pragma ident	"%Z%%M%	%I%	%E% SMI"
27
28	.inline	_curthread, 0
29	.register %g7, #scratch
30	mov	%g7, %o0
31	.end
32
33	.inline	__curthread, 0
34	.register %g7, #scratch
35	ld	[%g7 + 80], %o0		! ul_self
36	.end
37
38	.inline	stkptr, 0
39	mov	%sp, %o0
40	.end
41
42	.inline	gethrtime, 0
43	ta	0x24
44	.end
45
46	.inline	set_lock_byte, 0
47	ldstub	[%o0], %o0
48	.end
49
50	/*
51	 * When compiling with -xarch=v8, the compiler refuses to
52	 * accept the 'cas' instruction, so we encode it in hex below.
53	 * We can't compile the 32-bit libc with -xarch=v8plus because
54	 * then %g5 would become a scratch register and we would break
55	 * 32-bit applications that use %g5 as an invariant register.
56	 */
57
58	.inline	cas32, 0
59	.word	0xd5e21009	! cas [%o0], %o1, %o2
60	mov	%o2, %o0
61	.end
62
63	.inline	swap32, 0
64	ld	[%o0], %o2
651:
66	mov	%o1, %o3
67	.word	0xd7e2100a	! cas [%o0], %o2, %o3
68	cmp	%o2, %o3
69	bne,a	1b
70	  mov	%o3, %o2
71	mov	%o3, %o0
72	.end
73
74	.inline	incr32, 0
75	ld	[%o0], %o2
761:
77	add	%o2, 1, %o3
78	.word	0xd7e2100a	! cas [%o0], %o2, %o3
79	cmp	%o2, %o3
80	bne,a	1b
81	  mov	%o3, %o2
82	.end
83
84	.inline	decr32, 0
85	ld	[%o0], %o2
861:
87	sub	%o2, 1, %o3
88	.word	0xd7e2100a	! cas [%o0], %o2, %o3
89	cmp	%o2, %o3
90	bne,a	1b
91	  mov	%o3, %o2
92	.end
93
94	.inline	caller, 0
95	mov	%i7, %o0
96	.end
97
98	.inline	getfp, 0
99	mov	%fp, %o0
100	.end
101