xref: /illumos-gate/usr/src/lib/libc/sparc/crt/stret.S (revision 55fea89d)
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
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate/*
237c478bd9Sstevel@tonic-gate * Copyright (c) 1987 Sun Microsystems, Inc.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate	.file	"stret.s"
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate#define FROM	%o0
337c478bd9Sstevel@tonic-gate#define SIZE	%o1
347c478bd9Sstevel@tonic-gate#define TO	%i0
357c478bd9Sstevel@tonic-gate#define MEMWORD	%o3	/* use o-registers as temps */
367c478bd9Sstevel@tonic-gate#define TEMP	%o4
377c478bd9Sstevel@tonic-gate#define TEMP2	%o5
387c478bd9Sstevel@tonic-gate#define UNIMP	0
397c478bd9Sstevel@tonic-gate#define MASK	0x00000fff
407c478bd9Sstevel@tonic-gate#define STRUCT_VAL_OFF	(16*4)
417c478bd9Sstevel@tonic-gate#if STRET4
427c478bd9Sstevel@tonic-gate#    define BYTES_PER_MOVE	4
437c478bd9Sstevel@tonic-gate#    define LD	ld
447c478bd9Sstevel@tonic-gate#    define ST	st
457c478bd9Sstevel@tonic-gate	ENTRY2(.stret4,.stret8)
467c478bd9Sstevel@tonic-gate#endif
477c478bd9Sstevel@tonic-gate#if STRET2
487c478bd9Sstevel@tonic-gate#    define BYTES_PER_MOVE	2
497c478bd9Sstevel@tonic-gate#    define LD	lduh
507c478bd9Sstevel@tonic-gate#    define ST	sth
517c478bd9Sstevel@tonic-gate	ENTRY(.stret2)
527c478bd9Sstevel@tonic-gate#endif
537c478bd9Sstevel@tonic-gate#if STRET1
547c478bd9Sstevel@tonic-gate#    define BYTES_PER_MOVE	1
557c478bd9Sstevel@tonic-gate#    define LD	ldub
567c478bd9Sstevel@tonic-gate#    define ST	stb
577c478bd9Sstevel@tonic-gate	ENTRY(.stret1)
587c478bd9Sstevel@tonic-gate#endif
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate	/*
617c478bd9Sstevel@tonic-gate	 * see if key matches: if not,
627c478bd9Sstevel@tonic-gate	 * structure value not expected,
637c478bd9Sstevel@tonic-gate	 * so just return
647c478bd9Sstevel@tonic-gate	 */
657c478bd9Sstevel@tonic-gate	ld	[%i7+8],MEMWORD
667c478bd9Sstevel@tonic-gate	and	SIZE,MASK,TEMP
677c478bd9Sstevel@tonic-gate	sethi	%hi(UNIMP),TEMP2
687c478bd9Sstevel@tonic-gate	or      TEMP,TEMP2,TEMP2
697c478bd9Sstevel@tonic-gate	cmp     TEMP2,MEMWORD
707c478bd9Sstevel@tonic-gate	bne	.LE12
717c478bd9Sstevel@tonic-gate	.empty
727c478bd9Sstevel@tonic-gate	/*
737c478bd9Sstevel@tonic-gate	 * set expected return value
747c478bd9Sstevel@tonic-gate	 */
757c478bd9Sstevel@tonic-gate.L14:
767c478bd9Sstevel@tonic-gate	ld	[%fp+STRUCT_VAL_OFF],TO		/* (DELAY SLOT) */
77*55fea89dSDan Cross	/*
787c478bd9Sstevel@tonic-gate	 * copy the struct using the same loop the compiler does
797c478bd9Sstevel@tonic-gate	 * for large structure assignment
807c478bd9Sstevel@tonic-gate	 */
817c478bd9Sstevel@tonic-gate.L15:
827c478bd9Sstevel@tonic-gate	subcc	SIZE,BYTES_PER_MOVE,SIZE
837c478bd9Sstevel@tonic-gate	LD	[FROM+SIZE],TEMP
847c478bd9Sstevel@tonic-gate	bg	.L15
857c478bd9Sstevel@tonic-gate	ST	TEMP,[TO+SIZE]			/* (DELAY SLOT) */
867c478bd9Sstevel@tonic-gate	/* bump return address */
877c478bd9Sstevel@tonic-gate	add	%i7,0x4,%i7
887c478bd9Sstevel@tonic-gate.LE12:
897c478bd9Sstevel@tonic-gate	jmp	%i7+8
907c478bd9Sstevel@tonic-gate	restore
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate#if STRET4
937c478bd9Sstevel@tonic-gate	SET_SIZE(.stret4)
947c478bd9Sstevel@tonic-gate	SET_SIZE(.stret8)
957c478bd9Sstevel@tonic-gate#endif
967c478bd9Sstevel@tonic-gate#if STRET2
977c478bd9Sstevel@tonic-gate	SET_SIZE(.stret2)
987c478bd9Sstevel@tonic-gate#endif
997c478bd9Sstevel@tonic-gate#if STRET1
1007c478bd9Sstevel@tonic-gate	SET_SIZE(.stret1)
1017c478bd9Sstevel@tonic-gate#endif
102