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 PENTIUM
kusano 2b45e8
#define P 88
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef P
kusano 2b45e8
#define P 400
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#define STACK	16
kusano 2b45e8
#define ARGS	24
kusano 2b45e8
	
kusano 2b45e8
#define NLDA	  0 + STACK(%esp)
kusano 2b45e8
#define XP	  4 + STACK(%esp)
kusano 2b45e8
#define MIN_M	  8 + STACK(%esp)
kusano 2b45e8
#define J	 12 + STACK(%esp)
kusano 2b45e8
#define IS	 16 + STACK(%esp)
kusano 2b45e8
kusano 2b45e8
#define M	 4 + STACK + ARGS(%esp)
kusano 2b45e8
#define N	 8 + STACK + ARGS(%esp)
kusano 2b45e8
#define K	12 + STACK + ARGS(%esp)
kusano 2b45e8
#ifdef DOUBLE
kusano 2b45e8
#define ALPHA_R	16 + STACK + ARGS(%esp)
kusano 2b45e8
#define ALPHA_I	24 + STACK + ARGS(%esp)
kusano 2b45e8
#define A	32 + STACK + ARGS(%esp)
kusano 2b45e8
#define LDA	36 + STACK + ARGS(%esp)
kusano 2b45e8
#define X	40 + STACK + ARGS(%esp)
kusano 2b45e8
#define INCX	44 + STACK + ARGS(%esp)
kusano 2b45e8
#define Y	48 + STACK + ARGS(%esp)
kusano 2b45e8
#define INCY	52 + STACK + ARGS(%esp)
kusano 2b45e8
#define BUFFER	56 + STACK + ARGS(%esp)
kusano 2b45e8
#else
kusano 2b45e8
#define ALPHA_R	16 + STACK + ARGS(%esp)
kusano 2b45e8
#define ALPHA_I	20 + STACK + ARGS(%esp)
kusano 2b45e8
#define A	24 + STACK + ARGS(%esp)
kusano 2b45e8
#define LDA	28 + STACK + ARGS(%esp)
kusano 2b45e8
#define X	32 + STACK + ARGS(%esp)
kusano 2b45e8
#define INCX	36 + STACK + ARGS(%esp)
kusano 2b45e8
#define Y	40 + STACK + ARGS(%esp)
kusano 2b45e8
#define INCY	44 + STACK + ARGS(%esp)
kusano 2b45e8
#define BUFFER	48 + STACK + ARGS(%esp)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
	PROLOGUE
kusano 2b45e8
kusano 2b45e8
	subl	$ARGS,	%esp
kusano 2b45e8
	pushl	%ebp
kusano 2b45e8
	pushl	%edi
kusano 2b45e8
	pushl	%esi
kusano 2b45e8
	pushl	%ebx
kusano 2b45e8
kusano 2b45e8
	PROFCODE
kusano 2b45e8
kusano 2b45e8
	FLD	ALPHA_I
kusano 2b45e8
	FLD	ALPHA_R
kusano 2b45e8
kusano 2b45e8
	movl	X, %edi			# X
kusano 2b45e8
kusano 2b45e8
	movl	$0, IS
kusano 2b45e8
kusano 2b45e8
	movl	M, %ebx
kusano 2b45e8
	movl	N, %ecx
kusano 2b45e8
	testl	%ebx, %ebx
kusano 2b45e8
	jle	.L79
kusano 2b45e8
kusano 2b45e8
	testl	%ecx, %ecx
kusano 2b45e8
	jle	.L79
kusano 2b45e8
kusano 2b45e8
	movl	INCX, %esi
kusano 2b45e8
	addl	%esi, %esi
kusano 2b45e8
	leal	(,%esi,SIZE), %esi
kusano 2b45e8
	movl	%esi, INCX
kusano 2b45e8
kusano 2b45e8
	movl	INCY, %esi
kusano 2b45e8
	addl	%esi, %esi
kusano 2b45e8
	leal	(, %esi, SIZE), %esi
kusano 2b45e8
	movl	%esi, INCY
kusano 2b45e8
kusano 2b45e8
	movl	LDA,  %ebx
