MIPS: Optimise core library functions for microMIPS.
PATCH v2 2/9 MIPS: Optimise core library functions for microMIPS.
From: "Steven J. Hill" <[email protected]>
Optimise some of the core library functions to use microMIPS instructions for binary size reduction. When the microMIPS ISA is not being used, the library functions compiled to binary are identical.
Signed-off-by Steven J. Hill <[email protected]>
--- arch/mips/include/asm/asm.h | 2 + arch/mips/include/asm/page.h | 6 +++ arch/mips/lib/memcpy.S | 17 +++++++-- arch/mips/lib/memset.S | 84 +++++++++++++++++++++++++++--------------- arch/mips/lib/strlen_user.S | 9 +++-- arch/mips/lib/strncpy_user.S | 28 +++++++------- arch/mips/lib/strnlen_user.S | 2 +- 7 files changed, 96 insertions(+), 52 deletions(-)
arch/mips/include/asm/asm.h +2 -0
@@ -296,6 +296,7 @@ symbol = value#define LONG_SUBU subu#define LONG_L lw#define LONG_S sw +#define LONG_SP swp#define LONG_SLL sll#define LONG_SLLV sllv#define LONG_SRL srl
@@ -318,6 +319,7 @@ symbol = value#define LONG_SUBU dsubu#define LONG_L ld#define LONG_S sd +#define LONG_SP sdp#define LONG_SLL dsll#define LONG_SLLV dsllv#define LONG_SRL dsrl
arch/mips/include/asm/page.h +6 -0
@@ -45,6 +45,12 @@#define HUGETLB_PAGE_ORDER ({BUILD_BUG(); 0; })#endif /* CONFIG_HUGETLB_PAGE */ +/* +* Clear and copy array sizes for micro-assembly of clear_page/copy_page. +*/ +#define CLEAR_PAGE_ARRAY_SIZE 288 +#define COPY_PAGE_ARRAY_SIZE 1344 +#ifndef __ASSEMBLY__#include <linux/pfn.h>
arch/mips/lib/memcpy.S +13 -4
@@ -10,6 +10,7 @@ * Copyright (C) 2002 Broadcom, Inc. * memcpy/copy_user author: Mark Vandevoorde * Copyright (C) 2007 Maciej W. Rozycki + * Copyright (C) 2011 MIPS Technologies, Inc. * * Mnemonic names for arguments to memcpy/__copy_user */
@@ -21,16 +22,14 @@ * end of memory on some systems. It's also a seriously bad idea on non * dma-coherent systems. */ -#ifdef CONFIG_DMA_NONCOHERENT -#undef CONFIG_CPU_HAS_PREFETCH -#endif -#ifdef CONFIG_MIPS_MALTA +#if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_MIPS_MALTA) #undef CONFIG_CPU_HAS_PREFETCH #endif #include <asm/asm.h> #include <asm/asm-offsets.h> #include <asm/regdef.h> +#include <asm/page.h> #define dst a0 #define src a1
@@ -564,3 +563,13 @@ LEAF(__rmemcpy) /* a0=dst a1=src a2=len */ jr ra move a2, zero END(__rmemcpy) + +LEAF(clear_page) +1: j 1b /* Dummy, will be replaced. */ + .space CLEAR_PAGE_ARRAY_SIZE + END(clear_page) + +LEAF(copy_page) +1: j 1b /* Dummy, will be replaced. */ + .space COPY_PAGE_ARRAY_SIZE + END(copy_page)
arch/mips/lib/memset.S +54 -30
150 lines not on this page · raw message
arch/mips/lib/strlen_user.S +5 -4
@@ -3,8 +3,9 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (c) 1996, 1998, 1999, 2004 by Ralf Baechle - * Copyright (c) 1999 Silicon Graphics, Inc. + * Copyright (C) 1996, 1998, 1999, 2004 by Ralf Baechle + * Copyright (C) 1999 Silicon Graphics, Inc. + * Copyright (C) 2011 MIPS Technologies, Inc. */ #include <asm/asm.h> #include <asm/asm-offsets.h>
@@ -28,9 +29,9 @@ LEAF(__strlen_user_asm) FEXPORT(__strlen_user_nocheck_asm) move v0, a0 -1: EX(lb, t0, (v0), .Lfault) +1: EX(lbu, v1, (v0), .Lfault) PTR_ADDIU v0, 1 - bnez t0, 1b + bnez v1, 1b PTR_SUBU v0, a0 jr ra END(__strlen_user_asm)
arch/mips/lib/strncpy_user.S +15 -13
@@ -3,7 +3,8 @@ * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (c) 1996, 1999 by Ralf Baechle + * Copyright (C) 1996, 1999 by Ralf Baechle + * Copyright (C) 2011 MIPS Technologies, Inc. */ #include <linux/errno.h> #include <asm/asm.h>
@@ -33,22 +34,23 @@ LEAF(__strncpy_from_user_asm) bnez v0, .Lfault FEXPORT(__strncpy_from_user_nocheck_asm) - move v0, zero - move v1, a1 .set noreorder -1: EX(lbu, t0, (v1), .Lfault) + move t0, zero + move v1, a1 +1: EX(lbu, v0, (v1), .Lfault) PTR_ADDIU v1, 1 R10KCBARRIER(0(ra)) - beqz t0, 2f - sb t0, (a0) - PTR_ADDIU v0, 1 - .set reorder - PTR_ADDIU a0, 1 - bne v0, a2, 1b -2: PTR_ADDU t0, a1, v0 - xor t0, a1 - bltz t0, .Lfault + beqz v0, 2f + sb v0, (a0) + PTR_ADDIU t0, 1 + bne t0, a2, 1b + PTR_ADDIU a0, 1 +2: PTR_ADDU v0, a1, t0 + xor v0, a1 + bltz v0, .Lfault + nop jr ra # return n + move v0, t0 END(__strncpy_from_user_asm) .Lfault: li v0, -EFAULT
arch/mips/lib/strnlen_user.S +1 -1
@@ -35,7 +35,7 @@ FEXPORT(__strnlen_user_nocheck_asm) PTR_ADDU a1, a0 # stop pointer 1: beq v0, a1, 1f # limit reached? EX(lb, t0, (v0), .Lfault) - PTR_ADDU v0, 1 + PTR_ADDIU v0, 1 bnez t0, 1b 1: PTR_SUBU v0, a0 jr ra
Signature · 1 line
1.7.10