1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_MemoryUtil.h
4 
5   Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Revision: 26187 $
14  *---------------------------------------------------------------------------*/
15 #ifndef NW_GFX_MEMORY_UTIL_H_
16 #define NW_GFX_MEMORY_UTIL_H_
17 
18 #include <nw/types.h>
19 #include <nw/ut/ut_RuntimeTypeInfo.h>
20 #include <nw/ut/ut_Inlines.h>
21 #include <nw/math.h>
22 #include <nw/ut/ut_MoveArray.h>
23 #include <nw/ut/ut_RuntimeTypeInfo.h>
24 
25 namespace nw {
26 namespace gfx {
27 namespace internal {
28 
29 #define DECL_SUB(size) \
30 asm u32* FastWordCopyAsm_##size(u32* /*dst*/, u32* /*src*/);
31 
32 DECL_SUB(2)
33 DECL_SUB(4)
34 DECL_SUB(6)
35 DECL_SUB(8)
36 DECL_SUB(10)
37 DECL_SUB(12)
38 DECL_SUB(14)
39 DECL_SUB(16)
40 DECL_SUB(18)
41 DECL_SUB(20)
42 DECL_SUB(22)
43 DECL_SUB(24)
44 DECL_SUB(26)
45 DECL_SUB(28)
46 DECL_SUB(30)
47 DECL_SUB(32)
48 DECL_SUB(34)
49 DECL_SUB(36)
50 DECL_SUB(38)
51 DECL_SUB(78)
52 
53 #undef DECL_SUB
54 
55 NW_FORCE_INLINE u32*
FastWordCopy(u32 * dst,u32 * src,u32 size)56 FastWordCopy(u32* dst, u32* src, u32 size)
57 {
58     size /= 4;
59     NW_ASSERT(size % 2 == 0);
60 
61 #define INVOKE_SUB(count) \
62     if (size == count) \
63     { \
64         return FastWordCopyAsm_##count(dst, src); \
65     }
66 
67     INVOKE_SUB(2)
68     INVOKE_SUB(4)
69     INVOKE_SUB(6)
70     INVOKE_SUB(8)
71     INVOKE_SUB(10)
72     INVOKE_SUB(12)
73     INVOKE_SUB(14)
74     INVOKE_SUB(16)
75     INVOKE_SUB(18)
76     INVOKE_SUB(20)
77     INVOKE_SUB(22)
78     INVOKE_SUB(24)
79     INVOKE_SUB(26)
80     INVOKE_SUB(28)
81     INVOKE_SUB(30)
82     INVOKE_SUB(32)
83     INVOKE_SUB(34)
84     INVOKE_SUB(36)
85     INVOKE_SUB(38)
86     INVOKE_SUB(78)
87 
88     NW_LOG("Unsupported size : %d\n", size);
89     NW_ASSERT(false);
90     return NULL;
91 #undef INVOKE_SUB
92 }
93 
94 } // namespace internal
95 } // namespace gfx
96 } // namespace nw
97 
98 #endif // NW_GFX_MEMORY_UTIL_H_
99