1 /* memcpy.S: optimised assembly memcpy
3 * Copyright (C) 2003, 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/>.
26 ###############################################################################
28 # void *memcpy(void *to, const char *from, size_t count)
30 # - NOTE: must not use any stack. exception detection performs function return
31 # to caller's fixup routine, aborting the remainder of the copy
33 ###############################################################################
35 .type memcpy,@function
38 orcc gr10,gr0,gr0,icc3
42 # optimise based on best common alignment for to, from & count
43 andicc.p gr4,#0x1f,gr0,icc0
45 andicc.p gr4,#0x0f,gr0,icc1
47 andicc.p gr4,#0x07,gr0,icc0
49 andicc.p gr4,#0x03,gr0,icc1
51 andicc.p gr4,#0x01,gr0,icc0
56 # do byte by byte copy
59 0: ldubu.p @(gr9,gr11),gr4
60 subicc gr10,#1,gr10,icc0
61 stbu.p gr4,@(gr3,gr11)
65 # do halfword by halfword copy
70 0: lduhu.p @(gr9,gr11),gr4
71 subicc gr10,#2,gr10,icc0
72 sthu.p gr4,@(gr3,gr11)
76 # do word by word copy
81 0: ldu.p @(gr9,gr11),gr4
82 subicc gr10,#4,gr10,icc0
87 # do double-word by double-word copy
91 0: lddu.p @(gr9,gr11),gr4
92 subicc gr10,#8,gr10,icc0
93 stdu.p gr4,@(gr3,gr11)
97 # do quad-word by quad-word copy
101 0: lddu @(gr9,gr11),gr4
102 lddu.p @(gr9,gr11),gr6
103 subicc gr10,#16,gr10,icc0
105 stdu.p gr6,@(gr3,gr11)
109 # do eight-word by eight-word copy
113 0: lddu @(gr9,gr11),gr4
115 lddu @(gr9,gr11),gr12
116 lddu.p @(gr9,gr11),gr14
117 subicc gr10,#32,gr10,icc0
120 stdu gr12,@(gr3,gr11)
121 stdu.p gr14,@(gr3,gr11)
125 .size memcpy, .-memcpy
127 libc_hidden_def(memcpy)