S390: Implement mempcpy with help of memcpy. [BZ #19765]
[glibc.git] / sysdeps / s390 / s390-32 / multiarch / memcpy-s390.S
blob297a8943b1f8dde09dc5ce4e02b324cdc6f49a09
1 /* CPU specific memcpy implementations.  32 bit S/390 version.
2    Copyright (C) 2012-2016 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
20 #include "sysdep.h"
21 #include "asm-syntax.h"
23 /* INPUT PARAMETERS
24      %r2 = target operands address
25      %r3 = source operands address
26      %r4 = number of bytes to copy.  */
28        .text
30 #if defined SHARED && IS_IN (libc)
32 ENTRY(____mempcpy_z196)
33         .machine "z196"
34         .machinemode "zarch_nohighgprs"
35         lr      %r1,%r2         # Use as dest
36         la      %r2,0(%r4,%r2)  # Return dest + n
37         j       .L_Z196_start
38 END(____mempcpy_z196)
40 ENTRY(__memcpy_z196)
41         .machine "z196"
42         .machinemode "zarch_nohighgprs"
43         lr      %r1,%r2         # r1: Use as dest ; r2: Return dest
44 .L_Z196_start:
45         llgfr   %r4,%r4
46         ltgr    %r4,%r4
47         je      .L_Z196_4
48         aghi    %r4,-1
49         srlg    %r5,%r4,8
50         ltgr    %r5,%r5
51         jne     .L_Z196_5
52 .L_Z196_3:
53         exrl    %r4,.L_Z196_14
54 .L_Z196_4:
55         br      %r14
56 .L_Z196_5:
57         cgfi    %r5,262144      # Switch to mvcle for copies >64MB
58         jh      __memcpy_mvcle
59 .L_Z196_2:
60         pfd     1,768(%r3)
61         pfd     2,768(%r1)
62         mvc     0(256,%r1),0(%r3)
63         aghi    %r5,-1
64         la      %r1,256(%r1)
65         la      %r3,256(%r3)
66         jne     .L_Z196_2
67         j       .L_Z196_3
68 .L_Z196_14:
69         mvc     0(1,%r1),0(%r3)
70 END(__memcpy_z196)
72 ENTRY(____mempcpy_z10)
73         .machine "z10"
74         .machinemode "zarch_nohighgprs"
75         lr      %r1,%r2         # Use as dest
76         la      %r2,0(%r4,%r2)  # Return dest + n
77         j       .L_Z10_start
78 END(____mempcpy_z10)
80 ENTRY(__memcpy_z10)
81         .machine "z10"
82         .machinemode "zarch_nohighgprs"
83         lr      %r1,%r2         # r1: Use as dest ; r2: Return dest
84 .L_Z10_start:
85         llgfr   %r4,%r4
86         cgije   %r4,0,.L_Z10_4
87         aghi    %r4,-1
88         srlg    %r5,%r4,8
89         cgijlh  %r5,0,.L_Z10_13
90 .L_Z10_3:
91         exrl    %r4,.L_Z10_15
92 .L_Z10_4:
93         br      %r14
94 .L_Z10_13:
95         cgfi    %r5,65535       # Switch to mvcle for copies >16MB
96         jh      __memcpy_mvcle
97 .L_Z10_12:
98         pfd     1,768(%r3)
99         pfd     2,768(%r1)
100         mvc     0(256,%r1),0(%r3)
101         la      %r1,256(%r1)
102         la      %r3,256(%r3)
103         brctg   %r5,.L_Z10_12
104         j       .L_Z10_3
105 .L_Z10_15:
106         mvc     0(1,%r1),0(%r3)
107 END(__memcpy_z10)
109 # define __mempcpy ____mempcpy_default
110 #endif /* SHARED && IS_IN (libc) */
112 #define memcpy __memcpy_default
113 #include "../memcpy.S"
114 #undef memcpy
116 #if defined SHARED && IS_IN (libc)
117 .globl   __GI_memcpy
118 .set     __GI_memcpy,__memcpy_default
119 .globl   __GI_mempcpy
120 .set     __GI_mempcpy,____mempcpy_default
121 .globl   __GI___mempcpy
122 .set     __GI___mempcpy,____mempcpy_default
123 #else
124 .globl   memcpy
125 .set     memcpy,__memcpy_default
126 .weak    mempcpy
127 .set     mempcpy,__mempcpy
128 #endif