kusano 2b45e8
/*********************************************************************/
kusano 2b45e8
/* Copyright 2009, 2010 The University of Texas at Austin.           */
kusano 2b45e8
/* All rights reserved.                                              */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/* Redistribution and use in source and binary forms, with or        */
kusano 2b45e8
/* without modification, are permitted provided that the following   */
kusano 2b45e8
/* conditions are met:                                               */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*   1. Redistributions of source code must retain the above         */
kusano 2b45e8
/*      copyright notice, this list of conditions and the following  */
kusano 2b45e8
/*      disclaimer.                                                  */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*   2. Redistributions in binary form must reproduce the above      */
kusano 2b45e8
/*      copyright notice, this list of conditions and the following  */
kusano 2b45e8
/*      disclaimer in the documentation and/or other materials       */
kusano 2b45e8
/*      provided with the distribution.                              */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/*    THIS  SOFTWARE IS PROVIDED  BY THE  UNIVERSITY OF  TEXAS AT    */
kusano 2b45e8
/*    AUSTIN  ``AS IS''  AND ANY  EXPRESS OR  IMPLIED WARRANTIES,    */
kusano 2b45e8
/*    INCLUDING, BUT  NOT LIMITED  TO, THE IMPLIED  WARRANTIES OF    */
kusano 2b45e8
/*    MERCHANTABILITY  AND FITNESS FOR  A PARTICULAR  PURPOSE ARE    */
kusano 2b45e8
/*    DISCLAIMED.  IN  NO EVENT SHALL THE UNIVERSITY  OF TEXAS AT    */
kusano 2b45e8
/*    AUSTIN OR CONTRIBUTORS BE  LIABLE FOR ANY DIRECT, INDIRECT,    */
kusano 2b45e8
/*    INCIDENTAL,  SPECIAL, EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES    */
kusano 2b45e8
/*    (INCLUDING, BUT  NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE    */
kusano 2b45e8
/*    GOODS  OR  SERVICES; LOSS  OF  USE,  DATA,  OR PROFITS;  OR    */
kusano 2b45e8
/*    BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF    */
kusano 2b45e8
/*    LIABILITY, WHETHER  IN CONTRACT, STRICT  LIABILITY, OR TORT    */
kusano 2b45e8
/*    (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY WAY OUT    */
kusano 2b45e8
/*    OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF ADVISED  OF  THE    */
kusano 2b45e8
/*    POSSIBILITY OF SUCH DAMAGE.                                    */
kusano 2b45e8
/*                                                                   */
kusano 2b45e8
/* The views and conclusions contained in the software and           */
kusano 2b45e8
/* documentation are those of the authors and should not be          */
kusano 2b45e8
/* interpreted as representing official policies, either expressed   */
kusano 2b45e8
/* or implied, of The University of Texas at Austin.                 */
kusano 2b45e8
/*********************************************************************/
kusano 2b45e8
kusano 2b45e8
#define ASSEMBLER
kusano 2b45e8
#include "common.h"
kusano 2b45e8
kusano 2b45e8
#define N	$4
kusano 2b45e8
#define	X	$5
kusano 2b45e8
#define INCX	$6
kusano 2b45e8
	
kusano 2b45e8
#define I	$3
kusano 2b45e8
#define TEMP	$7
kusano 2b45e8
kusano 2b45e8
#define a1	$f4
kusano 2b45e8
#define a2	$f5
kusano 2b45e8
#define a3	$f6
kusano 2b45e8
#define a4	$f7
kusano 2b45e8
#define a5	$f8
kusano 2b45e8
#define a6	$f9
kusano 2b45e8
#define a7	$f10
kusano 2b45e8
#define a8	$f11
kusano 2b45e8
kusano 2b45e8
#define t1	$f12
kusano 2b45e8
#define t2	$f13
kusano 2b45e8
#define t3	$f14
kusano 2b45e8
#define t4	$f15
kusano 2b45e8
#define t5	$f16
kusano 2b45e8
#define t6	$f17
kusano 2b45e8
#define t7	$f18
kusano 2b45e8
#define t8	$f19
kusano 2b45e8
kusano 2b45e8
#define s1	$f0
kusano 2b45e8
#define s2	$f1
kusano 2b45e8
#define s3	$f2
kusano 2b45e8
#define s4	$f3
kusano 2b45e8
kusano 2b45e8
#define	x1	$2
kusano 2b45e8
#define	x2	$8
kusano 2b45e8
#define	x3	$9
kusano 2b45e8
#define	x4	$10
kusano 2b45e8
	
kusano 2b45e8
	PROLOGUE
kusano 2b45e8
	
