int checksum_count=0;
static uae_u8* current_compile_p=NULL;
static uae_u8* max_compile_start;
-uae_u8* compiled_code=NULL;
+static uae_u8* compiled_code=NULL;
static uae_s32 reg_alloc_run;
static int lazy_flush = 1; // Flag: lazy translation cache invalidation
static void* popall_recompile_block=NULL;
static void* popall_check_checksum=NULL;
-extern uae_u32 oink;
-extern unsigned long foink3;
-extern unsigned long foink;
-
/* The 68k only ever executes from even addresses. So right now, we
-waste half the entries in this array
-UPDATE: We now use those entries to store the start of the linked
-lists that we maintain for each hash result. */
+ * waste half the entries in this array
+ * UPDATE: We now use those entries to store the start of the linked
+ * lists that we maintain for each hash result.
+ */
static cacheline cache_tags[TAGSIZE];
static int letit=0;
static blockinfo* hold_bi[MAX_HOLD_BI];
uae_u32 m68k_pc_offset;
/* Some arithmetic operations can be optimized away if the operands
-are known to be constant. But that's only a good idea when the
-side effects they would have on the flags are not important. This
-variable indicates whether we need the side effects or not
-*/
+ * are known to be constant. But that's only a good idea when the
+ * side effects they would have on the flags are not important. This
+ * variable indicates whether we need the side effects or not
+ */
uae_u32 needflags=0;
/* Flag handling is complicated.
-
-x86 instructions create flags, which quite often are exactly what we
-want. So at times, the "68k" flags are actually in the x86 flags.
-
-Then again, sometimes we do x86 instructions that clobber the x86
-flags, but don't represent a corresponding m68k instruction. In that
-case, we have to save them.
-
-We used to save them to the stack, but now store them back directly
-into the regflags.cznv of the traditional emulation. Thus some odd
-names.
-
-So flags can be in either of two places (used to be three; boy were
-things complicated back then!); And either place can contain either
-valid flags or invalid trash (and on the stack, there was also the
-option of "nothing at all", now gone). A couple of variables keep
-track of the respective states.
-
-To make things worse, we might or might not be interested in the flags.
-by default, we are, but a call to dont_care_flags can change that
-until the next call to live_flags. If we are not, pretty much whatever
-is in the register and/or the native flags is seen as valid.
-*/
-
-
-STATIC_INLINE blockinfo* get_blockinfo(uae_u32 cl)
+ *
+ * x86 instructions create flags, which quite often are exactly what we
+ * want. So at times, the "68k" flags are actually in the x86 flags.
+ *
+ * Then again, sometimes we do x86 instructions that clobber the x86
+ * flags, but don't represent a corresponding m68k instruction. In that
+ * case, we have to save them.
+ *
+ * We used to save them to the stack, but now store them back directly
+ * into the regflags.cznv of the traditional emulation. Thus some odd
+ * names.
+ *
+ * So flags can be in either of two places (used to be three; boy were
+ * things complicated back then!); And either place can contain either
+ * valid flags or invalid trash (and on the stack, there was also the
+ * option of "nothing at all", now gone). A couple of variables keep
+ * track of the respective states.
+ *
+ * To make things worse, we might or might not be interested in the flags.
+ * by default, we are, but a call to dont_care_flags can change that
+ * until the next call to live_flags. If we are not, pretty much whatever
+ * is in the register and/or the native flags is seen as valid.
+ */
+
+static inline blockinfo* get_blockinfo(uae_u32 cl)
{
return cache_tags[cl+1].bi;
}
-STATIC_INLINE blockinfo* get_blockinfo_addr(void* addr)
+static inline blockinfo* get_blockinfo_addr(void* addr)
{
blockinfo* bi=get_blockinfo(cacheline(addr));
/*******************************************************************
-* All sorts of list related functions for all of the lists *
-*******************************************************************/
+ * All sorts of list related functions for all of the lists *
+ *******************************************************************/
-STATIC_INLINE void remove_from_cl_list(blockinfo* bi)
+static inline void remove_from_cl_list(blockinfo* bi)
{
uae_u32 cl=cacheline(bi->pc_p);
cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
}
-STATIC_INLINE void remove_from_list(blockinfo* bi)
+static inline void remove_from_list(blockinfo* bi)
{
if (bi->prev_p)
*(bi->prev_p)=bi->next;
bi->next->prev_p=bi->prev_p;
}
-STATIC_INLINE void remove_from_lists(blockinfo* bi)
+static inline void remove_from_lists(blockinfo* bi)
{
remove_from_list(bi);
remove_from_cl_list(bi);
}
-STATIC_INLINE void add_to_cl_list(blockinfo* bi)
+static inline void add_to_cl_list(blockinfo* bi)
{
uae_u32 cl=cacheline(bi->pc_p);
cache_tags[cl].handler=bi->handler_to_use;
}
-STATIC_INLINE void raise_in_cl_list(blockinfo* bi)
+static inline void raise_in_cl_list(blockinfo* bi)
{
remove_from_cl_list(bi);
add_to_cl_list(bi);
}
-STATIC_INLINE void add_to_active(blockinfo* bi)
+static inline void add_to_active(blockinfo* bi)
{
if (active)
active->prev_p=&(bi->next);
bi->prev_p=&active;
}
-STATIC_INLINE void add_to_dormant(blockinfo* bi)
+static inline void add_to_dormant(blockinfo* bi)
{
if (dormant)
dormant->prev_p=&(bi->next);
bi->prev_p=&dormant;
}
-STATIC_INLINE void remove_dep(dependency* d)
+static inline void remove_dep(dependency* d)
{
if (d->prev_p)
*(d->prev_p)=d->next;
}
/* This block's code is about to be thrown away, so it no longer
-depends on anything else */
-STATIC_INLINE void remove_deps(blockinfo* bi)
+ depends on anything else */
+static inline void remove_deps(blockinfo* bi)
{
remove_dep(&(bi->dep[0]));
remove_dep(&(bi->dep[1]));
}
-STATIC_INLINE void adjust_jmpdep(dependency* d, void* a)
+static inline void adjust_jmpdep(dependency* d, void* a)
{
*(d->jmp_off)=(uae_u32)a-((uae_u32)d->jmp_off+4);
}
/********************************************************************
-* Soft flush handling support functions *
-********************************************************************/
+ * Soft flush handling support functions *
+ ********************************************************************/
-STATIC_INLINE void set_dhtu(blockinfo* bi, void* dh)
+static inline void set_dhtu(blockinfo* bi, void* dh)
{
//write_log (_T("JIT: bi is %p\n"),bi);
if (dh!=bi->direct_handler_to_use) {
}
}
-STATIC_INLINE void invalidate_block(blockinfo* bi)
+static inline void invalidate_block(blockinfo* bi)
{
int i;
remove_deps(bi);
}
-STATIC_INLINE void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae_u32 target)
+static inline void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae_u32 target)
{
blockinfo* tbi=get_blockinfo_addr((void*)target);
tbi->deplist=&(bi->dep[i]);
}
-STATIC_INLINE void big_to_small_state(bigstate* b, smallstate* s)
+static inline void big_to_small_state(bigstate* b, smallstate* s)
{
int i;
int count=0;
}
}
-STATIC_INLINE void attached_state(blockinfo* bi)
+static inline void attached_state(blockinfo* bi)
{
bi->havestate=1;
if (bi->direct_handler_to_use==bi->direct_handler)
bi->status=BI_TARGETTED;
}
-STATIC_INLINE blockinfo* get_blockinfo_addr_new(void* addr, int setstate)
+static inline blockinfo* get_blockinfo_addr_new(void* addr, int setstate)
{
blockinfo* bi=get_blockinfo_addr(addr);
int i;
static void prepare_block(blockinfo* bi);
-STATIC_INLINE void alloc_blockinfos(void)
+static inline void alloc_blockinfos(void)
{
int i;
blockinfo* bi;
}
/********************************************************************
-* Preferences handling. This is just a convenient place to put it *
-********************************************************************/
+ * Preferences handling. This is just a convenient place to put it *
+ ********************************************************************/
extern bool have_done_picasso;
bool check_prefs_changed_comp (void)
}
/********************************************************************
-* Get the optimizer stuff *
-********************************************************************/
+ * Get the optimizer stuff *
+ ********************************************************************/
//#include "compemu_optimizer.c"
#include "compemu_optimizer_x86.cpp"
/********************************************************************
-* Functions to emit data into memory, and other general support *
-********************************************************************/
+ * Functions to emit data into memory, and other general support *
+ ********************************************************************/
static uae_u8* target;
{
}
-STATIC_INLINE void emit_byte(uae_u8 x)
+static inline void emit_byte(uae_u8 x)
{
*target++=x;
}
-STATIC_INLINE void emit_word(uae_u16 x)
+static inline void emit_word(uae_u16 x)
{
*((uae_u16*)target)=x;
target+=2;
}
-STATIC_INLINE void emit_long(uae_u32 x)
+static inline void emit_long(uae_u32 x)
{
*((uae_u32*)target)=x;
target+=4;
}
-STATIC_INLINE uae_u32 reverse32(uae_u32 oldv)
+static inline uae_u32 reverse32(uae_u32 oldv)
{
return ((oldv>>24)&0xff) | ((oldv>>8)&0xff00) |
((oldv<<8)&0xff0000) | ((oldv<<24)&0xff000000);
target=t;
}
-STATIC_INLINE uae_u8* get_target_noopt(void)
+static inline uae_u8* get_target_noopt(void)
{
return target;
}
-STATIC_INLINE uae_u8* get_target(void)
+static inline uae_u8* get_target(void)
{
lopt_emit_all();
return get_target_noopt();
/********************************************************************
-* Getting the information about the target CPU *
-********************************************************************/
+ * Getting the information about the target CPU *
+ ********************************************************************/
#include "codegen_x86.cpp"
/********************************************************************
-* Flags status handling. EMIT TIME! *
-********************************************************************/
+ * Flags status handling. EMIT TIME! *
+ ********************************************************************/
static void bt_l_ri_noclobber(RR4 r, IMM i);
live.flags_on_stack=VALID;
}
-STATIC_INLINE void clobber_flags(void)
+static inline void clobber_flags(void)
{
if (live.flags_in_flags==VALID && live.flags_on_stack!=VALID)
flags_to_stack();
}
/* Prepare for leaving the compiled stuff */
-STATIC_INLINE void flush_flags(void)
+static inline void flush_flags(void)
{
flags_to_stack();
return;
int touchcnt;
/********************************************************************
-* register allocation per block logging *
-********************************************************************/
+ * register allocation per block logging *
+ ********************************************************************/
static uae_s8 vstate[VREGS];
static uae_s8 nstate[N_REGS];
#define L_NEEDED -2
#define L_UNNEEDED -3
-STATIC_INLINE void log_startblock(void)
+static inline void log_startblock(void)
{
int i;
for (i=0;i<VREGS;i++)
nstate[i]=L_UNKNOWN;
}
-STATIC_INLINE void log_isused(int n)
+static inline void log_isused(int n)
{
if (nstate[n]==L_UNKNOWN)
nstate[n]=L_UNAVAIL;
}
-STATIC_INLINE void log_isreg(int n, int r)
+static inline void log_isreg(int n, int r)
{
if (nstate[n]==L_UNKNOWN)
nstate[n]=r;
vstate[r]=L_NEEDED;
}
-STATIC_INLINE void log_clobberreg(int r)
+static inline void log_clobberreg(int r)
{
if (vstate[r]==L_UNKNOWN)
vstate[r]=L_UNNEEDED;
/* This ends all possibility of clever register allocation */
-STATIC_INLINE void log_flush(void)
+static inline void log_flush(void)
{
int i;
for (i=0;i<VREGS;i++)
nstate[i]=L_UNAVAIL;
}
-STATIC_INLINE void log_dump(void)
+static inline void log_dump(void)
{
int i;
}
/********************************************************************
-* register status handling. EMIT TIME! *
-********************************************************************/
+ * register status handling. EMIT TIME! *
+ ********************************************************************/
-STATIC_INLINE void set_status(int r, int status)
+static inline void set_status(int r, int status)
{
if (status==ISCONST)
log_clobberreg(r);
live.state[r].status=status;
}
-
-STATIC_INLINE int isinreg(int r)
+static inline int isinreg(int r)
{
return live.state[r].status==CLEAN || live.state[r].status==DIRTY;
}
-STATIC_INLINE void adjust_nreg(int r, uae_u32 val)
+static inline void adjust_nreg(int r, uae_u32 val)
{
if (!val)
return;
}
}
-STATIC_INLINE int isconst(int r)
+static inline int isconst(int r)
{
return live.state[r].status==ISCONST;
}
return isconst(r);
}
-STATIC_INLINE void writeback_const(int r)
+static inline void writeback_const(int r)
{
if (!isconst(r))
return;
set_status(r,INMEM);
}
-STATIC_INLINE void tomem_c(int r)
+static inline void tomem_c(int r)
{
if (isconst(r)) {
writeback_const(r);
set_status(r,INMEM);
}
-STATIC_INLINE void free_nreg(int r)
+static inline void free_nreg(int r)
{
int i=live.nat[r].nholds;
}
/* Use with care! */
-STATIC_INLINE void isclean(int r)
+static inline void isclean(int r)
{
if (!isinreg(r))
return;
set_status(r,CLEAN);
}
-STATIC_INLINE void disassociate(int r)
+static inline void disassociate(int r)
{
isclean(r);
evict(r);
}
-STATIC_INLINE void set_const(int r, uae_u32 val)
+static inline void set_const(int r, uae_u32 val)
{
disassociate(r);
live.state[r].val=val;
set_status(r,ISCONST);
}
-STATIC_INLINE uae_u32 get_offset(int r)
+static inline uae_u32 get_offset(int r)
{
return live.state[r].val;
}
}
-STATIC_INLINE void make_exclusive(int r, int size, int spec)
+static inline void make_exclusive(int r, int size, int spec)
{
reg_status oldstate;
int rr=live.state[r].realreg;
unlock2(rr);
}
-STATIC_INLINE void add_offset(int r, uae_u32 off)
+static inline void add_offset(int r, uae_u32 off)
{
live.state[r].val+=off;
}
-STATIC_INLINE void remove_offset(int r, int spec)
+static inline void remove_offset(int r, int spec)
{
int rr;
jit_abort (_T("JIT: Failed in remove_offset\n"));
}
-STATIC_INLINE void remove_all_offsets(void)
+static inline void remove_all_offsets(void)
{
int i;
remove_offset(i,-1);
}
-STATIC_INLINE int readreg_general(int r, int size, int spec, int can_offset)
+static inline int readreg_general(int r, int size, int spec, int can_offset)
{
int n;
int answer=-1;
}
-STATIC_INLINE int writereg_general(int r, int size, int spec)
+static inline int writereg_general(int r, int size, int spec)
{
int n;
int answer=-1;
return writereg_general(r,size,spec);
}
-STATIC_INLINE int rmw_general(int r, int wsize, int rsize, int spec)
+static inline int rmw_general(int r, int wsize, int rsize, int spec)
{
int n;
int answer=-1;
}
/********************************************************************
-* FPU register status handling. EMIT TIME! *
-********************************************************************/
+ * FPU register status handling. EMIT TIME! *
+ ********************************************************************/
static void f_tomem(int r)
{
}
-STATIC_INLINE int f_isinreg(int r)
+static inline int f_isinreg(int r)
{
return live.fate[r].status==CLEAN || live.fate[r].status==DIRTY;
}
live.fate[r].realreg=-1;
}
-STATIC_INLINE void f_free_nreg(int r)
+static inline void f_free_nreg(int r)
{
int i=live.fat[r].nholds;
/* Use with care! */
-STATIC_INLINE void f_isclean(int r)
+static inline void f_isclean(int r)
{
if (!f_isinreg(r))
return;
live.fate[r].status=CLEAN;
}
-STATIC_INLINE void f_disassociate(int r)
+static inline void f_disassociate(int r)
{
f_isclean(r);
f_evict(r);
live.fat[r].locked++;
}
-STATIC_INLINE int f_readreg(int r)
+static inline int f_readreg(int r)
{
int n;
int answer=-1;
return answer;
}
-STATIC_INLINE void f_make_exclusive(int r, int clobber)
+static inline void f_make_exclusive(int r, int clobber)
{
freg_status oldstate;
int rr=live.fate[r].realreg;
}
-STATIC_INLINE int f_writereg(int r)
+static inline int f_writereg(int r)
{
int n;
int answer=-1;
#include "compemu_midfunc_x86.cpp"
- /********************************************************************
- * Support functions exposed to gencomp. CREATE time *
- ********************************************************************/
+/********************************************************************
+ * Support functions exposed to gencomp. CREATE time *
+ ********************************************************************/
int kill_rodent(int r)
{
}
/********************************************************************
-* Support functions exposed to newcpu *
-********************************************************************/
+ * Support functions exposed to newcpu *
+ ********************************************************************/
uae_u32 scratch[VREGS];
fptype fscratch[VFREGS];
#if USE_MATCHSTATE
/* This is going to be, amongst other things, a more elaborate version of
flush() */
-STATIC_INLINE void match_states(smallstate* s)
+static inline void match_states(smallstate* s)
{
uae_s8 vton[VREGS];
uae_s8 ndone[N_REGS];
}
}
#else
-STATIC_INLINE void match_states(smallstate* s)
+static inline void match_states(smallstate* s)
{
flush(1);
}
}
/********************************************************************
-* Support functions, internal *
-********************************************************************/
+ * Support functions, internal *
+ ********************************************************************/
static void align_target(uae_u32 a)
*target++=0x90;
}
-STATIC_INLINE int isinrom(uae_u32 addr)
+static inline int isinrom(uae_u32 addr)
{
return (addr>=(uae_u32)kickmem_bank.baseaddr &&
addr<(uae_u32)kickmem_bank.baseaddr+8*65536);
}
/* Make sure all registers that will get clobbered by a call are
-save and sound in memory */
+ save and sound in memory */
static void prepare_for_call_1(void)
{
flush_all(); /* If there are registers that don't get clobbered,
}
/* We will call a C routine in a moment. That will clobber all registers,
-so we need to disassociate everything */
+ so we need to disassociate everything */
static void prepare_for_call_2(void)
{
int i;
/********************************************************************
-* Memory access and related functions, CREATE time *
-********************************************************************/
+ * Memory access and related functions, CREATE time *
+ ********************************************************************/
void register_branch(uae_u32 not_taken, uae_u32 taken, uae_u8 cond)
{
}
}
-STATIC_INLINE void writemem(int address, int source, int offset, int size, int tmp)
+static inline void writemem(int address, int source, int offset, int size, int tmp)
{
int f=tmp;
writemem_real(address,source,20,1,tmp,0);
}
-STATIC_INLINE void writeword_general(int address, int source, int tmp,
+static inline void writeword_general(int address, int source, int tmp,
int clobber)
{
int distrust = currprefs.comptrustword;
writeword_general(address,source,tmp,0);
}
-STATIC_INLINE void writelong_general(int address, int source, int tmp,
+static inline void writelong_general(int address, int source, int tmp,
int clobber)
{
int distrust = currprefs.comptrustlong;
-STATIC_INLINE void readmem(int address, int dest, int offset, int size, int tmp)
+static inline void readmem(int address, int dest, int offset, int size, int tmp)
{
int f=tmp;
/* This one might appear a bit odd... */
-STATIC_INLINE void get_n_addr_old(int address, int dest, int tmp)
+static inline void get_n_addr_old(int address, int dest, int tmp)
{
readmem(address,dest,24,4,tmp);
}
-STATIC_INLINE void get_n_addr_real(int address, int dest, int tmp)
+static inline void get_n_addr_real(int address, int dest, int tmp)
{
int f=tmp;
if (address!=dest)
forget_about(tmp);
}
-STATIC_INLINE unsigned int cft_map (unsigned int f)
+static inline unsigned int cft_map (unsigned int f)
{
return ((f >> 8) & 255) | ((f & 255) << 8);
}
}
-STATIC_INLINE void create_popalls(void)
+static inline void create_popalls(void)
{
int i,r;
raw_jmp_m_indexed((uae_u32)cache_tags,r,4);
}
-STATIC_INLINE void reset_lists(void)
+static inline void reset_lists(void)
{
int i;
int failure;
-
void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
{
if (letit && compiled_code && currprefs.cpu_model>=68020) {