kusano 2b45e8
kusano 2b45e8
	movl	N,    %eax
kusano 2b45e8
	imull	%ebx, %eax
kusano 2b45e8
	movl	$P,   %esi
kusano 2b45e8
	subl	%eax, %esi
kusano 2b45e8
	leal	(, %esi, SIZE), %esi
kusano 2b45e8
	addl	%esi, %esi
kusano 2b45e8
	movl	%esi, NLDA
kusano 2b45e8
kusano 2b45e8
	leal	(,%ebx,SIZE), %esi
kusano 2b45e8
	addl	%esi, %esi
kusano 2b45e8
	movl	%esi, LDA
kusano 2b45e8
	ALIGN_2
kusano 2b45e8
kusano 2b45e8
.L32:
kusano 2b45e8
	movl	IS,   %esi
kusano 2b45e8
kusano 2b45e8
	movl	$P,   %edx
kusano 2b45e8
	movl	M,    %eax
kusano 2b45e8
	subl	%esi, %eax
kusano 2b45e8
	cmpl	%edx, %eax
kusano 2b45e8
#ifdef PENTIUM
kusano 2b45e8
	jle	.L33
kusano 2b45e8
	movl	%edx, %eax
kusano 2b45e8
.L33:
kusano 2b45e8
#else
kusano 2b45e8
	cmovg	%edx, %eax
kusano 2b45e8
#endif
kusano 2b45e8
	movl	%eax, MIN_M
kusano 2b45e8
kusano 2b45e8
	movl	IS,   %ecx
kusano 2b45e8
	addl	%ecx, %ecx
kusano 2b45e8
	leal	(%edi,%ecx,SIZE), %ecx		# xp = x + is
kusano 2b45e8
	movl	INCX, %ebx
kusano 2b45e8
	movl	%ecx, XP
kusano 2b45e8
	cmpl	$2 * SIZE, %ebx
kusano 2b45e8
	je	.L34
kusano 2b45e8
kusano 2b45e8
	movl	BUFFER, %esi
kusano 2b45e8
	movl	MIN_M, %eax
kusano 2b45e8
	movl	%esi, XP
kusano 2b45e8
	sarl	$1, %eax
kusano 2b45e8
	jle	.L35
kusano 2b45e8
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L36:
kusano 2b45e8
	FLD	0 * SIZE(%edi)
kusano 2b45e8
	FLD	1 * SIZE(%edi)
kusano 2b45e8
	addl	%ebx,%edi		# x += incx
kusano 2b45e8
	FLD	0 * SIZE(%edi)
kusano 2b45e8
	FLD	1 * SIZE(%edi)
kusano 2b45e8
	addl	%ebx,%edi		# x += incx
kusano 2b45e8
kusano 2b45e8
	FST	3 * SIZE(%esi)
kusano 2b45e8
	FST	2 * SIZE(%esi)
kusano 2b45e8
	FST	1 * SIZE(%esi)
kusano 2b45e8
	FST	0 * SIZE(%esi)
kusano 2b45e8
kusano 2b45e8
	addl	$4 * SIZE, %esi		# xp += 4
kusano 2b45e8
	decl	%eax
kusano 2b45e8
	jg	.L36
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L35:
kusano 2b45e8
	movl	MIN_M, %eax
kusano 2b45e8
	andl	$1,%eax
kusano 2b45e8
	jle	.L34
kusano 2b45e8
kusano 2b45e8
	FLD	0 * SIZE(%edi)
kusano 2b45e8
	FLD	1 * SIZE(%edi)
kusano 2b45e8
	addl	%ebx,%edi		# x += incx
kusano 2b45e8
	FST	1 * SIZE(%esi)
kusano 2b45e8
	FST	0 * SIZE(%esi)
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
/* Main Routine */
kusano 2b45e8
kusano 2b45e8
.L34:
kusano 2b45e8
	movl	Y, %ebp			# coffset = y
kusano 2b45e8
kusano 2b45e8
	movl	N, %ecx
kusano 2b45e8
	testl	%ecx, %ecx
