[Scummvm-cvs-logs] SF.net SVN: scummvm:[52817] scummvm/trunk
Bluddy at users.sourceforge.net
Bluddy at users.sourceforge.net
Mon Sep 20 16:10:45 CEST 2010
Revision: 52817
http://scummvm.svn.sourceforge.net/scummvm/?rev=52817&view=rev
Author: Bluddy
Date: 2010-09-20 14:10:44 +0000 (Mon, 20 Sep 2010)
Log Message:
-----------
PSP: switch from wrapping memcpy to defining our own memcpy
The advantage is that we get to do inlining and even use lwl and lwr instructions where appropriate. We have to do it ourselves because the PSP doesn't tolerate built-in instructions, but also we have a more efficient memcpy than the lib's.
Modified Paths:
--------------
scummvm/trunk/backends/platform/psp/memory.cpp
scummvm/trunk/backends/platform/psp/memory.h
scummvm/trunk/common/scummsys.h
scummvm/trunk/configure
Property Changed:
----------------
scummvm/trunk/configure
Modified: scummvm/trunk/backends/platform/psp/memory.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/memory.cpp 2010-09-20 14:09:39 UTC (rev 52816)
+++ scummvm/trunk/backends/platform/psp/memory.cpp 2010-09-20 14:10:44 UTC (rev 52817)
@@ -37,23 +37,6 @@
//#define TEST_MEMORY_COPY
-extern "C" {
-
-#ifdef TEST_MEMORY_COPY /* we won't be able to run in this case b/c of printouts */
-extern void *__real_memcpy(void *dst, void *src, size_t bytes);
-#endif
-
-void *__wrap_memcpy(void *dst, void *src, size_t bytes) {
-#ifdef TEST_MEMORY_COPY /* we won't be able to run in this case */
- return __real_memcpy(dst, src, bytes);
-#else
- PspMemory::fastCopy((byte *)dst, (byte *)src, bytes);
- return dst;
-#endif
-}
-
-}
-
void PspMemory::copy(byte *dst, const byte *src, uint32 bytes) {
DEBUG_ENTER_FUNC();
Modified: scummvm/trunk/backends/platform/psp/memory.h
===================================================================
--- scummvm/trunk/backends/platform/psp/memory.h 2010-09-20 14:09:39 UTC (rev 52816)
+++ scummvm/trunk/backends/platform/psp/memory.h 2010-09-20 14:10:44 UTC (rev 52817)
@@ -32,8 +32,20 @@
//#define __PSP_DEBUG_PRINT__
-#include "backends/platform/psp/trace.h"
+//#include "backends/platform/psp/trace.h"
+// These instructions don't generate automatically but are faster then copying byte by byte
+inline void lwl_copy(byte *dst, const byte *src) {
+ register uint32 data;
+ asm volatile ("lwr %0,0(%1)\n\t"
+ "lwl %0,3(%1)\n\t"
+ : "=&r" (data) : "r" (src), "m" (*src));
+
+ asm volatile ("swr %1,0(%2)\n\t"
+ "swl %1,3(%2)\n\t"
+ : "=m" (*dst) : "r" (data), "r" (dst));
+}
+
/**
* Class that does memory copying and swapping if needed
*/
@@ -46,22 +58,39 @@
static inline void copy8(byte *dst, const byte *src, int32 bytes) {
//PSP_DEBUG_PRINT("copy8 called with dst[%p], src[%p], bytes[%d]\n", dst, src, bytes);
- for (;bytes; bytes--) {
+ uint32 words = bytes >> 2;
+ for (; words; words--) {
+ lwl_copy(dst, src);
+ dst += 4;
+ src += 4;
+ }
+
+ uint32 bytesLeft = bytes & 0x3;
+ for (; bytesLeft; bytesLeft--) {
*dst++ = *src++;
}
}
public:
// This is the interface to the outside world
- static void fastCopy(byte *dst, const byte *src, uint32 bytes) {
+ static void *fastCopy(void *dstv, const void *srcv, int32 bytes) {
+ byte *dst = (byte *)dstv;
+ byte *src = (byte *)srcv;
+
if (bytes < MIN_AMOUNT_FOR_COMPLEX_COPY) {
copy8(dst, src, bytes);
} else { // go to more powerful copy
copy(dst, src, bytes);
}
+
+ return dstv;
}
};
+inline void *psp_memcpy(void *dst, const void *src, int32 bytes) {
+ return PspMemory::fastCopy(dst, src, bytes);
+}
+
#endif /* PSP_MEMORY_H */
#if defined(PSP_INCLUDE_SWAP) && !defined(PSP_MEMORY_SWAP_H)
Modified: scummvm/trunk/common/scummsys.h
===================================================================
--- scummvm/trunk/common/scummsys.h 2010-09-20 14:09:39 UTC (rev 52816)
+++ scummvm/trunk/common/scummsys.h 2010-09-20 14:10:44 UTC (rev 52817)
@@ -315,12 +315,16 @@
#elif defined(__PSP__)
#include <malloc.h>
+ #include "backends/platform/psp/memory.h"
#define scumm_stricmp strcasecmp
#define scumm_strnicmp strncasecmp
#define SCUMM_LITTLE_ENDIAN
#define SCUMM_NEED_ALIGNMENT
+
+ /* to make an efficient, inlined memcpy implementation */
+ #define memcpy(dst, src, size) psp_memcpy(dst, src, size)
#elif defined(__amigaos4__)
Modified: scummvm/trunk/configure
===================================================================
--- scummvm/trunk/configure 2010-09-20 14:09:39 UTC (rev 52816)
+++ scummvm/trunk/configure 2010-09-20 14:10:44 UTC (rev 52817)
@@ -2098,7 +2098,7 @@
PLUGIN_EXTRA_DEPS = $(EXECUTABLE)
CXXFLAGS += -DDYNAMIC_MODULES
LDFLAGS += -Wl,-T$(srcdir)/backends/platform/psp/main_prog.ld
-PLUGIN_LDFLAGS = -nostartfiles -Wl,-q,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/platform/psp/plugin.syms,-T$(srcdir)/backends/platform/psp/plugin.ld -lstdc++ -lc -lm -Wl,--wrap,memcpy
+PLUGIN_LDFLAGS = -nostartfiles -Wl,-q,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/platform/psp/plugin.syms,-T$(srcdir)/backends/platform/psp/plugin.ld -lstdc++ -lc -lm
PRE_OBJS_FLAGS := -Wl,--whole-archive
POST_OBJS_FLAGS := -Wl,--no-whole-archive
'
@@ -2665,7 +2665,6 @@
psp)
DEFINES="$DEFINES -D__PSP__ -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL"
LIBS="$LIBS -lpng -Wl,-Map,mapfile.txt"
- LDFLAGS="$LDFLAGS -Wl,--wrap,memcpy"
;;
samsungtv)
find_sdlconfig
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list