xref: /freebsd/lib/libc/powerpc64/string/memcpy_vsx.S (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1e16c1865SLeandro Lupori/*-
2e16c1865SLeandro Lupori * Copyright (c) 2018 Instituto de Pesquisas Eldorado
3e16c1865SLeandro Lupori * All rights reserved.
4e16c1865SLeandro Lupori *
5e16c1865SLeandro Lupori * Redistribution and use in source and binary forms, with or without
6e16c1865SLeandro Lupori * modification, are permitted provided that the following conditions
7e16c1865SLeandro Lupori * are met:
8e16c1865SLeandro Lupori * 1. Redistributions of source code must retain the above copyright
9e16c1865SLeandro Lupori *    notice, this list of conditions and the following disclaimer.
10e16c1865SLeandro Lupori * 2. Redistributions in binary form must reproduce the above copyright
11e16c1865SLeandro Lupori *    notice, this list of conditions and the following disclaimer in the
12e16c1865SLeandro Lupori *    documentation and/or other materials provided with the distribution.
13e16c1865SLeandro Lupori * 3. Neither the name of the author nor the names of its contributors may
14e16c1865SLeandro Lupori *    be used to endorse or promote products derived from this software
15e16c1865SLeandro Lupori *
16e16c1865SLeandro Lupori * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17e16c1865SLeandro Lupori * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18e16c1865SLeandro Lupori * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19e16c1865SLeandro Lupori * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20e16c1865SLeandro Lupori * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21e16c1865SLeandro Lupori * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22e16c1865SLeandro Lupori * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23e16c1865SLeandro Lupori * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24e16c1865SLeandro Lupori * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25e16c1865SLeandro Lupori * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26e16c1865SLeandro Lupori * SUCH DAMAGE.
27e16c1865SLeandro Lupori */
28e16c1865SLeandro Lupori
29e16c1865SLeandro Lupori#define FN_NAME			__memcpy_vsx
30e16c1865SLeandro Lupori#define BLOCK_BITS		6
31*00797360SJustin Hibbits#define	ALIGN_MASK		0xf
32e16c1865SLeandro Lupori
33e16c1865SLeandro Lupori/*
34e16c1865SLeandro Lupori * r5: bytes to copy (multiple of BLOCK_BYTES)
35e16c1865SLeandro Lupori *
36e16c1865SLeandro Lupori */
37e16c1865SLeandro Lupori#define FN_COPY_LOOP \
38e16c1865SLeandro Lupori	/* Load CTR with number of blocks */		 \
39e16c1865SLeandro Lupori	srdi	%r5, %r5, BLOCK_BITS			;\
40e16c1865SLeandro Lupori	mtctr	%r5					;\
41e16c1865SLeandro Lupori	/* Prepare indexes to load and store data */	 \
42e16c1865SLeandro Lupori	xor	%r6, %r6, %r6				;\
43e16c1865SLeandro Lupori	li	%r9,  16				;\
44e16c1865SLeandro Lupori	li	%r10, 32				;\
45e16c1865SLeandro Lupori	li	%r11, 48				;\
46e16c1865SLeandro Lupori.Lcopy_vsx_loop:					 \
47e16c1865SLeandro Lupori	lxvd2x	%vs6, %r6,  %r4				;\
48e16c1865SLeandro Lupori	lxvd2x	%vs7, %r9,  %r4				;\
49e16c1865SLeandro Lupori	lxvd2x	%vs8, %r10, %r4				;\
50e16c1865SLeandro Lupori	lxvd2x	%vs9, %r11, %r4				;\
51e16c1865SLeandro Lupori	stxvd2x	%vs6, %r6,  %r3				;\
52e16c1865SLeandro Lupori	stxvd2x	%vs7, %r9,  %r3				;\
53e16c1865SLeandro Lupori	stxvd2x	%vs8, %r10, %r3				;\
54e16c1865SLeandro Lupori	stxvd2x	%vs9, %r11, %r3				;\
55e16c1865SLeandro Lupori							 \
56e16c1865SLeandro Lupori	addi	%r3, %r3, BLOCK_BYTES			;\
57e16c1865SLeandro Lupori	addi	%r4, %r4, BLOCK_BYTES			;\
58e16c1865SLeandro Lupori	bdnz	.Lcopy_vsx_loop				;\
59e16c1865SLeandro Lupori							 \
60e16c1865SLeandro Lupori	/* Check if there is remaining bytes */		 \
61e16c1865SLeandro Lupori	cmpd	%r7, 0					;\
62e16c1865SLeandro Lupori	beq		.Lexit				;\
63e16c1865SLeandro Lupori
64e16c1865SLeandro Lupori#include "memcpy.S"
65