xref: /titanic_52/usr/src/lib/libc/sparc/crt/stret.s (revision 0eb822a1c0c2bea495647510b75f77f0e57633eb)
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, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright (c) 1987 Sun Microsystems, Inc.
24 */
25
26#ident	"%Z%%M%	%I%	%E% SMI"
27
28	.file	"stret.s"
29
30#include <sys/asm_linkage.h>
31
32#define FROM	%o0
33#define SIZE	%o1
34#define TO	%i0
35#define MEMWORD	%o3	/* use o-registers as temps */
36#define TEMP	%o4
37#define TEMP2	%o5
38#define UNIMP	0
39#define MASK	0x00000fff
40#define STRUCT_VAL_OFF	(16*4)
41#if STRET4
42#    define BYTES_PER_MOVE	4
43#    define LD	ld
44#    define ST	st
45	ENTRY2(.stret4,.stret8)
46#endif
47#if STRET2
48#    define BYTES_PER_MOVE	2
49#    define LD	lduh
50#    define ST	sth
51	ENTRY(.stret2)
52#endif
53#if STRET1
54#    define BYTES_PER_MOVE	1
55#    define LD	ldub
56#    define ST	stb
57	ENTRY(.stret1)
58#endif
59
60	/*
61	 * see if key matches: if not,
62	 * structure value not expected,
63	 * so just return
64	 */
65	ld	[%i7+8],MEMWORD
66	and	SIZE,MASK,TEMP
67	sethi	%hi(UNIMP),TEMP2
68	or      TEMP,TEMP2,TEMP2
69	cmp     TEMP2,MEMWORD
70	bne	.LE12
71	.empty
72	/*
73	 * set expected return value
74	 */
75.L14:
76	ld	[%fp+STRUCT_VAL_OFF],TO		/* (DELAY SLOT) */
77	/*
78	 * copy the struct using the same loop the compiler does
79	 * for large structure assignment
80	 */
81.L15:
82	subcc	SIZE,BYTES_PER_MOVE,SIZE
83	LD	[FROM+SIZE],TEMP
84	bg	.L15
85	ST	TEMP,[TO+SIZE]			/* (DELAY SLOT) */
86	/* bump return address */
87	add	%i7,0x4,%i7
88.LE12:
89	jmp	%i7+8
90	restore
91
92#if STRET4
93	SET_SIZE(.stret4)
94	SET_SIZE(.stret8)
95#endif
96#if STRET2
97	SET_SIZE(.stret2)
98#endif
99#if STRET1
100	SET_SIZE(.stret1)
101#endif
102