~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/lib/strchr.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/arm64/lib/strchr.S (Version linux-6.12-rc7) and /arch/alpha/lib/strchr.S (Version linux-5.15.171)


  1 /* SPDX-License-Identifier: GPL-2.0-only */    !!   1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*                                                  2 /*
  3  * Based on arch/arm/lib/strchr.S              !!   3  * arch/alpha/lib/strchr.S
                                                   >>   4  * Contributed by Richard Henderson (rth@tamu.edu)
  4  *                                                  5  *
  5  * Copyright (C) 1995-2000 Russell King        !!   6  * Return the address of a given character within a null-terminated
  6  * Copyright (C) 2013 ARM Ltd.                 !!   7  * string, or null if it is not found.
  7  */                                                 8  */
                                                   >>   9 #include <asm/export.h>
                                                   >>  10 #include <asm/regdef.h>
  8                                                    11 
  9 #include <linux/linkage.h>                     !!  12         .set noreorder
 10 #include <asm/assembler.h>                     !!  13         .set noat
 11                                                    14 
 12 /*                                             !!  15         .align 3
 13  * Find the first occurrence of a character in !!  16         .globl strchr
 14  *                                             !!  17         .ent strchr
 15  * Parameters:                                 !!  18 strchr:
 16  *      x0 - str                               !!  19         .frame sp, 0, ra
 17  *      x1 - c                                 !!  20         .prologue 0
 18  * Returns:                                    !!  21 
 19  *      x0 - address of first occurrence of 'c !!  22         zapnot  a1, 1, a1       # e0    : zero extend the search character
 20  */                                            !!  23         ldq_u   t0, 0(a0)       # .. e1 : load first quadword
 21 SYM_FUNC_START(__pi_strchr)                    !!  24         sll     a1, 8, t5       # e0    : replicate the search character
 22         and     w1, w1, #0xff                  !!  25         andnot  a0, 7, v0       # .. e1 : align our loop pointer
 23 1:      ldrb    w2, [x0], #1                   !!  26         or      t5, a1, a1      # e0    :
 24         cmp     w2, w1                         !!  27         lda     t4, -1          # .. e1 : build garbage mask
 25         ccmp    w2, wzr, #4, ne                !!  28         sll     a1, 16, t5      # e0    :
 26         b.ne    1b                             !!  29         cmpbge  zero, t0, t2    # .. e1 : bits set iff byte == zero
 27         sub     x0, x0, #1                     !!  30         mskqh   t4, a0, t4      # e0    :
 28         cmp     w2, w1                         !!  31         or      t5, a1, a1      # .. e1 :
 29         csel    x0, x0, xzr, eq                !!  32         sll     a1, 32, t5      # e0    :
 30         ret                                    !!  33         cmpbge  zero, t4, t4    # .. e1 : bits set iff byte is garbage
 31 SYM_FUNC_END(__pi_strchr)                      !!  34         or      t5, a1, a1      # e0    :
                                                   >>  35         xor     t0, a1, t1      # .. e1 : make bytes == c zero
                                                   >>  36         cmpbge  zero, t1, t3    # e0    : bits set iff byte == c
                                                   >>  37         or      t2, t3, t0      # e1    : bits set iff char match or zero match
                                                   >>  38         andnot  t0, t4, t0      # e0    : clear garbage bits
                                                   >>  39         bne     t0, $found      # .. e1 (zdb)
                                                   >>  40 
                                                   >>  41 $loop:  ldq     t0, 8(v0)       # e0    :
                                                   >>  42         addq    v0, 8, v0       # .. e1 :
                                                   >>  43         nop                     # e0    :
                                                   >>  44         xor     t0, a1, t1      # .. e1 (ev5 data stall)
                                                   >>  45         cmpbge  zero, t0, t2    # e0    : bits set iff byte == 0
                                                   >>  46         cmpbge  zero, t1, t3    # .. e1 : bits set iff byte == c
                                                   >>  47         or      t2, t3, t0      # e0    :
                                                   >>  48         beq     t0, $loop       # .. e1 (zdb)
                                                   >>  49 
                                                   >>  50 $found: negq    t0, t1          # e0    : clear all but least set bit
                                                   >>  51         and     t0, t1, t0      # e1 (stall)
                                                   >>  52 
                                                   >>  53         and     t0, t3, t1      # e0    : bit set iff byte was the char
                                                   >>  54         beq     t1, $retnull    # .. e1 (zdb)
                                                   >>  55 
                                                   >>  56         and     t0, 0xf0, t2    # e0    : binary search for that set bit
                                                   >>  57         and     t0, 0xcc, t3    # .. e1 :
                                                   >>  58         and     t0, 0xaa, t4    # e0    :
                                                   >>  59         cmovne  t2, 4, t2       # .. e1 :
                                                   >>  60         cmovne  t3, 2, t3       # e0    :
                                                   >>  61         cmovne  t4, 1, t4       # .. e1 :
                                                   >>  62         addq    t2, t3, t2      # e0    :
                                                   >>  63         addq    v0, t4, v0      # .. e1 :
                                                   >>  64         addq    v0, t2, v0      # e0    :
                                                   >>  65         ret                     # .. e1 :
                                                   >>  66 
                                                   >>  67 $retnull:
                                                   >>  68         mov     zero, v0        # e0    :
                                                   >>  69         ret                     # .. e1 :
 32                                                    70 
 33 SYM_FUNC_ALIAS_WEAK(strchr, __pi_strchr)       !!  71         .end strchr
 34 EXPORT_SYMBOL_NOKASAN(strchr)                  !!  72         EXPORT_SYMBOL(strchr)
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php