125184Sjkh # Alpha 21064 __udiv_qrnnd
225184Sjkh # Copyright (C) 1992, 1994, 1995, 2000 Free Software Foundation, Inc.
334395Sjkh
425184Sjkh # This file is part of GCC.
525184Sjkh
625184Sjkh # The GNU MP Library is free software; you can redistribute it and/or modify
725184Sjkh # it under the terms of the GNU General Public License as published by
825184Sjkh # the Free Software Foundation; either version 2 of the License, or (at your
925184Sjkh # option) any later version.
1025184Sjkh
1125184Sjkh # In addition to the permissions in the GNU General Public License, the
1225184Sjkh # Free Software Foundation gives you unlimited permission to link the
1325184Sjkh # compiled version of this file with other programs, and to distribute
1425184Sjkh # those programs without any restriction coming from the use of this
1525184Sjkh # file.  (The General Public License restrictions do apply in other
1625184Sjkh # respects; for example, they cover modification of the file, and
1725184Sjkh # distribution when not linked into another program.)
1825184Sjkh
1925184Sjkh # This file is distributed in the hope that it will be useful, but
2025184Sjkh # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2125184Sjkh # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
2225184Sjkh # License for more details.
2325184Sjkh
2425184Sjkh # You should have received a copy of the GNU General Public License
2525184Sjkh # along with GCC; see the file COPYING.  If not, write to the
2625184Sjkh # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
2725184Sjkh # MA 02111-1307, USA.
2825184Sjkh#include <linux/export.h>
2925184Sjkh
3025184Sjkh        .set noreorder
3133682Sbrian        .set noat
3225184Sjkh
3325184Sjkh	.text
3425184Sjkh
3525184Sjkh	.globl __udiv_qrnnd
3625184Sjkh	.ent __udiv_qrnnd
3725184Sjkh__udiv_qrnnd:
3825184Sjkh	.frame $30,0,$26,0
3925184Sjkh	.prologue 0
4025184Sjkh
4125184Sjkh#define cnt	$2
4225184Sjkh#define tmp	$3
4325184Sjkh#define rem_ptr	$16
4425184Sjkh#define n1	$17
4525184Sjkh#define n0	$18
4625184Sjkh#define d	$19
4725184Sjkh#define qb	$20
4825184Sjkh#define AT	$at
4925184Sjkh
5025184Sjkh	ldiq	cnt,16
5125184Sjkh	blt	d,$largedivisor
5225184Sjkh
5325184Sjkh$loop1:	cmplt	n0,0,tmp
5425184Sjkh	addq	n1,n1,n1
5525184Sjkh	bis	n1,tmp,n1
5625184Sjkh	addq	n0,n0,n0
5729300Sdanny	cmpule	d,n1,qb
5829300Sdanny	subq	n1,d,tmp
5929300Sdanny	cmovne	qb,tmp,n1
6029300Sdanny	bis	n0,qb,n0
6132382Salex	cmplt	n0,0,tmp
6232382Salex	addq	n1,n1,n1
6332382Salex	bis	n1,tmp,n1
6429300Sdanny	addq	n0,n0,n0
6529300Sdanny	cmpule	d,n1,qb
6629300Sdanny	subq	n1,d,tmp
6729300Sdanny	cmovne	qb,tmp,n1
6829300Sdanny	bis	n0,qb,n0
6929300Sdanny	cmplt	n0,0,tmp
7029300Sdanny	addq	n1,n1,n1
7129300Sdanny	bis	n1,tmp,n1
7229300Sdanny	addq	n0,n0,n0
7329300Sdanny	cmpule	d,n1,qb
7429300Sdanny	subq	n1,d,tmp
7529300Sdanny	cmovne	qb,tmp,n1
7629300Sdanny	bis	n0,qb,n0
7729300Sdanny	cmplt	n0,0,tmp
7829300Sdanny	addq	n1,n1,n1
7929300Sdanny	bis	n1,tmp,n1
8029300Sdanny	addq	n0,n0,n0
8125364Sjkh	cmpule	d,n1,qb
8229300Sdanny	subq	n1,d,tmp
8329300Sdanny	cmovne	qb,tmp,n1
8433337Salex	bis	n0,qb,n0
8533337Salex	subq	cnt,1,cnt
8633149Salex	bgt	cnt,$loop1
8733149Salex	stq	n1,0(rem_ptr)
8833149Salex	bis	$31,n0,$0
8933149Salex	ret	$31,($26),1
9029300Sdanny
9125184Sjkh$largedivisor:
9225184Sjkh	and	n0,1,$4
9329300Sdanny
9429300Sdanny	srl	n0,1,n0
9525184Sjkh	sll	n1,63,tmp
9625184Sjkh	or	tmp,n0,n0
9725184Sjkh	srl	n1,1,n1
9825184Sjkh
9925184Sjkh	and	d,1,$6
10025184Sjkh	srl	d,1,$5
10125184Sjkh	addq	$5,$6,$5
10225184Sjkh
10325184Sjkh$loop2:	cmplt	n0,0,tmp
10425184Sjkh	addq	n1,n1,n1
10525184Sjkh	bis	n1,tmp,n1
10625184Sjkh	addq	n0,n0,n0
10725184Sjkh	cmpule	$5,n1,qb
10825184Sjkh	subq	n1,$5,tmp
10927218Spst	cmovne	qb,tmp,n1
11027218Spst	bis	n0,qb,n0
11127218Spst	cmplt	n0,0,tmp
11227218Spst	addq	n1,n1,n1
11327218Spst	bis	n1,tmp,n1
11427218Spst	addq	n0,n0,n0
11525184Sjkh	cmpule	$5,n1,qb
11625365Sjkh	subq	n1,$5,tmp
11725184Sjkh	cmovne	qb,tmp,n1
11825184Sjkh	bis	n0,qb,n0
11925184Sjkh	cmplt	n0,0,tmp
12033439Sguido	addq	n1,n1,n1
12133439Sguido	bis	n1,tmp,n1
12233439Sguido	addq	n0,n0,n0
12333439Sguido	cmpule	$5,n1,qb
12433439Sguido	subq	n1,$5,tmp
12533439Sguido	cmovne	qb,tmp,n1
12633439Sguido	bis	n0,qb,n0
12733439Sguido	cmplt	n0,0,tmp
12833439Sguido	addq	n1,n1,n1
12933439Sguido	bis	n1,tmp,n1
13025184Sjkh	addq	n0,n0,n0
13125184Sjkh	cmpule	$5,n1,qb
13225184Sjkh	subq	n1,$5,tmp
13325184Sjkh	cmovne	qb,tmp,n1
13425184Sjkh	bis	n0,qb,n0
13525365Sjkh	subq	cnt,1,cnt
13625184Sjkh	bgt	cnt,$loop2
13725184Sjkh
13825184Sjkh	addq	n1,n1,n1
13925184Sjkh	addq	$4,n1,n1
14025184Sjkh	bne	$6,$Odd
14125184Sjkh	stq	n1,0(rem_ptr)
14225184Sjkh	bis	$31,n0,$0
14325765Sjkh	ret	$31,($26),1
14425765Sjkh
14525765Sjkh$Odd:
14625765Sjkh	/* q' in n0. r' in n1 */
14725765Sjkh	addq	n1,n0,n1
14834395Sjkh
14934395Sjkh	cmpult	n1,n0,tmp	# tmp := carry from addq
15034395Sjkh	subq	n1,d,AT
15134395Sjkh	addq	n0,tmp,n0
15225184Sjkh	cmovne	tmp,AT,n1
15325184Sjkh
15425184Sjkh	cmpult	n1,d,tmp
15525184Sjkh	addq	n0,1,AT
15625184Sjkh	cmoveq	tmp,AT,n0
15725184Sjkh	subq	n1,d,AT
15825184Sjkh	cmoveq	tmp,AT,n1
15932949Swollman
16025184Sjkh	stq	n1,0(rem_ptr)
16125184Sjkh	bis	$31,n0,$0
16231472Sobrien	ret	$31,($26),1
16331472Sobrien
16431472Sobrien	.end	__udiv_qrnnd
16525184SjkhEXPORT_SYMBOL(__udiv_qrnnd)
16631472Sobrien