Commit c2959956 authored by Mao Minkai's avatar Mao Minkai Committed by guzitao
Browse files

sw64: choose lib at compile time

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB73UR



--------------------------------

Compile both SISD and SIMD version of memcpy/memset like libs and let
the compiler optimize out the unused version based on kernel config.

Signed-off-by: default avatarMao Minkai <maominkai@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent bb2c1f34
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -22,20 +22,16 @@ lib-y = __divlu.o __remlu.o __divwu.o __remwu.o \
lib-clear_page-y := clear_page.o
lib-clear_page-$(CONFIG_DEEP_CLEAR_PAGE) := deep-clear_page.o

lib-clear_user-y := clear_user.o
lib-clear_user-$(CONFIG_DEEP_CLEAR_USER) := deep-clear_user-hw_una.o deep-clear_user-sw_una.o
lib-clear_user-y := clear_user.o deep-clear_user-hw_una.o deep-clear_user-sw_una.o

lib-copy_page-y := copy_page.o
lib-copy_page-$(CONFIG_DEEP_COPY_PAGE) := deep-copy_page.o

lib-copy_user-y := copy_user.o
lib-copy_user-$(CONFIG_DEEP_COPY_USER) := deep-copy_user-hw_una.o deep-copy_user-sw_una.o
lib-copy_user-y := copy_user.o deep-copy_user-hw_una.o deep-copy_user-sw_una.o

lib-memcpy-y := memcpy.o
lib-memcpy-$(CONFIG_DEEP_MEMCPY) := deep-memcpy-hw_una.o deep-memcpy-sw_una.o
lib-memcpy-y := memcpy.o deep-memcpy-hw_una.o deep-memcpy-sw_una.o

lib-memset-y := memset.o
lib-memset-$(CONFIG_DEEP_MEMSET) := deep-memset-hw_una.o deep-memset-sw_una.o
lib-memset-y := memset.o deep-memset-hw_una.o deep-memset-sw_una.o

lib-$(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) += uaccess_flushcache.o

+4 −6
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
 * stuff.
 *
 */
#include <asm/export.h>
/* Allow an exception for an insn; exit if we get one.  */
#define EX(x,y...)			\
	99: x,##y;			\
@@ -23,11 +22,11 @@
	.set noreorder
	.align 4

	.globl __clear_user
	.ent __clear_user
	.globl ____clear_user_sisd
	.ent ____clear_user_sisd
	.frame $30, 0, $26
	.prologue 0
__clear_user:
____clear_user_sisd:
	and	$17, $17, $0
	and	$16, 7, $4
	beq	$0, $zerolength
@@ -98,5 +97,4 @@ $tail:
	clr	$0
	ret	$31, ($26), 1

	.end __clear_user
	EXPORT_SYMBOL(__clear_user)
	.end ____clear_user_sisd
+4 −6
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@
 * only _after_ a successful copy). There is also some rather minor
 * exception setup stuff..
 */
#include <asm/export.h>
/* Allow an exception for an insn; exit if we get one.  */
#define EXI(x,y...)			\
	99: x,##y;			\
@@ -27,9 +26,9 @@

	.set noat
	.align 4
	.globl __copy_user
	.ent __copy_user
__copy_user:
	.globl ____copy_user_sisd
	.ent ____copy_user_sisd
____copy_user_sisd:
	.prologue 0
	and	$18, $18, $0
	and	$16, 7, $3
@@ -102,5 +101,4 @@ $exitin:
$exitout:
	ret	$31, ($26), 1

	.end __copy_user
	EXPORT_SYMBOL(__copy_user)
	.end ____copy_user_sisd
+5 −10
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Reasonably optimized memcpy() routine for the sw64
 * Reasonably optimized ____memcpy_sisd() routine for the sw64
 *
 *	- memory accessed as aligned quadwords only
 *	- uses bcmpge to compare 8 bytes in parallel
@@ -8,14 +8,13 @@
 * Temp usage notes:
 *	$1, $2, - scratch
 */
#include <asm/export.h>
	.set noreorder
	.set noat

	.align 4
	.globl memcpy
	.ent memcpy
memcpy:
	.globl ____memcpy_sisd
	.ent ____memcpy_sisd
____memcpy_sisd:
	.frame $30, 0, $26, 0
	.prologue 0

@@ -194,8 +193,4 @@ $misalign_byte:
$nomoredata:
	ret	$31, ($26), 1

	.end memcpy
	EXPORT_SYMBOL(memcpy)
/* For backwards module compatibility.  */
__memcpy = memcpy
.globl __memcpy
	.end ____memcpy_sisd
+4 −46
Original line number Diff line number Diff line
@@ -13,35 +13,16 @@
 * hand, so they might well be incorrect, please do tell me about it..)
 */

#include <asm/export.h>

	.set noat
	.set noreorder
.text
	.globl memset
	.globl __memset
	.globl ___memset
	.globl __memsetw
	.globl __constant_c_memset
	.globl ____constant_c_memset_sisd

	.ent ___memset
.align 5
___memset:
	.ent ____constant_c_memset_sisd
	.frame $30, 0, $26, 0
	.prologue 0

	and	$17, 255, $1
	inslb	$17, 1, $17
	bis	$17, $1, $17
	sll	$17, 16, $1

	bis	$17, $1, $17
	sll	$17, 32, $1
	bis	$17, $1, $17
	ldl_u	$31, 0($30)

.align 5
__constant_c_memset:
____constant_c_memset_sisd:
	addl	$18, $16, $6
	bis	$16, $16, $0
	xor	$16, $6, $1
@@ -127,27 +108,4 @@ within_one_quad_loop:

end:
	ret	$31, ($26), 1
	.end ___memset
	EXPORT_SYMBOL(___memset)

	.align 5
	.ent __memsetw
__memsetw:
	.prologue 0

	inslh	$17, 0, $1
	inslh	$17, 2, $2
	inslh	$17, 4, $3
	or	$1, $2, $1
	inslh	$17, 6, $4
	or	$1, $3, $1
	or	$1, $4, $17
	br __constant_c_memset

	.end __memsetw
	EXPORT_SYMBOL(__memsetw)

memset = ___memset
EXPORT_SYMBOL(memset)
__memset = ___memset
EXPORT_SYMBOL(__memset)
	.end ____constant_c_memset_sisd
Loading