]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
JIT: merge a bit more code, added compemu_midfunc_x86.h
authorFrode Solheim <frode@fs-uae.net>
Sun, 6 Sep 2015 20:26:19 +0000 (22:26 +0200)
committerFrode Solheim <frode@fs-uae.net>
Sun, 6 Sep 2015 20:26:19 +0000 (22:26 +0200)
jit/codegen_x86.cpp
jit/compemu.h
jit/compemu_midfunc_x86.h [new file with mode: 0644]
jit/compemu_support.cpp

index 5a38cc2ee6feeafad91e8432050e2a810b153b73..ae2e6071ed1bb5bba632bf590960e7ccebb1689a 100644 (file)
@@ -3149,6 +3149,7 @@ static inline void raw_inc_sp(int off)
 #include "exception_handler.cpp"
 #endif
 
+static
 void compiler_status() {
        jit_log("compiled code starts at %p, current at %08x", compiled_code, (unsigned int)(current_compile_p - compiled_code));
 }
@@ -3403,6 +3404,7 @@ raw_init_cpu(void)
        if (tune_alignment) {
                align_loops = x86_alignments[c->x86_processor].align_loop;
 #ifdef UAE
+               /* FIXME: using hard-coded align_jumps right now */
 #else
                align_jumps = x86_alignments[c->x86_processor].align_jump;
 #endif
index 3716ea8d7cbdf87550c131bf146863a14ac9f002..dca34dcf4f65ab4f2796aa7335cb1f4493c7870e 100644 (file)
@@ -98,6 +98,15 @@ extern void alloc_cache(void);
 extern void compile_block(cpu_history* pc_hist, int blocklen, int totcyles);
 extern int check_for_cache_miss(void);
 
+static inline void flush_icache(int n)
+{
+       flush_icache(0, n);
+}
+
+static inline void flush_icache_hard(int n)
+{
+       flush_icache(0, n);
+}
 
 #define scaled_cycles(x) (currprefs.m68k_speed<0?(((x)/SCALE)?(((x)/SCALE<MAXCYCLES?((x)/SCALE):MAXCYCLES)):1):(x))
 
@@ -268,6 +277,12 @@ extern int touchcnt;
 #define PEEPHOLE_O 2000000
 #define DECLARE(func) extern void func
 
+/* What we expose to the outside */
+#define DECLARE_MIDFUNC(func) extern void func
+
+#include "compemu_midfunc_x86.h"
+
+#undef DECLARE_MIDFUNC
 
 /* What we expose to the outside */
 DECLARE(bt_l_ri(RR4 r, IMM i));
diff --git a/jit/compemu_midfunc_x86.h b/jit/compemu_midfunc_x86.h
new file mode 100644 (file)
index 0000000..ba80727
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  compiler/compemu_midfunc_x86.h - Native MIDFUNCS for IA-32 and AMD64
+ *
+ * Copyright (c) 2014 Jens Heitmann of ARAnyM dev team (see AUTHORS)
+ *
+ * Inspired by Christian Bauer's Basilisk II
+ *
+ *  Original 68040 JIT compiler for UAE, copyright 2000-2002 Bernd Meyer
+ *
+ *  Adaptation for Basilisk II and improvements, copyright 2000-2002
+ *    Gwenole Beauchesne
+ *
+ *  Basilisk II (C) 1997-2002 Christian Bauer
+ *
+ *  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
+ *
+ *  Note:
+ *      File is included by compemu.h
+ *
+ */
+
+DECLARE_MIDFUNC(mul_32_32(RW4 d, RR4 s));
+DECLARE_MIDFUNC(or_l_rm(RW4 d, IMM s));
index 05ee8896015c30fb5a6f375096f017eb2dd7f602..675395a9ec534ab8135fa42408d2ff212a725abf 100644 (file)
@@ -90,6 +90,7 @@
 #ifdef UAE
 
 #define UNUSED(x)
+/* FIXME: Looks like HAVE_GET_WORD_UNSWAPPED should be defined for little-endian / ARAnyM */
 #define HAVE_GET_WORD_UNSWAPPED
 #include "uae.h"
 #include "uae/log.h"
@@ -700,6 +701,53 @@ public:
        }
 };
 
