From 77b3625763ae4d5aa6aaa9d44fbc1bfec6b29335 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 6 Aug 2014 04:26:52 -0400 Subject: Add mempcpy implementation A GNU extension that returns dst + size instead of dst. It's a nice shortcut when copying strings with a known size or back-to-back blocks and you have to do it often. May of course be called directly or alternately through __builtin_mempcpy in some compiler versions. For ASM on native targets, it is implemented as an alternate entrypoint to memcpy which adds minimal code and overhead. Change-Id: I4cbb3483f6df3c1007247fe0a95fd7078737462b --- firmware/asm/mips/memcpy.S | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'firmware/asm/mips') diff --git a/firmware/asm/mips/memcpy.S b/firmware/asm/mips/memcpy.S index edbf5ac5eb..ec1625bb4f 100644 --- a/firmware/asm/mips/memcpy.S +++ b/firmware/asm/mips/memcpy.S @@ -43,8 +43,16 @@ .global memcpy .type memcpy, %function + .global mempcpy + .type mempcpy, %function .set noreorder +mempcpy: + slti t0, a2, 8 # Less than 8? + bne t0, zero, last8 + addu v0, a0, a2 # exit value = s1 + n + b 1f + xor t0, a1, a0 # Find a0/a1 displacement (fill delay) memcpy: slti t0, a2, 8 # Less than 8? @@ -52,7 +60,8 @@ memcpy: move v0, a0 # Setup exit value before too late xor t0, a1, a0 # Find a0/a1 displacement - andi t0, 0x3 + +1: andi t0, 0x3 bne t0, zero, shift # Go handle the unaligned case subu t1, zero, a1 andi t1, 0x3 # a0/a1 are aligned, but are we -- cgit v1.2.3