Blame thirdparty/openblas/xianyi-OpenBLAS-e6e87a2/kernel/x86_64/xgemv_n.S

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 "l2param.h"
kusano 2b45e8
kusano 2b45e8
#define P		32
kusano 2b45e8
	
kusano 2b45e8
#define STACKSIZE	80
kusano 2b45e8
	
kusano 2b45e8
#define ALPHA_R		 8 + STACKSIZE(%rsp)
kusano 2b45e8
#define ALPHA_I		24 + STACKSIZE(%rsp)
kusano 2b45e8
#define OLD_INCX	40 + STACKSIZE(%rsp)
kusano 2b45e8
#define OLD_Y		48 + STACKSIZE(%rsp)
kusano 2b45e8
#define OLD_INCY	56 + STACKSIZE(%rsp)
kusano 2b45e8
#define BUFFER		64 + STACKSIZE(%rsp)
kusano 2b45e8
kusano 2b45e8
#define PLDA_M	        56            (%rsp)
kusano 2b45e8
#define IS		64	      (%rsp)
kusano 2b45e8
kusano 2b45e8
#define M	  %rdi
kusano 2b45e8
#define N	  %rsi
kusano 2b45e8
#define A	  %rcx
kusano 2b45e8
#define LDA	  %r8
kusano 2b45e8
#define X	  %r9
kusano 2b45e8
#define INCX	  %rdx
kusano 2b45e8
#define Y	  %rbp
kusano 2b45e8
#define INCY	  %r10
kusano 2b45e8
kusano 2b45e8
#define TEMP	%rax
kusano 2b45e8
#define I	%rax
kusano 2b45e8
#define J	%r11
kusano 2b45e8
#define A1	%r12
kusano 2b45e8
#define X1	%r13
kusano 2b45e8
#define Y1	%r14
kusano 2b45e8
#define XP	%r15
kusano 2b45e8
#define MIN_N	%rbx
kusano 2b45e8
	
kusano 2b45e8
kusano 2b45e8
	PROLOGUE
kusano 2b45e8
	PROFCODE
kusano 2b45e8
kusano 2b45e8
	subq	$STACKSIZE, %rsp
kusano 2b45e8
	movq	%rbx,  0(%rsp)
kusano 2b45e8
	movq	%rbp,  8(%rsp)
kusano 2b45e8
	movq	%r12, 16(%rsp)
kusano 2b45e8
	movq	%r13, 24(%rsp)
kusano 2b45e8
	movq	%r14, 32(%rsp)
kusano 2b45e8
	movq	%r15, 40(%rsp)
kusano 2b45e8
kusano 2b45e8
	movq	OLD_INCX,   INCX
kusano 2b45e8
	movq	OLD_Y,      Y
kusano 2b45e8
	movq	OLD_INCY,   INCY
kusano 2b45e8
kusano 2b45e8
	FLD	ALPHA_I
kusano 2b45e8
	FLD	ALPHA_R
kusano 2b45e8
kusano 2b45e8
	salq	$ZBASE_SHIFT, INCX
kusano 2b45e8
	salq	$ZBASE_SHIFT, INCY
kusano 2b45e8
kusano 2b45e8
	movq	$0, IS
kusano 2b45e8
kusano 2b45e8
	test	M, M
kusano 2b45e8
	jle	.L79
kusano 2b45e8
	test	N, N
kusano 2b45e8
	jle	.L79
kusano 2b45e8
kusano 2b45e8
	movq	LDA, %rax
kusano 2b45e8
	imulq	$P,  %rax		# P * lda
kusano 2b45e8
	subq	M   ,%rax		# P * lda - m
kusano 2b45e8
	salq	$ZBASE_SHIFT, %rax
kusano 2b45e8
	movq	%rax, PLDA_M
kusano 2b45e8
kusano 2b45e8
	salq	$ZBASE_SHIFT, LDA
kusano 2b45e8
	ALIGN_2
kusano 2b45e8
kusano 2b45e8
.L32:
kusano 2b45e8
	movq	$P,  %rax
kusano 2b45e8
	movq	N,    MIN_N
kusano 2b45e8
	subq	IS,   MIN_N
kusano 2b45e8
	cmpq	%rax, MIN_N
kusano 2b45e8
	cmovg	%rax, MIN_N
kusano 2b45e8
kusano 2b45e8
	movq	IS, XP