+#if USE_SEPARATE_BIA
+static LazyBlockAllocator<blockinfo> BlockInfoAllocator;
+static LazyBlockAllocator<checksum_info> ChecksumInfoAllocator;
+#else
+static HardBlockAllocator<blockinfo> BlockInfoAllocator;
+static HardBlockAllocator<checksum_info> ChecksumInfoAllocator;
+#endif
+
+static inline checksum_info *alloc_checksum_info(void)
+{
+       checksum_info *csi = ChecksumInfoAllocator.acquire();
+       csi->next = NULL;
+       return csi;
+}
+
+static inline void free_checksum_info(checksum_info *csi)
+{
+       csi->next = NULL;
+       ChecksumInfoAllocator.release(csi);
+}
+
+static inline void free_checksum_info_chain(checksum_info *csi)
+{
+       while (csi != NULL) {
+               checksum_info *csi2 = csi->next;
+               free_checksum_info(csi);
+               csi = csi2;
+       }
+}
+
+static inline blockinfo *alloc_blockinfo(void)
+{
+       blockinfo *bi = BlockInfoAllocator.acquire();
+#if USE_CHECKSUM_INFO
+       bi->csi = NULL;
+#endif
+       return bi;
+}
+
+static inline void free_blockinfo(blockinfo *bi)
+{
+#if USE_CHECKSUM_INFO
+       free_checksum_info_chain(bi->csi);
+       bi->csi = NULL;
+#endif
+       BlockInfoAllocator.release(bi);
+}
 
 static inline void alloc_blockinfos(void)
 {
@@ -1103,6 +1151,7 @@ static uae_s8 nstate[N_REGS];
 #ifdef UAE
 static inline void big_to_small_state(bigstate* b, smallstate* s)
 {
+       /* FIXME: replace with ARAnyM version */
        int i;
        int count=0;
 
@@ -2260,6 +2309,7 @@ static void fflags_into_flags_internal(uae_u32 tmp)
  ********************************************************************/
 
 #ifdef UAE
+/* FIXME: implement */
 #else
 void set_zero(int r, int tmp)
 {
@@ -2317,13 +2367,24 @@ static inline const char *str_on_off(bool b)
        return b ? "on" : "off";
 }
 
+static
 void compiler_init(void)
 {
        static bool initialized = false;
        if (initialized)
                return;
+
+#if PROFILE_UNTRANSLATED_INSNS
+       panicbug("<JIT compiler> : gather statistics on untranslated insns count");
+#endif
+
+#if PROFILE_COMPILE_TIME
+       panicbug("<JIT compiler> : gather statistics on translation time");
+       emul_start_time = clock();
+#endif
 }
 
+static
 void compiler_exit(void)
 {
 #if PROFILE_COMPILE_TIME
@@ -2404,6 +2465,11 @@ void init_comp(void)
        uae_u8* cw=can_word;
        uae_u8* au=always_used;
 
+#ifdef RECORD_REGISTER_USAGE
+       for (i=0;i<16;i++)
+               reg_count_local[i] = 0;
+#endif
+
        for (i=0;i<VREGS;i++) {
                live.state[i].realreg=-1;
                live.state[i].needflush=NF_SCRATCH;
@@ -3293,6 +3359,7 @@ static void check_checksum(void)
 static inline void match_states(blockinfo* bi)
 {
 #ifdef UAE
+       /* FIXME: replace with ARAnyM version */
        flush(1);
 #else
        int i;
@@ -4340,7 +4407,7 @@ void exec_nostats(void)
 #endif
 
 #ifdef UAE
-    /* Different implementation in newcpu.cpp */
+/* FIXME: check differences against UAE execute_normal (newcpu.cpp) */
 #else
 void execute_normal(void)
 {
@@ -4376,6 +4443,7 @@ void execute_normal(void)
 typedef void (*compiled_handler)(void);
 
 #ifdef UAE
+/* FIXME: check differences against UAE m68k_do_compile_execute */
 #else
 void m68k_do_compile_execute(void)
 {
@@ -4391,6 +4459,7 @@ void m68k_do_compile_execute(void)
 #endif
 
 #ifdef UAE
+/* FIXME: check differences against UAE m68k_compile_execute */
 #else
 void m68k_compile_execute (void)
 {