xref: /linux/arch/loongarch/lib/xor_simd_glue.c (revision 55ec81f7517fad09135f65552cea0a3ee84fff30)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * LoongArch SIMD XOR operations
4  *
5  * Copyright (C) 2023 WANG Xuerui <git@xen0n.name>
6  */
7 
8 #include <linux/export.h>
9 #include <linux/sched.h>
10 #include <asm/fpu.h>
11 #include <asm/xor_simd.h>
12 #include "xor_simd.h"
13 
14 #define MAKE_XOR_GLUE_2(flavor)							\
15 void xor_##flavor##_2(unsigned long bytes, unsigned long * __restrict p1,	\
16 		      const unsigned long * __restrict p2)			\
17 {										\
18 	kernel_fpu_begin();							\
19 	__xor_##flavor##_2(bytes, p1, p2);					\
20 	kernel_fpu_end();							\
21 }										\
22 EXPORT_SYMBOL_GPL(xor_##flavor##_2)
23 
24 #define MAKE_XOR_GLUE_3(flavor)							\
25 void xor_##flavor##_3(unsigned long bytes, unsigned long * __restrict p1,	\
26 		      const unsigned long * __restrict p2,			\
27 		      const unsigned long * __restrict p3)			\
28 {										\
29 	kernel_fpu_begin();							\
30 	__xor_##flavor##_3(bytes, p1, p2, p3);					\
31 	kernel_fpu_end();							\
32 }										\
33 EXPORT_SYMBOL_GPL(xor_##flavor##_3)
34 
35 #define MAKE_XOR_GLUE_4(flavor)							\
36 void xor_##flavor##_4(unsigned long bytes, unsigned long * __restrict p1,	\
37 		      const unsigned long * __restrict p2,			\
38 		      const unsigned long * __restrict p3,			\
39 		      const unsigned long * __restrict p4)			\
40 {										\
41 	kernel_fpu_begin();							\
42 	__xor_##flavor##_4(bytes, p1, p2, p3, p4);				\
43 	kernel_fpu_end();							\
44 }										\
45 EXPORT_SYMBOL_GPL(xor_##flavor##_4)
46 
47 #define MAKE_XOR_GLUE_5(flavor)							\
48 void xor_##flavor##_5(unsigned long bytes, unsigned long * __restrict p1,	\
49 		      const unsigned long * __restrict p2,			\
50 		      const unsigned long * __restrict p3,			\
51 		      const unsigned long * __restrict p4,			\
52 		      const unsigned long * __restrict p5)			\
53 {										\
54 	kernel_fpu_begin();							\
55 	__xor_##flavor##_5(bytes, p1, p2, p3, p4, p5);				\
56 	kernel_fpu_end();							\
57 }										\
58 EXPORT_SYMBOL_GPL(xor_##flavor##_5)
59 
60 #define MAKE_XOR_GLUES(flavor)		\
61 	MAKE_XOR_GLUE_2(flavor);	\
62 	MAKE_XOR_GLUE_3(flavor);	\
63 	MAKE_XOR_GLUE_4(flavor);	\
64 	MAKE_XOR_GLUE_5(flavor)
65 
66 #ifdef CONFIG_CPU_HAS_LSX
67 MAKE_XOR_GLUES(lsx);
68 #endif
69 
70 #ifdef CONFIG_CPU_HAS_LASX
71 MAKE_XOR_GLUES(lasx);
72 #endif
73