1 /* SPDX-License-Identifier: GPL-2.0 */
3 * linux/arch/m32r/lib/memset.S
5 * Copyright (C) 2001,2002 Hiroyuki Kondo, and Hirokazu Takata
6 * Copyright (C) 2004 Hirokazu Takata
8 * void *memset(void *dst, int val, int len);
20 #ifdef CONFIG_ISA_DUAL_ISSUE
30 word_align_check: /* len >= 4 */
34 neg r3, r3 /* r3 = -(r3 - 4) */
36 stb r1, @r4 || addi r4, #1
37 addi r2, #-1 || addi r3, #-1
42 and3 r1, r1, #0x00ff /* r1: abababab <-- ??????ab */
44 or r1, r3 || addi r4, #-4
46 or r1, r3 || addi r2, #-4
48 st r1, @+r4 || addi r2, #-4
49 bgtz r2, word_set_loop
50 bnez r2, byte_set_wrap
54 qword_align_check: /* len >= 16 */
56 bnez r3, word_align_check
58 and3 r1, r1, #0x00ff /* r1: abababab <-- ??????ab */
60 or r1, r3 || addi r4, #-4
62 or r1, r3 || ldi r5, #16
64 ld r3, @(4,r4) /* cache line allocate */
65 st r1, @+r4 || addi r2, #-16
66 st r1, @+r4 || cmpu r2, r5
69 bnc qword_set_loop || cmpz r2
83 #if defined(CONFIG_ISA_M32R2)
85 addi r2, #-1 || stb r1, @r4+
87 #elif defined(CONFIG_ISA_M32R)
89 addi r2, #-1 || stb r1, @r4
93 #error unknown isa configuration
98 #else /* not CONFIG_ISA_DUAL_ISSUE */
105 bnc qword_align_check
108 word_align_check: /* len >= 4 */
112 neg r3, r3 /* r3 = -(r3 - 4) */
122 and3 r1, r1, #0x00ff /* r1: abababab <-- ??????ab */
132 bgtz r2, word_set_loop
133 bnez r2, byte_set_wrap
137 qword_align_check: /* len >= 16 */
139 bnez r3, word_align_check
141 and3 r1, r1, #0x00ff /* r1: abababab <-- ??????ab */
148 ld r3, @(4,r4) /* cache line allocate */
156 bnez r2, set_remainder
177 #endif /* not CONFIG_ISA_DUAL_ISSUE */