Blame sysdeps/mips/mips64/mul_1.S

Packit 6c4009
/* MIPS3 __mpn_mul_1 -- Multiply a limb vector with a single limb and
Packit 6c4009
 * store the product in a second limb vector.
Packit 6c4009
 *
Packit 6c4009
 * Copyright (C) 1992-2018 Free Software Foundation, Inc.
Packit 6c4009
 *
Packit 6c4009
 * This file is part of the GNU MP Library.
Packit 6c4009
 *
Packit 6c4009
 * The GNU MP Library is free software; you can redistribute it and/or modify
Packit 6c4009
 * it under the terms of the GNU Lesser General Public License as published by
Packit 6c4009
 * the Free Software Foundation; either version 2.1 of the License, or (at your
Packit 6c4009
 * option) any later version.
Packit 6c4009
 *
Packit 6c4009
 * The GNU MP Library is distributed in the hope that it will be useful, but
Packit 6c4009
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 6c4009
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
Packit 6c4009
 * License for more details.
Packit 6c4009
 *
Packit 6c4009
 * You should have received a copy of the GNU Lesser General Public License
Packit 6c4009
 * along with the GNU MP Library.  If not, see
Packit 6c4009
 * <http://www.gnu.org/licenses/>.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
#include <sys/asm.h>
Packit 6c4009
Packit 6c4009
/* INPUT PARAMETERS
Packit 6c4009
 * res_ptr	$4
Packit 6c4009
 * s1_ptr	$5
Packit 6c4009
 * size		$6
Packit 6c4009
 * s2_limb	$7
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#ifdef __PIC__
Packit 6c4009
	.option pic2
Packit 6c4009
#endif
Packit 6c4009
ENTRY (__mpn_mul_1)
Packit 6c4009
#ifdef __PIC__
Packit 6c4009
	SETUP_GP /* ??? unused */
Packit 6c4009
#endif
Packit 6c4009
	.set    noreorder
Packit 6c4009
	.set    nomacro
Packit 6c4009
Packit 6c4009
 # warm up phase 0
Packit 6c4009
	ld	$8,0($5)
Packit 6c4009
Packit 6c4009
 # warm up phase 1
Packit 6c4009
	daddiu	$5,$5,8
Packit 6c4009
#if __mips_isa_rev < 6
Packit 6c4009
	dmultu	$8,$7
Packit 6c4009
#else
Packit 6c4009
	dmulu	$11,$8,$7
Packit 6c4009
	dmuhu	$12,$8,$7
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
	daddiu	$6,$6,-1
Packit 6c4009
	beq	$6,$0,L(LC0)
Packit 6c4009
	move	$2,$0		# zero cy2
Packit 6c4009
Packit 6c4009
	daddiu	$6,$6,-1
Packit 6c4009
	beq	$6,$0,L(LC1)
Packit 6c4009
	ld	$8,0($5)	# load new s1 limb as early as possible
Packit 6c4009
Packit 6c4009
#if __mips_isa_rev < 6
Packit 6c4009
L(Loop):	mflo	$10
Packit 6c4009
	mfhi	$9
Packit 6c4009
#else
Packit 6c4009
L(Loop):	move	$10,$11
Packit 6c4009
		move	$9,$12
Packit 6c4009
#endif
Packit 6c4009
	daddiu	$5,$5,8
Packit 6c4009
	daddu	$10,$10,$2	# add old carry limb to low product limb
Packit 6c4009
#if __mips_isa_rev < 6
Packit 6c4009
	dmultu	$8,$7
Packit 6c4009
#else
Packit 6c4009
	dmulu	$11,$8,$7
Packit 6c4009
	dmuhu	$12,$8,$7
Packit 6c4009
#endif
Packit 6c4009
	ld	$8,0($5)	# load new s1 limb as early as possible
Packit 6c4009
	daddiu	$6,$6,-1	# decrement loop counter
Packit 6c4009
	sltu	$2,$10,$2	# carry from previous addition -> $2
Packit 6c4009
	sd	$10,0($4)
Packit 6c4009
	daddiu	$4,$4,8
Packit 6c4009
	bne	$6,$0,L(Loop)
Packit 6c4009
	daddu	$2,$9,$2	# add high product limb and carry from addition
Packit 6c4009
Packit 6c4009
 # cool down phase 1
Packit 6c4009
#if __mips_isa_rev < 6
Packit 6c4009
L(LC1):	mflo	$10
Packit 6c4009
	mfhi	$9
Packit 6c4009
#else
Packit 6c4009
L(LC1):	move	$10,$11
Packit 6c4009
	move	$9,$12
Packit 6c4009
#endif
Packit 6c4009
	daddu	$10,$10,$2
Packit 6c4009
	sltu	$2,$10,$2
Packit 6c4009
#if __mips_isa_rev < 6
Packit 6c4009
	dmultu	$8,$7
Packit 6c4009
#else
Packit 6c4009
	dmulu	$11,$8,$7
Packit 6c4009
	dmuhu	$12,$8,$7
Packit 6c4009
#endif
Packit 6c4009
	sd	$10,0($4)
Packit 6c4009
	daddiu	$4,$4,8
Packit 6c4009
	daddu	$2,$9,$2	# add high product limb and carry from addition
Packit 6c4009
Packit 6c4009
 # cool down phase 0
Packit 6c4009
#if  __mips_isa_rev < 6
Packit 6c4009
L(LC0):	mflo	$10
Packit 6c4009
	mfhi	$9
Packit 6c4009
#else
Packit 6c4009
L(LC0):	move	$10,$11
Packit 6c4009
	move	$9,$12
Packit 6c4009
#endif
Packit 6c4009
	daddu	$10,$10,$2
Packit 6c4009
	sltu	$2,$10,$2
Packit 6c4009
	sd	$10,0($4)
Packit 6c4009
	j	$31
Packit 6c4009
	daddu	$2,$9,$2	# add high product limb and carry from addition
Packit 6c4009
Packit 6c4009
END (__mpn_mul_1)