kusano 2b45e8
#ifdef F_INTERFACE
kusano 2b45e8
	LDINT	N,     0(N)
kusano 2b45e8
	LDINT	INCX,  0(INCX)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
	blez	N, .L999
kusano 2b45e8
	li	x1, 0
kusano 2b45e8
kusano 2b45e8
	blez	INCX, .L999
kusano 2b45e8
	dsll	INCX, INCX, ZBASE_SHIFT
kusano 2b45e8
kusano 2b45e8
	LD	a1,  0 * SIZE(X)
kusano 2b45e8
	LD	a2,  1 * SIZE(X)
kusano 2b45e8
kusano 2b45e8
	FABS	t1, a1
kusano 2b45e8
	FABS	t2, a2
kusano 2b45e8
	
kusano 2b45e8
	ADD	s1, t1, t2
kusano 2b45e8
	ADD	s2, t1, t2
kusano 2b45e8
	ADD	s3, t1, t2
kusano 2b45e8
	ADD	s4, t1, t2
kusano 2b45e8
kusano 2b45e8
	daddiu	N, N, -1
kusano 2b45e8
kusano 2b45e8
	blez	N, .L999
kusano 2b45e8
	li	x1, 1
kusano 2b45e8
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	li	x2, 1
kusano 2b45e8
kusano 2b45e8
	dsra	I, N, 2
kusano 2b45e8
	li	x3, 1
kusano 2b45e8
kusano 2b45e8
	li	TEMP, 2
kusano 2b45e8
kusano 2b45e8
	blez	I, .L15
kusano 2b45e8
	li	x4, 1
kusano 2b45e8
kusano 2b45e8
	LD	a1,  0 * SIZE(X)
kusano 2b45e8
	LD	a2,  1 * SIZE(X)
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	LD	a3,  0 * SIZE(X)
kusano 2b45e8
	LD	a4,  1 * SIZE(X)
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	LD	a5,  0 * SIZE(X)
kusano 2b45e8
	LD	a6,  1 * SIZE(X)
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	LD	a7,  0 * SIZE(X)
kusano 2b45e8
	LD	a8,  1 * SIZE(X)
kusano 2b45e8
	daddiu	I, I, -1
kusano 2b45e8
kusano 2b45e8
	blez	I, .L13
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	.align 3
kusano 2b45e8
kusano 2b45e8
.L12:
kusano 2b45e8
	FABS	t1, a1
kusano 2b45e8
	LD	a1,  0 * SIZE(X)
kusano 2b45e8
	FABS	t2, a2
kusano 2b45e8
	LD	a2,  1 * SIZE(X)
kusano 2b45e8
kusano 2b45e8
	FABS	t3, a3
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	FABS	t4, a4
kusano 2b45e8
	NOP
kusano 2b45e8
kusano 2b45e8
	FABS	t5, a5
kusano 2b45e8
	LD	a3,  0 * SIZE(X)
kusano 2b45e8
	FABS	t6, a6
kusano 2b45e8
	LD	a4,  1 * SIZE(X)
kusano 2b45e8
	FABS	t7, a7
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	FABS	t8, a8
kusano 2b45e8
	NOP
kusano 2b45e8
kusano 2b45e8
	ADD	t1, t1, t2
kusano 2b45e8
	LD	a5,  0 * SIZE(X)
kusano 2b45e8
	ADD	t3, t3, t4
kusano 2b45e8
	LD	a6,  1 * SIZE(X)
kusano 2b45e8
	ADD	t5, t5, t6
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	ADD	t7, t7, t8
kusano 2b45e8
	NOP
kusano 2b45e8
kusano 2b45e8
	CMPLT	$fcc0, t1, s1
kusano 2b45e8
	LD	a7,  0 * SIZE(X)
kusano 2b45e8
	CMPLT	$fcc1, t3, s2
kusano 2b45e8
	LD	a8,  1 * SIZE(X)
kusano 2b45e8
	CMPLT	$fcc2, t5, s3
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
	CMPLT	$fcc3, t7, s4
kusano 2b45e8
	daddiu	I, I, -1
kusano 2b45e8
kusano 2b45e8
	CMOVT	s1, t1, $fcc0
kusano 2b45e8
	movt	x1, TEMP, $fcc0
kusano 2b45e8
	CMOVT	s2, t3, $fcc1
kusano 2b45e8
	movt	x2, TEMP, $fcc1
kusano 2b45e8
kusano 2b45e8
	CMOVT	s3, t5, $fcc2
kusano 2b45e8
	movt	x3, TEMP, $fcc2
kusano 2b45e8
	CMOVT	s4, t7, $fcc3