kusano 2b45e8
	jle	.L60
kusano 2b45e8
	ALIGN_2
kusano 2b45e8
kusano 2b45e8
.L61:
kusano 2b45e8
	movl	A, %ebx			# a_offset = a
kusano 2b45e8
	fldz				# ct1 = ZERO
kusano 2b45e8
	movl	LDA, %edx
kusano 2b45e8
	fldz				# ct1 = ZERO
kusano 2b45e8
kusano 2b45e8
	addl	%ebx, %edx
kusano 2b45e8
	fldz				# ct1 = ZERO
kusano 2b45e8
	movl	%edx, A
kusano 2b45e8
	fldz				# ct1 = ZERO
kusano 2b45e8
kusano 2b45e8
	movl	XP, %esi
kusano 2b45e8
kusano 2b45e8
	FLD	(%esi)			#  bt1 = *(b_offset + 0)
kusano 2b45e8
kusano 2b45e8
	movl	MIN_M, %eax
kusano 2b45e8
	sarl	$1,    %eax
kusano 2b45e8
	jle	.L64
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
#define PRESIZE 8
kusano 2b45e8
kusano 2b45e8
.L65:
kusano 2b45e8
#ifdef HAS_PREFETCH
kusano 2b45e8
       prefetcht0	PRESIZE * SIZE(%ebx)
kusano 2b45e8
       prefetcht0	PRESIZE * SIZE(%esi)
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
	FLD	 0 * SIZE(%ebx)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1), %st			# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(2)		# ct1 += at1
kusano 2b45e8
kusano 2b45e8
	FMUL	 1 * SIZE(%ebx)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
#ifndef CONJ
kusano 2b45e8
	faddp	%st, %st(2)		# ct2 += bt1
kusano 2b45e8
#else
kusano 2b45e8
	fsubrp	%st, %st(2)		# ct2 -= bt1
kusano 2b45e8
#endif
kusano 2b45e8
	FLD	 1 * SIZE(%esi)		# bt1  = *(b_offset + 1)
kusano 2b45e8
kusano 2b45e8
	FLD	 0 * SIZE(%ebx)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1), %st		# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(4)		# ct3 += at1
kusano 2b45e8
kusano 2b45e8
	FMUL	 1 * SIZE(%ebx)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	faddp	%st, %st(4)		# ct4 += bt1
kusano 2b45e8
	FLD	 2 * SIZE(%esi)		# bt1  = *(b_offset + 1)
kusano 2b45e8
kusano 2b45e8
	FLD	 2 * SIZE(%ebx)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1), %st		# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(2)		# ct1 += at1
kusano 2b45e8
kusano 2b45e8
	FMUL	 3 * SIZE(%ebx)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
#ifndef CONJ
kusano 2b45e8
	faddp	%st, %st(2)		# ct2 += bt1
kusano 2b45e8
#else
kusano 2b45e8
	fsubrp	%st, %st(2)		# ct2 -= bt1
kusano 2b45e8
#endif
kusano 2b45e8
	FLD	 3 * SIZE(%esi)		# bt1  = *(b_offset + 1)
kusano 2b45e8
kusano 2b45e8
	FLD	 2 * SIZE(%ebx)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1), %st		# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(4)		# ct3 += at1
kusano 2b45e8
kusano 2b45e8
	FMUL	 3 * SIZE(%ebx)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	faddp	%st, %st(4)		# ct4 += bt1
kusano 2b45e8
	FLD	 4 * SIZE(%esi)		# bt1  = *(b_offset + 1)
kusano 2b45e8
kusano 2b45e8
	addl	$4 * SIZE, %esi
kusano 2b45e8
	addl	$4 * SIZE, %ebx
kusano 2b45e8
	decl	%eax
kusano 2b45e8
	jg	.L65
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L64:
kusano 2b45e8
	movl	MIN_M, %eax
kusano 2b45e8
	andl	$1, %eax
kusano 2b45e8
	jle	.L70
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L71:
kusano 2b45e8
	FLD	 0 * SIZE(%ebx)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1), %st		# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(2)		# ct1 += at1
