17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57257d1braf * Common Development and Distribution License (the "License").
67257d1braf * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217257d1braf
227257d1braf/*
237257d1braf * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247257d1braf * Use is subject to license terms.
257257d1braf */
267257d1braf
277c478bdstevel@tonic-gate/*	Copyright (c) 1988 AT&T	*/
287c478bdstevel@tonic-gate/*	  All Rights Reserved	*/
297c478bdstevel@tonic-gate
309a70fc3Mark J. Nelson	.file	"lshiftl.s"
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate/*
337c478bdstevel@tonic-gate * Shift a double long value. Ported from m32 version to sparc.
347c478bdstevel@tonic-gate *
357c478bdstevel@tonic-gate *	dl_t
367c478bdstevel@tonic-gate *	lshiftl (op, cnt)
377c478bdstevel@tonic-gate *		dl_t	op;
387c478bdstevel@tonic-gate *		int	cnt;
397c478bdstevel@tonic-gate */
407c478bdstevel@tonic-gate
417257d1braf#include "SYS.h"
427c478bdstevel@tonic-gate
437c478bdstevel@tonic-gate	ENTRY(lshiftl)
447c478bdstevel@tonic-gate
457c478bdstevel@tonic-gate	ld	[%o7+8],%o4		! Instruction at ret-addr should be a
467c478bdstevel@tonic-gate	cmp     %o4,8			! 'unimp 8' indicating a valid call.
477c478bdstevel@tonic-gate	be	1f			! if OK, go forward.
487c478bdstevel@tonic-gate	nop				! delay instruction.
497c478bdstevel@tonic-gate	jmp	%o7+8			! return
507c478bdstevel@tonic-gate	nop				! delay instruction.
517c478bdstevel@tonic-gate
527c478bdstevel@tonic-gate1:
537c478bdstevel@tonic-gate	ld	[%o0+0],%o2		! fetch op.dl_hop
547c478bdstevel@tonic-gate	ld	[%o0+4],%o3		! fetch op.dl_lop
557c478bdstevel@tonic-gate	subcc	%g0,%o1,%o4		! test cnt < 0 and save reciprocol
567c478bdstevel@tonic-gate	bz	.done
577c478bdstevel@tonic-gate	ld	[%sp+(16*4)],%o0	! address to store result into
587c478bdstevel@tonic-gate	bg	.right			!
597c478bdstevel@tonic-gate	nop
607c478bdstevel@tonic-gate					! Positive (or null) shift (left)
617c478bdstevel@tonic-gate	and	%o1,0x3f,%o1		! Reduce range to 0..63
627c478bdstevel@tonic-gate	subcc	%o1,32,%o5		! cnt - 32 (also test cnt >= 32)
637c478bdstevel@tonic-gate	bneg,a	.leftsmall		!
647c478bdstevel@tonic-gate	add	%o4,32,%o4		! 32 - cnt (actually ((-cnt) + 32)
657c478bdstevel@tonic-gate	sll	%o3,%o5,%o2		! R.h = R.l << (cnt - 32)
667c478bdstevel@tonic-gate	ba	.done			!
677c478bdstevel@tonic-gate	or	%g0,%g0,%o3		! R.l = 0
687c478bdstevel@tonic-gate
697c478bdstevel@tonic-gate.leftsmall:
707c478bdstevel@tonic-gate	srl	%o3,%o4,%o5		! temp = R.l >> (31 - cnt)
717c478bdstevel@tonic-gate	sll	%o3,%o1,%o3		! R.l = R.l << cnt
727c478bdstevel@tonic-gate	sll	%o2,%o1,%o2		! R.h = R.h << cnt
737c478bdstevel@tonic-gate	ba	.done			!
747c478bdstevel@tonic-gate	or	%o2,%o5,%o2		! R.h = R.h | temp
757c478bdstevel@tonic-gate
767c478bdstevel@tonic-gate.right:					! Negative shift (right)
777c478bdstevel@tonic-gate	and	%o4,0x3f,%o4		! Reduce range to 0..63
787c478bdstevel@tonic-gate	subcc	%o4,32,%o5		! cnt - 32 (also test cnt >= 32)
797c478bdstevel@tonic-gate	bneg,a	.rightsmall		!
807c478bdstevel@tonic-gate	add	%o1,32,%o1		! 32 - cnt (actually ((-cnt) + 32)
817c478bdstevel@tonic-gate	srl	%o2,%o5,%o3		! R.l = R.h >> (cnt - 32)
827c478bdstevel@tonic-gate	ba	.done			!
837c478bdstevel@tonic-gate	or	%g0,%g0,%o2		! R.h = 0
847c478bdstevel@tonic-gate
857c478bdstevel@tonic-gate.rightsmall:
867c478bdstevel@tonic-gate	sll	%o2,%o1,%o5		! temp = R.h << (31 - cnt)
877c478bdstevel@tonic-gate	srl	%o3,%o4,%o3		! R.l = R.l >> cnt
887c478bdstevel@tonic-gate	srl	%o2,%o4,%o2		! R.h = R.h >> cnt
897c478bdstevel@tonic-gate	ba	.done			!
907c478bdstevel@tonic-gate	or	%o3,%o5,%o3		! R.l = R.l | temp
917c478bdstevel@tonic-gate
927c478bdstevel@tonic-gate.done:
937c478bdstevel@tonic-gate	st	%o2,[%o0+0]		! store result, dl_hop
947c478bdstevel@tonic-gate	jmp	%o7+12			! return
957c478bdstevel@tonic-gate	st	%o3,[%o0+4]		! store result, dl_lop
967c478bdstevel@tonic-gate
977c478bdstevel@tonic-gate	SET_SIZE(lshiftl)
98