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
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 8 * 8
kusano 2b45e8
kusano 2b45e8
	PROLOGUE
kusano 2b45e8
	PROFCODE
kusano 2b45e8
	.frame	$sp, STACKSIZE, $26, 0
kusano 2b45e8
kusano 2b45e8
	lda	$sp, -STACKSIZE($sp)
kusano 2b45e8
kusano 2b45e8
	stt	$f2,   0($sp)
kusano 2b45e8
	fclr	$f16
kusano 2b45e8
	cmplt	$31, N,    $2
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,  $0
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	stt	$f6,  32($sp)
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	stt	$f7,  40($sp)
kusano 2b45e8
	stt	$f8,  48($sp)
kusano 2b45e8
	stt	$f9,  56($sp)
kusano 2b45e8
kusano 2b45e8
	fclr	$f0
kusano 2b45e8
	beq	$0,  $End		# if (n <= 0) or (incx <= 0) return
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
	LD	$f20,  0 * SIZE(X)
kusano 2b45e8
	LD	$f21,  1 * SIZE(X)
kusano 2b45e8
	sra	N, 2, $1
kusano 2b45e8
	addq	INCX, INCX, INCX
kusano 2b45e8
kusano 2b45e8
	fabs	$f20, $f20
kusano 2b45e8
	fabs	$f21, $f21
kusano 2b45e8
	addt	$f20, $f21, $f0
kusano 2b45e8
	ble	$1,  $L15
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
	lda	$1,  -1($1)
kusano 2b45e8
	unop
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	LD	$f22,  0 * SIZE(X)
kusano 2b45e8
	fmov	$f0,  $f1
kusano 2b45e8
	LD	$f23,  1 * SIZE(X)
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	LD	$f24,  0 * SIZE(X)
kusano 2b45e8
	fmov	$f0,  $f2
kusano 2b45e8
	LD	$f25,  1 * SIZE(X)
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	LD	$f26,  0 * SIZE(X)
kusano 2b45e8
	fmov	$f0,  $f3
kusano 2b45e8
	LD	$f27,  1 * SIZE(X)
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fabs	$f20, $f8
kusano 2b45e8
	fabs	$f21, $f9
kusano 2b45e8
	fabs	$f22, $f10
kusano 2b45e8
	fabs	$f23, $f11
kusano 2b45e8
kusano 2b45e8
	fabs	$f24, $f12
kusano 2b45e8
	fabs	$f25, $f13
kusano 2b45e8
	fabs	$f26, $f14
kusano 2b45e8
	fabs	$f27, $f15
kusano 2b45e8
kusano 2b45e8
	ble	$1, $L14
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
	LD	$f20,  0 * SIZE(X)
kusano 2b45e8
	LD	$f21,  1 * SIZE(X)
kusano 2b45e8
	lda	$1,  -1($1)
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	LD	$f22,  0 * SIZE(X)
kusano 2b45e8
	LD	$f23,  1 * SIZE(X)
kusano 2b45e8
	unop
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	LD	$f24,  0 * SIZE(X)
kusano 2b45e8
	LD	$f25,  1 * SIZE(X)
kusano 2b45e8
	unop
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	LD	$f26,  0 * SIZE(X)
kusano 2b45e8
	LD	$f27,  1 * SIZE(X)
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	ble	$1, $L13
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L12:
kusano 2b45e8
	addt	$f8,  $f9,  $f16
kusano 2b45e8
	unop
kusano 2b45e8
	fabs	$f20, $f8
kusano 2b45e8
	ldl	$31, 64 * SIZE(X)
kusano 2b45e8
kusano 2b45e8
	addt	$f10, $f11, $f17
kusano 2b45e8
	unop
kusano 2b45e8
	fabs	$f21, $f9
kusano 2b45e8
	LD	$f20,  0 * SIZE(X)
kusano 2b45e8
kusano 2b45e8
	addt	$f12, $f13, $f18
kusano 2b45e8
	LD	$f21,  1 * SIZE(X)
kusano 2b45e8
	fabs	$f22, $f10
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	addt	$f14, $f15, $f19
kusano 2b45e8
	LD	$f22,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f23, $f11
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	CMPLT($f0,  $f16), $f4
kusano 2b45e8
	LD	$f23,  1 * SIZE(X)
kusano 2b45e8
	fabs	$f24, $f12
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	CMPLT($f1,  $f17), $f5
kusano 2b45e8
	LD	$f24,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f25, $f13
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	CMPLT($f2,  $f18), $f6
kusano 2b45e8
	LD	$f25,  1 * SIZE(X)
