Merge tag 'rproc-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc...
[linux.git] / arch / loongarch / lib / xor_simd.c
blob84cd24b728c47968344ef2b771895e0e321262dd
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * LoongArch SIMD XOR operations
5 * Copyright (C) 2023 WANG Xuerui <git@xen0n.name>
6 */
8 #include "xor_simd.h"
11 * Process one cache line (64 bytes) per loop. This is assuming all future
12 * popular LoongArch cores are similar performance-characteristics-wise to the
13 * current models.
15 #define LINE_WIDTH 64
17 #ifdef CONFIG_CPU_HAS_LSX
19 #define LD(reg, base, offset) \
20 "vld $vr" #reg ", %[" #base "], " #offset "\n\t"
21 #define ST(reg, base, offset) \
22 "vst $vr" #reg ", %[" #base "], " #offset "\n\t"
23 #define XOR(dj, k) "vxor.v $vr" #dj ", $vr" #dj ", $vr" #k "\n\t"
25 #define LD_INOUT_LINE(base) \
26 LD(0, base, 0) \
27 LD(1, base, 16) \
28 LD(2, base, 32) \
29 LD(3, base, 48)
31 #define LD_AND_XOR_LINE(base) \
32 LD(4, base, 0) \
33 LD(5, base, 16) \
34 LD(6, base, 32) \
35 LD(7, base, 48) \
36 XOR(0, 4) \
37 XOR(1, 5) \
38 XOR(2, 6) \
39 XOR(3, 7)
41 #define ST_LINE(base) \
42 ST(0, base, 0) \
43 ST(1, base, 16) \
44 ST(2, base, 32) \
45 ST(3, base, 48)
47 #define XOR_FUNC_NAME(nr) __xor_lsx_##nr
48 #include "xor_template.c"
50 #undef LD
51 #undef ST
52 #undef XOR
53 #undef LD_INOUT_LINE
54 #undef LD_AND_XOR_LINE
55 #undef ST_LINE
56 #undef XOR_FUNC_NAME
58 #endif /* CONFIG_CPU_HAS_LSX */
60 #ifdef CONFIG_CPU_HAS_LASX
62 #define LD(reg, base, offset) \
63 "xvld $xr" #reg ", %[" #base "], " #offset "\n\t"
64 #define ST(reg, base, offset) \
65 "xvst $xr" #reg ", %[" #base "], " #offset "\n\t"
66 #define XOR(dj, k) "xvxor.v $xr" #dj ", $xr" #dj ", $xr" #k "\n\t"
68 #define LD_INOUT_LINE(base) \
69 LD(0, base, 0) \
70 LD(1, base, 32)
72 #define LD_AND_XOR_LINE(base) \
73 LD(2, base, 0) \
74 LD(3, base, 32) \
75 XOR(0, 2) \
76 XOR(1, 3)
78 #define ST_LINE(base) \
79 ST(0, base, 0) \
80 ST(1, base, 32)
82 #define XOR_FUNC_NAME(nr) __xor_lasx_##nr
83 #include "xor_template.c"
85 #undef LD
86 #undef ST
87 #undef XOR
88 #undef LD_INOUT_LINE
89 #undef LD_AND_XOR_LINE
90 #undef ST_LINE
91 #undef XOR_FUNC_NAME
93 #endif /* CONFIG_CPU_HAS_LASX */