Blame sysdeps/s390/multiarch/wcscmp-vx.S

Packit Service 1f32a9
/* Vector optimized 32/64 bit S/390 version of wcscmp.
Packit Service 1f32a9
   Copyright (C) 2015-2018 Free Software Foundation, Inc.
Packit Service 1f32a9
   This file is part of the GNU C Library.
Packit Service 1f32a9
Packit Service 1f32a9
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 1f32a9
   modify it under the terms of the GNU Lesser General Public
Packit Service 1f32a9
   License as published by the Free Software Foundation; either
Packit Service 1f32a9
   version 2.1 of the License, or (at your option) any later version.
Packit Service 1f32a9
Packit Service 1f32a9
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 1f32a9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 1f32a9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 1f32a9
   Lesser General Public License for more details.
Packit Service 1f32a9
Packit Service 1f32a9
   You should have received a copy of the GNU Lesser General Public
Packit Service 1f32a9
   License along with the GNU C Library; if not, see
Packit Service 1f32a9
   <http://www.gnu.org/licenses/>.  */
Packit Service 1f32a9
Packit Service 1f32a9
#if defined HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc)
Packit Service 1f32a9
Packit Service 1f32a9
# include "sysdep.h"
Packit Service 1f32a9
# include "asm-syntax.h"
Packit Service 1f32a9
Packit Service 1f32a9
	.text
Packit Service 1f32a9
Packit Service 1f32a9
/* int wcscmp (const wchar_t *s1, const wchar_t *s2)
Packit Service 1f32a9
   Compare two strings
Packit Service 1f32a9
Packit Service 1f32a9
   Register usage:
Packit Service 1f32a9
   -r1=loaded byte count s1
Packit Service 1f32a9
   -r2=s1
Packit Service 1f32a9
   -r3=s2
Packit Service 1f32a9
   -r4=loaded byte coutn s2, tmp
Packit Service 1f32a9
   -r5=current_len
Packit Service 1f32a9
   -v16=part of s1
Packit Service 1f32a9
   -v17=part of s2
Packit Service 1f32a9
   -v18=index of unequal
Packit Service 1f32a9
*/
Packit Service 1f32a9
ENTRY(__wcscmp_vx)
Packit Service 1f32a9
	.machine "z13"
Packit Service 1f32a9
	.machinemode "zarch_nohighgprs"
Packit Service 1f32a9
Packit Service 1f32a9
	lghi	%r5,0		/* current_len = 0.  */
Packit Service 1f32a9
Packit Service 1f32a9
.Lloop:
Packit Service 1f32a9
	vlbb	%v16,0(%r5,%r2),6 /* Load s1 to block boundary.  */
Packit Service 1f32a9
	vlbb	%v17,0(%r5,%r3),6 /* Load s2 to block boundary.  */
Packit Service 1f32a9
	lcbb	%r1,0(%r5,%r2),6 /* Get loaded byte count of s1.  */
Packit Service 1f32a9
	jo	.Llt16_1	/* Jump away if vr is not fully loaded.  */
Packit Service 1f32a9
	lcbb	%r4,0(%r5,%r3),6
Packit Service 1f32a9
	jo	.Llt16_2	/* Jump away if vr is not fully loaded.  */
Packit Service 1f32a9
	/* Both vrs are fully loaded.  */
Packit Service 1f32a9
	aghi	%r5,16
Packit Service 1f32a9
	vfenezfs %v18,%v16,%v17	/* Compare not equal with zero search.  */
Packit Service 1f32a9
	jno	.Lfound
Packit Service 1f32a9
Packit Service 1f32a9
	vlbb	%v16,0(%r5,%r2),6
Packit Service 1f32a9
	vlbb	%v17,0(%r5,%r3),6
Packit Service 1f32a9
	lcbb	%r1,0(%r5,%r2),6
Packit Service 1f32a9
	jo	.Llt16_1
Packit Service 1f32a9
	lcbb	%r4,0(%r5,%r3),6
Packit Service 1f32a9
	jo	.Llt16_2
Packit Service 1f32a9
	aghi	%r5,16
Packit Service 1f32a9
	vfenezfs %v18,%v16,%v17
Packit Service 1f32a9
	jno	.Lfound
Packit Service 1f32a9
Packit Service 1f32a9
	vlbb	%v16,0(%r5,%r2),6
Packit Service 1f32a9
	vlbb	%v17,0(%r5,%r3),6
Packit Service 1f32a9
	lcbb	%r1,0(%r5,%r2),6
Packit Service 1f32a9
	jo	.Llt16_1
