Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * arch/alpha/lib/ev67-strcat.S
0004  * 21264 version contributed by Rick Gorton <rick.gorton@alpha-processor.com>
0005  *
0006  * Append a null-terminated string from SRC to DST.
0007  *
0008  * Much of the information about 21264 scheduling/coding comes from:
0009  *  Compiler Writer's Guide for the Alpha 21264
0010  *  abbreviated as 'CWG' in other comments here
0011  *  ftp.digital.com/pub/Digital/info/semiconductor/literature/dsc-library.html
0012  * Scheduling notation:
0013  *  E   - either cluster
0014  *  U   - upper subcluster; U0 - subcluster U0; U1 - subcluster U1
0015  *  L   - lower subcluster; L0 - subcluster L0; L1 - subcluster L1
0016  * Try not to change the actual algorithm if possible for consistency.
0017  * Commentary: It seems bogus to walk the input string twice - once
0018  * to determine the length, and then again while doing the copy.
0019  * A significant (future) enhancement would be to only read the input
0020  * string once.
0021  */
0022 
0023 #include <asm/export.h>
0024     .text
0025 
0026     .align 4
0027     .globl strcat
0028     .ent strcat
0029 strcat:
0030     .frame $30, 0, $26
0031     .prologue 0
0032 
0033     mov $16, $0     # E : set up return value
0034     /* Find the end of the string.  */
0035     ldq_u   $1, 0($16)  # L : load first quadword (a0 may be misaligned)
0036     lda     $2, -1      # E :
0037     insqh   $2, $16, $2 # U :
0038 
0039     andnot  $16, 7, $16 # E :
0040     or      $2, $1, $1  # E :
0041     cmpbge  $31, $1, $2 # E : bits set iff byte == 0
0042     bne     $2, $found  # U :
0043 
0044 $loop:  ldq     $1, 8($16)  # L :
0045     addq    $16, 8, $16 # E :
0046     cmpbge  $31, $1, $2 # E :
0047     beq     $2, $loop   # U :
0048 
0049 $found: cttz    $2, $3      # U0 :
0050     addq    $16, $3, $16    # E :
0051     /* Now do the append.  */
0052     mov $26, $23    # E :
0053     br  __stxcpy    # L0 :
0054 
0055     .end strcat
0056     EXPORT_SYMBOL(strcat)