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
#ifdef XDOUBLE
kusano 2b45e8
#define PREFETCH_SIZE ( 8 * 16 +  4)
kusano 2b45e8
#elif defined(DOUBLE)
kusano 2b45e8
#define PREFETCH_SIZE (16 * 16 +  8)
kusano 2b45e8
#else
kusano 2b45e8
#define PREFETCH_SIZE (32 * 16 + 16)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if   !defined(USE_MIN) &&  defined(USE_ABS)
kusano 2b45e8
#define FMAX	famax
kusano 2b45e8
#elif !defined(USE_MIN) && !defined(USE_ABS)
kusano 2b45e8
#define FMAX	fmax
kusano 2b45e8
#elif  defined(USE_MIN) &&  defined(USE_ABS)
kusano 2b45e8
#define FMAX	famin
kusano 2b45e8
#else
kusano 2b45e8
#define FMAX	fmin
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#define RET	r8
kusano 2b45e8
kusano 2b45e8
#define N	r32
kusano 2b45e8
#define DX	r33
kusano 2b45e8
#define INCX	r34
kusano 2b45e8
kusano 2b45e8
#define PRE1	r2
kusano 2b45e8
#define J	r14
kusano 2b45e8
#define K	r15
kusano 2b45e8
#define X2	r16
kusano 2b45e8
#define X3	r17
kusano 2b45e8
#define INCX5	r18
kusano 2b45e8
#define INCX16	r19
kusano 2b45e8
kusano 2b45e8
#define DMAX1	f8
kusano 2b45e8
#define DMAX2	f9
kusano 2b45e8
#define DMAX3	f10
kusano 2b45e8
#define DMAX4	f11
kusano 2b45e8
#define DMAX5	f12
kusano 2b45e8
#define DMAX6	f13
kusano 2b45e8
#define DMAX7	f14
kusano 2b45e8
#define DMAX8	f15
kusano 2b45e8
kusano 2b45e8
#define PR	r30
kusano 2b45e8
#define ARLC	r31
kusano 2b45e8
kusano 2b45e8
	PROLOGUE
kusano 2b45e8
	.prologue
kusano 2b45e8
	PROFCODE
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	mov	RET = 0
kusano 2b45e8
	mov	DMAX1  = f0
kusano 2b45e8
	.save	ar.lc, ARLC
kusano 2b45e8
	mov	ARLC = ar.lc
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	.body
kusano 2b45e8
kusano 2b45e8
#ifdef F_INTERFACE
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	LDINT	N = [N]
kusano 2b45e8
	LDINT	INCX = [INCX]
kusano 2b45e8
	nop.i 0
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
#ifndef USE64BITINT
kusano 2b45e8
	{ .mii
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	sxt4	N = N
kusano 2b45e8
	sxt4	INCX = INCX
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
	{ .mii
kusano 2b45e8
	mov	PR = pr
kusano 2b45e8
	cmp.ge	p6, p0 = 0, INCX
kusano 2b45e8
	}
kusano 2b45e8
	{ .mbb
kusano 2b45e8
	cmp.ge	p8, p0 = 0, N
kusano 2b45e8
	(p8) br.ret.sptk.many b0
kusano 2b45e8
	(p6) br.ret.sptk.many b0
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	LDFD	DMAX1 = [DX]
kusano 2b45e8
	shladd	INCX = INCX, BASE_SHIFT, r0
kusano 2b45e8
	mov	pr.rot= 0
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	add	DX = DX, INCX
kusano 2b45e8
	adds	K = -1, N
kusano 2b45e8
	mov	DMAX2 = DMAX1
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	shladd	X2    = INCX, 2, DX
kusano 2b45e8
	mov	DMAX5 = DMAX1
kusano 2b45e8
	shr	J =  K, 4
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	cmp.eq	p16, p0 = r0, r0
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	mov	DMAX6 = DMAX1
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	shladd	INCX5 = INCX, 2, INCX
kusano 2b45e8
	mov	DMAX3 = DMAX1
kusano 2b45e8
	mov	ar.ec= 4
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
#ifdef XDOUBLE
kusano 2b45e8
	shladd	INCX16= INCX, 3, r0
kusano 2b45e8
#else
kusano 2b45e8
	shladd	INCX16= INCX, 4, r0
kusano 2b45e8
#endif
kusano 2b45e8
	adds	J = -1, J
kusano 2b45e8
	mov	DMAX7 = DMAX1
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	adds	PRE1 = PREFETCH_SIZE * SIZE, DX
kusano 2b45e8
	mov	DMAX4 = DMAX1
kusano 2b45e8
	mov	ar.lc = J
kusano 2b45e8
	}
kusano 2b45e8
	{ .mfb
kusano 2b45e8
	cmp.eq	p7 ,p0  =  -1, J
kusano 2b45e8
	mov	DMAX8 = DMAX1
kusano 2b45e8
	(p7) br.cond.dpnt  .L15
kusano 2b45e8
	}
kusano 2b45e8
	.align 32
kusano 2b45e8
	;;
kusano 2b45e8
.L10:
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) lfetch.nt1  [PRE1], INCX16
kusano 2b45e8
	(p16) LDFD	f32 = [DX], INCX