kusano 2b45e8
	salq	$ZBASE_SHIFT, XP
kusano 2b45e8
	leaq	(X,XP, 1), XP
kusano 2b45e8
kusano 2b45e8
	cmpq	$2 * SIZE, INCX
kusano 2b45e8
	je	.L34
kusano 2b45e8
kusano 2b45e8
	movq	BUFFER, XP
kusano 2b45e8
	movq	XP,     X1
kusano 2b45e8
kusano 2b45e8
	movq	MIN_N, I
kusano 2b45e8
	sarq	$1,    I
kusano 2b45e8
	jle	.L35
kusano 2b45e8
	ALIGN_2
kusano 2b45e8
kusano 2b45e8
.L36:
kusano 2b45e8
	FLD	0 * SIZE(X)
kusano 2b45e8
	FLD	1 * SIZE(X)
kusano 2b45e8
	addq	INCX,X		# x += incx
kusano 2b45e8
	FLD	0 * SIZE(X)
kusano 2b45e8
	FLD	1 * SIZE(X)
kusano 2b45e8
	addq	INCX,X		# x += incx
kusano 2b45e8
kusano 2b45e8
	FST	3 * SIZE(X1)
kusano 2b45e8
	FST	2 * SIZE(X1)
kusano 2b45e8
	FST	1 * SIZE(X1)
kusano 2b45e8
	FST	0 * SIZE(X1)
kusano 2b45e8
kusano 2b45e8
	addq	$4 * SIZE, X1		# xp += 4
kusano 2b45e8
	decq	I
kusano 2b45e8
	jg	.L36
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L35:
kusano 2b45e8
	movq	MIN_N, I
kusano 2b45e8
	andq	$1,    I
kusano 2b45e8
	jle	.L34
kusano 2b45e8
kusano 2b45e8
	FLD	0 * SIZE(X)
kusano 2b45e8
	FLD	1 * SIZE(X)
kusano 2b45e8
	addq	INCX,X		# x += incx
kusano 2b45e8
	FST	1 * SIZE(X1)
kusano 2b45e8
	FST	0 * SIZE(X1)
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
/* Main Routine */
kusano 2b45e8
.L34:
kusano 2b45e8
	movq	 Y, Y1		# c_offset
kusano 2b45e8
	movq	 M, J		# j = m
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L61:
kusano 2b45e8
	movq	A, A1			# a_offset = a
kusano 2b45e8
	addq	$2 * SIZE, A		# a++
kusano 2b45e8
kusano 2b45e8
	fldz
kusano 2b45e8
	fldz
kusano 2b45e8
	fldz
kusano 2b45e8
	fldz
kusano 2b45e8
kusano 2b45e8
	movq	XP, X1
kusano 2b45e8
	FLD	(X1)			#  bt1 = *(b_offset + 0)
kusano 2b45e8
kusano 2b45e8
	movq	MIN_N, I
kusano 2b45e8
	sarq	$1,    I
kusano 2b45e8
	jle	.L64
kusano 2b45e8
	ALIGN_3
kusano 2b45e8
kusano 2b45e8
.L65:
kusano 2b45e8
	FLD	 0 * SIZE(A1)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1)			# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(2)		# ct1 += at1
kusano 2b45e8
kusano 2b45e8
	FLD	 1 * SIZE(A1)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	fmulp	 %st, %st(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(X1)		# bt1  = *(b_offset + 1)
kusano 2b45e8
kusano 2b45e8
	FLD	 0 * SIZE(A1)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1)			# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(4)		# ct3 += at1
kusano 2b45e8
kusano 2b45e8
	FLD	 1 * SIZE(A1)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	fmulp	 %st, %st(1)
kusano 2b45e8
	faddp	%st, %st(4)		# ct4 += bt1
kusano 2b45e8
	FLD	 2 * SIZE(X1)		# bt1  = *(b_offset + 2)
kusano 2b45e8
kusano 2b45e8
	addq	$2 * SIZE, X1		# b_offset += 2
kusano 2b45e8
	addq	LDA,  A1		# a_offset += lda
kusano 2b45e8
kusano 2b45e8
	FLD	 0 * SIZE(A1)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1)			# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(2)		# ct1 += at1
