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
#include "version.h"
kusano 2b45e8
kusano 2b45e8
#define N	$16
kusano 2b45e8
#define X	$17
kusano 2b45e8
#define INCX	$18
kusano 2b45e8
#define XX	$19
kusano 2b45e8
kusano 2b45e8
#ifndef USE_MIN
kusano 2b45e8
#define CMPLT(a, b) cmptlt a, b
kusano 2b45e8
#else
kusano 2b45e8
#define CMPLT(a, b) cmptlt b, a
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#define STACKSIZE 6 * 8
kusano 2b45e8
kusano 2b45e8
	PROLOGUE
kusano 2b45e8
	PROFCODE
kusano 2b45e8
	.frame	$sp, STACKSIZE, $26, 0
kusano 2b45e8
kusano 2b45e8
#ifdef F_INTERFACE
kusano 2b45e8
	ldl	N,     0(N)		# n
kusano 2b45e8
	ldl	INCX,  0(INCX)		# incx
kusano 2b45e8
#endif
kusano 2b45e8
	lda	$sp, -STACKSIZE($sp)
kusano 2b45e8
	mov	X, XX
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
	stt	$f2,   0($sp)
kusano 2b45e8
	fclr	$f16
kusano 2b45e8
	cmplt	$31, N,    $2
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	stt	$f3,   8($sp)
kusano 2b45e8
	fclr	$f17
kusano 2b45e8
	cmplt	$31, INCX, $3
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	stt	$f4,  16($sp)
kusano 2b45e8
	fclr	$f18
kusano 2b45e8
	SXADDQ	INCX, $31, INCX
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	stt	$f5,  24($sp)
kusano 2b45e8
	fclr	$f19
kusano 2b45e8
	and	$2,  $3,  $2
kusano 2b45e8
	clr	$0
kusano 2b45e8
kusano 2b45e8
	stt	$f6,  32($sp)
kusano 2b45e8
	fclr	$f0
kusano 2b45e8
	sra	N, 3, $1
kusano 2b45e8
	beq	$2,  $End		# if (n <= 0) or (incx <= 0) return
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
	LD	$f20,  0 * SIZE(X)
kusano 2b45e8
	unop
kusano 2b45e8
	fabs	$f20, $f0
kusano 2b45e8
	ble	$1,  $L15
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
	fabs	$f20, $f1
kusano 2b45e8
	unop
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	LD	$f21,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f20, $f2
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	LD	$f22,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f20, $f3
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	LD	$f23,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f20, $f4
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	LD	$f24,  0 * SIZE(X)
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	fabs	$f20, $f5
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	LD	$f25,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f20, $f6
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	LD	$f26,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f20, $f28
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	lda	$1,  -1($1)
kusano 2b45e8
kusano 2b45e8
	LD	$f27,  0 * SIZE(X)
kusano 2b45e8
	unop
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	ble	$1, $L13
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L12:
kusano 2b45e8
	fcmovne	$f16, $f12, $f4
kusano 2b45e8
	unop
kusano 2b45e8
	fabs	$f20, $f29
kusano 2b45e8
	ldl	$31, 56 * SIZE(X)
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f17, $f13, $f5
kusano 2b45e8
	LD	$f20,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f21, $f30
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f18, $f14, $f6
kusano 2b45e8
	LD	$f21,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f22, $f10
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f19, $f15, $f28
kusano 2b45e8
	LD	$f22,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f23, $f11
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fabs	$f24, $f12
kusano 2b45e8
	LD	$f23,  0 * SIZE(X)
kusano 2b45e8
	CMPLT($f0,  $f29),  $f16
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fabs	$f25, $f13
kusano 2b45e8
	LD	$f24,  0 * SIZE(X)
kusano 2b45e8
	CMPLT($f1,  $f30),  $f17
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fabs	$f26, $f14
kusano 2b45e8
	LD	$f25,  0 * SIZE(X)
kusano 2b45e8
	CMPLT($f2,  $f10), $f18
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fabs	$f27, $f15
kusano 2b45e8
	LD	$f26,  0 * SIZE(X)
kusano 2b45e8
	CMPLT($f3,  $f11), $f19
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f16, $f29,  $f0
kusano 2b45e8
	LD	$f27,  0 * SIZE(X)
kusano 2b45e8
	CMPLT($f4,  $f12), $f16
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f17, $f30,  $f1
kusano 2b45e8
	unop
kusano 2b45e8
	CMPLT($f5,  $f13), $f17
