hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/s390/multiarch/memset-s390x.S

Packit f7c38e
/* Set a block of memory to some byte value.  31/64 bit S/390 version.
Packit 6c4009
   Copyright (C) 2012-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
Packit 6c4009
#include "sysdep.h"
Packit 6c4009
#include "asm-syntax.h"
Packit 6c4009
Packit 6c4009
/* INPUT PARAMETERS
Packit 6c4009
     %r2 = address of memory area
Packit 6c4009
     %r3 = byte to fill memory with
Packit 6c4009
     %r4 = number of bytes to fill.  */
Packit 6c4009
Packit 6c4009
       .text
Packit 6c4009
Packit 6c4009
#if IS_IN (libc)
Packit 6c4009
Packit 6c4009
ENTRY(__memset_z196)
Packit 6c4009
	.machine "z196"
Packit f7c38e
	.machinemode "zarch_nohighgprs"
Packit f7c38e
# if !defined __s390x__
Packit f7c38e
	llgfr	%r4,%r4
Packit f7c38e
# endif /* !defined __s390x__  */
Packit 6c4009
	ltgr    %r4,%r4
Packit 6c4009
	je      .L_Z196_4
Packit 6c4009
	stc     %r3,0(%r2)
Packit 6c4009
	lgr     %r1,%r2
Packit 6c4009
	cghi    %r4,1
Packit 6c4009
	je      .L_Z196_4
Packit 6c4009
	aghi    %r4,-2
Packit 6c4009
	srlg    %r5,%r4,8
Packit 6c4009
	ltgr    %r5,%r5
Packit 6c4009
	jne     .L_Z196_1
Packit 6c4009
.L_Z196_3:
Packit 6c4009
	exrl    %r4,.L_Z196_17
Packit 6c4009
.L_Z196_4:
Packit 6c4009
	br      %r14
Packit 6c4009
.L_Z196_1:
Packit 6c4009
	cgfi	%r5,1048576
Packit 6c4009
	jh	__memset_mvcle	   # Switch to mvcle for >256MB
Packit 6c4009
.L_Z196_2:
Packit 6c4009
	pfd     2,1024(%r1)
Packit 6c4009
	mvc     1(256,%r1),0(%r1)
Packit 6c4009
	aghi    %r5,-1
Packit 6c4009
	la      %r1,256(%r1)
Packit 6c4009
	jne     .L_Z196_2
Packit 6c4009
	j       .L_Z196_3
Packit 6c4009
.L_Z196_17:
Packit 6c4009
	mvc     1(1,%r1),0(%r1)
Packit 6c4009
END(__memset_z196)
Packit 6c4009
Packit 6c4009
ENTRY(__memset_z10)
Packit 6c4009
	.machine "z10"
Packit f7c38e
	.machinemode "zarch_nohighgprs"
Packit f7c38e
# if !defined __s390x__
Packit f7c38e
	llgfr	%r4,%r4
Packit f7c38e
# endif /* !defined __s390x__  */
Packit 6c4009
	cgije   %r4,0,.L_Z10_4
Packit 6c4009
	stc     %r3,0(%r2)
Packit 6c4009
	lgr     %r1,%r2
Packit 6c4009
	cgije   %r4,1,.L_Z10_4
Packit 6c4009
	aghi    %r4,-2
Packit 6c4009
	srlg    %r5,%r4,8
Packit 6c4009
	cgijlh  %r5,0,.L_Z10_15
Packit 6c4009
.L_Z10_3:
Packit 6c4009
	exrl    %r4,.L_Z10_18
Packit 6c4009
.L_Z10_4:
Packit 6c4009
	br      %r14
Packit 6c4009
.L_Z10_15:
Packit 6c4009
	cgfi	%r5,163840          # Switch to mvcle for >40MB
Packit 6c4009
	jh	__memset_mvcle
Packit 6c4009
.L_Z10_14:
Packit 6c4009
	pfd     2,1024(%r1)
Packit 6c4009
	mvc     1(256,%r1),0(%r1)
Packit 6c4009
	la      %r1,256(%r1)
Packit 6c4009
	brctg   %r5,.L_Z10_14
Packit 6c4009
	j       .L_Z10_3
Packit 6c4009
.L_Z10_18:
Packit 6c4009
	mvc     1(1,%r1),0(%r1)
Packit 6c4009
END(__memset_z10)
Packit 6c4009
Packit 6c4009
ENTRY(__memset_mvcle)
Packit 6c4009
	aghi	%r4,2               # take back the change done by the caller
Packit 6c4009
	lgr	%r0,%r2		    # save source address
Packit 6c4009
	lgr	%r1,%r3		    # move pad byte to R1
Packit 6c4009
	lgr	%r3,%r4             # move length to r3
Packit 6c4009
	sgr	%r4,%r4		    # no source for MVCLE, only a pad byte
Packit 6c4009
	sgr	%r5,%r5
Packit 6c4009
.L0:	mvcle	%r2,%r4,0(%r1)	    # thats it, MVCLE is your friend
Packit 6c4009
	jo	.L0
Packit 6c4009
	lgr	%r2,%r0		    # return value is source address
Packit 6c4009
.L1:
Packit 6c4009
	br	%r14
Packit 6c4009
END(__memset_mvcle)
Packit 6c4009
Packit 6c4009
#endif /* IS_IN (libc) */
Packit 6c4009
Packit 6c4009
#include "../memset.S"
Packit 6c4009
Packit 6c4009
#if !IS_IN (libc)
Packit 6c4009
.globl   memset
Packit 6c4009
.set     memset,__memset_default
Packit 6c4009
#elif defined SHARED && IS_IN (libc)
Packit 6c4009
.globl   __GI_memset
Packit 6c4009
.set     __GI_memset,__memset_default
Packit 6c4009
#endif