kusano 2b45e8
	(p19) FMAX DMAX1 = f35, DMAX1
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f48 = [X2], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX5 = f51, DMAX5
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f36 = [DX], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX2 = f39, DMAX2
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f52 = [X2], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX6 = f55, DMAX6
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f40 = [DX], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX3 = f43, DMAX3
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f56 = [X2], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX7 = f59, DMAX7
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f44 = [DX], INCX5
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX4 = f47, DMAX4
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f60 = [X2], INCX5
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX8 = f63, DMAX8
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
#ifdef XDOUBLE
kusano 2b45e8
	(p16) lfetch.nt1  [PRE1], INCX16
kusano 2b45e8
#endif
kusano 2b45e8
	(p16) LDFD	f64 = [DX], INCX
kusano 2b45e8
#ifndef XDOUBLE
kusano 2b45e8
	nop.m 0
kusano 2b45e8
#endif
kusano 2b45e8
	(p19) FMAX DMAX1 = f67, DMAX1
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f80 = [X2], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX5 = f83, DMAX5
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f68 = [DX], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX2 = f71, DMAX2
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f84 = [X2], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX6 = f87, DMAX6
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f72 = [DX], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX3 = f75, DMAX3
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f88 = [X2], INCX
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX7 = f91, DMAX7
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p16) LDFD	f76 = [DX], INCX5
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	(p19) FMAX DMAX4 = f79, DMAX4
kusano 2b45e8
	}
kusano 2b45e8
	{ .mfb
kusano 2b45e8
	(p16) LDFD	f92 = [X2], INCX5
kusano 2b45e8
	(p19) FMAX DMAX8 = f95, DMAX8
kusano 2b45e8
	br.ctop.sptk.few .L10
kusano 2b45e8
	}
kusano 2b45e8
	.align 32
kusano 2b45e8
	;;
kusano 2b45e8
.L15:
kusano 2b45e8
	and	J =  15, K
kusano 2b45e8
	tbit.z	p0, p12 = K, 3
kusano 2b45e8
	mov	X3 = DX
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p12) LDFD	f32 = [DX], INCX
kusano 2b45e8
	(p12) LDFD	f36 = [X2], INCX
kusano 2b45e8
	tbit.z	p0, p13 = K, 2
kusano 2b45e8
	}
kusano 2b45e8
	{ .mib
kusano 2b45e8
	cmp.eq	p8 ,p0  =   r0, J
kusano 2b45e8
	tbit.z	p0, p14 = K, 1
kusano 2b45e8
	(p8) br.cond.dpnt  .L99
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p12) LDFD	f33 = [DX], INCX
kusano 2b45e8
	(p12) LDFD	f37 = [X2], INCX
kusano 2b45e8
	tbit.z	p0, p15 = K, 0
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p12) LDFD	f34 = [DX], INCX
kusano 2b45e8
	(p12) LDFD	f38 = [X2], INCX
