| ... | ... |
@@ -27,7 +27,7 @@ void arm_jit_close(); |
| 27 | 27 |
void arm_jit_sync(); |
| 28 | 28 |
template<int PROCNUM> uint32_t arm_jit_compile(); |
| 29 | 29 |
|
| 30 |
-#if defined(_WINDOWS) || defined(DESMUME_COCOA) |
|
| 30 |
+#if defined(_WINDOWS) || defined(DESMUME_COCOA) || defined(HAVE_JIT) |
|
| 31 | 31 |
# define MAPPED_JIT_FUNCS |
| 32 | 32 |
#endif |
| 33 | 33 |
|
| ... | ... |
@@ -16,8 +16,7 @@ |
| 16 | 16 |
along with the this software. If not, see <http://www.gnu.org/licenses/>. |
| 17 | 17 |
*/ |
| 18 | 18 |
|
| 19 |
-#ifndef ARM_JIT |
|
| 20 |
-#define ARM_JIT |
|
| 19 |
+#pragma once |
|
| 21 | 20 |
|
| 22 | 21 |
#include "types.h" |
| 23 | 22 |
|
| ... | ... |
@@ -62,6 +61,3 @@ inline uintptr_t &JIT_COMPILED_FUNC_PREMASKED(uint32_t adr, uint32_t PROCNUM, ui |
| 62 | 61 |
#define JIT_COMPILED_FUNC_KNOWNBANK(adr, bank, mask, ofs) JIT_COMPILED_FUNC(adr, PROCNUM) |
| 63 | 62 |
inline bool JIT_MAPPED(uint32_t adr, uint32_t PROCNUM) { return true; }
|
| 64 | 63 |
#endif |
| 65 |
- |
|
| 66 |
- |
|
| 67 |
-#endif |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,67 @@ |
| 1 |
+/* Copyright (C) 2006 yopyop |
|
| 2 |
+ Copyright (C) 2011 Loren Merritt |
|
| 3 |
+ Copyright (C) 2012 DeSmuME team |
|
| 4 |
+ |
|
| 5 |
+ This file is free software: you can redistribute it and/or modify |
|
| 6 |
+ it under the terms of the GNU General Public License as published by |
|
| 7 |
+ the Free Software Foundation, either version 3 of the License, or |
|
| 8 |
+ (at your option) any later version. |
|
| 9 |
+ |
|
| 10 |
+ This file is distributed in the hope that it will be useful, |
|
| 11 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 13 |
+ GNU General Public License for more details. |
|
| 14 |
+ |
|
| 15 |
+ You should have received a copy of the GNU General Public License |
|
| 16 |
+ along with the this software. If not, see <http://www.gnu.org/licenses/>. |
|
| 17 |
+*/ |
|
| 18 |
+ |
|
| 19 |
+#ifndef ARM_JIT |
|
| 20 |
+#define ARM_JIT |
|
| 21 |
+ |
|
| 22 |
+#include "types.h" |
|
| 23 |
+ |
|
| 24 |
+typedef uint32_t (FASTCALL *ArmOpCompiled)(); |
|
| 25 |
+ |
|
| 26 |
+void arm_jit_reset(bool enable); |
|
| 27 |
+void arm_jit_close(); |
|
| 28 |
+void arm_jit_sync(); |
|
| 29 |
+template<int PROCNUM> uint32_t arm_jit_compile(); |
|
| 30 |
+ |
|
| 31 |
+#ifdef _WINDOWS |
|
| 32 |
+# define MAPPED_JIT_FUNCS |
|
| 33 |
+#endif |
|
| 34 |
+ |
|
| 35 |
+#ifdef MAPPED_JIT_FUNCS |
|
| 36 |
+struct JIT_struct |
|
| 37 |
+{
|
|
| 38 |
+ // only include the memory types that code can execute from |
|
| 39 |
+ uintptr_t MAIN_MEM[0x800000]; |
|
| 40 |
+ uintptr_t SWIRAM[0x4000]; |
|
| 41 |
+ uintptr_t ARM9_ITCM[0x4000]; |
|
| 42 |
+ uintptr_t ARM9_LCDC[0x52000]; |
|
| 43 |
+ uintptr_t ARM9_BIOS[0x4000]; |
|
| 44 |
+ uintptr_t ARM7_BIOS[0x2000]; |
|
| 45 |
+ uintptr_t ARM7_ERAM[0x8000]; |
|
| 46 |
+ uintptr_t ARM7_WIRAM[0x8000]; |
|
| 47 |
+ uintptr_t ARM7_WRAM[0x20000]; |
|
| 48 |
+ |
|
| 49 |
+ static uintptr_t *JIT_MEM[2][0x4000]; |
|
| 50 |
+}; |
|
| 51 |
+extern CACHE_ALIGN JIT_struct JIT; |
|
| 52 |
+inline uintptr_t &JIT_COMPILED_FUNC(uint32_t adr, uint32_t PROCNUM) { return JIT.JIT_MEM[PROCNUM][(adr & 0x0FFFC000) >> 14][(adr & 0x00003FFE) >> 1]; }
|
|
| 53 |
+inline uintptr_t &JIT_COMPILED_FUNC_PREMASKED(uint32_t adr, uint32_t PROCNUM, uint32_t ofs) { return JIT.JIT_MEM[PROCNUM][adr >> 14][((adr & 0x00003FFE) >> 1) + ofs]; }
|
|
| 54 |
+#define JIT_COMPILED_FUNC_KNOWNBANK(adr, bank, mask, ofs) JIT.bank[(((adr) & (mask)) >> 1) + ofs] |
|
| 55 |
+inline bool JIT_MAPPED(uint32_t adr, uint32_t PROCNUM) { return !!JIT.JIT_MEM[PROCNUM][adr >> 14]; }
|
|
| 56 |
+#else |
|
| 57 |
+// actually an array of function pointers, but they fit in 32bit address space, so might as well save memory |
|
| 58 |
+extern uintptr_t compiled_funcs[]; |
|
| 59 |
+// there isn't anything mapped between 07000000 and 0EFFFFFF, so we can mask off bit 27 and get away with a smaller array |
|
| 60 |
+inline uintptr_r &JIT_COMPILED_FUNC(uint32_t adr, uint32_t PROCNUM) { compiled_funcs[(adr & 0x07FFFFFE) >> 1]; }
|
|
| 61 |
+inline uintptr_t &JIT_COMPILED_FUNC_PREMASKED(uint32_t adr, uint32_t PROCNUM, uint32_t ofs) { return JIT_COMPILED_FUNC(adr, PROCNUM); }
|
|
| 62 |
+#define JIT_COMPILED_FUNC_KNOWNBANK(adr, bank, mask, ofs) JIT_COMPILED_FUNC(adr, PROCNUM) |
|
| 63 |
+inline bool JIT_MAPPED(uint32_t adr, uint32_t PROCNUM) { return true; }
|
|
| 64 |
+#endif |
|
| 65 |
+ |
|
| 66 |
+ |
|
| 67 |
+#endif |