kusano 2b45e8
kusano 2b45e8
	FMUL	 1 * SIZE(%ebx)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
#ifndef CONJ
kusano 2b45e8
	faddp	%st, %st(2)		# ct2 += bt1
kusano 2b45e8
#else
kusano 2b45e8
	fsubrp	%st, %st(2)		# ct2 -= bt1
kusano 2b45e8
#endif
kusano 2b45e8
	FLD	 1 * SIZE(%esi)		# bt1  = *(b_offset + 1)
kusano 2b45e8
kusano 2b45e8
	FLD	 0 * SIZE(%ebx)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1), %st		# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(4)		# ct3 += at1
kusano 2b45e8
kusano 2b45e8
	FMUL	 1 * SIZE(%ebx)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	faddp	%st, %st(4)		# ct4 += bt1
kusano 2b45e8
	fldz
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L70:
kusano 2b45e8
#ifndef C_SUN
kusano 2b45e8
	ffreep	%st(0)
kusano 2b45e8
#else
kusano 2b45e8
	.byte	0xdf
kusano 2b45e8
	.byte	0xc0
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef XCONJ
kusano 2b45e8
#ifndef CONJ
kusano 2b45e8
	fsubp	%st, %st(3)
kusano 2b45e8
	faddp	%st, %st(1)
kusano 2b45e8
#else
kusano 2b45e8
	faddp	%st, %st(3)
kusano 2b45e8
	faddp	%st, %st(1)
kusano 2b45e8
#endif
kusano 2b45e8
#else
kusano 2b45e8
#ifndef CONJ
kusano 2b45e8
	faddp	%st, %st(3)
kusano 2b45e8
	fsubp	%st, %st(1)
kusano 2b45e8
#else
kusano 2b45e8
	fsubp	%st, %st(3)
kusano 2b45e8
	fsubp	%st, %st(1)
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
	fld	%st(0)		# ct4 = ct2
kusano 2b45e8
	fmul	%st(4), %st
kusano 2b45e8
	fld	%st(2)
kusano 2b45e8
	fmul	%st(4), %st
kusano 2b45e8
	fsubp	%st, %st(1)
kusano 2b45e8
kusano 2b45e8
	FADD	0 * SIZE(%ebp)
kusano 2b45e8
	FST	0 * SIZE(%ebp)
kusano 2b45e8
kusano 2b45e8
	fmul	%st(2), %st
kusano 2b45e8
	fxch	%st(1)
kusano 2b45e8
	fmul	%st(3), %st
kusano 2b45e8
	faddp	%st, %st(1)
kusano 2b45e8
kusano 2b45e8
	FADD	1 * SIZE(%ebp)
kusano 2b45e8
	FST	1 * SIZE(%ebp)
kusano 2b45e8
	addl	INCY, %ebp
kusano 2b45e8
kusano 2b45e8
	decl	%ecx
kusano 2b45e8
	jg	.L61
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L60:
kusano 2b45e8
	movl	A, %ebx
kusano 2b45e8
	addl	NLDA, %ebx
kusano 2b45e8
	movl	%ebx, A
kusano 2b45e8
kusano 2b45e8
	addl	$P,  IS
kusano 2b45e8
	movl	M, %esi
kusano 2b45e8
	cmpl	%esi, IS
kusano 2b45e8
	jl	.L32
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L79:
kusano 2b45e8
#ifndef C_SUN
kusano 2b45e8
	ffreep	%st(0)
kusano 2b45e8
	ffreep	%st(0)
kusano 2b45e8
#else
kusano 2b45e8
	.byte	0xdf
kusano 2b45e8
	.byte	0xc0
kusano 2b45e8
	.byte	0xdf
kusano 2b45e8
	.byte	0xc0
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
	popl	%ebx
kusano 2b45e8
	popl	%esi
kusano 2b45e8
	popl	%edi
kusano 2b45e8
	popl	%ebp
kusano 2b45e8
	addl	$ARGS, %esp
kusano 2b45e8
	ret
kusano 2b45e8
kusano 2b45e8
	EPILOGUE
kusano 2b45e8