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

TOMOYO Linux Cross Reference
Linux/arch/openrisc/lib/memset.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/openrisc/lib/memset.S (Version linux-6.12-rc7) and /arch/mips/lib/memset.S (Version linux-4.4.302)


  1 /* SPDX-License-Identifier: GPL-2.0-or-later * << 
  2 /*                                                  1 /*
  3  * OpenRISC memset.S                           !!   2  * This file is subject to the terms and conditions of the GNU General Public
                                                   >>   3  * License.  See the file "COPYING" in the main directory of this archive
                                                   >>   4  * for more details.
  4  *                                                  5  *
  5  * Hand-optimized assembler version of memset  !!   6  * Copyright (C) 1998, 1999, 2000 by Ralf Baechle
  6  * Algorithm inspired by several other arch-sp !!   7  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  7  * in the kernel tree                          !!   8  * Copyright (C) 2007 by Maciej W. Rozycki
  8  *                                             !!   9  * Copyright (C) 2011, 2012 MIPS Technologies, Inc.
  9  * Copyright (C) 2015 Olof Kindgren <olof.kindg !!  10  */
                                                   >>  11 #include <asm/asm.h>
                                                   >>  12 #include <asm/asm-offsets.h>
                                                   >>  13 #include <asm/regdef.h>
                                                   >>  14 
                                                   >>  15 #if LONGSIZE == 4
                                                   >>  16 #define LONG_S_L swl
                                                   >>  17 #define LONG_S_R swr
                                                   >>  18 #else
                                                   >>  19 #define LONG_S_L sdl
                                                   >>  20 #define LONG_S_R sdr
                                                   >>  21 #endif
                                                   >>  22 
                                                   >>  23 #ifdef CONFIG_CPU_MICROMIPS
                                                   >>  24 #define STORSIZE (LONGSIZE * 2)
                                                   >>  25 #define STORMASK (STORSIZE - 1)
                                                   >>  26 #define FILL64RG t8
                                                   >>  27 #define FILLPTRG t7
                                                   >>  28 #undef  LONG_S
                                                   >>  29 #define LONG_S LONG_SP
                                                   >>  30 #else
                                                   >>  31 #define STORSIZE LONGSIZE
                                                   >>  32 #define STORMASK LONGMASK
                                                   >>  33 #define FILL64RG a1
                                                   >>  34 #define FILLPTRG t0
                                                   >>  35 #endif
                                                   >>  36 
                                                   >>  37 #define LEGACY_MODE 1
                                                   >>  38 #define EVA_MODE    2
                                                   >>  39 
                                                   >>  40 /*
                                                   >>  41  * No need to protect it with EVA #ifdefery. The generated block of code
                                                   >>  42  * will never be assembled if EVA is not enabled.
 10  */                                                43  */
                                                   >>  44 #define __EVAFY(insn, reg, addr) __BUILD_EVA_INSN(insn##e, reg, addr)
                                                   >>  45 #define ___BUILD_EVA_INSN(insn, reg, addr) __EVAFY(insn, reg, addr)
 11                                                    46 
 12         .global memset                         !!  47 #define EX(insn,reg,addr,handler)                       \
 13         .type   memset, @function              !!  48         .if \mode == LEGACY_MODE;                       \
 14 memset:                                        !!  49 9:              insn    reg, addr;                      \
 15         /* arguments:                          !!  50         .else;                                          \
 16          * r3 = *s                             !!  51 9:              ___BUILD_EVA_INSN(insn, reg, addr);     \
 17          * r4 = c                              !!  52         .endif;                                         \
 18          * r5 = n                              !!  53         .section __ex_table,"a";                        \
 19          * r13, r15, r17, r19 used as temp reg !!  54         PTR     9b, handler;                            \
 20         */                                     !!  55         .previous
 21                                                !!  56 
 22         /* Exit if n == 0 */                   !!  57         .macro  f_fill64 dst, offset, val, fixup, mode
 23         l.sfeqi         r5, 0                  !!  58         EX(LONG_S, \val, (\offset +  0 * STORSIZE)(\dst), \fixup)
 24         l.bf            4f                     !!  59         EX(LONG_S, \val, (\offset +  1 * STORSIZE)(\dst), \fixup)
 25                                                !!  60         EX(LONG_S, \val, (\offset +  2 * STORSIZE)(\dst), \fixup)
 26         /* Truncate c to char */               !!  61         EX(LONG_S, \val, (\offset +  3 * STORSIZE)(\dst), \fixup)
 27         l.andi          r13, r4, 0xff          !!  62 #if ((defined(CONFIG_CPU_MICROMIPS) && (LONGSIZE == 4)) || !defined(CONFIG_CPU_MICROMIPS))
 28                                                !!  63         EX(LONG_S, \val, (\offset +  4 * STORSIZE)(\dst), \fixup)
 29         /* Skip word extension if c is 0 */    !!  64         EX(LONG_S, \val, (\offset +  5 * STORSIZE)(\dst), \fixup)
 30         l.sfeqi         r13, 0                 !!  65         EX(LONG_S, \val, (\offset +  6 * STORSIZE)(\dst), \fixup)
 31         l.bf            1f                     !!  66         EX(LONG_S, \val, (\offset +  7 * STORSIZE)(\dst), \fixup)
 32         /* Check for at least two whole words  !!  67 #endif
 33          l.sfleui       r5, 7                  !!  68 #if (!defined(CONFIG_CPU_MICROMIPS) && (LONGSIZE == 4))
 34                                                !!  69         EX(LONG_S, \val, (\offset +  8 * STORSIZE)(\dst), \fixup)
 35         /* Extend char c to 32-bit word cccc i !!  70         EX(LONG_S, \val, (\offset +  9 * STORSIZE)(\dst), \fixup)
 36         l.slli          r15, r13, 16  // r13 = !!  71         EX(LONG_S, \val, (\offset + 10 * STORSIZE)(\dst), \fixup)
 37         l.or            r13, r13, r15 // r13 = !!  72         EX(LONG_S, \val, (\offset + 11 * STORSIZE)(\dst), \fixup)
 38         l.slli          r15, r13, 8   // r13 = !!  73         EX(LONG_S, \val, (\offset + 12 * STORSIZE)(\dst), \fixup)
 39         l.or            r13, r13, r15 // r13 = !!  74         EX(LONG_S, \val, (\offset + 13 * STORSIZE)(\dst), \fixup)
 40                                                !!  75         EX(LONG_S, \val, (\offset + 14 * STORSIZE)(\dst), \fixup)
 41 1:      l.addi          r19, r3, 0 // Set r19  !!  76         EX(LONG_S, \val, (\offset + 15 * STORSIZE)(\dst), \fixup)
 42         /* Jump to byte copy loop if less than !!  77 #endif
 43         l.bf            3f                     !!  78         .endm
 44          l.or           r17, r5, r0 // Set r17 !!  79 
 45                                                !!  80         .set    noreorder
 46         /* Mask out two LSBs to check alignmen !!  81         .align  5
 47         l.andi          r15, r3, 0x3           !!  82 
 48                                                !!  83         /*
 49         /* lsb == 00, jump to word copy loop * !!  84          * Macro to generate the __bzero{,_user} symbol
 50         l.sfeqi         r15, 0                 !!  85          * Arguments:
 51         l.bf            2f                     !!  86          * mode: LEGACY_MODE or EVA_MODE
 52          l.addi         r19, r3, 0 // Set r19  !!  87          */
 53                                                !!  88         .macro __BUILD_BZERO mode
 54         /* lsb == 01,10 or 11 */               !!  89         /* Initialize __memset if this is the first time we call this macro */
 55         l.sb            0(r3), r13   // *src = !!  90         .ifnotdef __memset
 56         l.addi          r17, r17, -1 // Decrea !!  91         .set __memset, 1
 57                                                !!  92         .hidden __memset /* Make sure it does not leak */
 58         l.sfeqi         r15, 3                 !!  93         .endif
 59         l.bf            2f                     !!  94 
 60          l.addi         r19, r3, 1  // src +=  !!  95         sltiu           t0, a2, STORSIZE        /* very small region? */
 61                                                !!  96         bnez            t0, .Lsmall_memset\@
 62         /* lsb == 01 or 10 */                  !!  97         andi            t0, a0, STORMASK        /* aligned? */
 63         l.sb            1(r3), r13   // *(src+ !!  98 
 64         l.addi          r17, r17, -1 // Decrea !!  99 #ifdef CONFIG_CPU_MICROMIPS
 65                                                !! 100         move            t8, a1                  /* used by 'swp' instruction */
 66         l.sfeqi         r15, 2                 !! 101         move            t9, a1
 67         l.bf            2f                     !! 102 #endif
 68          l.addi         r19, r3, 2  // src +=  !! 103 #ifndef CONFIG_CPU_DADDI_WORKAROUNDS
 69                                                !! 104         beqz            t0, 1f
 70         /* lsb == 01 */                        !! 105         PTR_SUBU        t0, STORSIZE            /* alignment in bytes */
 71         l.sb            2(r3), r13   // *(src+ !! 106 #else
 72         l.addi          r17, r17, -1 // Decrea !! 107         .set            noat
 73         l.addi          r19, r3, 3   // src += !! 108         li              AT, STORSIZE
 74                                                !! 109         beqz            t0, 1f
 75         /* Word copy loop */                   !! 110         PTR_SUBU        t0, AT                  /* alignment in bytes */
 76 2:      l.sw            0(r19), r13  // *src = !! 111         .set            at
 77         l.addi          r17, r17, -4 // Decrea !! 112 #endif
 78         l.sfgeui        r17, 4                 !! 113 
 79         l.bf            2b                     !! 114 #ifndef CONFIG_CPU_MIPSR6
 80          l.addi         r19, r19, 4  // Increa !! 115         R10KCBARRIER(0(ra))
 81                                                !! 116 #ifdef __MIPSEB__
 82         /* When n > 0, copy the remaining byte !! 117         EX(LONG_S_L, a1, (a0), .Lfirst_fixup\@) /* make word/dword aligned */
 83         l.sfeqi         r17, 0                 !! 118 #else
 84         l.bf            4f                     !! 119         EX(LONG_S_R, a1, (a0), .Lfirst_fixup\@) /* make word/dword aligned */
 85                                                !! 120 #endif
 86         /* Byte copy loop */                   !! 121         PTR_SUBU        a0, t0                  /* long align ptr */
 87 3:      l.addi          r17, r17, -1 // Decrea !! 122         PTR_ADDU        a2, t0                  /* correct size */
 88         l.sb            0(r19), r13  // *src = !! 123 
 89         l.sfnei         r17, 0                 !! 124 #else /* CONFIG_CPU_MIPSR6 */
 90         l.bf            3b                     !! 125 #define STORE_BYTE(N)                           \
 91          l.addi         r19, r19, 1  // Increa !! 126         EX(sb, a1, N(a0), .Lbyte_fixup\@);      \
                                                   >> 127         beqz            t0, 0f;                 \
                                                   >> 128         PTR_ADDU        t0, 1;
                                                   >> 129 
                                                   >> 130         PTR_ADDU        a2, t0                  /* correct size */
                                                   >> 131         PTR_ADDU        t0, 1
                                                   >> 132         STORE_BYTE(0)
                                                   >> 133         STORE_BYTE(1)
                                                   >> 134 #if LONGSIZE == 4
                                                   >> 135         EX(sb, a1, 2(a0), .Lbyte_fixup\@)
                                                   >> 136 #else
                                                   >> 137         STORE_BYTE(2)
                                                   >> 138         STORE_BYTE(3)
                                                   >> 139         STORE_BYTE(4)
                                                   >> 140         STORE_BYTE(5)
                                                   >> 141         EX(sb, a1, 6(a0), .Lbyte_fixup\@)
                                                   >> 142 #endif
                                                   >> 143 0:
                                                   >> 144         ori             a0, STORMASK
                                                   >> 145         xori            a0, STORMASK
                                                   >> 146         PTR_ADDIU       a0, STORSIZE
                                                   >> 147 #endif /* CONFIG_CPU_MIPSR6 */
                                                   >> 148 1:      ori             t1, a2, 0x3f            /* # of full blocks */
                                                   >> 149         xori            t1, 0x3f
                                                   >> 150         beqz            t1, .Lmemset_partial\@  /* no block to fill */
                                                   >> 151         andi            t0, a2, 0x40-STORSIZE
                                                   >> 152 
                                                   >> 153         PTR_ADDU        t1, a0                  /* end address */
                                                   >> 154         .set            reorder
                                                   >> 155 1:      PTR_ADDIU       a0, 64
                                                   >> 156         R10KCBARRIER(0(ra))
                                                   >> 157         f_fill64 a0, -64, FILL64RG, .Lfwd_fixup\@, \mode
                                                   >> 158         bne             t1, a0, 1b
                                                   >> 159         .set            noreorder
                                                   >> 160 
                                                   >> 161 .Lmemset_partial\@:
                                                   >> 162         R10KCBARRIER(0(ra))
                                                   >> 163         PTR_LA          t1, 2f                  /* where to start */
                                                   >> 164 #ifdef CONFIG_CPU_MICROMIPS
                                                   >> 165         LONG_SRL        t7, t0, 1
                                                   >> 166 #endif
                                                   >> 167 #if LONGSIZE == 4
                                                   >> 168         PTR_SUBU        t1, FILLPTRG
                                                   >> 169 #else
                                                   >> 170         .set            noat
                                                   >> 171         LONG_SRL        AT, FILLPTRG, 1
                                                   >> 172         PTR_SUBU        t1, AT
                                                   >> 173         .set            at
                                                   >> 174 #endif
                                                   >> 175         jr              t1
                                                   >> 176         PTR_ADDU        a0, t0                  /* dest ptr */
                                                   >> 177 
                                                   >> 178         .set            push
                                                   >> 179         .set            noreorder
                                                   >> 180         .set            nomacro
                                                   >> 181         /* ... but first do longs ... */
                                                   >> 182         f_fill64 a0, -64, FILL64RG, .Lpartial_fixup\@, \mode
                                                   >> 183 2:      .set            pop
                                                   >> 184         andi            a2, STORMASK            /* At most one long to go */
                                                   >> 185 
                                                   >> 186         beqz            a2, 1f
                                                   >> 187 #ifndef CONFIG_CPU_MIPSR6
                                                   >> 188         PTR_ADDU        a0, a2                  /* What's left */
                                                   >> 189         R10KCBARRIER(0(ra))
                                                   >> 190 #ifdef __MIPSEB__
                                                   >> 191         EX(LONG_S_R, a1, -1(a0), .Llast_fixup\@)
                                                   >> 192 #else
                                                   >> 193         EX(LONG_S_L, a1, -1(a0), .Llast_fixup\@)
                                                   >> 194 #endif
                                                   >> 195 #else
                                                   >> 196         PTR_SUBU        t0, $0, a2
                                                   >> 197         PTR_ADDIU       t0, 1
                                                   >> 198         STORE_BYTE(0)
                                                   >> 199         STORE_BYTE(1)
                                                   >> 200 #if LONGSIZE == 4
                                                   >> 201         EX(sb, a1, 2(a0), .Lbyte_fixup\@)
                                                   >> 202 #else
                                                   >> 203         STORE_BYTE(2)
                                                   >> 204         STORE_BYTE(3)
                                                   >> 205         STORE_BYTE(4)
                                                   >> 206         STORE_BYTE(5)
                                                   >> 207         EX(sb, a1, 6(a0), .Lbyte_fixup\@)
                                                   >> 208 #endif
                                                   >> 209 0:
                                                   >> 210 #endif
                                                   >> 211 1:      jr              ra
                                                   >> 212         move            a2, zero
                                                   >> 213 
                                                   >> 214 .Lsmall_memset\@:
                                                   >> 215         beqz            a2, 2f
                                                   >> 216         PTR_ADDU        t1, a0, a2
                                                   >> 217 
                                                   >> 218 1:      PTR_ADDIU       a0, 1                   /* fill bytewise */
                                                   >> 219         R10KCBARRIER(0(ra))
                                                   >> 220         bne             t1, a0, 1b
                                                   >> 221          EX(sb, a1, -1(a0), .Lsmall_fixup\@)
                                                   >> 222 
                                                   >> 223 2:      jr              ra                      /* done */
                                                   >> 224         move            a2, zero
                                                   >> 225         .if __memset == 1
                                                   >> 226         END(memset)
                                                   >> 227         .set __memset, 0
                                                   >> 228         .hidden __memset
                                                   >> 229         .endif
                                                   >> 230 
                                                   >> 231 .Lbyte_fixup\@:
                                                   >> 232         PTR_SUBU        a2, $0, t0
                                                   >> 233         jr              ra
                                                   >> 234          PTR_ADDIU      a2, 1
                                                   >> 235 
                                                   >> 236 .Lfirst_fixup\@:
                                                   >> 237         jr      ra
                                                   >> 238         nop
                                                   >> 239 
                                                   >> 240 .Lfwd_fixup\@:
                                                   >> 241         PTR_L           t0, TI_TASK($28)
                                                   >> 242         andi            a2, 0x3f
                                                   >> 243         LONG_L          t0, THREAD_BUADDR(t0)
                                                   >> 244         LONG_ADDU       a2, t1
                                                   >> 245         jr              ra
                                                   >> 246         LONG_SUBU       a2, t0
                                                   >> 247 
                                                   >> 248 .Lpartial_fixup\@:
                                                   >> 249         PTR_L           t0, TI_TASK($28)
                                                   >> 250         andi            a2, STORMASK
                                                   >> 251         LONG_L          t0, THREAD_BUADDR(t0)
                                                   >> 252         LONG_ADDU       a2, a0
                                                   >> 253         jr              ra
                                                   >> 254         LONG_SUBU       a2, t0
                                                   >> 255 
                                                   >> 256 .Llast_fixup\@:
                                                   >> 257         jr              ra
                                                   >> 258          nop
                                                   >> 259 
                                                   >> 260 .Lsmall_fixup\@:
                                                   >> 261         PTR_SUBU        a2, t1, a0
                                                   >> 262         jr              ra
                                                   >> 263          PTR_ADDIU      a2, 1
                                                   >> 264 
                                                   >> 265         .endm
                                                   >> 266 
                                                   >> 267 /*
                                                   >> 268  * memset(void *s, int c, size_t n)
                                                   >> 269  *
                                                   >> 270  * a0: start of area to clear
                                                   >> 271  * a1: char to fill with
                                                   >> 272  * a2: size of area to clear
                                                   >> 273  */
 92                                                   274 
 93 4:      l.jr            r9                     !! 275 LEAF(memset)
 94          l.ori          r11, r3, 0             !! 276         beqz            a1, 1f
                                                   >> 277         move            v0, a0                  /* result */
                                                   >> 278 
                                                   >> 279         andi            a1, 0xff                /* spread fillword */
                                                   >> 280         LONG_SLL                t1, a1, 8
                                                   >> 281         or              a1, t1
                                                   >> 282         LONG_SLL                t1, a1, 16
                                                   >> 283 #if LONGSIZE == 8
                                                   >> 284         or              a1, t1
                                                   >> 285         LONG_SLL                t1, a1, 32
                                                   >> 286 #endif
                                                   >> 287         or              a1, t1
                                                   >> 288 1:
                                                   >> 289 #ifndef CONFIG_EVA
                                                   >> 290 FEXPORT(__bzero)
                                                   >> 291 #else
                                                   >> 292 FEXPORT(__bzero_kernel)
                                                   >> 293 #endif
                                                   >> 294         __BUILD_BZERO LEGACY_MODE
                                                   >> 295 
                                                   >> 296 #ifdef CONFIG_EVA
                                                   >> 297 LEAF(__bzero)
                                                   >> 298         __BUILD_BZERO EVA_MODE
                                                   >> 299 END(__bzero)
                                                   >> 300 #endif
                                                      

~ [ 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