Packit Service 1f32a9
	lcbb	%r4,0(%r5,%r3),6
Packit Service 1f32a9
	jo	.Llt16_2
Packit Service 1f32a9
	aghi	%r5,16
Packit Service 1f32a9
	vfenezfs %v18,%v16,%v17
Packit Service 1f32a9
	jno	.Lfound
Packit Service 1f32a9
Packit Service 1f32a9
	vlbb	%v16,0(%r5,%r2),6
Packit Service 1f32a9
	vlbb	%v17,0(%r5,%r3),6
Packit Service 1f32a9
	lcbb	%r1,0(%r5,%r2),6
Packit Service 1f32a9
	jo	.Llt16_1
Packit Service 1f32a9
	lcbb	%r4,0(%r5,%r3),6
Packit Service 1f32a9
	jo	.Llt16_2
Packit Service 1f32a9
	aghi	%r5,16
Packit Service 1f32a9
	vfenezfs %v18,%v16,%v17
Packit Service 1f32a9
	jno	.Lfound
Packit Service 1f32a9
	j	.Lloop
Packit Service 1f32a9
Packit Service 1f32a9
.Lcmp_one_char:
Packit Service 1f32a9
	/* At least one of both strings is not 4-byte aligned
Packit Service 1f32a9
	   and there is no full character before next block-boundary.
Packit Service 1f32a9
	   Compare one character to get over the boundary and
Packit Service 1f32a9
	   proceed with normal loop!  */
Packit Service 1f32a9
	vlef	%v16,0(%r5,%r2),0 /* Load one character.  */
Packit Service 1f32a9
	vlef	%v17,0(%r5,%r3),0
Packit Service 1f32a9
	lghi	%r1,4		/* Loaded byte count is 4.  */
Packit Service 1f32a9
	j	.Llt_cmp	/* Proceed with comparision.  */
Packit Service 1f32a9
Packit Service 1f32a9
.Llt16_1:
Packit Service 1f32a9
	lcbb	%r4,0(%r5,%r3),6 /* Get loaded byte count of s2.  */
Packit Service 1f32a9
.Llt16_2:
Packit Service 1f32a9
	clr	%r1,%r4
Packit Service 1f32a9
	locrh	%r1,%r4		/* Get minimum of bytes loaded in s1/2.  */
Packit Service 1f32a9
	nill	%r1,65532	/* Align bytes loaded to full characters.  */
Packit Service 1f32a9
	jz	.Lcmp_one_char	/* Jump away if no full char is available.  */
Packit Service 1f32a9
.Llt_cmp:
Packit Service 1f32a9
	algfr	%r5,%r1		/* Add smallest loaded bytes to current_len.  */
Packit Service 1f32a9
	vfenezfs %v18,%v16,%v17	/* Compare not equal with zero search.  */
Packit Service 1f32a9
	vlgvb	%r4,%v18,7	/* Get not equal index or 16 if all equal.  */
Packit Service 1f32a9
	clrjl	%r4,%r1,.Lfound /* Jump away if miscompare is within loaded
Packit Service 1f32a9
				    bytes.  */
Packit Service 1f32a9
	j	.Lloop
Packit Service 1f32a9
Packit Service 1f32a9
.Lfound:
Packit Service 1f32a9
	/* vfenezf found an unequal element or zero.
Packit Service 1f32a9
	   This instruction compares unsigned words, but wchar_t is signed.
Packit Service 1f32a9
	   Thus we have to compare the found element again.  */
Packit Service 1f32a9
	vlgvb	%r4,%v18,7	/* Extract not equal byte-index,  */
Packit Service 1f32a9
	srl	%r4,2		/* Convert it to character-index.  */
Packit Service 1f32a9
	vlgvf	%r3,%v16,0(%r4)	/* Load character-values.  */
Packit Service 1f32a9
	vlgvf	%r4,%v17,0(%r4)
Packit Service 1f32a9
	cr	%r3,%r4
Packit Service 1f32a9
	je	.Lend_equal
Packit Service 1f32a9
	lghi	%r2,1
Packit Service 1f32a9
	lghi	%r1,-1
Packit Service 1f32a9
	locgrl	%r2,%r1
Packit Service 1f32a9
	br	%r14
Packit Service 1f32a9
.Lend_equal:
Packit Service 1f32a9
	lghi	%r2,0
Packit Service 1f32a9
	br	%r14
Packit Service 1f32a9
END(__wcscmp_vx)
Packit Service 1f32a9
#endif /* HAVE_S390_VX_ASM_SUPPORT && IS_IN (libc) */