Blame thirdparty/openblas/xianyi-OpenBLAS-e6e87a2/kernel/x86/gemm_tcopy_2_sse.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
kusano 2b45e8
#define RPREFETCHSIZE	12
kusano 2b45e8
#define WPREFETCHSIZE (RPREFETCHSIZE * 2)
kusano 2b45e8
#define PREFETCH      prefetcht0
kusano 2b45e8
#define PREFETCHW     prefetcht2
kusano 2b45e8
kusano 2b45e8
#define STACK	16
kusano 2b45e8
#define ARGS	 8
kusano 2b45e8
	
kusano 2b45e8
#define J	 0 + STACK(%esp)
kusano 2b45e8
#define BOFFSET2 4 + STACK(%esp)
kusano 2b45e8
kusano 2b45e8
#define M	 4 + STACK + ARGS(%esp)
kusano 2b45e8
#define N	 8 + STACK + ARGS(%esp)
kusano 2b45e8
#define A	12 + STACK + ARGS(%esp)
kusano 2b45e8
#define LDA	16 + STACK + ARGS(%esp)
kusano 2b45e8
#define B	20 + STACK + ARGS(%esp)
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
	movl	A, %ebp
kusano 2b45e8
	movl	B, %edi
kusano 2b45e8
kusano 2b45e8
	movl	M,   %ebx
kusano 2b45e8
	movl	N,   %eax
kusano 2b45e8
	andl	$-2, %eax
kusano 2b45e8
kusano 2b45e8
	imull	%ebx, %eax		# m * ( n & ~1)
kusano 2b45e8
kusano 2b45e8
	leal	(%edi,%eax,SIZE), %eax	# boffset2 = b + m * (n & ~1)
kusano 2b45e8
	movl	%eax, BOFFSET2
kusano 2b45e8
kusano 2b45e8
	movl	M, %esi
kusano 2b45e8
#ifdef DOUBLE
kusano 2b45e8
	sall	$4,%esi
kusano 2b45e8
#else
kusano 2b45e8
	sall	$3,%esi
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
	sarl	$1,  %ebx		# if !(m & 1) goto L28
kusano 2b45e8
	movl	%ebx, J
kusano 2b45e8
	jle	.L28
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L39:
kusano 2b45e8
	movl	%ebp, %edx		# aoffset1 = a
kusano 2b45e8
	movl	LDA,  %eax
kusano 2b45e8
	movl	N,    %ebx
kusano 2b45e8
kusano 2b45e8
	leal	(%ebp, %eax,SIZE), %ecx	# aoffset2 = a + lda
kusano 2b45e8
	leal	(%ecx, %eax,SIZE), %ebp	# aoffset += 2 * lda
kusano 2b45e8
	movl	%edi, %eax		# boffset1 = b_offset
kusano 2b45e8
	addl	$4 * SIZE, %edi		# boffset += 4
kusano 2b45e8
kusano 2b45e8
	sarl	$2, %ebx
kusano 2b45e8
	jle	.L32
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L36:
kusano 2b45e8
	PREFETCH	RPREFETCHSIZE * SIZE(%edx)
kusano 2b45e8
kusano 2b45e8
	movsd	0 * SIZE(%edx), %xmm0
kusano 2b45e8
	movhps	1 * SIZE(%edx), %xmm0
kusano 2b45e8
	movsd	0 * SIZE(%ecx), %xmm2
kusano 2b45e8
	movhps	1 * SIZE(%ecx), %xmm2
kusano 2b45e8
kusano 2b45e8
	PREFETCH	RPREFETCHSIZE * SIZE(%ecx)
kusano 2b45e8
kusano 2b45e8
	movsd	2 * SIZE(%edx), %xmm4
kusano 2b45e8
	movhps	3 * SIZE(%edx), %xmm4
kusano 2b45e8
	movsd	2 * SIZE(%ecx), %xmm6
kusano 2b45e8
	movhps	3 * SIZE(%ecx), %xmm6
kusano 2b45e8
kusano 2b45e8
	movaps	%xmm0, 0 * SIZE(%eax)
kusano 2b45e8
	movaps	%xmm2, 2 * SIZE(%eax)
kusano 2b45e8
kusano 2b45e8
	addl	%esi, %eax
kusano 2b45e8
kusano 2b45e8
	movaps	%xmm4, 0 * SIZE(%eax)
kusano 2b45e8
	movaps	%xmm6, 2 * SIZE(%eax)
kusano 2b45e8
kusano 2b45e8
	addl	$4 * SIZE, %ecx