kusano 2b45e8
kusano 2b45e8
	FLD	 1 * SIZE(A1)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	fmulp	 %st, %st(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(X1)		# bt1  = *(b_offset + 1)
kusano 2b45e8
kusano 2b45e8
	FLD	 0 * SIZE(A1)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1)			# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(4)		# ct3 += at1
kusano 2b45e8
kusano 2b45e8
	FLD	 1 * SIZE(A1)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	fmulp	 %st, %st(1)
kusano 2b45e8
	faddp	%st, %st(4)		# ct4 += bt1
kusano 2b45e8
	FLD	 2 * SIZE(X1)		# bt1  = *(b_offset + 2)
kusano 2b45e8
kusano 2b45e8
	addq	$2 * SIZE, X1		# b_offset += 2
kusano 2b45e8
	addq	LDA,  A1		# a_offset += lda
kusano 2b45e8
kusano 2b45e8
	decq	I
kusano 2b45e8
	jg	.L65
kusano 2b45e8
kusano 2b45e8
.L64:
kusano 2b45e8
	movq	MIN_N, I
kusano 2b45e8
	andq	$1, I
kusano 2b45e8
	jle	.L70
kusano 2b45e8
	ALIGN_2
kusano 2b45e8
kusano 2b45e8
.L71:
kusano 2b45e8
	FLD	 0 * SIZE(A1)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1)			# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(2)		# ct1 += at1
kusano 2b45e8
kusano 2b45e8
	FLD	 1 * SIZE(A1)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	fmulp	 %st, %st(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(X1)		# bt1  = *(b_offset + 1)
kusano 2b45e8
kusano 2b45e8
	FLD	 0 * SIZE(A1)		# at1  = *(a_offset + 0)
kusano 2b45e8
	fmul	%st(1)			# at1 *= bt1
kusano 2b45e8
	faddp	%st, %st(4)		# ct3 += at1
kusano 2b45e8
kusano 2b45e8
	FLD	 1 * SIZE(A1)		# bt1 *= *(a_offset + 1)
kusano 2b45e8
	fmulp	 %st, %st(1)
kusano 2b45e8
	faddp	%st, %st(4)		# ct4 += bt1
kusano 2b45e8
	fldz
kusano 2b45e8
	ALIGN_2
kusano 2b45e8
kusano 2b45e8
.L70:
kusano 2b45e8
	ffreep	%st(0)
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)
kusano 2b45e8
	fld	%st(2)
kusano 2b45e8
	fmul	%st(4)
kusano 2b45e8
	fsubp	%st, %st(1)
kusano 2b45e8
kusano 2b45e8
	FLD	0 * SIZE(Y1)
kusano 2b45e8
	faddp	 %st, %st(1)
kusano 2b45e8
	FST	0 * SIZE(Y1)
kusano 2b45e8
kusano 2b45e8
	fmul	%st(2)
kusano 2b45e8
	fxch	%st(1)
kusano 2b45e8
	fmul	%st(3)
kusano 2b45e8
	faddp	%st, %st(1)
kusano 2b45e8
kusano 2b45e8
	FLD	1 * SIZE(Y1)
kusano 2b45e8
	faddp	 %st, %st(1)
kusano 2b45e8
	FST	1 * SIZE(Y1)
kusano 2b45e8
kusano 2b45e8
	addq	INCY, Y1
kusano 2b45e8
	decq	J
kusano 2b45e8
	jg	.L61
kusano 2b45e8
kusano 2b45e8
.L60:
kusano 2b45e8
	addq	PLDA_M, A
kusano 2b45e8
	addq	$P, IS
kusano 2b45e8
	cmpq	N,  IS
kusano 2b45e8
	jl	.L32
kusano 2b45e8
kusano 2b45e8
.L79:
kusano 2b45e8
	ffreep	%st
kusano 2b45e8
	ffreep	%st
kusano 2b45e8
kusano 2b45e8
	movq	  0(%rsp), %rbx
kusano 2b45e8
	movq	  8(%rsp), %rbp
kusano 2b45e8
	movq	 16(%rsp), %r12
kusano 2b45e8
	movq	 24(%rsp), %r13
kusano 2b45e8
	movq	 32(%rsp), %r14
kusano 2b45e8
	movq	 40(%rsp), %r15
kusano 2b45e8
	addq	$STACKSIZE, %rsp
kusano 2b45e8
	ret
kusano 2b45e8
	EPILOGUE