1 /* Optimized strcpy stpcpy implementation using LoongArch LASX instructions.
2 Copyright (C) 2023-2024 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 <https://www.gnu.org/licenses/>. */
20 #include <sys/regdef.h>
23 #if IS_IN (libc) && !defined __loongarch_soft_float
26 # define STRCPY __strcpy_lasx
41 bltu t8, t0, L(page_cross_start)
47 xvsetanyeqz.b fcc0, xr0
59 xvsetanyeqz.b fcc0, xr0
67 xvsetanyeqz.b fcc0, xr0
69 bceqz fcc0, L(al_loop)
72 xvpickve.w xr1, xr0, 4
88 bstrins.d a4, zero, 4, 0
92 xvpickve.w xr1, xr0, 4
97 beq t0, t7, L(start_entry)
101 bltu t8, t0, L(un_page_cross)
106 xvsetanyeqz.b fcc0, xr0
107 bcnez fcc0, L(un_end)
114 bltu t8, t0, L(page_cross_loop)
119 xvsetanyeqz.b fcc0, xr0
120 bceqz fcc0, L(un_loop)
125 xvpickve.w xr1, xr0, 4
126 vilvl.h vr0, vr1, vr0
136 xvst xr0, dstend, -31
143 xvpickve.w xr1, xr0, 4
144 vilvl.h vr0, vr1, vr0
148 beq t0, t7, L(un_start_entry)
156 xvpickve.w xr1, xr0, 4
158 vilvl.h vr0, vr1, vr0
161 beq t0, t7, L(un_loop_entry)
166 xvpickve.w xr1, xr0, 4
167 vilvl.h vr0, vr1, vr0
196 bltu t0, t1, L(less_3)
205 beqz t0, L(zero_byte)
214 libc_hidden_builtin_def (STRCPY)