kusano 2b45e8
	addl	$4 * SIZE, %edx
kusano 2b45e8
	addl	%esi, %eax
kusano 2b45e8
	decl	%ebx
kusano 2b45e8
	jne	.L36
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L32:
kusano 2b45e8
	movl	N,  %ebx
kusano 2b45e8
	test	$2, %ebx
kusano 2b45e8
	je	.L37
kusano 2b45e8
kusano 2b45e8
	PREFETCH	RPREFETCHSIZE * SIZE(%edx)
kusano 2b45e8
	movsd	0 * SIZE(%edx), %xmm0
kusano 2b45e8
	movhps	1 * SIZE(%edx), %xmm0
kusano 2b45e8
kusano 2b45e8
	PREFETCH	RPREFETCHSIZE * SIZE(%ecx)
kusano 2b45e8
	movsd	0 * SIZE(%ecx), %xmm2
kusano 2b45e8
	movhps	1 * SIZE(%ecx), %xmm2
kusano 2b45e8
kusano 2b45e8
	movaps	%xmm0, 0 * SIZE(%eax)
kusano 2b45e8
	movaps	%xmm2, 2 * SIZE(%eax)
kusano 2b45e8
kusano 2b45e8
	addl	$2 * SIZE, %ecx
kusano 2b45e8
	addl	$2 * SIZE, %edx
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L37:
kusano 2b45e8
	movl	N, %ebx
kusano 2b45e8
	test	$1, %ebx
kusano 2b45e8
	je	.L38
kusano 2b45e8
kusano 2b45e8
	movl	BOFFSET2, %eax
kusano 2b45e8
kusano 2b45e8
	movsd	0 * SIZE(%edx), %xmm0
kusano 2b45e8
	movhps	0 * SIZE(%ecx), %xmm0
kusano 2b45e8
	movaps	%xmm0, 0 * SIZE(%eax)
kusano 2b45e8
kusano 2b45e8
	addl	$2 * SIZE, %eax
kusano 2b45e8
	movl	%eax, BOFFSET2
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L38:
kusano 2b45e8
	decl	J
kusano 2b45e8
	jg	.L39
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L28:
kusano 2b45e8
	movl	M,  %eax
kusano 2b45e8
	movl	N, %ebx
kusano 2b45e8
kusano 2b45e8
	testb	$1, %al
kusano 2b45e8
	je	.L40
kusano 2b45e8
kusano 2b45e8
	sarl	$2, %ebx
kusano 2b45e8
	jle	.L41
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L45:
kusano 2b45e8
	movsd	0 * SIZE(%ebp), %xmm0
kusano 2b45e8
	movhps	1 * SIZE(%ebp), %xmm0
kusano 2b45e8
	movsd	2 * SIZE(%ebp), %xmm2
kusano 2b45e8
	movhps	3 * SIZE(%ebp), %xmm2
kusano 2b45e8
kusano 2b45e8
	movaps	%xmm0, 0 * SIZE(%edi)
kusano 2b45e8
kusano 2b45e8
	addl	%esi, %edi
kusano 2b45e8
kusano 2b45e8
	movaps  %xmm2, 0 * SIZE(%edi)
kusano 2b45e8
kusano 2b45e8
	addl	%esi,%edi
kusano 2b45e8
	addl	$4 * SIZE, %ebp
kusano 2b45e8
	decl	%ebx
kusano 2b45e8
	jg	.L45
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L41:
kusano 2b45e8
	movl	N,  %ebx
kusano 2b45e8
	test	$2, %ebx
kusano 2b45e8
	je	.L46
kusano 2b45e8
kusano 2b45e8
	movsd	0 * SIZE(%ebp), %xmm0
kusano 2b45e8
	movhps	1 * SIZE(%ebp), %xmm0
kusano 2b45e8
	movaps	%xmm0, 0 * SIZE(%edi)
kusano 2b45e8
	addl	$2 * SIZE, %ebp
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L46:
kusano 2b45e8
	movl	N,  %ebx
kusano 2b45e8
	test	$1, %ebx
kusano 2b45e8
	je	.L40
kusano 2b45e8
kusano 2b45e8
	movl	BOFFSET2, %eax
kusano 2b45e8
kusano 2b45e8
	movsd	0 * SIZE(%ebp), %xmm0
kusano 2b45e8
	movsd	%xmm0, 0 * SIZE(%eax)
kusano 2b45e8
	ALIGN_4
kusano 2b45e8
kusano 2b45e8
.L40:
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