xref: /freebsd/contrib/bionic-x86_64-string/sse2-strcat-slm.S (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1*8ddb146aSEd Maste/*
2*8ddb146aSEd MasteCopyright (c) 2014, Intel Corporation
3*8ddb146aSEd MasteAll rights reserved.
4*8ddb146aSEd Maste
5*8ddb146aSEd MasteRedistribution and use in source and binary forms, with or without
6*8ddb146aSEd Mastemodification, are permitted provided that the following conditions are met:
7*8ddb146aSEd Maste
8*8ddb146aSEd Maste    * Redistributions of source code must retain the above copyright notice,
9*8ddb146aSEd Maste    * this list of conditions and the following disclaimer.
10*8ddb146aSEd Maste
11*8ddb146aSEd Maste    * Redistributions in binary form must reproduce the above copyright notice,
12*8ddb146aSEd Maste    * this list of conditions and the following disclaimer in the documentation
13*8ddb146aSEd Maste    * and/or other materials provided with the distribution.
14*8ddb146aSEd Maste
15*8ddb146aSEd Maste    * Neither the name of Intel Corporation nor the names of its contributors
16*8ddb146aSEd Maste    * may be used to endorse or promote products derived from this software
17*8ddb146aSEd Maste    * without specific prior written permission.
18*8ddb146aSEd Maste
19*8ddb146aSEd MasteTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20*8ddb146aSEd MasteANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21*8ddb146aSEd MasteWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22*8ddb146aSEd MasteDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23*8ddb146aSEd MasteANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24*8ddb146aSEd Maste(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25*8ddb146aSEd MasteLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26*8ddb146aSEd MasteANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27*8ddb146aSEd Maste(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28*8ddb146aSEd MasteSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*8ddb146aSEd Maste*/
30*8ddb146aSEd Maste
31*8ddb146aSEd Maste#ifndef STRCAT
32*8ddb146aSEd Maste# define STRCAT		strcat
33*8ddb146aSEd Maste#endif
34*8ddb146aSEd Maste
35*8ddb146aSEd Maste#ifndef L
36*8ddb146aSEd Maste# define L(label)		.L##label
37*8ddb146aSEd Maste#endif
38*8ddb146aSEd Maste
39*8ddb146aSEd Maste#ifndef cfi_startproc
40*8ddb146aSEd Maste# define cfi_startproc		 .cfi_startproc
41*8ddb146aSEd Maste#endif
42*8ddb146aSEd Maste
43*8ddb146aSEd Maste#ifndef cfi_endproc
44*8ddb146aSEd Maste# define cfi_endproc		.cfi_endproc
45*8ddb146aSEd Maste#endif
46*8ddb146aSEd Maste
47*8ddb146aSEd Maste#ifndef ENTRY
48*8ddb146aSEd Maste# define ENTRY(name)		\
49*8ddb146aSEd Maste	.type name,  @function;		\
50*8ddb146aSEd Maste	.globl name;		\
51*8ddb146aSEd Maste	.p2align 4;		\
52*8ddb146aSEd Mastename:		\
53*8ddb146aSEd Maste	cfi_startproc
54*8ddb146aSEd Maste#endif
55*8ddb146aSEd Maste
56*8ddb146aSEd Maste#ifndef END
57*8ddb146aSEd Maste# define END(name)		\
58*8ddb146aSEd Maste	cfi_endproc;		\
59*8ddb146aSEd Maste	.size name, .-name
60*8ddb146aSEd Maste#endif
61*8ddb146aSEd Maste
62*8ddb146aSEd Maste#define USE_AS_STRCAT
63*8ddb146aSEd Maste
64*8ddb146aSEd Maste.text
65*8ddb146aSEd MasteENTRY (STRCAT)
66*8ddb146aSEd Maste	mov	%rdi, %r9
67*8ddb146aSEd Maste#ifdef USE_AS_STRNCAT
68*8ddb146aSEd Maste	mov	%rdx, %r8
69*8ddb146aSEd Maste#endif
70*8ddb146aSEd Maste
71*8ddb146aSEd Maste#define RETURN jmp L(Strcpy)
72*8ddb146aSEd Maste#include "sse2-strlen-slm.S"
73*8ddb146aSEd Maste
74*8ddb146aSEd Maste#undef RETURN
75*8ddb146aSEd Maste#define RETURN ret
76*8ddb146aSEd Maste
77*8ddb146aSEd MasteL(Strcpy):
78*8ddb146aSEd Maste	lea	(%r9, %rax), %rdi
79*8ddb146aSEd Maste	mov	%rsi, %rcx
80*8ddb146aSEd Maste	mov	%r9, %rax	/* save result */
81*8ddb146aSEd Maste
82*8ddb146aSEd Maste#ifdef USE_AS_STRNCAT
83*8ddb146aSEd Maste	test	%r8, %r8
84*8ddb146aSEd Maste	jz	L(ExitZero)
85*8ddb146aSEd Maste# define USE_AS_STRNCPY
86*8ddb146aSEd Maste#endif
87*8ddb146aSEd Maste#include "sse2-strcpy-slm.S"
88