kusano 2b45e8
	movt	x4, TEMP, $fcc3
kusano 2b45e8
kusano 2b45e8
	bgtz	I, .L12
kusano 2b45e8
	daddiu	TEMP, TEMP, 4
kusano 2b45e8
	.align 3
kusano 2b45e8
kusano 2b45e8
.L13:
kusano 2b45e8
	FABS	t1, a1
kusano 2b45e8
	FABS	t2, a2
kusano 2b45e8
	FABS	t3, a3
kusano 2b45e8
	FABS	t4, a4
kusano 2b45e8
kusano 2b45e8
	FABS	t5, a5
kusano 2b45e8
	FABS	t6, a6
kusano 2b45e8
	FABS	t7, a7
kusano 2b45e8
	FABS	t8, a8
kusano 2b45e8
kusano 2b45e8
	ADD	t1, t1, t2
kusano 2b45e8
	ADD	t3, t3, t4
kusano 2b45e8
	ADD	t5, t5, t6
kusano 2b45e8
	ADD	t7, t7, t8
kusano 2b45e8
kusano 2b45e8
	CMPLT	$fcc0, t1, s1
kusano 2b45e8
	CMPLT	$fcc1, t3, s2
kusano 2b45e8
	CMPLT	$fcc2, t5, s3
kusano 2b45e8
	CMPLT	$fcc3, t7, s4
kusano 2b45e8
kusano 2b45e8
	CMOVT	s1, t1, $fcc0
kusano 2b45e8
	movt	x1, TEMP, $fcc0
kusano 2b45e8
	CMOVT	s2, t3, $fcc1
kusano 2b45e8
	movt	x2, TEMP, $fcc1
kusano 2b45e8
kusano 2b45e8
	CMOVT	s3, t5, $fcc2
kusano 2b45e8
	movt	x3, TEMP, $fcc2
kusano 2b45e8
	CMOVT	s4, t7, $fcc3
kusano 2b45e8
	movt	x4, TEMP, $fcc3
kusano 2b45e8
kusano 2b45e8
	daddiu	TEMP, TEMP, 4
kusano 2b45e8
	daddiu	x2, x2, 1
kusano 2b45e8
	daddiu	x3, x3, 2
kusano 2b45e8
	daddiu	x4, x4, 3
kusano 2b45e8
	.align 3
kusano 2b45e8
kusano 2b45e8
.L15:
kusano 2b45e8
	andi	I,  N, 3
kusano 2b45e8
	blez	I, .L998
kusano 2b45e8
	NOP
kusano 2b45e8
	.align	3
kusano 2b45e8
kusano 2b45e8
.L16:
kusano 2b45e8
	LD	a1,  0 * SIZE(X)
kusano 2b45e8
	LD	a2,  1 * SIZE(X)
kusano 2b45e8
	daddu	X, X, INCX
kusano 2b45e8
kusano 2b45e8
	FABS	t1, a1
kusano 2b45e8
	FABS	t2, a2
kusano 2b45e8
kusano 2b45e8
	ADD	t1, t1, t2
kusano 2b45e8
kusano 2b45e8
	daddiu	I, I, -1
kusano 2b45e8
kusano 2b45e8
	CMPLT	$fcc0, t1, s1
kusano 2b45e8
	NOP
kusano 2b45e8
	CMOVT	s1, t1, $fcc0
kusano 2b45e8
	movt	x1, TEMP, $fcc0
kusano 2b45e8
kusano 2b45e8
	bgtz	I, .L16
kusano 2b45e8
	daddiu	TEMP, TEMP, 1
kusano 2b45e8
	.align 3
kusano 2b45e8
kusano 2b45e8
.L998:
kusano 2b45e8
	CMPLT	$fcc0, s2, s1
kusano 2b45e8
	CMPLT	$fcc1, s4, s3
kusano 2b45e8
kusano 2b45e8
	CMOVT	s1, s2, $fcc0
kusano 2b45e8
	movt	x1, x2, $fcc0
kusano 2b45e8
	CMOVT	s3, s4, $fcc1
kusano 2b45e8
	movt	x3, x4, $fcc1
kusano 2b45e8
kusano 2b45e8
	CMPLT	$fcc0, s3, s1
kusano 2b45e8
	CMOVT	s1, s3, $fcc0
kusano 2b45e8
	movt	x1, x3, $fcc0
kusano 2b45e8
	.align 3
kusano 2b45e8
kusano 2b45e8
.L999:
kusano 2b45e8
	j	$31
kusano 2b45e8
	NOP
kusano 2b45e8
kusano 2b45e8
	EPILOGUE