kusano 2b45e8
	(p12) shladd X3 = INCX, 3, X3
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p12) LDFD	f35 = [DX], INCX5
kusano 2b45e8
	(p12) LDFD	f39 = [X2], INCX5
kusano 2b45e8
	(p13) shladd X3 = INCX, 2, X3
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p13) LDFD	f40 = [DX], INCX
kusano 2b45e8
	(p14) LDFD	f44 = [X3], INCX
kusano 2b45e8
	nop.i 0
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmi
kusano 2b45e8
	(p13) LDFD	f41 = [DX], INCX
kusano 2b45e8
	(p14) LDFD	f45 = [X3], INCX
kusano 2b45e8
	nop.i 0
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p13) LDFD	f42 = [DX], INCX
kusano 2b45e8
	nop.m 0 
kusano 2b45e8
	(p12) FMAX DMAX1 = f32, DMAX1
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p15) LDFD	f46 = [X3], INCX
kusano 2b45e8
	nop.m 0 
kusano 2b45e8
	(p12) FMAX DMAX5 = f36, DMAX5
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	(p13) LDFD	f43 = [DX], INCX
kusano 2b45e8
	nop.m 0 
kusano 2b45e8
	(p12) FMAX DMAX2 = f33, DMAX2
kusano 2b45e8
	}
kusano 2b45e8
	(p12) FMAX DMAX6 = f37, DMAX6
kusano 2b45e8
	(p12) FMAX DMAX3 = f34, DMAX3
kusano 2b45e8
	(p12) FMAX DMAX7 = f38, DMAX7
kusano 2b45e8
	(p12) FMAX DMAX4 = f35, DMAX4
kusano 2b45e8
	(p12) FMAX DMAX8 = f39, DMAX8
kusano 2b45e8
	;;
kusano 2b45e8
	(p13) FMAX DMAX1 = f40, DMAX1
kusano 2b45e8
	(p14) FMAX DMAX5 = f44, DMAX5
kusano 2b45e8
	(p13) FMAX DMAX2 = f41, DMAX2
kusano 2b45e8
	(p14) FMAX DMAX6 = f45, DMAX6
kusano 2b45e8
	(p13) FMAX DMAX3 = f42, DMAX3
kusano 2b45e8
	(p15) FMAX DMAX7 = f46, DMAX7
kusano 2b45e8
	(p13) FMAX DMAX4 = f43, DMAX4
kusano 2b45e8
	;;
kusano 2b45e8
	.align 32
kusano 2b45e8
	
kusano 2b45e8
.L99:
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	FMAX	DMAX1 = DMAX5, DMAX1
kusano 2b45e8
	mov	ar.lc = ARLC
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	FMAX	DMAX2 = DMAX6, DMAX2
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfi
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	FMAX	DMAX3 = DMAX7, DMAX3
kusano 2b45e8
	mov	pr = PR, -65474
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	nop.m 0
kusano 2b45e8
	FMAX	DMAX4 = DMAX8, DMAX4
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mmf
kusano 2b45e8
 	FMAX	DMAX1 = DMAX2, DMAX1
kusano 2b45e8
	}
kusano 2b45e8
	{ .mmf
kusano 2b45e8
	FMAX	DMAX3 = DMAX4, DMAX3
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
#ifndef USE_ABS
kusano 2b45e8
	{ .mfb
kusano 2b45e8
 	FMAX	DMAX1 = DMAX3, DMAX1
kusano 2b45e8
	br.ret.sptk.many b0
kusano 2b45e8
	}
kusano 2b45e8
#else
kusano 2b45e8
	{ .mmf
kusano 2b45e8
 	FMAX	DMAX1 = DMAX3, DMAX1
kusano 2b45e8
	}
kusano 2b45e8
	;;
kusano 2b45e8
	{ .mfb
kusano 2b45e8
 	fabs	DMAX1 = DMAX1
kusano 2b45e8
	br.ret.sptk.many b0
kusano 2b45e8
	}
kusano 2b45e8
#endif
kusano 2b45e8
	;;
kusano 2b45e8
	EPILOGUE
kusano 2b45e8
kusano 2b45e8
kusano 2b45e8