kusano 2b45e8
	lda	$1,   -1($1)		# i --
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f18, $f10, $f2
kusano 2b45e8
	unop
kusano 2b45e8
	CMPLT($f6,  $f14), $f18
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f19, $f11, $f3
kusano 2b45e8
	unop
kusano 2b45e8
	CMPLT($f28,  $f15), $f19
kusano 2b45e8
	bgt	$1,$L12
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L13:
kusano 2b45e8
	fcmovne	$f16, $f12, $f4
kusano 2b45e8
	fabs	$f20, $f29
kusano 2b45e8
	fcmovne	$f17, $f13, $f5
kusano 2b45e8
	fabs	$f21, $f30
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f18, $f14, $f6
kusano 2b45e8
	fabs	$f22, $f10
kusano 2b45e8
	fcmovne	$f19, $f15, $f28
kusano 2b45e8
	fabs	$f23, $f11
kusano 2b45e8
kusano 2b45e8
	fabs	$f24, $f12
kusano 2b45e8
	CMPLT($f0,  $f29),  $f16
kusano 2b45e8
	fabs	$f25, $f13
kusano 2b45e8
	CMPLT($f1,  $f30),  $f17
kusano 2b45e8
kusano 2b45e8
	fabs	$f26, $f14
kusano 2b45e8
	CMPLT($f2,  $f10), $f18
kusano 2b45e8
	fabs	$f27, $f15
kusano 2b45e8
	CMPLT($f3,  $f11), $f19
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f16, $f29,  $f0
kusano 2b45e8
	CMPLT($f4,  $f12), $f16
kusano 2b45e8
	fcmovne	$f17, $f30,  $f1
kusano 2b45e8
	CMPLT($f5,  $f13), $f17
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f18, $f10, $f2
kusano 2b45e8
	CMPLT($f6,  $f14), $f18
kusano 2b45e8
	fcmovne	$f19, $f11, $f3
kusano 2b45e8
	CMPLT($f28,  $f15), $f19
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f16, $f12, $f4
kusano 2b45e8
	CMPLT($f0,  $f1), $f16
kusano 2b45e8
	fcmovne	$f17, $f13, $f5
kusano 2b45e8
	CMPLT($f2,  $f3), $f17
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f18, $f14, $f6
kusano 2b45e8
	CMPLT($f4,  $f5), $f18
kusano 2b45e8
	fcmovne	$f19, $f15, $f28
kusano 2b45e8
	CMPLT($f6,  $f28), $f19
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f16, $f1, $f0
kusano 2b45e8
	fcmovne	$f17, $f3, $f2
kusano 2b45e8
	fcmovne	$f18, $f5, $f4
kusano 2b45e8
	fcmovne	$f19, $f28, $f6
kusano 2b45e8
kusano 2b45e8
	CMPLT($f0,  $f2), $f16
kusano 2b45e8
	CMPLT($f4,  $f6), $f17
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f16, $f2, $f0
kusano 2b45e8
	fcmovne	$f17, $f6, $f4
kusano 2b45e8
kusano 2b45e8
	CMPLT($f0,  $f4), $f16
kusano 2b45e8
	fcmovne	$f16, $f4, $f0
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L15:
kusano 2b45e8
	and	N, 7, $1
kusano 2b45e8
	unop
kusano 2b45e8
	unop
kusano 2b45e8
	ble	$1,  $L20
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L16:
kusano 2b45e8
	LD	$f20,  0 * SIZE(X)
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fabs	$f20, $f29
kusano 2b45e8
	CMPLT($f0,  $f29), $f16
kusano 2b45e8
	fcmovne	$f16, $f29, $f0
kusano 2b45e8
kusano 2b45e8
	lda	$1,   -1($1)		# i --
kusano 2b45e8
	bgt	$1, $L16
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L20:
kusano 2b45e8
	sra	N, 3, $1
kusano 2b45e8
	ble	$1,  $L40
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
	LD	$f10,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	LD	$f11,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
kusano 2b45e8
	LD	$f12,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	LD	$f13,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
kusano 2b45e8
	LD	$f14,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	LD	$f15,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
kusano 2b45e8
	LD	$f16,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	LD	$f17,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
kusano 2b45e8
	fabs	$f10, $f18
kusano 2b45e8
	fabs	$f11, $f19
kusano 2b45e8
	fabs	$f12, $f20
kusano 2b45e8
	fabs	$f13, $f21
kusano 2b45e8
kusano 2b45e8
	lda	$1,  -1($1)
kusano 2b45e8
	ble	$1, $L23
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L22:
kusano 2b45e8
	LD	$f10,  0 * SIZE(XX)
