1*4882a593Smuzhiyun/* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun/* 3*4882a593Smuzhiyun * arch/alpha/lib/ev67-strcat.S 4*4882a593Smuzhiyun * 21264 version contributed by Rick Gorton <rick.gorton@alpha-processor.com> 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Append a null-terminated string from SRC to DST. 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * Much of the information about 21264 scheduling/coding comes from: 9*4882a593Smuzhiyun * Compiler Writer's Guide for the Alpha 21264 10*4882a593Smuzhiyun * abbreviated as 'CWG' in other comments here 11*4882a593Smuzhiyun * ftp.digital.com/pub/Digital/info/semiconductor/literature/dsc-library.html 12*4882a593Smuzhiyun * Scheduling notation: 13*4882a593Smuzhiyun * E - either cluster 14*4882a593Smuzhiyun * U - upper subcluster; U0 - subcluster U0; U1 - subcluster U1 15*4882a593Smuzhiyun * L - lower subcluster; L0 - subcluster L0; L1 - subcluster L1 16*4882a593Smuzhiyun * Try not to change the actual algorithm if possible for consistency. 17*4882a593Smuzhiyun * Commentary: It seems bogus to walk the input string twice - once 18*4882a593Smuzhiyun * to determine the length, and then again while doing the copy. 19*4882a593Smuzhiyun * A significant (future) enhancement would be to only read the input 20*4882a593Smuzhiyun * string once. 21*4882a593Smuzhiyun */ 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun#include <asm/export.h> 24*4882a593Smuzhiyun .text 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun .align 4 27*4882a593Smuzhiyun .globl strcat 28*4882a593Smuzhiyun .ent strcat 29*4882a593Smuzhiyunstrcat: 30*4882a593Smuzhiyun .frame $30, 0, $26 31*4882a593Smuzhiyun .prologue 0 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun mov $16, $0 # E : set up return value 34*4882a593Smuzhiyun /* Find the end of the string. */ 35*4882a593Smuzhiyun ldq_u $1, 0($16) # L : load first quadword (a0 may be misaligned) 36*4882a593Smuzhiyun lda $2, -1 # E : 37*4882a593Smuzhiyun insqh $2, $16, $2 # U : 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun andnot $16, 7, $16 # E : 40*4882a593Smuzhiyun or $2, $1, $1 # E : 41*4882a593Smuzhiyun cmpbge $31, $1, $2 # E : bits set iff byte == 0 42*4882a593Smuzhiyun bne $2, $found # U : 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun$loop: ldq $1, 8($16) # L : 45*4882a593Smuzhiyun addq $16, 8, $16 # E : 46*4882a593Smuzhiyun cmpbge $31, $1, $2 # E : 47*4882a593Smuzhiyun beq $2, $loop # U : 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun$found: cttz $2, $3 # U0 : 50*4882a593Smuzhiyun addq $16, $3, $16 # E : 51*4882a593Smuzhiyun /* Now do the append. */ 52*4882a593Smuzhiyun mov $26, $23 # E : 53*4882a593Smuzhiyun br __stxcpy # L0 : 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun .end strcat 56*4882a593Smuzhiyun EXPORT_SYMBOL(strcat) 57