From ecc90b0916cfe7585275796e0013631a3465a705 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Mon, 5 Dec 2005 20:37:46 +0000 Subject: [PATCH] Better mechanism to dispatch arch-dependent JIT headers as we can't use raw arch names (e.g. mips expands to 1, thus not finding the header) --- .../src/kpx_cpu/src/cpu/jit/basic-dyngen.hpp | 1 - .../src/kpx_cpu/src/cpu/jit/dyngen-exec.h | 4 +- .../src/kpx_cpu/src/cpu/jit/jit-cache.hpp | 3 + .../src/kpx_cpu/src/cpu/jit/jit-config.hpp | 41 ------------ .../kpx_cpu/src/cpu/jit/jit-target-dispatch.h | 63 +++++++++++++++++++ 5 files changed, 69 insertions(+), 43 deletions(-) create mode 100644 SheepShaver/src/kpx_cpu/src/cpu/jit/jit-target-dispatch.h diff --git a/SheepShaver/src/kpx_cpu/src/cpu/jit/basic-dyngen.hpp b/SheepShaver/src/kpx_cpu/src/cpu/jit/basic-dyngen.hpp index 1bcd9ea1..c858a3e3 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/jit/basic-dyngen.hpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/jit/basic-dyngen.hpp @@ -23,7 +23,6 @@ #include "cpu/jit/jit-config.hpp" #include "cpu/jit/jit-cache.hpp" -#include JIT_TARGET_INCLUDE(jit-target-cache.hpp) // Set jump target address static inline void dg_set_jmp_target(uint8 *jmp_addr, uint8 *addr) diff --git a/SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen-exec.h b/SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen-exec.h index 2692e54d..666edda4 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen-exec.h +++ b/SheepShaver/src/kpx_cpu/src/cpu/jit/dyngen-exec.h @@ -22,7 +22,9 @@ #define DYNGEN_EXEC_H #include "cpu/jit/jit-config.hpp" -#include JIT_TARGET_INCLUDE(dyngen-target-exec.h) + +#define _JIT_HEADER dyngen-target-exec.h +#include "cpu/jit/jit-target-dispatch.h" /* define virtual register set */ #define REG_A0 AREG0 diff --git a/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-cache.hpp b/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-cache.hpp index d303413e..5219bda5 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-cache.hpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-cache.hpp @@ -21,6 +21,9 @@ #ifndef JIT_CACHE_H #define JIT_CACHE_H +#define _JIT_HEADER jit-target-cache.hpp +#include "cpu/jit/jit-target-dispatch.h" + /** * Basic translation cache **/ diff --git a/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-config.hpp b/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-config.hpp index 1f537dd4..44fd2458 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-config.hpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-config.hpp @@ -59,45 +59,4 @@ #endif #endif -/** - * Helpers to reach JIT backends headers - **/ - -#if ENABLE_DYNGEN -#if defined(__powerpc__) || defined(__ppc__) -#define JIT_TARGET ppc -#endif -#if defined(__i386__) -#define JIT_TARGET x86 -#endif -#if defined(__x86_64__) -#define JIT_TARGET amd64 -#endif -#if defined(__s390__) -#define JIT_TARGET s390 -#endif -#if defined(__alpha__) -#define JIT_TARGET alpha -#endif -#if defined(__ia64__) -#define JIT_TARGET ia64 -#endif -#if defined(__sparc__) -#define JIT_TARGET sparc -#endif -#if defined(__arm__) -#define JIT_TARGET arm -#endif -#if defined(__mc68000) -#define JIT_TARGET m68k -#endif -#ifndef JIT_TARGET -#error "Unsupported architecture for JIT1" -#endif - -#define JIT_PATH_CONCAT(X, Y) X/Y -#define JIT_MAKE_HEADER(PATH, HEADER) -#define JIT_TARGET_INCLUDE(HEADER) JIT_MAKE_HEADER(JIT_PATH_CONCAT(cpu/jit,JIT_TARGET),HEADER) -#endif - #endif /* JIT_CONFIG_H */ diff --git a/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-target-dispatch.h b/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-target-dispatch.h new file mode 100644 index 00000000..d9d852e5 --- /dev/null +++ b/SheepShaver/src/kpx_cpu/src/cpu/jit/jit-target-dispatch.h @@ -0,0 +1,63 @@ +/* + * jit-target-dispatch.h - JIT headers dispatcher + * + * Kheperix (C) 2003-2005 Gwenole Beauchesne + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Undefine some built-ins */ +#ifdef i386 +#undef i386 +#define _jit_defined_i386 +#endif +#ifdef amd64 +#undef amd64 +#define _jit_defined_amd64 +#endif +#ifdef mips +#undef mips +#define _jit_defined_mips +#endif + +/* Dispatch arch dependent header */ +#define _JIT_MAKE_HEADER(arch,header) +#if defined(__x86_64__) +#include _JIT_MAKE_HEADER(amd64,_JIT_HEADER) +#elif defined(__i386__) +#include _JIT_MAKE_HEADER(i386,_JIT_HEADER) +#elif defined(__powerpc__) +#include _JIT_MAKE_HEADER(ppc,_JIT_HEADER) +#elif defined(__mips__) +#include _JIT_MAKE_HEADER(mips,_JIT_HEADER) +#else +#error "Unknown architecture, please submit bug report" +#endif +#undef _JIT_MAKE_HEADER +#undef _JIT_HEADER + +/* Redefine built-ins */ +#ifdef _jit_defined_i386 +#undef _jit_defined_i386 +#define i386 1 +#endif +#ifdef _jit_defined_amd64 +#undef _jit_defined_amd64 +#define amd64 1 +#endif +#ifdef _jit_defined_mips +#undef _jit_defined_mips +#define mips 1 +#endif