kusano 2b45e8
	fabs	$f14, $f22
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	cmpteq	$f0, $f18, $f2	
kusano 2b45e8
kusano 2b45e8
	LD	$f11,  0 * SIZE(XX)
kusano 2b45e8
	fabs	$f15, $f23
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	cmpteq	$f0, $f19, $f3
kusano 2b45e8
kusano 2b45e8
	LD	$f12,  0 * SIZE(XX)
kusano 2b45e8
	fabs	$f16, $f24
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	cmpteq	$f0, $f20, $f4
kusano 2b45e8
kusano 2b45e8
	LD	$f13,  0 * SIZE(XX)
kusano 2b45e8
	fabs	$f17, $f25
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	cmpteq	$f0, $f21, $f5
kusano 2b45e8
kusano 2b45e8
	LD	$f14,  0 * SIZE(XX)
kusano 2b45e8
	lda	$1,   -1($1)		# i --
kusano 2b45e8
	cmpteq	$f0, $f22, $f26
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f2,  $End
kusano 2b45e8
kusano 2b45e8
	LD	$f15,  0 * SIZE(XX)
kusano 2b45e8
	cmpteq	$f0, $f23, $f27
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f3,  $End
kusano 2b45e8
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	cmpteq	$f0, $f24, $f28
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f4,  $End
kusano 2b45e8
kusano 2b45e8
	LD	$f16,  0 * SIZE(XX)
kusano 2b45e8
	cmpteq	$f0, $f25, $f29
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f5,  $End
kusano 2b45e8
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fabs	$f10, $f18
kusano 2b45e8
	fbne	$f26, $End
kusano 2b45e8
kusano 2b45e8
	LD	$f17,  0 * SIZE(XX)
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fabs	$f11, $f19
kusano 2b45e8
	fbne	$f27, $End
kusano 2b45e8
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fabs	$f12, $f20
kusano 2b45e8
	fbne	$f28, $End
kusano 2b45e8
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fabs	$f13, $f21
kusano 2b45e8
	fbne	$f29, $End
kusano 2b45e8
	bgt	$1,  $L22
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L23:
kusano 2b45e8
	fabs	$f14, $f22
kusano 2b45e8
	cmpteq	$f0, $f18, $f2	
kusano 2b45e8
	fabs	$f15, $f23
kusano 2b45e8
	cmpteq	$f0, $f19, $f3
kusano 2b45e8
kusano 2b45e8
	fabs	$f16, $f24
kusano 2b45e8
	cmpteq	$f0, $f20, $f4
kusano 2b45e8
	fabs	$f17, $f25
kusano 2b45e8
	cmpteq	$f0, $f21, $f5
kusano 2b45e8
kusano 2b45e8
	cmpteq	$f0, $f22, $f26
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	unop
kusano 2b45e8
	fbne	$f2,  $End
kusano 2b45e8
kusano 2b45e8
	cmpteq	$f0, $f23, $f27
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	unop
kusano 2b45e8
	fbne	$f3,  $End
kusano 2b45e8
kusano 2b45e8
	cmpteq	$f0, $f24, $f28
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	unop
kusano 2b45e8
	fbne	$f4,  $End
kusano 2b45e8
kusano 2b45e8
	cmpteq	$f0, $f25, $f29
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	unop
kusano 2b45e8
	fbne	$f5,  $End
kusano 2b45e8
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f26, $End
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f27, $End
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f28, $End
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f29, $End
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L40:
kusano 2b45e8
	LD	$f20,  0 * SIZE(XX)
kusano 2b45e8
	addq	XX, INCX, XX
kusano 2b45e8
kusano 2b45e8
	fabs	$f20, $f25
kusano 2b45e8
	cmpteq	$f0, $f25, $f29
kusano 2b45e8
kusano 2b45e8
	lda	$0,    1($0)
kusano 2b45e8
	fbne	$f29,  $End
kusano 2b45e8
	br	$31, $L40
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$End:
kusano 2b45e8
	ldt	$f2,   0($sp)
kusano 2b45e8
	ldt	$f3,   8($sp)
kusano 2b45e8
	ldt	$f4,  16($sp)
kusano 2b45e8
	ldt	$f5,  24($sp)
kusano 2b45e8
kusano 2b45e8
	ldt	$f6,  32($sp)
kusano 2b45e8
	lda	$sp,  STACKSIZE($sp)
kusano 2b45e8
	ret
kusano 2b45e8
kusano 2b45e8
	EPILOGUE