kusano 2b45e8
	fabs	$f26, $f14
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	CMPLT($f3,  $f19), $f7
kusano 2b45e8
	LD	$f26,  0 * SIZE(X)
kusano 2b45e8
	fabs	$f27, $f15
kusano 2b45e8
	unop
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f4, $f16, $f0
kusano 2b45e8
	LD	$f27,  1 * SIZE(X)
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
	lda	$1,   -1($1)		# i --
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f5, $f17, $f1
kusano 2b45e8
	fcmovne	$f6, $f18, $f2
kusano 2b45e8
	fcmovne	$f7, $f19, $f3
kusano 2b45e8
	bgt	$1,$L12
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L13:
kusano 2b45e8
	addt	$f8,  $f9,  $f16
kusano 2b45e8
	fabs	$f20, $f8
kusano 2b45e8
kusano 2b45e8
	addt	$f10, $f11, $f17
kusano 2b45e8
	fabs	$f21, $f9
kusano 2b45e8
kusano 2b45e8
	addt	$f12, $f13, $f18
kusano 2b45e8
	fabs	$f22, $f10
kusano 2b45e8
kusano 2b45e8
	addt	$f14, $f15, $f19
kusano 2b45e8
	fabs	$f23, $f11
kusano 2b45e8
kusano 2b45e8
	CMPLT($f0,  $f16), $f4
kusano 2b45e8
	fabs	$f24, $f12
kusano 2b45e8
kusano 2b45e8
	CMPLT($f1,  $f17), $f5
kusano 2b45e8
	fabs	$f25, $f13
kusano 2b45e8
kusano 2b45e8
	CMPLT($f2,  $f18), $f6
kusano 2b45e8
	fabs	$f26, $f14
kusano 2b45e8
	CMPLT($f3,  $f19), $f7
kusano 2b45e8
	fabs	$f27, $f15
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f4, $f16, $f0
kusano 2b45e8
	fcmovne	$f5, $f17, $f1
kusano 2b45e8
	fcmovne	$f6, $f18, $f2
kusano 2b45e8
	fcmovne	$f7, $f19, $f3
kusano 2b45e8
	.align 4
kusano 2b45e8
	
kusano 2b45e8
$L14:
kusano 2b45e8
	addt	$f8,  $f9,  $f16
kusano 2b45e8
	addt	$f10, $f11, $f17
kusano 2b45e8
	addt	$f12, $f13, $f18
kusano 2b45e8
	addt	$f14, $f15, $f19
kusano 2b45e8
kusano 2b45e8
	CMPLT($f0,  $f16), $f4
kusano 2b45e8
	CMPLT($f1,  $f17), $f5
kusano 2b45e8
	CMPLT($f2,  $f18), $f6
kusano 2b45e8
	CMPLT($f3,  $f19), $f7
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f4, $f16, $f0
kusano 2b45e8
	fcmovne	$f5, $f17, $f1
kusano 2b45e8
	fcmovne	$f6, $f18, $f2
kusano 2b45e8
	fcmovne	$f7, $f19, $f3
kusano 2b45e8
kusano 2b45e8
	CMPLT($f0,  $f1), $f16
kusano 2b45e8
	CMPLT($f2,  $f3), $f17
kusano 2b45e8
kusano 2b45e8
	fcmovne	$f16, $f1, $f0
kusano 2b45e8
	fcmovne	$f17, $f3, $f2
kusano 2b45e8
kusano 2b45e8
	CMPLT($f0,  $f2), $f16
kusano 2b45e8
	fcmovne	$f16, $f2, $f0
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L15:
kusano 2b45e8
	and	N, 3, $1
kusano 2b45e8
	unop
kusano 2b45e8
	unop
kusano 2b45e8
	ble	$1,  $End
kusano 2b45e8
	.align 4
kusano 2b45e8
kusano 2b45e8
$L16:
kusano 2b45e8
	LD	$f20,  0 * SIZE(X)
kusano 2b45e8
	LD	$f21,  1 * SIZE(X)
kusano 2b45e8
	unop
kusano 2b45e8
	addq	X, INCX, X
kusano 2b45e8
kusano 2b45e8
	fabs	$f20, $f29
kusano 2b45e8
	fabs	$f21, $f30
kusano 2b45e8
	addt	$f29, $f30, $f29
kusano 2b45e8
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
$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
	ldt	$f7,  40($sp)
kusano 2b45e8
	ldt	$f8,  48($sp)
kusano 2b45e8
	ldt	$f9,  56($sp)
kusano 2b45e8
	lda	$sp,  STACKSIZE($sp)
kusano 2b45e8
	ret
kusano 2b45e8
kusano 2b45e8
	EPILOGUE