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.
+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.
+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.
+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.
+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.
+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;
+ return cache_tags[cl+1].bi;
}
STATIC_INLINE blockinfo* get_blockinfo_addr(void* addr)
{
- blockinfo* bi=get_blockinfo(cacheline(addr));
+ blockinfo* bi=get_blockinfo(cacheline(addr));
- while (bi) {
- if (bi->pc_p==addr)
- return bi;
- bi=bi->next_same_cl;
- }
- return NULL;
+ while (bi) {
+ if (bi->pc_p==addr)
+ return bi;
+ bi=bi->next_same_cl;
+ }
+ return NULL;
}
/*******************************************************************
- * 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)
{
- uae_u32 cl=cacheline(bi->pc_p);
+ uae_u32 cl=cacheline(bi->pc_p);
- if (bi->prev_same_cl_p)
- *(bi->prev_same_cl_p)=bi->next_same_cl;
- if (bi->next_same_cl)
- bi->next_same_cl->prev_same_cl_p=bi->prev_same_cl_p;
- if (cache_tags[cl+1].bi)
- cache_tags[cl].handler=cache_tags[cl+1].bi->handler_to_use;
- else
- cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
+ if (bi->prev_same_cl_p)
+ *(bi->prev_same_cl_p)=bi->next_same_cl;
+ if (bi->next_same_cl)
+ bi->next_same_cl->prev_same_cl_p=bi->prev_same_cl_p;
+ if (cache_tags[cl+1].bi)
+ cache_tags[cl].handler=cache_tags[cl+1].bi->handler_to_use;
+ else
+ cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
}
STATIC_INLINE void remove_from_list(blockinfo* bi)
{
- if (bi->prev_p)
- *(bi->prev_p)=bi->next;
- if (bi->next)
- bi->next->prev_p=bi->prev_p;
+ if (bi->prev_p)
+ *(bi->prev_p)=bi->next;
+ if (bi->next)
+ bi->next->prev_p=bi->prev_p;
}
STATIC_INLINE void remove_from_lists(blockinfo* bi)
{
- remove_from_list(bi);
- remove_from_cl_list(bi);
+ remove_from_list(bi);
+ remove_from_cl_list(bi);
}
STATIC_INLINE void add_to_cl_list(blockinfo* bi)
{
- uae_u32 cl=cacheline(bi->pc_p);
+ uae_u32 cl=cacheline(bi->pc_p);
- if (cache_tags[cl+1].bi)
- cache_tags[cl+1].bi->prev_same_cl_p=&(bi->next_same_cl);
- bi->next_same_cl=cache_tags[cl+1].bi;
+ if (cache_tags[cl+1].bi)
+ cache_tags[cl+1].bi->prev_same_cl_p=&(bi->next_same_cl);
+ bi->next_same_cl=cache_tags[cl+1].bi;
- cache_tags[cl+1].bi=bi;
- bi->prev_same_cl_p=&(cache_tags[cl+1].bi);
+ cache_tags[cl+1].bi=bi;
+ bi->prev_same_cl_p=&(cache_tags[cl+1].bi);
- cache_tags[cl].handler=bi->handler_to_use;
+ cache_tags[cl].handler=bi->handler_to_use;
}
STATIC_INLINE void raise_in_cl_list(blockinfo* bi)
{
- remove_from_cl_list(bi);
- add_to_cl_list(bi);
+ remove_from_cl_list(bi);
+ add_to_cl_list(bi);
}
STATIC_INLINE void add_to_active(blockinfo* bi)
{
- if (active)
- active->prev_p=&(bi->next);
- bi->next=active;
+ if (active)
+ active->prev_p=&(bi->next);
+ bi->next=active;
- active=bi;
- bi->prev_p=&active;
+ active=bi;
+ bi->prev_p=&active;
}
STATIC_INLINE void add_to_dormant(blockinfo* bi)
{
- if (dormant)
- dormant->prev_p=&(bi->next);
- bi->next=dormant;
+ if (dormant)
+ dormant->prev_p=&(bi->next);
+ bi->next=dormant;
- dormant=bi;
- bi->prev_p=&dormant;
+ dormant=bi;
+ bi->prev_p=&dormant;
}
STATIC_INLINE void remove_dep(dependency* d)
{
- if (d->prev_p)
- *(d->prev_p)=d->next;
- if (d->next)
- d->next->prev_p=d->prev_p;
- d->prev_p=NULL;
- d->next=NULL;
+ if (d->prev_p)
+ *(d->prev_p)=d->next;
+ if (d->next)
+ d->next->prev_p=d->prev_p;
+ d->prev_p=NULL;
+ d->next=NULL;
}
/* This block's code is about to be thrown away, so it no longer
- depends on anything else */
+depends on anything else */
STATIC_INLINE void remove_deps(blockinfo* bi)
{
- remove_dep(&(bi->dep[0]));
- remove_dep(&(bi->dep[1]));
+ remove_dep(&(bi->dep[0]));
+ remove_dep(&(bi->dep[1]));
}
STATIC_INLINE void adjust_jmpdep(dependency* d, void* a)
{
- *(d->jmp_off)=(uae_u32)a-((uae_u32)d->jmp_off+4);
+ *(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)
{
- //write_log (L"JIT: bi is %p\n",bi);
- if (dh!=bi->direct_handler_to_use) {
- dependency* x=bi->deplist;
- //write_log (L"JIT: bi->deplist=%p\n",bi->deplist);
- while (x) {
- //write_log (L"JIT: x is %p\n",x);
- //write_log (L"JIT: x->next is %p\n",x->next);
- //write_log (L"JIT: x->prev_p is %p\n",x->prev_p);
-
- if (x->jmp_off) {
- adjust_jmpdep(x,dh);
- }
- x=x->next;
+ //write_log (L"JIT: bi is %p\n",bi);
+ if (dh!=bi->direct_handler_to_use) {
+ dependency* x=bi->deplist;
+ //write_log (L"JIT: bi->deplist=%p\n",bi->deplist);
+ while (x) {
+ //write_log (L"JIT: x is %p\n",x);
+ //write_log (L"JIT: x->next is %p\n",x->next);
+ //write_log (L"JIT: x->prev_p is %p\n",x->prev_p);
+
+ if (x->jmp_off) {
+ adjust_jmpdep(x,dh);
+ }
+ x=x->next;
+ }
+ bi->direct_handler_to_use=(cpuop_func*)dh;
}
- bi->direct_handler_to_use=(cpuop_func*)dh;
- }
}
STATIC_INLINE void invalidate_block(blockinfo* bi)
{
- int i;
+ int i;
- bi->optlevel=0;
- bi->count=currprefs.optcount[0]-1;
- bi->handler=NULL;
- bi->handler_to_use=(cpuop_func*)popall_execute_normal;
- bi->direct_handler=NULL;
- set_dhtu(bi,bi->direct_pen);
- bi->needed_flags=0xff;
+ bi->optlevel=0;
+ bi->count=currprefs.optcount[0]-1;
+ bi->handler=NULL;
+ bi->handler_to_use=(cpuop_func*)popall_execute_normal;
+ bi->direct_handler=NULL;
+ set_dhtu(bi,bi->direct_pen);
+ bi->needed_flags=0xff;
- for (i=0;i<2;i++) {
- bi->dep[i].jmp_off=NULL;
- bi->dep[i].target=NULL;
- }
- remove_deps(bi);
+ for (i=0;i<2;i++) {
+ bi->dep[i].jmp_off=NULL;
+ bi->dep[i].target=NULL;
+ }
+ remove_deps(bi);
}
STATIC_INLINE void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae_u32 target)
{
- blockinfo* tbi=get_blockinfo_addr((void*)target);
+ blockinfo* tbi=get_blockinfo_addr((void*)target);
- Dif(!tbi) {
- jit_abort (L"JIT: Could not create jmpdep!\n");
- }
- bi->dep[i].jmp_off=jmpaddr;
- bi->dep[i].target=tbi;
- bi->dep[i].next=tbi->deplist;
- if (bi->dep[i].next)
- bi->dep[i].next->prev_p=&(bi->dep[i].next);
- bi->dep[i].prev_p=&(tbi->deplist);
- tbi->deplist=&(bi->dep[i]);
+ Dif(!tbi) {
+ jit_abort (L"JIT: Could not create jmpdep!\n");
+ }
+ bi->dep[i].jmp_off=jmpaddr;
+ bi->dep[i].target=tbi;
+ bi->dep[i].next=tbi->deplist;
+ if (bi->dep[i].next)
+ bi->dep[i].next->prev_p=&(bi->dep[i].next);
+ bi->dep[i].prev_p=&(tbi->deplist);
+ tbi->deplist=&(bi->dep[i]);
}
STATIC_INLINE void big_to_small_state(bigstate* b, smallstate* s)
{
- int i;
- int count=0;
-
- for (i=0;i<N_REGS;i++) {
- s->nat[i].validsize=0;
- s->nat[i].dirtysize=0;
- if (b->nat[i].nholds) {
- int index=b->nat[i].nholds-1;
- int r=b->nat[i].holds[index];
- s->nat[i].holds=r;
- s->nat[i].validsize=b->state[r].validsize;
- s->nat[i].dirtysize=b->state[r].dirtysize;
- count++;
+ int i;
+ int count=0;
+
+ for (i=0;i<N_REGS;i++) {
+ s->nat[i].validsize=0;
+ s->nat[i].dirtysize=0;
+ if (b->nat[i].nholds) {
+ int index=b->nat[i].nholds-1;
+ int r=b->nat[i].holds[index];
+ s->nat[i].holds=r;
+ s->nat[i].validsize=b->state[r].validsize;
+ s->nat[i].dirtysize=b->state[r].dirtysize;
+ count++;
+ }
+ }
+ write_log (L"JIT: count=%d\n",count);
+ for (i=0;i<N_REGS;i++) { // FIXME --- don't do dirty yet
+ s->nat[i].dirtysize=0;
}
- }
- write_log (L"JIT: count=%d\n",count);
- for (i=0;i<N_REGS;i++) { // FIXME --- don't do dirty yet
- s->nat[i].dirtysize=0;
- }
}
STATIC_INLINE void attached_state(blockinfo* bi)
{
- bi->havestate=1;
- if (bi->direct_handler_to_use==bi->direct_handler)
- set_dhtu(bi,bi->direct_pen);
- bi->direct_handler=bi->direct_pen;
- bi->status=BI_TARGETTED;
+ bi->havestate=1;
+ if (bi->direct_handler_to_use==bi->direct_handler)
+ set_dhtu(bi,bi->direct_pen);
+ bi->direct_handler=bi->direct_pen;
+ bi->status=BI_TARGETTED;
}
STATIC_INLINE blockinfo* get_blockinfo_addr_new(void* addr, int setstate)
{
- blockinfo* bi=get_blockinfo_addr(addr);
- int i;
+ blockinfo* bi=get_blockinfo_addr(addr);
+ int i;
#if USE_OPTIMIZER
- if (reg_alloc_run)
- return NULL;
+ if (reg_alloc_run)
+ return NULL;
#endif
- if (!bi) {
- for (i=0;i<MAX_HOLD_BI && !bi;i++) {
- if (hold_bi[i]) {
- uae_u32 cl=cacheline(addr);
-
- bi=hold_bi[i];
- hold_bi[i]=NULL;
- bi->pc_p=(uae_u8*)addr;
- invalidate_block(bi);
- add_to_active(bi);
- add_to_cl_list(bi);
-
- }
+ if (!bi) {
+ for (i=0;i<MAX_HOLD_BI && !bi;i++) {
+ if (hold_bi[i]) {
+ uae_u32 cl=cacheline(addr);
+
+ bi=hold_bi[i];
+ hold_bi[i]=NULL;
+ bi->pc_p=(uae_u8*)addr;
+ invalidate_block(bi);
+ add_to_active(bi);
+ add_to_cl_list(bi);
+
+ }
+ }
+ }
+ if (!bi) {
+ jit_abort (L"JIT: Looking for blockinfo, can't find free one\n");
}
- }
- if (!bi) {
- jit_abort (L"JIT: Looking for blockinfo, can't find free one\n");
- }
#if USE_MATCHSTATE
- if (setstate &&
- !bi->havestate) {
- big_to_small_state(&live,&(bi->env));
- attached_state(bi);
- }
+ if (setstate &&
+ !bi->havestate) {
+ big_to_small_state(&live,&(bi->env));
+ attached_state(bi);
+ }
#endif
- return bi;
+ return bi;
}
static void prepare_block(blockinfo* bi);
STATIC_INLINE void alloc_blockinfos(void)
{
- int i;
- blockinfo* bi;
+ int i;
+ blockinfo* bi;
- for (i=0;i<MAX_HOLD_BI;i++) {
- if (hold_bi[i])
- return;
- bi=hold_bi[i]=(blockinfo*)current_compile_p;
- current_compile_p+=sizeof(blockinfo);
+ for (i=0;i<MAX_HOLD_BI;i++) {
+ if (hold_bi[i])
+ return;
+ bi=hold_bi[i]=(blockinfo*)current_compile_p;
+ current_compile_p+=sizeof(blockinfo);
- prepare_block(bi);
- }
+ prepare_block(bi);
+ }
}
/********************************************************************
- * Preferences handling. This is just a convenient place to put it *
- ********************************************************************/
+* Preferences handling. This is just a convenient place to put it *
+********************************************************************/
extern int have_done_picasso;
int check_prefs_changed_comp (void)
{
- int changed = 0;
- static int cachesize_prev, comptrust_prev, canbang_prev;
-
- if (currprefs.comptrustbyte != changed_prefs.comptrustbyte ||
- currprefs.comptrustword != changed_prefs.comptrustword ||
- currprefs.comptrustlong != changed_prefs.comptrustlong ||
- currprefs.comptrustnaddr!= changed_prefs.comptrustnaddr ||
- currprefs.compnf != changed_prefs.compnf ||
- currprefs.comp_hardflush != changed_prefs.comp_hardflush ||
- currprefs.comp_constjump != changed_prefs.comp_constjump ||
- currprefs.comp_oldsegv != changed_prefs.comp_oldsegv ||
- currprefs.compfpu != changed_prefs.compfpu ||
- currprefs.fpu_strict != changed_prefs.fpu_strict)
- changed = 1;
-
- currprefs.comptrustbyte = changed_prefs.comptrustbyte;
- currprefs.comptrustword = changed_prefs.comptrustword;
- currprefs.comptrustlong = changed_prefs.comptrustlong;
- currprefs.comptrustnaddr= changed_prefs.comptrustnaddr;
- currprefs.compnf = changed_prefs.compnf;
- currprefs.comp_hardflush = changed_prefs.comp_hardflush;
- currprefs.comp_constjump = changed_prefs.comp_constjump;
- currprefs.comp_oldsegv = changed_prefs.comp_oldsegv;
- currprefs.compfpu = changed_prefs.compfpu;
- currprefs.fpu_strict = changed_prefs.fpu_strict;
-
- if (currprefs.cachesize != changed_prefs.cachesize) {
- if (currprefs.cachesize && !changed_prefs.cachesize) {
- cachesize_prev = currprefs.cachesize;
- comptrust_prev = currprefs.comptrustbyte;
- canbang_prev = canbang;
- } else if (!currprefs.cachesize && changed_prefs.cachesize == cachesize_prev) {
- changed_prefs.comptrustbyte = currprefs.comptrustbyte = comptrust_prev;
- changed_prefs.comptrustword = currprefs.comptrustword = comptrust_prev;
- changed_prefs.comptrustlong = currprefs.comptrustlong = comptrust_prev;
- changed_prefs.comptrustnaddr = currprefs.comptrustnaddr = comptrust_prev;
- }
- currprefs.cachesize = changed_prefs.cachesize;
- alloc_cache();
- changed = 1;
- }
- if (!candirect)
- canbang = 0;
-
- // Turn off illegal-mem logging when using JIT...
- if(currprefs.cachesize)
- currprefs.illegal_mem = changed_prefs.illegal_mem;// = 0;
-
- currprefs.comp_midopt = changed_prefs.comp_midopt;
- currprefs.comp_lowopt = changed_prefs.comp_lowopt;
-
- if ((!canbang || !currprefs.cachesize) && currprefs.comptrustbyte != 1) {
- // Set all of these to indirect when canbang == 0
- // Basically, set the compforcesettings option...
- currprefs.comptrustbyte = 1;
- currprefs.comptrustword = 1;
- currprefs.comptrustlong = 1;
- currprefs.comptrustnaddr= 1;
-
- changed_prefs.comptrustbyte = 1;
- changed_prefs.comptrustword = 1;
- changed_prefs.comptrustlong = 1;
- changed_prefs.comptrustnaddr= 1;
-
- changed = 1;
-
- if (currprefs.cachesize)
- write_log (L"JIT: Reverting to \"indirect\" access, because canbang is zero!\n");
- }
-
- if (changed)
- write_log (L"JIT: cache=%d. b=%d w=%d l=%d fpu=%d nf=%d const=%d hard=%d\n",
- currprefs.cachesize,
- currprefs.comptrustbyte, currprefs.comptrustword, currprefs.comptrustlong,
- currprefs.compfpu, currprefs.compnf, currprefs.comp_constjump, currprefs.comp_hardflush);
+ int changed = 0;
+ static int cachesize_prev, comptrust_prev, canbang_prev;
+
+ if (currprefs.comptrustbyte != changed_prefs.comptrustbyte ||
+ currprefs.comptrustword != changed_prefs.comptrustword ||
+ currprefs.comptrustlong != changed_prefs.comptrustlong ||
+ currprefs.comptrustnaddr!= changed_prefs.comptrustnaddr ||
+ currprefs.compnf != changed_prefs.compnf ||
+ currprefs.comp_hardflush != changed_prefs.comp_hardflush ||
+ currprefs.comp_constjump != changed_prefs.comp_constjump ||
+ currprefs.comp_oldsegv != changed_prefs.comp_oldsegv ||
+ currprefs.compfpu != changed_prefs.compfpu ||
+ currprefs.fpu_strict != changed_prefs.fpu_strict)
+ changed = 1;
+
+ currprefs.comptrustbyte = changed_prefs.comptrustbyte;
+ currprefs.comptrustword = changed_prefs.comptrustword;
+ currprefs.comptrustlong = changed_prefs.comptrustlong;
+ currprefs.comptrustnaddr= changed_prefs.comptrustnaddr;
+ currprefs.compnf = changed_prefs.compnf;
+ currprefs.comp_hardflush = changed_prefs.comp_hardflush;
+ currprefs.comp_constjump = changed_prefs.comp_constjump;
+ currprefs.comp_oldsegv = changed_prefs.comp_oldsegv;
+ currprefs.compfpu = changed_prefs.compfpu;
+ currprefs.fpu_strict = changed_prefs.fpu_strict;
+
+ if (currprefs.cachesize != changed_prefs.cachesize) {
+ if (currprefs.cachesize && !changed_prefs.cachesize) {
+ cachesize_prev = currprefs.cachesize;
+ comptrust_prev = currprefs.comptrustbyte;
+ canbang_prev = canbang;
+ } else if (!currprefs.cachesize && changed_prefs.cachesize == cachesize_prev) {
+ changed_prefs.comptrustbyte = currprefs.comptrustbyte = comptrust_prev;
+ changed_prefs.comptrustword = currprefs.comptrustword = comptrust_prev;
+ changed_prefs.comptrustlong = currprefs.comptrustlong = comptrust_prev;
+ changed_prefs.comptrustnaddr = currprefs.comptrustnaddr = comptrust_prev;
+ }
+ currprefs.cachesize = changed_prefs.cachesize;
+ alloc_cache();
+ changed = 1;
+ }
+ if (!candirect)
+ canbang = 0;
+
+ // Turn off illegal-mem logging when using JIT...
+ if(currprefs.cachesize)
+ currprefs.illegal_mem = changed_prefs.illegal_mem;// = 0;
+
+ currprefs.comp_midopt = changed_prefs.comp_midopt;
+ currprefs.comp_lowopt = changed_prefs.comp_lowopt;
+
+ if ((!canbang || !currprefs.cachesize) && currprefs.comptrustbyte != 1) {
+ // Set all of these to indirect when canbang == 0
+ // Basically, set the compforcesettings option...
+ currprefs.comptrustbyte = 1;
+ currprefs.comptrustword = 1;
+ currprefs.comptrustlong = 1;
+ currprefs.comptrustnaddr= 1;
+
+ changed_prefs.comptrustbyte = 1;
+ changed_prefs.comptrustword = 1;
+ changed_prefs.comptrustlong = 1;
+ changed_prefs.comptrustnaddr= 1;
+
+ changed = 1;
+
+ if (currprefs.cachesize)
+ write_log (L"JIT: Reverting to \"indirect\" access, because canbang is zero!\n");
+ }
+
+ if (changed)
+ write_log (L"JIT: cache=%d. b=%d w=%d l=%d fpu=%d nf=%d const=%d hard=%d\n",
+ currprefs.cachesize,
+ currprefs.comptrustbyte, currprefs.comptrustword, currprefs.comptrustlong,
+ currprefs.compfpu, currprefs.compnf, currprefs.comp_constjump, currprefs.comp_hardflush);
#if 0
- if (!currprefs.compforcesettings) {
- int stop=0;
- if (currprefs.comptrustbyte!=0 && currprefs.comptrustbyte!=3)
- stop = 1, write_log (L"JIT: comptrustbyte is not 'direct' or 'afterpic'\n");
- if (currprefs.comptrustword!=0 && currprefs.comptrustword!=3)
- stop = 1, write_log (L"JIT: comptrustword is not 'direct' or 'afterpic'\n");
- if (currprefs.comptrustlong!=0 && currprefs.comptrustlong!=3)
- stop = 1, write_log (L"JIT: comptrustlong is not 'direct' or 'afterpic'\n");
- if (currprefs.comptrustnaddr!=0 && currprefs.comptrustnaddr!=3)
- stop = 1, write_log (L"JIT: comptrustnaddr is not 'direct' or 'afterpic'\n");
- if (currprefs.compnf!=1)
- stop = 1, write_log (L"JIT: compnf is not 'yes'\n");
- if (currprefs.cachesize<1024)
- stop = 1, write_log (L"JIT: cachesize is less than 1024\n");
- if (currprefs.comp_hardflush)
- stop = 1, write_log (L"JIT: comp_flushmode is 'hard'\n");
- if (!canbang)
- stop = 1, write_log (L"JIT: Cannot use most direct memory access,\n"
- " and unable to recover from failed guess!\n");
- if (stop) {
- gui_message("JIT: Configuration problems were detected!\n"
- "JIT: These will adversely affect performance, and should\n"
- "JIT: not be used. For more info, please see README.JIT-tuning\n"
- "JIT: in the UAE documentation directory. You can force\n"
- "JIT: your settings to be used by setting\n"
- "JIT: 'compforcesettings=yes'\n"
- "JIT: in your config file\n");
- exit(1);
- }
- }
+ if (!currprefs.compforcesettings) {
+ int stop=0;
+ if (currprefs.comptrustbyte!=0 && currprefs.comptrustbyte!=3)
+ stop = 1, write_log (L"JIT: comptrustbyte is not 'direct' or 'afterpic'\n");
+ if (currprefs.comptrustword!=0 && currprefs.comptrustword!=3)
+ stop = 1, write_log (L"JIT: comptrustword is not 'direct' or 'afterpic'\n");
+ if (currprefs.comptrustlong!=0 && currprefs.comptrustlong!=3)
+ stop = 1, write_log (L"JIT: comptrustlong is not 'direct' or 'afterpic'\n");
+ if (currprefs.comptrustnaddr!=0 && currprefs.comptrustnaddr!=3)
+ stop = 1, write_log (L"JIT: comptrustnaddr is not 'direct' or 'afterpic'\n");
+ if (currprefs.compnf!=1)
+ stop = 1, write_log (L"JIT: compnf is not 'yes'\n");
+ if (currprefs.cachesize<1024)
+ stop = 1, write_log (L"JIT: cachesize is less than 1024\n");
+ if (currprefs.comp_hardflush)
+ stop = 1, write_log (L"JIT: comp_flushmode is 'hard'\n");
+ if (!canbang)
+ stop = 1, write_log (L"JIT: Cannot use most direct memory access,\n"
+ " and unable to recover from failed guess!\n");
+ if (stop) {
+ gui_message("JIT: Configuration problems were detected!\n"
+ "JIT: These will adversely affect performance, and should\n"
+ "JIT: not be used. For more info, please see README.JIT-tuning\n"
+ "JIT: in the UAE documentation directory. You can force\n"
+ "JIT: your settings to be used by setting\n"
+ "JIT: 'compforcesettings=yes'\n"
+ "JIT: in your config file\n");
+ exit(1);
+ }
+ }
#endif
- return changed;
+ return changed;
}
/********************************************************************
- * 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)
{
- *target++=x;
+ *target++=x;
}
STATIC_INLINE void emit_word(uae_u16 x)
{
- *((uae_u16*)target)=x;
- target+=2;
+ *((uae_u16*)target)=x;
+ target+=2;
}
STATIC_INLINE void emit_long(uae_u32 x)
{
- *((uae_u32*)target)=x;
- target+=4;
+ *((uae_u32*)target)=x;
+ target+=4;
}
STATIC_INLINE uae_u32 reverse32(uae_u32 oldv)
{
- return ((oldv>>24)&0xff) | ((oldv>>8)&0xff00) |
- ((oldv<<8)&0xff0000) | ((oldv<<24)&0xff000000);
+ return ((oldv>>24)&0xff) | ((oldv>>8)&0xff00) |
+ ((oldv<<8)&0xff0000) | ((oldv<<24)&0xff000000);
}
void set_target(uae_u8* t)
{
- lopt_emit_all();
- target=t;
+ lopt_emit_all();
+ target=t;
}
STATIC_INLINE uae_u8* get_target_noopt(void)
{
- return target;
+ return target;
}
STATIC_INLINE uae_u8* get_target(void)
{
- lopt_emit_all();
- return get_target_noopt();
+ lopt_emit_all();
+ return get_target_noopt();
}
/********************************************************************
- * Getting the information about the target CPU *
- ********************************************************************/
+* Getting the information about the target CPU *
+********************************************************************/
#include "compemu_raw_x86.cpp"
/********************************************************************
- * Flags status handling. EMIT TIME! *
- ********************************************************************/
+* Flags status handling. EMIT TIME! *
+********************************************************************/
static void bt_l_ri_noclobber(R4 r, IMM i);
static void make_flags_live_internal(void)
{
- if (live.flags_in_flags==VALID)
- return;
- Dif (live.flags_on_stack==TRASH) {
- jit_abort (L"JIT: Want flags, got something on stack, but it is TRASH\n");
- }
- if (live.flags_on_stack==VALID) {
- int tmp;
- tmp=readreg_specific(FLAGTMP,4,FLAG_NREG2);
- raw_reg_to_flags(tmp);
- unlock(tmp);
+ if (live.flags_in_flags==VALID)
+ return;
+ Dif (live.flags_on_stack==TRASH) {
+ jit_abort (L"JIT: Want flags, got something on stack, but it is TRASH\n");
+ }
+ if (live.flags_on_stack==VALID) {
+ int tmp;
+ tmp=readreg_specific(FLAGTMP,4,FLAG_NREG2);
+ raw_reg_to_flags(tmp);
+ unlock(tmp);
- live.flags_in_flags=VALID;
- return;
- }
- jit_abort (L"JIT: Huh? live.flags_in_flags=%d, live.flags_on_stack=%d, but need to make live\n",
- live.flags_in_flags,live.flags_on_stack);
+ live.flags_in_flags=VALID;
+ return;
+ }
+ jit_abort (L"JIT: Huh? live.flags_in_flags=%d, live.flags_on_stack=%d, but need to make live\n",
+ live.flags_in_flags,live.flags_on_stack);
}
static void flags_to_stack(void)
{
- if (live.flags_on_stack==VALID)
- return;
- if (!live.flags_are_important) {
+ if (live.flags_on_stack==VALID)
+ return;
+ if (!live.flags_are_important) {
+ live.flags_on_stack=VALID;
+ return;
+ }
+ Dif (live.flags_in_flags!=VALID)
+ jit_abort (L"flags_to_stack != VALID");
+ else {
+ int tmp;
+ tmp=writereg_specific(FLAGTMP,4,FLAG_NREG1);
+ raw_flags_to_reg(tmp);
+ unlock(tmp);
+ }
live.flags_on_stack=VALID;
- return;
- }
- Dif (live.flags_in_flags!=VALID)
- jit_abort (L"flags_to_stack != VALID");
- else {
- int tmp;
- tmp=writereg_specific(FLAGTMP,4,FLAG_NREG1);
- raw_flags_to_reg(tmp);
- unlock(tmp);
- }
- live.flags_on_stack=VALID;
}
STATIC_INLINE void clobber_flags(void)
{
- if (live.flags_in_flags==VALID && live.flags_on_stack!=VALID)
- flags_to_stack();
- live.flags_in_flags=TRASH;
+ if (live.flags_in_flags==VALID && live.flags_on_stack!=VALID)
+ flags_to_stack();
+ live.flags_in_flags=TRASH;
}
/* Prepare for leaving the compiled stuff */
STATIC_INLINE void flush_flags(void)
{
- flags_to_stack();
- return;
+ 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];
STATIC_INLINE void log_startblock(void)
{
- int i;
- for (i=0;i<VREGS;i++)
- vstate[i]=L_UNKNOWN;
- for (i=0;i<N_REGS;i++)
- nstate[i]=L_UNKNOWN;
+ int i;
+ for (i=0;i<VREGS;i++)
+ vstate[i]=L_UNKNOWN;
+ for (i=0;i<N_REGS;i++)
+ nstate[i]=L_UNKNOWN;
}
STATIC_INLINE void log_isused(int n)
{
- if (nstate[n]==L_UNKNOWN)
- nstate[n]=L_UNAVAIL;
+ if (nstate[n]==L_UNKNOWN)
+ nstate[n]=L_UNAVAIL;
}
STATIC_INLINE void log_isreg(int n, int r)
{
- if (nstate[n]==L_UNKNOWN)
- nstate[n]=r;
- if (vstate[r]==L_UNKNOWN)
- vstate[r]=L_NEEDED;
+ if (nstate[n]==L_UNKNOWN)
+ nstate[n]=r;
+ if (vstate[r]==L_UNKNOWN)
+ vstate[r]=L_NEEDED;
}
STATIC_INLINE void log_clobberreg(int r)
{
- if (vstate[r]==L_UNKNOWN)
- vstate[r]=L_UNNEEDED;
+ if (vstate[r]==L_UNKNOWN)
+ vstate[r]=L_UNNEEDED;
}
/* This ends all possibility of clever register allocation */
STATIC_INLINE void log_flush(void)
{
- int i;
- for (i=0;i<VREGS;i++)
- if (vstate[i]==L_UNKNOWN)
- vstate[i]=L_NEEDED;
- for (i=0;i<N_REGS;i++)
- if (nstate[i]==L_UNKNOWN)
- nstate[i]=L_UNAVAIL;
+ int i;
+ for (i=0;i<VREGS;i++)
+ if (vstate[i]==L_UNKNOWN)
+ vstate[i]=L_NEEDED;
+ for (i=0;i<N_REGS;i++)
+ if (nstate[i]==L_UNKNOWN)
+ nstate[i]=L_UNAVAIL;
}
STATIC_INLINE void log_dump(void)
{
- int i;
+ int i;
- return;
+ return;
- write_log (L"----------------------\n");
- for (i=0;i<N_REGS;i++) {
- switch(nstate[i]) {
- case L_UNKNOWN: write_log (L"Nat %d : UNKNOWN\n",i); break;
- case L_UNAVAIL: write_log (L"Nat %d : UNAVAIL\n",i); break;
- default: write_log (L"Nat %d : %d\n",i,nstate[i]); break;
+ write_log (L"----------------------\n");
+ for (i=0;i<N_REGS;i++) {
+ switch(nstate[i]) {
+ case L_UNKNOWN: write_log (L"Nat %d : UNKNOWN\n",i); break;
+ case L_UNAVAIL: write_log (L"Nat %d : UNAVAIL\n",i); break;
+ default: write_log (L"Nat %d : %d\n",i,nstate[i]); break;
+ }
+ }
+ for (i=0;i<VREGS;i++) {
+ if (vstate[i]==L_UNNEEDED)
+ write_log (L"Virt %d: UNNEEDED\n",i);
}
- }
- for (i=0;i<VREGS;i++) {
- if (vstate[i]==L_UNNEEDED)
- write_log (L"Virt %d: UNNEEDED\n",i);
- }
}
/********************************************************************
- * register status handling. EMIT TIME! *
- ********************************************************************/
+* register status handling. EMIT TIME! *
+********************************************************************/
STATIC_INLINE void set_status(int r, int status)
{
- if (status==ISCONST)
- log_clobberreg(r);
- live.state[r].status=status;
+ if (status==ISCONST)
+ log_clobberreg(r);
+ live.state[r].status=status;
}
STATIC_INLINE int isinreg(int r)
{
- return live.state[r].status==CLEAN || live.state[r].status==DIRTY;
+ return live.state[r].status==CLEAN || live.state[r].status==DIRTY;
}
STATIC_INLINE void adjust_nreg(int r, uae_u32 val)
{
- if (!val)
- return;
- raw_lea_l_brr(r,r,val);
+ if (!val)
+ return;
+ raw_lea_l_brr(r,r,val);
}
static void tomem(int r)
{
- int rr=live.state[r].realreg;
+ int rr=live.state[r].realreg;
- if (isinreg(r)) {
- if (live.state[r].val &&
- live.nat[rr].nholds==1 &&
- !live.nat[rr].locked) {
- // write_log (L"JIT: RemovingA offset %x from reg %d (%d) at %p\n",
- // live.state[r].val,r,rr,target);
- adjust_nreg(rr,live.state[r].val);
- live.state[r].val=0;
- live.state[r].dirtysize=4;
- set_status(r,DIRTY);
+ if (isinreg(r)) {
+ if (live.state[r].val &&
+ live.nat[rr].nholds==1 &&
+ !live.nat[rr].locked) {
+ // write_log (L"JIT: RemovingA offset %x from reg %d (%d) at %p\n",
+ // live.state[r].val,r,rr,target);
+ adjust_nreg(rr,live.state[r].val);
+ live.state[r].val=0;
+ live.state[r].dirtysize=4;
+ set_status(r,DIRTY);
+ }
}
- }
- if (live.state[r].status==DIRTY) {
- switch (live.state[r].dirtysize) {
- case 1: raw_mov_b_mr((uae_u32)live.state[r].mem,rr); break;
- case 2: raw_mov_w_mr((uae_u32)live.state[r].mem,rr); break;
- case 4: raw_mov_l_mr((uae_u32)live.state[r].mem,rr); break;
- default: abort();
+ if (live.state[r].status==DIRTY) {
+ switch (live.state[r].dirtysize) {
+ case 1: raw_mov_b_mr((uae_u32)live.state[r].mem,rr); break;
+ case 2: raw_mov_w_mr((uae_u32)live.state[r].mem,rr); break;
+ case 4: raw_mov_l_mr((uae_u32)live.state[r].mem,rr); break;
+ default: abort();
+ }
+ set_status(r,CLEAN);
+ live.state[r].dirtysize=0;
}
- set_status(r,CLEAN);
- live.state[r].dirtysize=0;
- }
}
STATIC_INLINE int isconst(int r)
{
- return live.state[r].status==ISCONST;
+ return live.state[r].status==ISCONST;
}
int is_const(int r)
{
- return isconst(r);
+ return isconst(r);
}
STATIC_INLINE void writeback_const(int r)
{
- if (!isconst(r))
- return;
- Dif (live.state[r].needflush==NF_HANDLER) {
- jit_abort (L"JIT: Trying to write back constant NF_HANDLER!\n");
- }
+ if (!isconst(r))
+ return;
+ Dif (live.state[r].needflush==NF_HANDLER) {
+ jit_abort (L"JIT: Trying to write back constant NF_HANDLER!\n");
+ }
- raw_mov_l_mi((uae_u32)live.state[r].mem,live.state[r].val);
- live.state[r].val=0;
- set_status(r,INMEM);
+ raw_mov_l_mi((uae_u32)live.state[r].mem,live.state[r].val);
+ live.state[r].val=0;
+ set_status(r,INMEM);
}
STATIC_INLINE void tomem_c(int r)
{
- if (isconst(r)) {
- writeback_const(r);
- }
- else
- tomem(r);
+ if (isconst(r)) {
+ writeback_const(r);
+ }
+ else
+ tomem(r);
}
static void evict(int r)
{
- int rr;
+ int rr;
- if (!isinreg(r))
- return;
- tomem(r);
- rr=live.state[r].realreg;
+ if (!isinreg(r))
+ return;
+ tomem(r);
+ rr=live.state[r].realreg;
- Dif (live.nat[rr].locked &&
- live.nat[rr].nholds==1) {
- jit_abort (L"JIT: register %d in nreg %d is locked!\n",r,live.state[r].realreg);
- }
+ Dif (live.nat[rr].locked &&
+ live.nat[rr].nholds==1) {
+ jit_abort (L"JIT: register %d in nreg %d is locked!\n",r,live.state[r].realreg);
+ }
- live.nat[rr].nholds--;
- if (live.nat[rr].nholds!=live.state[r].realind) { /* Was not last */
- int topreg=live.nat[rr].holds[live.nat[rr].nholds];
- int thisind=live.state[r].realind;
- live.nat[rr].holds[thisind]=topreg;
- live.state[topreg].realind=thisind;
- }
- live.state[r].realreg=-1;
- set_status(r,INMEM);
+ live.nat[rr].nholds--;
+ if (live.nat[rr].nholds!=live.state[r].realind) { /* Was not last */
+ int topreg=live.nat[rr].holds[live.nat[rr].nholds];
+ int thisind=live.state[r].realind;
+ live.nat[rr].holds[thisind]=topreg;
+ live.state[topreg].realind=thisind;
+ }
+ live.state[r].realreg=-1;
+ set_status(r,INMEM);
}
STATIC_INLINE void free_nreg(int r)
{
- int i=live.nat[r].nholds;
+ int i=live.nat[r].nholds;
- while (i) {
- int vr;
+ while (i) {
+ int vr;
- --i;
- vr=live.nat[r].holds[i];
- evict(vr);
- }
- Dif (live.nat[r].nholds!=0) {
- jit_abort (L"JIT: Failed to free nreg %d, nholds is %d\n",r,live.nat[r].nholds);
- }
+ --i;
+ vr=live.nat[r].holds[i];
+ evict(vr);
+ }
+ Dif (live.nat[r].nholds!=0) {
+ jit_abort (L"JIT: Failed to free nreg %d, nholds is %d\n",r,live.nat[r].nholds);
+ }
}
/* Use with care! */
STATIC_INLINE void isclean(int r)
{
- if (!isinreg(r))
- return;
- live.state[r].validsize=4;
- live.state[r].dirtysize=0;
- live.state[r].val=0;
- set_status(r,CLEAN);
+ if (!isinreg(r))
+ return;
+ live.state[r].validsize=4;
+ live.state[r].dirtysize=0;
+ live.state[r].val=0;
+ set_status(r,CLEAN);
}
STATIC_INLINE void disassociate(int r)
{
- isclean(r);
- evict(r);
+ isclean(r);
+ evict(r);
}
STATIC_INLINE void set_const(int r, uae_u32 val)
{
- disassociate(r);
- live.state[r].val=val;
- set_status(r,ISCONST);
+ disassociate(r);
+ live.state[r].val=val;
+ set_status(r,ISCONST);
}
STATIC_INLINE uae_u32 get_offset(int r)
{
- return live.state[r].val;
+ return live.state[r].val;
}
static int alloc_reg_hinted(int r, int size, int willclobber, int hint)
{
- int bestreg;
- uae_s32 when;
- int i;
- uae_s32 badness=0; /* to shut up gcc */
- bestreg=-1;
- when=2000000000;
-
- for (i=N_REGS;i--;) {
- badness=live.nat[i].touched;
- if (live.nat[i].nholds==0)
- badness=0;
- if (i==hint)
- badness-=200000000;
- if (!live.nat[i].locked && badness<when) {
- if ((size==1 && live.nat[i].canbyte) ||
- (size==2 && live.nat[i].canword) ||
- (size==4)) {
- bestreg=i;
- when=badness;
- if (live.nat[i].nholds==0 && hint<0)
- break;
+ int bestreg;
+ uae_s32 when;
+ int i;
+ uae_s32 badness=0; /* to shut up gcc */
+ bestreg=-1;
+ when=2000000000;
+
+ for (i=N_REGS;i--;) {
+ badness=live.nat[i].touched;
+ if (live.nat[i].nholds==0)
+ badness=0;
if (i==hint)
- break;
- }
+ badness-=200000000;
+ if (!live.nat[i].locked && badness<when) {
+ if ((size==1 && live.nat[i].canbyte) ||
+ (size==2 && live.nat[i].canword) ||
+ (size==4)) {
+ bestreg=i;
+ when=badness;
+ if (live.nat[i].nholds==0 && hint<0)
+ break;
+ if (i==hint)
+ break;
+ }
+ }
}
- }
- Dif (bestreg==-1)
- jit_abort (L"alloc_reg_hinted bestreg=-1");
+ Dif (bestreg==-1)
+ jit_abort (L"alloc_reg_hinted bestreg=-1");
- if (live.nat[bestreg].nholds>0) {
- free_nreg(bestreg);
- }
- if (isinreg(r)) {
- int rr=live.state[r].realreg;
- /* This will happen if we read a partially dirty register at a
- bigger size */
- Dif (willclobber || live.state[r].validsize>=size)
- jit_abort (L"willclobber || live.state[r].validsize>=size");
- Dif (live.nat[rr].nholds!=1)
- jit_abort (L"live.nat[rr].nholds!=1");
- if (size==4 && live.state[r].validsize==2) {
- log_isused(bestreg);
- raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
- raw_bswap_32(bestreg);
- raw_zero_extend_16_rr(rr,rr);
- raw_zero_extend_16_rr(bestreg,bestreg);
- raw_bswap_32(bestreg);
- raw_lea_l_rr_indexed(rr,rr,bestreg);
- live.state[r].validsize=4;
- live.nat[rr].touched=touchcnt++;
- return rr;
- }
- if (live.state[r].validsize==1) {
- /* Nothing yet */
+ if (live.nat[bestreg].nholds>0) {
+ free_nreg(bestreg);
+ }
+ if (isinreg(r)) {
+ int rr=live.state[r].realreg;
+ /* This will happen if we read a partially dirty register at a
+ bigger size */
+ Dif (willclobber || live.state[r].validsize>=size)
+ jit_abort (L"willclobber || live.state[r].validsize>=size");
+ Dif (live.nat[rr].nholds!=1)
+ jit_abort (L"live.nat[rr].nholds!=1");
+ if (size==4 && live.state[r].validsize==2) {
+ log_isused(bestreg);
+ raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
+ raw_bswap_32(bestreg);
+ raw_zero_extend_16_rr(rr,rr);
+ raw_zero_extend_16_rr(bestreg,bestreg);
+ raw_bswap_32(bestreg);
+ raw_lea_l_rr_indexed(rr,rr,bestreg);
+ live.state[r].validsize=4;
+ live.nat[rr].touched=touchcnt++;
+ return rr;
+ }
+ if (live.state[r].validsize==1) {
+ /* Nothing yet */
+ }
+ evict(r);
}
- evict(r);
- }
- if (!willclobber) {
- if (live.state[r].status!=UNDEF) {
- if (isconst(r)) {
- raw_mov_l_ri(bestreg,live.state[r].val);
- live.state[r].val=0;
- live.state[r].dirtysize=4;
- set_status(r,DIRTY);
- log_isused(bestreg);
- }
- else {
- if (r==FLAGTMP)
- raw_load_flagreg(bestreg,r);
- else if (r==FLAGX)
- raw_load_flagx(bestreg,r);
+ if (!willclobber) {
+ if (live.state[r].status!=UNDEF) {
+ if (isconst(r)) {
+ raw_mov_l_ri(bestreg,live.state[r].val);
+ live.state[r].val=0;
+ live.state[r].dirtysize=4;
+ set_status(r,DIRTY);
+ log_isused(bestreg);
+ }
+ else {
+ if (r==FLAGTMP)
+ raw_load_flagreg(bestreg,r);
+ else if (r==FLAGX)
+ raw_load_flagx(bestreg,r);
+ else {
+ raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
+ }
+ live.state[r].dirtysize=0;
+ set_status(r,CLEAN);
+ log_isreg(bestreg,r);
+ }
+ }
else {
- raw_mov_l_rm(bestreg,(uae_u32)live.state[r].mem);
+ live.state[r].val=0;
+ live.state[r].dirtysize=0;
+ set_status(r,CLEAN);
+ log_isused(bestreg);
}
- live.state[r].dirtysize=0;
- set_status(r,CLEAN);
- log_isreg(bestreg,r);
- }
- }
- else {
- live.state[r].val=0;
- live.state[r].dirtysize=0;
- set_status(r,CLEAN);
- log_isused(bestreg);
- }
- live.state[r].validsize=4;
- }
- else { /* this is the easiest way, but not optimal. FIXME! */
- /* Now it's trickier, but hopefully still OK */
- if (!isconst(r) || size==4) {
- live.state[r].validsize=size;
- live.state[r].dirtysize=size;
- live.state[r].val=0;
- set_status(r,DIRTY);
- if (size==4)
- log_isused(bestreg);
- else
- log_isreg(bestreg,r);
+ live.state[r].validsize=4;
}
- else {
- if (live.state[r].status!=UNDEF)
- raw_mov_l_ri(bestreg,live.state[r].val);
- live.state[r].val=0;
- live.state[r].validsize=4;
- live.state[r].dirtysize=4;
- set_status(r,DIRTY);
- log_isused(bestreg);
+ else { /* this is the easiest way, but not optimal. FIXME! */
+ /* Now it's trickier, but hopefully still OK */
+ if (!isconst(r) || size==4) {
+ live.state[r].validsize=size;
+ live.state[r].dirtysize=size;
+ live.state[r].val=0;
+ set_status(r,DIRTY);
+ if (size==4)
+ log_isused(bestreg);
+ else
+ log_isreg(bestreg,r);
+ }
+ else {
+ if (live.state[r].status!=UNDEF)
+ raw_mov_l_ri(bestreg,live.state[r].val);
+ live.state[r].val=0;
+ live.state[r].validsize=4;
+ live.state[r].dirtysize=4;
+ set_status(r,DIRTY);
+ log_isused(bestreg);
+ }
}
- }
- live.state[r].realreg=bestreg;
- live.state[r].realind=live.nat[bestreg].nholds;
- live.nat[bestreg].touched=touchcnt++;
- live.nat[bestreg].holds[live.nat[bestreg].nholds]=r;
- live.nat[bestreg].nholds++;
+ live.state[r].realreg=bestreg;
+ live.state[r].realind=live.nat[bestreg].nholds;
+ live.nat[bestreg].touched=touchcnt++;
+ live.nat[bestreg].holds[live.nat[bestreg].nholds]=r;
+ live.nat[bestreg].nholds++;
- return bestreg;
+ return bestreg;
}
static int alloc_reg(int r, int size, int willclobber)
{
- return alloc_reg_hinted(r,size,willclobber,-1);
+ return alloc_reg_hinted(r,size,willclobber,-1);
}
static void unlock(int r)
{
- Dif (!live.nat[r].locked)
- jit_abort (L"unlock %d not locked", r);
- live.nat[r].locked--;
+ Dif (!live.nat[r].locked)
+ jit_abort (L"unlock %d not locked", r);
+ live.nat[r].locked--;
}
static void setlock(int r)
{
- live.nat[r].locked++;
+ live.nat[r].locked++;
}
static void mov_nregs(int d, int s)
{
- int ns=live.nat[s].nholds;
- int nd=live.nat[d].nholds;
- int i;
+ int ns=live.nat[s].nholds;
+ int nd=live.nat[d].nholds;
+ int i;
- if (s==d)
- return;
+ if (s==d)
+ return;
- if (nd>0)
- free_nreg(d);
+ if (nd>0)
+ free_nreg(d);
- raw_mov_l_rr(d,s);
- log_isused(d);
+ raw_mov_l_rr(d,s);
+ log_isused(d);
- for (i=0;i<live.nat[s].nholds;i++) {
- int vs=live.nat[s].holds[i];
+ for (i=0;i<live.nat[s].nholds;i++) {
+ int vs=live.nat[s].holds[i];
- live.state[vs].realreg=d;
- live.state[vs].realind=i;
- live.nat[d].holds[i]=vs;
- }
- live.nat[d].nholds=live.nat[s].nholds;
+ live.state[vs].realreg=d;
+ live.state[vs].realind=i;
+ live.nat[d].holds[i]=vs;
+ }
+ live.nat[d].nholds=live.nat[s].nholds;
- live.nat[s].nholds=0;
+ live.nat[s].nholds=0;
}
STATIC_INLINE void make_exclusive(int r, int size, int spec)
{
- reg_status oldstate;
- int rr=live.state[r].realreg;
- int nr;
- int nind;
- int ndirt=0;
- int i;
+ reg_status oldstate;
+ int rr=live.state[r].realreg;
+ int nr;
+ int nind;
+ int ndirt=0;
+ int i;
- if (!isinreg(r))
- return;
- if (live.nat[rr].nholds==1)
- return;
- for (i=0;i<live.nat[rr].nholds;i++) {
- int vr=live.nat[rr].holds[i];
- if (vr!=r &&
- (live.state[vr].status==DIRTY || live.state[vr].val))
- ndirt++;
- }
- if (!ndirt && size<live.state[r].validsize && !live.nat[rr].locked) {
- /* Everything else is clean, so let's keep this register */
+ if (!isinreg(r))
+ return;
+ if (live.nat[rr].nholds==1)
+ return;
for (i=0;i<live.nat[rr].nholds;i++) {
- int vr=live.nat[rr].holds[i];
- if (vr!=r) {
- evict(vr);
- i--; /* Try that index again! */
- }
+ int vr=live.nat[rr].holds[i];
+ if (vr!=r &&
+ (live.state[vr].status==DIRTY || live.state[vr].val))
+ ndirt++;
}
- Dif (live.nat[rr].nholds!=1) {
- jit_abort (L"JIT: natreg %d holds %d vregs, %d not exclusive\n",
- rr,live.nat[rr].nholds,r);
+ if (!ndirt && size<live.state[r].validsize && !live.nat[rr].locked) {
+ /* Everything else is clean, so let's keep this register */
+ for (i=0;i<live.nat[rr].nholds;i++) {
+ int vr=live.nat[rr].holds[i];
+ if (vr!=r) {
+ evict(vr);
+ i--; /* Try that index again! */
+ }
+ }
+ Dif (live.nat[rr].nholds!=1) {
+ jit_abort (L"JIT: natreg %d holds %d vregs, %d not exclusive\n",
+ rr,live.nat[rr].nholds,r);
+ }
+ return;
}
- return;
- }
-
- /* We have to split the register */
- oldstate=live.state[r];
-
- setlock(rr); /* Make sure this doesn't go away */
- /* Forget about r being in the register rr */
- disassociate(r);
- /* Get a new register, that we will clobber completely */
- if (oldstate.status==DIRTY) {
- /* If dirtysize is <4, we need a register that can handle the
- eventual smaller memory store! Thanks to Quake68k for exposing
- this detail ;-) */
- nr=alloc_reg_hinted(r,oldstate.dirtysize,1,spec);
- }
- else {
- nr=alloc_reg_hinted(r,4,1,spec);
- }
- nind=live.state[r].realind;
- live.state[r]=oldstate; /* Keep all the old state info */
- live.state[r].realreg=nr;
- live.state[r].realind=nind;
-
- if (size<live.state[r].validsize) {
- if (live.state[r].val) {
- /* Might as well compensate for the offset now */
- raw_lea_l_brr(nr,rr,oldstate.val);
- live.state[r].val=0;
- live.state[r].dirtysize=4;
- set_status(r,DIRTY);
+
+ /* We have to split the register */
+ oldstate=live.state[r];
+
+ setlock(rr); /* Make sure this doesn't go away */
+ /* Forget about r being in the register rr */
+ disassociate(r);
+ /* Get a new register, that we will clobber completely */
+ if (oldstate.status==DIRTY) {
+ /* If dirtysize is <4, we need a register that can handle the
+ eventual smaller memory store! Thanks to Quake68k for exposing
+ this detail ;-) */
+ nr=alloc_reg_hinted(r,oldstate.dirtysize,1,spec);
}
- else
- raw_mov_l_rr(nr,rr); /* Make another copy */
- }
- unlock(rr);
+ else {
+ nr=alloc_reg_hinted(r,4,1,spec);
+ }
+ nind=live.state[r].realind;
+ live.state[r]=oldstate; /* Keep all the old state info */
+ live.state[r].realreg=nr;
+ live.state[r].realind=nind;
+
+ if (size<live.state[r].validsize) {
+ if (live.state[r].val) {
+ /* Might as well compensate for the offset now */
+ raw_lea_l_brr(nr,rr,oldstate.val);
+ live.state[r].val=0;
+ live.state[r].dirtysize=4;
+ set_status(r,DIRTY);
+ }
+ else
+ raw_mov_l_rr(nr,rr); /* Make another copy */
+ }
+ unlock(rr);
}
STATIC_INLINE void add_offset(int r, uae_u32 off)
{
- live.state[r].val+=off;
+ live.state[r].val+=off;
}
STATIC_INLINE void remove_offset(int r, int spec)
{
- int rr;
+ int rr;
- if (isconst(r))
- return;
- if (live.state[r].val==0)
- return;
- if (isinreg(r) && live.state[r].validsize<4)
- evict(r);
+ if (isconst(r))
+ return;
+ if (live.state[r].val==0)
+ return;
+ if (isinreg(r) && live.state[r].validsize<4)
+ evict(r);
- if (!isinreg(r))
- alloc_reg_hinted(r,4,0,spec);
+ if (!isinreg(r))
+ alloc_reg_hinted(r,4,0,spec);
- Dif (live.state[r].validsize!=4) {
- jit_abort (L"JIT: Validsize=%d in remove_offset\n",live.state[r].validsize);
- }
- make_exclusive(r,0,-1);
- /* make_exclusive might have done the job already */
- if (live.state[r].val==0)
- return;
+ Dif (live.state[r].validsize!=4) {
+ jit_abort (L"JIT: Validsize=%d in remove_offset\n",live.state[r].validsize);
+ }
+ make_exclusive(r,0,-1);
+ /* make_exclusive might have done the job already */
+ if (live.state[r].val==0)
+ return;
- rr=live.state[r].realreg;
+ rr=live.state[r].realreg;
- if (live.nat[rr].nholds==1) {
- //write_log (L"JIT: RemovingB offset %x from reg %d (%d) at %p\n",
- // live.state[r].val,r,rr,target);
- adjust_nreg(rr,live.state[r].val);
- live.state[r].dirtysize=4;
- live.state[r].val=0;
- set_status(r,DIRTY);
- return;
- }
- jit_abort (L"JIT: Failed in remove_offset\n");
+ if (live.nat[rr].nholds==1) {
+ //write_log (L"JIT: RemovingB offset %x from reg %d (%d) at %p\n",
+ // live.state[r].val,r,rr,target);
+ adjust_nreg(rr,live.state[r].val);
+ live.state[r].dirtysize=4;
+ live.state[r].val=0;
+ set_status(r,DIRTY);
+ return;
+ }
+ jit_abort (L"JIT: Failed in remove_offset\n");
}
STATIC_INLINE void remove_all_offsets(void)
{
- int i;
+ int i;
- for (i=0;i<VREGS;i++)
- remove_offset(i,-1);
+ for (i=0;i<VREGS;i++)
+ remove_offset(i,-1);
}
STATIC_INLINE int readreg_general(int r, int size, int spec, int can_offset)
{
- int n;
- int answer=-1;
+ int n;
+ int answer=-1;
- if (live.state[r].status==UNDEF) {
- write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
- }
- if (!can_offset)
- remove_offset(r,spec);
-
- if (isinreg(r) && live.state[r].validsize>=size) {
- n=live.state[r].realreg;
- switch(size) {
- case 1:
- if (live.nat[n].canbyte || spec>=0) {
- answer=n;
- }
- break;
- case 2:
- if (live.nat[n].canword || spec>=0) {
- answer=n;
- }
- break;
- case 4:
- answer=n;
- break;
- default: abort();
+ if (live.state[r].status==UNDEF) {
+ write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
+ }
+ if (!can_offset)
+ remove_offset(r,spec);
+
+ if (isinreg(r) && live.state[r].validsize>=size) {
+ n=live.state[r].realreg;
+ switch(size) {
+ case 1:
+ if (live.nat[n].canbyte || spec>=0) {
+ answer=n;
+ }
+ break;
+ case 2:
+ if (live.nat[n].canword || spec>=0) {
+ answer=n;
+ }
+ break;
+ case 4:
+ answer=n;
+ break;
+ default: abort();
+ }
+ if (answer<0)
+ evict(r);
+ }
+ /* either the value was in memory to start with, or it was evicted and
+ is in memory now */
+ if (answer<0) {
+ answer=alloc_reg_hinted(r,spec>=0?4:size,0,spec);
}
- if (answer<0)
- evict(r);
- }
- /* either the value was in memory to start with, or it was evicted and
- is in memory now */
- if (answer<0) {
- answer=alloc_reg_hinted(r,spec>=0?4:size,0,spec);
- }
- if (spec>=0 && spec!=answer) {
- /* Too bad */
- mov_nregs(spec,answer);
- answer=spec;
- }
- live.nat[answer].locked++;
- live.nat[answer].touched=touchcnt++;
- return answer;
+ if (spec>=0 && spec!=answer) {
+ /* Too bad */
+ mov_nregs(spec,answer);
+ answer=spec;
+ }
+ live.nat[answer].locked++;
+ live.nat[answer].touched=touchcnt++;
+ return answer;
}
static int readreg(int r, int size)
{
- return readreg_general(r,size,-1,0);
+ return readreg_general(r,size,-1,0);
}
static int readreg_specific(int r, int size, int spec)
{
- return readreg_general(r,size,spec,0);
+ return readreg_general(r,size,spec,0);
}
static int readreg_offset(int r, int size)
{
- return readreg_general(r,size,-1,1);
+ return readreg_general(r,size,-1,1);
}
STATIC_INLINE int writereg_general(int r, int size, int spec)
{
- int n;
- int answer=-1;
-
- if (size<4) {
- remove_offset(r,spec);
- }
+ int n;
+ int answer=-1;
- make_exclusive(r,size,spec);
- if (isinreg(r)) {
- int nvsize=size>live.state[r].validsize?size:live.state[r].validsize;
- int ndsize=size>live.state[r].dirtysize?size:live.state[r].dirtysize;
- n=live.state[r].realreg;
-
- Dif (live.nat[n].nholds!=1)
- jit_abort (L"live.nat[%d].nholds!=1", n);
- switch(size) {
- case 1:
- if (live.nat[n].canbyte || spec>=0) {
- live.state[r].dirtysize=ndsize;
- live.state[r].validsize=nvsize;
- answer=n;
- }
- break;
- case 2:
- if (live.nat[n].canword || spec>=0) {
- live.state[r].dirtysize=ndsize;
- live.state[r].validsize=nvsize;
- answer=n;
- }
- break;
- case 4:
- live.state[r].dirtysize=ndsize;
- live.state[r].validsize=nvsize;
- answer=n;
- break;
- default: abort();
+ if (size<4) {
+ remove_offset(r,spec);
}
- if (answer<0)
- evict(r);
- }
- /* either the value was in memory to start with, or it was evicted and
- is in memory now */
- if (answer<0) {
- answer=alloc_reg_hinted(r,size,1,spec);
- }
- if (spec>=0 && spec!=answer) {
- mov_nregs(spec,answer);
- answer=spec;
- }
- if (live.state[r].status==UNDEF)
- live.state[r].validsize=4;
- live.state[r].dirtysize=size>live.state[r].dirtysize?size:live.state[r].dirtysize;
- live.state[r].validsize=size>live.state[r].validsize?size:live.state[r].validsize;
- live.nat[answer].locked++;
- live.nat[answer].touched=touchcnt++;
- if (size==4) {
- live.state[r].val=0;
- }
- else {
- Dif (live.state[r].val) {
- jit_abort (L"JIT: Problem with val\n");
+ make_exclusive(r,size,spec);
+ if (isinreg(r)) {
+ int nvsize=size>live.state[r].validsize?size:live.state[r].validsize;
+ int ndsize=size>live.state[r].dirtysize?size:live.state[r].dirtysize;
+ n=live.state[r].realreg;
+
+ Dif (live.nat[n].nholds!=1)
+ jit_abort (L"live.nat[%d].nholds!=1", n);
+ switch(size) {
+ case 1:
+ if (live.nat[n].canbyte || spec>=0) {
+ live.state[r].dirtysize=ndsize;
+ live.state[r].validsize=nvsize;
+ answer=n;
+ }
+ break;
+ case 2:
+ if (live.nat[n].canword || spec>=0) {
+ live.state[r].dirtysize=ndsize;
+ live.state[r].validsize=nvsize;
+ answer=n;
+ }
+ break;
+ case 4:
+ live.state[r].dirtysize=ndsize;
+ live.state[r].validsize=nvsize;
+ answer=n;
+ break;
+ default: abort();
+ }
+ if (answer<0)
+ evict(r);
+ }
+ /* either the value was in memory to start with, or it was evicted and
+ is in memory now */
+ if (answer<0) {
+ answer=alloc_reg_hinted(r,size,1,spec);
+ }
+ if (spec>=0 && spec!=answer) {
+ mov_nregs(spec,answer);
+ answer=spec;
+ }
+ if (live.state[r].status==UNDEF)
+ live.state[r].validsize=4;
+ live.state[r].dirtysize=size>live.state[r].dirtysize?size:live.state[r].dirtysize;
+ live.state[r].validsize=size>live.state[r].validsize?size:live.state[r].validsize;
+
+ live.nat[answer].locked++;
+ live.nat[answer].touched=touchcnt++;
+ if (size==4) {
+ live.state[r].val=0;
+ }
+ else {
+ Dif (live.state[r].val) {
+ jit_abort (L"JIT: Problem with val\n");
+ }
}
- }
- set_status(r,DIRTY);
- return answer;
+ set_status(r,DIRTY);
+ return answer;
}
static int writereg(int r, int size)
{
- return writereg_general(r,size,-1);
+ return writereg_general(r,size,-1);
}
static int writereg_specific(int r, int size, int spec)
{
- return writereg_general(r,size,spec);
+ return writereg_general(r,size,spec);
}
STATIC_INLINE int rmw_general(int r, int wsize, int rsize, int spec)
{
- int n;
- int answer=-1;
-
- if (live.state[r].status==UNDEF) {
- write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
- }
- remove_offset(r,spec);
- make_exclusive(r,0,spec);
-
- Dif (wsize<rsize) {
- jit_abort (L"JIT: Cannot handle wsize<rsize in rmw_general()\n");
- }
- if (isinreg(r) && live.state[r].validsize>=rsize) {
- n=live.state[r].realreg;
- Dif (live.nat[n].nholds!=1)
- jit_abort (L"live.nat[n].nholds!=1", n);
-
- switch(rsize) {
- case 1:
- if (live.nat[n].canbyte || spec>=0) {
- answer=n;
- }
- break;
- case 2:
- if (live.nat[n].canword || spec>=0) {
- answer=n;
- }
- break;
- case 4:
- answer=n;
- break;
- default: abort();
+ int n;
+ int answer=-1;
+
+ if (live.state[r].status==UNDEF) {
+ write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
}
- if (answer<0)
- evict(r);
- }
- /* either the value was in memory to start with, or it was evicted and
- is in memory now */
- if (answer<0) {
- answer=alloc_reg_hinted(r,spec>=0?4:rsize,0,spec);
- }
-
- if (spec>=0 && spec!=answer) {
- /* Too bad */
- mov_nregs(spec,answer);
- answer=spec;
- }
- if (wsize>live.state[r].dirtysize)
- live.state[r].dirtysize=wsize;
- if (wsize>live.state[r].validsize)
- live.state[r].validsize=wsize;
- set_status(r,DIRTY);
-
- live.nat[answer].locked++;
- live.nat[answer].touched=touchcnt++;
-
- Dif (live.state[r].val) {
- jit_abort (L"JIT: Problem with val(rmw)\n");
- }
- return answer;
+ remove_offset(r,spec);
+ make_exclusive(r,0,spec);
+
+ Dif (wsize<rsize) {
+ jit_abort (L"JIT: Cannot handle wsize<rsize in rmw_general()\n");
+ }
+ if (isinreg(r) && live.state[r].validsize>=rsize) {
+ n=live.state[r].realreg;
+ Dif (live.nat[n].nholds!=1)
+ jit_abort (L"live.nat[n].nholds!=1", n);
+
+ switch(rsize) {
+ case 1:
+ if (live.nat[n].canbyte || spec>=0) {
+ answer=n;
+ }
+ break;
+ case 2:
+ if (live.nat[n].canword || spec>=0) {
+ answer=n;
+ }
+ break;
+ case 4:
+ answer=n;
+ break;
+ default: abort();
+ }
+ if (answer<0)
+ evict(r);
+ }
+ /* either the value was in memory to start with, or it was evicted and
+ is in memory now */
+ if (answer<0) {
+ answer=alloc_reg_hinted(r,spec>=0?4:rsize,0,spec);
+ }
+
+ if (spec>=0 && spec!=answer) {
+ /* Too bad */
+ mov_nregs(spec,answer);
+ answer=spec;
+ }
+ if (wsize>live.state[r].dirtysize)
+ live.state[r].dirtysize=wsize;
+ if (wsize>live.state[r].validsize)
+ live.state[r].validsize=wsize;
+ set_status(r,DIRTY);
+
+ live.nat[answer].locked++;
+ live.nat[answer].touched=touchcnt++;
+
+ Dif (live.state[r].val) {
+ jit_abort (L"JIT: Problem with val(rmw)\n");
+ }
+ return answer;
}
static int rmw(int r, int wsize, int rsize)
{
- return rmw_general(r,wsize,rsize,-1);
+ return rmw_general(r,wsize,rsize,-1);
}
static int rmw_specific(int r, int wsize, int rsize, int spec)
{
- return rmw_general(r,wsize,rsize,spec);
+ return rmw_general(r,wsize,rsize,spec);
}
/* needed for restoring the carry flag on non-P6 cores */
static void bt_l_ri_noclobber(R4 r, IMM i)
{
- int size=4;
- if (i<16)
- size=2;
- r=readreg(r,size);
- raw_bt_l_ri(r,i);
- unlock(r);
+ int size=4;
+ if (i<16)
+ size=2;
+ r=readreg(r,size);
+ raw_bt_l_ri(r,i);
+ unlock(r);
}
/********************************************************************
- * FPU register status handling. EMIT TIME! *
- ********************************************************************/
+* FPU register status handling. EMIT TIME! *
+********************************************************************/
static void f_tomem(int r)
{
- if (live.fate[r].status==DIRTY) {
+ if (live.fate[r].status==DIRTY) {
#if USE_LONG_DOUBLE
- raw_fmov_ext_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg);
+ raw_fmov_ext_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg);
#else
- raw_fmov_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg);
+ raw_fmov_mr((uae_u32)live.fate[r].mem,live.fate[r].realreg);
#endif
- live.fate[r].status=CLEAN;
- }
+ live.fate[r].status=CLEAN;
+ }
}
static void f_tomem_drop(int r)
{
- if (live.fate[r].status==DIRTY) {
+ if (live.fate[r].status==DIRTY) {
#if USE_LONG_DOUBLE
- raw_fmov_ext_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg);
+ raw_fmov_ext_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg);
#else
- raw_fmov_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg);
+ raw_fmov_mr_drop((uae_u32)live.fate[r].mem,live.fate[r].realreg);
#endif
- live.fate[r].status=INMEM;
- }
+ live.fate[r].status=INMEM;
+ }
}
STATIC_INLINE int f_isinreg(int r)
{
- return live.fate[r].status==CLEAN || live.fate[r].status==DIRTY;
+ return live.fate[r].status==CLEAN || live.fate[r].status==DIRTY;
}
static void f_evict(int r)
{
- int rr;
+ int rr;
- if (!f_isinreg(r))
- return;
- rr=live.fate[r].realreg;
- if (live.fat[rr].nholds==1)
- f_tomem_drop(r);
- else
- f_tomem(r);
-
- Dif (live.fat[rr].locked &&
- live.fat[rr].nholds==1) {
- jit_abort (L"JIT: FPU register %d in nreg %d is locked!\n",r,live.fate[r].realreg);
- }
-
- live.fat[rr].nholds--;
- if (live.fat[rr].nholds!=live.fate[r].realind) { /* Was not last */
- int topreg=live.fat[rr].holds[live.fat[rr].nholds];
- int thisind=live.fate[r].realind;
- live.fat[rr].holds[thisind]=topreg;
- live.fate[topreg].realind=thisind;
- }
- live.fate[r].status=INMEM;
- live.fate[r].realreg=-1;
+ if (!f_isinreg(r))
+ return;
+ rr=live.fate[r].realreg;
+ if (live.fat[rr].nholds==1)
+ f_tomem_drop(r);
+ else
+ f_tomem(r);
+
+ Dif (live.fat[rr].locked &&
+ live.fat[rr].nholds==1) {
+ jit_abort (L"JIT: FPU register %d in nreg %d is locked!\n",r,live.fate[r].realreg);
+ }
+
+ live.fat[rr].nholds--;
+ if (live.fat[rr].nholds!=live.fate[r].realind) { /* Was not last */
+ int topreg=live.fat[rr].holds[live.fat[rr].nholds];
+ int thisind=live.fate[r].realind;
+ live.fat[rr].holds[thisind]=topreg;
+ live.fate[topreg].realind=thisind;
+ }
+ live.fate[r].status=INMEM;
+ live.fate[r].realreg=-1;
}
STATIC_INLINE void f_free_nreg(int r)
{
- int i=live.fat[r].nholds;
+ int i=live.fat[r].nholds;
- while (i) {
- int vr;
+ while (i) {
+ int vr;
- --i;
- vr=live.fat[r].holds[i];
- f_evict(vr);
- }
- Dif (live.fat[r].nholds!=0) {
- jit_abort (L"JIT: Failed to free nreg %d, nholds is %d\n",r,live.fat[r].nholds);
- }
+ --i;
+ vr=live.fat[r].holds[i];
+ f_evict(vr);
+ }
+ Dif (live.fat[r].nholds!=0) {
+ jit_abort (L"JIT: Failed to free nreg %d, nholds is %d\n",r,live.fat[r].nholds);
+ }
}
/* Use with care! */
STATIC_INLINE void f_isclean(int r)
{
- if (!f_isinreg(r))
- return;
- live.fate[r].status=CLEAN;
+ if (!f_isinreg(r))
+ return;
+ live.fate[r].status=CLEAN;
}
STATIC_INLINE void f_disassociate(int r)
{
- f_isclean(r);
- f_evict(r);
+ f_isclean(r);
+ f_evict(r);
}
static int f_alloc_reg(int r, int willclobber)
{
- int bestreg;
- uae_s32 when;
- int i;
- uae_s32 badness;
- bestreg=-1;
- when=2000000000;
- for (i=N_FREGS;i--;) {
- badness=live.fat[i].touched;
- if (live.fat[i].nholds==0)
- badness=0;
-
- if (!live.fat[i].locked && badness<when) {
- bestreg=i;
- when=badness;
- if (live.fat[i].nholds==0)
- break;
- }
- }
- Dif (bestreg==-1)
- abort();
-
- if (live.fat[bestreg].nholds>0) {
- f_free_nreg(bestreg);
- }
- if (f_isinreg(r)) {
- f_evict(r);
- }
+ int bestreg;
+ uae_s32 when;
+ int i;
+ uae_s32 badness;
+ bestreg=-1;
+ when=2000000000;
+ for (i=N_FREGS;i--;) {
+ badness=live.fat[i].touched;
+ if (live.fat[i].nholds==0)
+ badness=0;
+
+ if (!live.fat[i].locked && badness<when) {
+ bestreg=i;
+ when=badness;
+ if (live.fat[i].nholds==0)
+ break;
+ }
+ }
+ Dif (bestreg==-1)
+ abort();
+
+ if (live.fat[bestreg].nholds>0) {
+ f_free_nreg(bestreg);
+ }
+ if (f_isinreg(r)) {
+ f_evict(r);
+ }
- if (!willclobber) {
- if (live.fate[r].status!=UNDEF) {
+ if (!willclobber) {
+ if (live.fate[r].status!=UNDEF) {
#if USE_LONG_DOUBLE
- raw_fmov_ext_rm(bestreg,(uae_u32)live.fate[r].mem);
+ raw_fmov_ext_rm(bestreg,(uae_u32)live.fate[r].mem);
#else
- raw_fmov_rm(bestreg,(uae_u32)live.fate[r].mem);
+ raw_fmov_rm(bestreg,(uae_u32)live.fate[r].mem);
#endif
+ }
+ live.fate[r].status=CLEAN;
}
- live.fate[r].status=CLEAN;
- }
- else {
- live.fate[r].status=DIRTY;
- }
- live.fate[r].realreg=bestreg;
- live.fate[r].realind=live.fat[bestreg].nholds;
- live.fat[bestreg].touched=touchcnt++;
- live.fat[bestreg].holds[live.fat[bestreg].nholds]=r;
- live.fat[bestreg].nholds++;
+ else {
+ live.fate[r].status=DIRTY;
+ }
+ live.fate[r].realreg=bestreg;
+ live.fate[r].realind=live.fat[bestreg].nholds;
+ live.fat[bestreg].touched=touchcnt++;
+ live.fat[bestreg].holds[live.fat[bestreg].nholds]=r;
+ live.fat[bestreg].nholds++;
- return bestreg;
+ return bestreg;
}
static void f_unlock(int r)
{
- Dif (!live.fat[r].locked)
- jit_abort (L"unlock %d", r);
- live.fat[r].locked--;
+ Dif (!live.fat[r].locked)
+ jit_abort (L"unlock %d", r);
+ live.fat[r].locked--;
}
static void f_setlock(int r)
{
- live.fat[r].locked++;
+ live.fat[r].locked++;
}
STATIC_INLINE int f_readreg(int r)
{
- int n;
- int answer=-1;
+ int n;
+ int answer=-1;
- if (f_isinreg(r)) {
- n=live.fate[r].realreg;
- answer=n;
- }
- /* either the value was in memory to start with, or it was evicted and
- is in memory now */
- if (answer<0)
- answer=f_alloc_reg(r,0);
+ if (f_isinreg(r)) {
+ n=live.fate[r].realreg;
+ answer=n;
+ }
+ /* either the value was in memory to start with, or it was evicted and
+ is in memory now */
+ if (answer<0)
+ answer=f_alloc_reg(r,0);
- live.fat[answer].locked++;
- live.fat[answer].touched=touchcnt++;
- return answer;
+ live.fat[answer].locked++;
+ live.fat[answer].touched=touchcnt++;
+ return answer;
}
STATIC_INLINE void f_make_exclusive(int r, int clobber)
{
- freg_status oldstate;
- int rr=live.fate[r].realreg;
- int nr;
- int nind;
- int ndirt=0;
- int i;
+ freg_status oldstate;
+ int rr=live.fate[r].realreg;
+ int nr;
+ int nind;
+ int ndirt=0;
+ int i;
- if (!f_isinreg(r))
- return;
- if (live.fat[rr].nholds==1)
- return;
- for (i=0;i<live.fat[rr].nholds;i++) {
- int vr=live.fat[rr].holds[i];
- if (vr!=r && live.fate[vr].status==DIRTY)
- ndirt++;
- }
- if (!ndirt && !live.fat[rr].locked) {
- /* Everything else is clean, so let's keep this register */
+ if (!f_isinreg(r))
+ return;
+ if (live.fat[rr].nholds==1)
+ return;
for (i=0;i<live.fat[rr].nholds;i++) {
- int vr=live.fat[rr].holds[i];
- if (vr!=r) {
- f_evict(vr);
- i--; /* Try that index again! */
- }
- }
- Dif (live.fat[rr].nholds!=1) {
- write_log (L"JIT: realreg %d holds %d (",rr,live.fat[rr].nholds);
- for (i=0;i<live.fat[rr].nholds;i++) {
- write_log (L"JIT: %d(%d,%d)",live.fat[rr].holds[i],
- live.fate[live.fat[rr].holds[i]].realreg,
- live.fate[live.fat[rr].holds[i]].realind);
- }
- write_log (L"\n");
- jit_abort (L"x");
+ int vr=live.fat[rr].holds[i];
+ if (vr!=r && live.fate[vr].status==DIRTY)
+ ndirt++;
+ }
+ if (!ndirt && !live.fat[rr].locked) {
+ /* Everything else is clean, so let's keep this register */
+ for (i=0;i<live.fat[rr].nholds;i++) {
+ int vr=live.fat[rr].holds[i];
+ if (vr!=r) {
+ f_evict(vr);
+ i--; /* Try that index again! */
+ }
+ }
+ Dif (live.fat[rr].nholds!=1) {
+ write_log (L"JIT: realreg %d holds %d (",rr,live.fat[rr].nholds);
+ for (i=0;i<live.fat[rr].nholds;i++) {
+ write_log (L"JIT: %d(%d,%d)",live.fat[rr].holds[i],
+ live.fate[live.fat[rr].holds[i]].realreg,
+ live.fate[live.fat[rr].holds[i]].realind);
+ }
+ write_log (L"\n");
+ jit_abort (L"x");
+ }
+ return;
}
- return;
- }
- /* We have to split the register */
- oldstate=live.fate[r];
+ /* We have to split the register */
+ oldstate=live.fate[r];
- f_setlock(rr); /* Make sure this doesn't go away */
- /* Forget about r being in the register rr */
- f_disassociate(r);
- /* Get a new register, that we will clobber completely */
- nr=f_alloc_reg(r,1);
- nind=live.fate[r].realind;
- if (!clobber)
- raw_fmov_rr(nr,rr); /* Make another copy */
- live.fate[r]=oldstate; /* Keep all the old state info */
- live.fate[r].realreg=nr;
- live.fate[r].realind=nind;
- f_unlock(rr);
+ f_setlock(rr); /* Make sure this doesn't go away */
+ /* Forget about r being in the register rr */
+ f_disassociate(r);
+ /* Get a new register, that we will clobber completely */
+ nr=f_alloc_reg(r,1);
+ nind=live.fate[r].realind;
+ if (!clobber)
+ raw_fmov_rr(nr,rr); /* Make another copy */
+ live.fate[r]=oldstate; /* Keep all the old state info */
+ live.fate[r].realreg=nr;
+ live.fate[r].realind=nind;
+ f_unlock(rr);
}
STATIC_INLINE int f_writereg(int r)
{
- int n;
- int answer=-1;
-
- f_make_exclusive(r,1);
- if (f_isinreg(r)) {
- n=live.fate[r].realreg;
- answer=n;
- }
- if (answer<0) {
- answer=f_alloc_reg(r,1);
- }
- live.fate[r].status=DIRTY;
- live.fat[answer].locked++;
- live.fat[answer].touched=touchcnt++;
- return answer;
-}
+ int n;
+ int answer=-1;
-static int f_rmw(int r)
+ f_make_exclusive(r,1);
+ if (f_isinreg(r)) {
+ n=live.fate[r].realreg;
+ answer=n;
+ }
+ if (answer<0) {
+ answer=f_alloc_reg(r,1);
+ }
+ live.fate[r].status=DIRTY;
+ live.fat[answer].locked++;
+ live.fat[answer].touched=touchcnt++;
+ return answer;
+}
+
+static int f_rmw(int r)
{
- int n;
+ int n;
- f_make_exclusive(r,0);
- if (f_isinreg(r)) {
- n=live.fate[r].realreg;
- }
- else
- n=f_alloc_reg(r,0);
- live.fate[r].status=DIRTY;
- live.fat[n].locked++;
- live.fat[n].touched=touchcnt++;
- return n;
+ f_make_exclusive(r,0);
+ if (f_isinreg(r)) {
+ n=live.fate[r].realreg;
+ }
+ else
+ n=f_alloc_reg(r,0);
+ live.fate[r].status=DIRTY;
+ live.fat[n].locked++;
+ live.fat[n].touched=touchcnt++;
+ return n;
}
static void fflags_into_flags_internal(uae_u32 tmp)
{
- int r;
+ int r;
- clobber_flags();
- r=f_readreg(FP_RESULT);
- raw_fflags_into_flags(r);
- f_unlock(r);
+ clobber_flags();
+ r=f_readreg(FP_RESULT);
+ raw_fflags_into_flags(r);
+ f_unlock(r);
}
/********************************************************************
- * CPU functions exposed to gencomp. Both CREATE and EMIT time *
- ********************************************************************/
+* CPU functions exposed to gencomp. Both CREATE and EMIT time *
+********************************************************************/
/*
- * RULES FOR HANDLING REGISTERS:
- *
- * * In the function headers, order the parameters
- * - 1st registers written to
- * - 2nd read/modify/write registers
- * - 3rd registers read from
- * * Before calling raw_*, you must call readreg, writereg or rmw for
- * each register
- * * The order for this is
- * - 1st call remove_offset for all registers written to with size<4
- * - 2nd call readreg for all registers read without offset
- * - 3rd call rmw for all rmw registers
- * - 4th call readreg_offset for all registers that can handle offsets
- * - 5th call get_offset for all the registers from the previous step
- * - 6th call writereg for all written-to registers
- * - 7th call raw_*
- * - 8th unlock all registers that were locked
- */
+* RULES FOR HANDLING REGISTERS:
+*
+* * In the function headers, order the parameters
+* - 1st registers written to
+* - 2nd read/modify/write registers
+* - 3rd registers read from
+* * Before calling raw_*, you must call readreg, writereg or rmw for
+* each register
+* * The order for this is
+* - 1st call remove_offset for all registers written to with size<4
+* - 2nd call readreg for all registers read without offset
+* - 3rd call rmw for all rmw registers
+* - 4th call readreg_offset for all registers that can handle offsets
+* - 5th call get_offset for all the registers from the previous step
+* - 6th call writereg for all written-to registers
+* - 7th call raw_*
+* - 8th unlock all registers that were locked
+*/
MIDFUNC(0,live_flags,(void))
{
- live.flags_on_stack=TRASH;
- live.flags_in_flags=VALID;
- live.flags_are_important=1;
+ live.flags_on_stack=TRASH;
+ live.flags_in_flags=VALID;
+ live.flags_are_important=1;
}
MENDFUNC(0,live_flags,(void))
-MIDFUNC(0,dont_care_flags,(void))
+ MIDFUNC(0,dont_care_flags,(void))
{
- live.flags_are_important=0;
+ live.flags_are_important=0;
}
MENDFUNC(0,dont_care_flags,(void))
-/*
- * Copy m68k C flag into m68k X flag
- *
- * FIXME: This needs to be moved into the machdep
- * part of the source because it depends on what bit
- * is used to hold X.
- */
-MIDFUNC(0,duplicate_carry,(void))
-{
- evict(FLAGX);
- make_flags_live_internal();
- COMPCALL(setcc_m)((uae_u32)live.state[FLAGX].mem + 1,2);
+ /*
+ * Copy m68k C flag into m68k X flag
+ *
+ * FIXME: This needs to be moved into the machdep
+ * part of the source because it depends on what bit
+ * is used to hold X.
+ */
+ MIDFUNC(0,duplicate_carry,(void))
+{
+ evict(FLAGX);
+ make_flags_live_internal();
+ COMPCALL(setcc_m)((uae_u32)live.state[FLAGX].mem + 1,2);
}
MENDFUNC(0,duplicate_carry,(void))
-/*
- * Set host C flag from m68k X flag.
- *
- * FIXME: This needs to be moved into the machdep
- * part of the source because it depends on what bit
- * is used to hold X.
- */
-MIDFUNC(0,restore_carry,(void))
-{
- if (!have_rat_stall) { /* Not a P6 core, i.e. no partial stalls */
- bt_l_ri_noclobber(FLAGX, 8);
- }
- else { /* Avoid the stall the above creates.
- This is slow on non-P6, though.
- */
- COMPCALL(rol_w_ri(FLAGX, 8));
- isclean(FLAGX);
- /* Why is the above faster than the below? */
- //raw_rol_b_mi((uae_u32)live.state[FLAGX].mem,8);
- }
+ /*
+ * Set host C flag from m68k X flag.
+ *
+ * FIXME: This needs to be moved into the machdep
+ * part of the source because it depends on what bit
+ * is used to hold X.
+ */
+ MIDFUNC(0,restore_carry,(void))
+{
+ if (!have_rat_stall) { /* Not a P6 core, i.e. no partial stalls */
+ bt_l_ri_noclobber(FLAGX, 8);
+ }
+ else { /* Avoid the stall the above creates.
+ This is slow on non-P6, though.
+ */
+ COMPCALL(rol_w_ri(FLAGX, 8));
+ isclean(FLAGX);
+ /* Why is the above faster than the below? */
+ //raw_rol_b_mi((uae_u32)live.state[FLAGX].mem,8);
+ }
}
MENDFUNC(0,restore_carry,(void))
-MIDFUNC(0,start_needflags,(void))
+ MIDFUNC(0,start_needflags,(void))
{
- needflags=1;
+ needflags=1;
}
MENDFUNC(0,start_needflags,(void))
-MIDFUNC(0,end_needflags,(void))
+ MIDFUNC(0,end_needflags,(void))
{
- needflags=0;
+ needflags=0;
}
MENDFUNC(0,end_needflags,(void))
-MIDFUNC(0,make_flags_live,(void))
+ MIDFUNC(0,make_flags_live,(void))
{
- make_flags_live_internal();
+ make_flags_live_internal();
}
MENDFUNC(0,make_flags_live,(void))
-MIDFUNC(1,fflags_into_flags,(W2 tmp))
+ MIDFUNC(1,fflags_into_flags,(W2 tmp))
{
- clobber_flags();
- fflags_into_flags_internal(tmp);
+ clobber_flags();
+ fflags_into_flags_internal(tmp);
}
MENDFUNC(1,fflags_into_flags,(W2 tmp))
-MIDFUNC(2,bt_l_ri,(R4 r, IMM i)) /* This is defined as only affecting C */
+ MIDFUNC(2,bt_l_ri,(R4 r, IMM i)) /* This is defined as only affecting C */
{
- int size=4;
- if (i<16)
- size=2;
- CLOBBER_BT;
- r=readreg(r,size);
- raw_bt_l_ri(r,i);
- unlock(r);
+ int size=4;
+ if (i<16)
+ size=2;
+ CLOBBER_BT;
+ r=readreg(r,size);
+ raw_bt_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,bt_l_ri,(R4 r, IMM i)) /* This is defined as only affecting C */
-MIDFUNC(2,bt_l_rr,(R4 r, R4 b)) /* This is defined as only affecting C */
+ MIDFUNC(2,bt_l_rr,(R4 r, R4 b)) /* This is defined as only affecting C */
{
- CLOBBER_BT;
- r=readreg(r,4);
- b=readreg(b,4);
- raw_bt_l_rr(r,b);
- unlock(r);
- unlock(b);
+ CLOBBER_BT;
+ r=readreg(r,4);
+ b=readreg(b,4);
+ raw_bt_l_rr(r,b);
+ unlock(r);
+ unlock(b);
}
MENDFUNC(2,bt_l_rr,(R4 r, R4 b)) /* This is defined as only affecting C */
-MIDFUNC(2,btc_l_ri,(RW4 r, IMM i))
+ MIDFUNC(2,btc_l_ri,(RW4 r, IMM i))
{
- int size=4;
- if (i<16)
- size=2;
- CLOBBER_BT;
- r=rmw(r,size,size);
- raw_btc_l_ri(r,i);
- unlock(r);
+ int size=4;
+ if (i<16)
+ size=2;
+ CLOBBER_BT;
+ r=rmw(r,size,size);
+ raw_btc_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,btc_l_ri,(RW4 r, IMM i))
-MIDFUNC(2,btc_l_rr,(RW4 r, R4 b))
+ MIDFUNC(2,btc_l_rr,(RW4 r, R4 b))
{
- CLOBBER_BT;
- b=readreg(b,4);
- r=rmw(r,4,4);
- raw_btc_l_rr(r,b);
- unlock(r);
- unlock(b);
+ CLOBBER_BT;
+ b=readreg(b,4);
+ r=rmw(r,4,4);
+ raw_btc_l_rr(r,b);
+ unlock(r);
+ unlock(b);
}
MENDFUNC(2,btc_l_rr,(RW4 r, R4 b))
-MIDFUNC(2,btr_l_ri,(RW4 r, IMM i))
+ MIDFUNC(2,btr_l_ri,(RW4 r, IMM i))
{
- int size=4;
- if (i<16)
- size=2;
- CLOBBER_BT;
- r=rmw(r,size,size);
- raw_btr_l_ri(r,i);
- unlock(r);
+ int size=4;
+ if (i<16)
+ size=2;
+ CLOBBER_BT;
+ r=rmw(r,size,size);
+ raw_btr_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,btr_l_ri,(RW4 r, IMM i))
-MIDFUNC(2,btr_l_rr,(RW4 r, R4 b))
+ MIDFUNC(2,btr_l_rr,(RW4 r, R4 b))
{
- CLOBBER_BT;
- b=readreg(b,4);
- r=rmw(r,4,4);
- raw_btr_l_rr(r,b);
- unlock(r);
- unlock(b);
+ CLOBBER_BT;
+ b=readreg(b,4);
+ r=rmw(r,4,4);
+ raw_btr_l_rr(r,b);
+ unlock(r);
+ unlock(b);
}
MENDFUNC(2,btr_l_rr,(RW4 r, R4 b))
-MIDFUNC(2,bts_l_ri,(RW4 r, IMM i))
+ MIDFUNC(2,bts_l_ri,(RW4 r, IMM i))
{
- int size=4;
- if (i<16)
- size=2;
- CLOBBER_BT;
- r=rmw(r,size,size);
- raw_bts_l_ri(r,i);
- unlock(r);
+ int size=4;
+ if (i<16)
+ size=2;
+ CLOBBER_BT;
+ r=rmw(r,size,size);
+ raw_bts_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,bts_l_ri,(RW4 r, IMM i))
-MIDFUNC(2,bts_l_rr,(RW4 r, R4 b))
+ MIDFUNC(2,bts_l_rr,(RW4 r, R4 b))
{
- CLOBBER_BT;
- b=readreg(b,4);
- r=rmw(r,4,4);
- raw_bts_l_rr(r,b);
- unlock(r);
- unlock(b);
+ CLOBBER_BT;
+ b=readreg(b,4);
+ r=rmw(r,4,4);
+ raw_bts_l_rr(r,b);
+ unlock(r);
+ unlock(b);
}
MENDFUNC(2,bts_l_rr,(RW4 r, R4 b))
-MIDFUNC(2,mov_l_rm,(W4 d, IMM s))
+ MIDFUNC(2,mov_l_rm,(W4 d, IMM s))
{
- CLOBBER_MOV;
- d=writereg(d,4);
- raw_mov_l_rm(d,s);
- unlock(d);
+ CLOBBER_MOV;
+ d=writereg(d,4);
+ raw_mov_l_rm(d,s);
+ unlock(d);
}
MENDFUNC(2,mov_l_rm,(W4 d, IMM s))
-MIDFUNC(1,call_r,(R4 r)) /* Clobbering is implicit */
+ MIDFUNC(1,call_r,(R4 r)) /* Clobbering is implicit */
{
- r=readreg(r,4);
- raw_call_r(r);
- unlock(r);
+ r=readreg(r,4);
+ raw_call_r(r);
+ unlock(r);
}
MENDFUNC(1,call_r,(R4 r)) /* Clobbering is implicit */
-MIDFUNC(2,sub_l_mi,(IMM d, IMM s))
+ MIDFUNC(2,sub_l_mi,(IMM d, IMM s))
{
- CLOBBER_SUB;
- raw_sub_l_mi(d,s) ;
+ CLOBBER_SUB;
+ raw_sub_l_mi(d,s) ;
}
MENDFUNC(2,sub_l_mi,(IMM d, IMM s))
-MIDFUNC(2,mov_l_mi,(IMM d, IMM s))
+ MIDFUNC(2,mov_l_mi,(IMM d, IMM s))
{
- CLOBBER_MOV;
- raw_mov_l_mi(d,s) ;
+ CLOBBER_MOV;
+ raw_mov_l_mi(d,s) ;
}
MENDFUNC(2,mov_l_mi,(IMM d, IMM s))
-MIDFUNC(2,mov_w_mi,(IMM d, IMM s))
+ MIDFUNC(2,mov_w_mi,(IMM d, IMM s))
{
- CLOBBER_MOV;
- raw_mov_w_mi(d,s) ;
+ CLOBBER_MOV;
+ raw_mov_w_mi(d,s) ;
}
MENDFUNC(2,mov_w_mi,(IMM d, IMM s))
-MIDFUNC(2,mov_b_mi,(IMM d, IMM s))
+ MIDFUNC(2,mov_b_mi,(IMM d, IMM s))
{
- CLOBBER_MOV;
- raw_mov_b_mi(d,s) ;
+ CLOBBER_MOV;
+ raw_mov_b_mi(d,s) ;
}
MENDFUNC(2,mov_b_mi,(IMM d, IMM s))
-MIDFUNC(2,rol_b_ri,(RW1 r, IMM i))
+ MIDFUNC(2,rol_b_ri,(RW1 r, IMM i))
{
- if (!i && !needflags)
+ if (!i && !needflags)
return;
- CLOBBER_ROL;
- r=rmw(r,1,1);
- raw_rol_b_ri(r,i);
- unlock(r);
+ CLOBBER_ROL;
+ r=rmw(r,1,1);
+ raw_rol_b_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,rol_b_ri,(RW1 r, IMM i))
-MIDFUNC(2,rol_w_ri,(RW2 r, IMM i))
+ MIDFUNC(2,rol_w_ri,(RW2 r, IMM i))
{
- if (!i && !needflags)
+ if (!i && !needflags)
return;
- CLOBBER_ROL;
- r=rmw(r,2,2);
- raw_rol_w_ri(r,i);
- unlock(r);
+ CLOBBER_ROL;
+ r=rmw(r,2,2);
+ raw_rol_w_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,rol_w_ri,(RW2 r, IMM i))
-MIDFUNC(2,rol_l_ri,(RW4 r, IMM i))
+ MIDFUNC(2,rol_l_ri,(RW4 r, IMM i))
{
- if (!i && !needflags)
+ if (!i && !needflags)
return;
- CLOBBER_ROL;
- r=rmw(r,4,4);
- raw_rol_l_ri(r,i);
- unlock(r);
+ CLOBBER_ROL;
+ r=rmw(r,4,4);
+ raw_rol_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,rol_l_ri,(RW4 r, IMM i))
-MIDFUNC(2,rol_l_rr,(RW4 d, R1 r))
+ MIDFUNC(2,rol_l_rr,(RW4 d, R1 r))
{
- if (isconst(r)) {
- COMPCALL(rol_l_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_ROL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,4,4);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
- }
- raw_rol_l_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(rol_l_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_ROL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,4,4);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+ }
+ raw_rol_l_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,rol_l_rr,(RW4 d, R1 r))
-MIDFUNC(2,rol_w_rr,(RW2 d, R1 r))
+ MIDFUNC(2,rol_w_rr,(RW2 d, R1 r))
{ /* Can only do this with r==1, i.e. cl */
- if (isconst(r)) {
- COMPCALL(rol_w_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_ROL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,2,2);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
- }
- raw_rol_w_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(rol_w_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_ROL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,2,2);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+ }
+ raw_rol_w_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,rol_w_rr,(RW2 d, R1 r))
-MIDFUNC(2,rol_b_rr,(RW1 d, R1 r))
+ MIDFUNC(2,rol_b_rr,(RW1 d, R1 r))
{ /* Can only do this with r==1, i.e. cl */
- if (isconst(r)) {
- COMPCALL(rol_b_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
-
- CLOBBER_ROL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,1,1);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
- }
- raw_rol_b_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(rol_b_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+
+ CLOBBER_ROL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,1,1);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+ }
+ raw_rol_b_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,rol_b_rr,(RW1 d, R1 r))
-MIDFUNC(2,shll_l_rr,(RW4 d, R1 r))
+ MIDFUNC(2,shll_l_rr,(RW4 d, R1 r))
{
- if (isconst(r)) {
- COMPCALL(shll_l_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_SHLL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,4,4);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
- }
- raw_shll_l_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shll_l_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_SHLL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,4,4);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+ }
+ raw_shll_l_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shll_l_rr,(RW4 d, R1 r))
-MIDFUNC(2,shll_w_rr,(RW2 d, R1 r))
+ MIDFUNC(2,shll_w_rr,(RW2 d, R1 r))
{ /* Can only do this with r==1, i.e. cl */
- if (isconst(r)) {
- COMPCALL(shll_w_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_SHLL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,2,2);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_shll_b\n",r);
- }
- raw_shll_w_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shll_w_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_SHLL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,2,2);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_shll_b\n",r);
+ }
+ raw_shll_w_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shll_w_rr,(RW2 d, R1 r))
-MIDFUNC(2,shll_b_rr,(RW1 d, R1 r))
+ MIDFUNC(2,shll_b_rr,(RW1 d, R1 r))
{ /* Can only do this with r==1, i.e. cl */
- if (isconst(r)) {
- COMPCALL(shll_b_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
-
- CLOBBER_SHLL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,1,1);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_shll_b\n",r);
- }
- raw_shll_b_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shll_b_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+
+ CLOBBER_SHLL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,1,1);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_shll_b\n",r);
+ }
+ raw_shll_b_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shll_b_rr,(RW1 d, R1 r))
-MIDFUNC(2,ror_b_ri,(R1 r, IMM i))
+ MIDFUNC(2,ror_b_ri,(R1 r, IMM i))
{
- if (!i && !needflags)
+ if (!i && !needflags)
return;
- CLOBBER_ROR;
- r=rmw(r,1,1);
- raw_ror_b_ri(r,i);
- unlock(r);
+ CLOBBER_ROR;
+ r=rmw(r,1,1);
+ raw_ror_b_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,ror_b_ri,(R1 r, IMM i))
-MIDFUNC(2,ror_w_ri,(R2 r, IMM i))
+ MIDFUNC(2,ror_w_ri,(R2 r, IMM i))
{
- if (!i && !needflags)
+ if (!i && !needflags)
return;
- CLOBBER_ROR;
- r=rmw(r,2,2);
- raw_ror_w_ri(r,i);
- unlock(r);
+ CLOBBER_ROR;
+ r=rmw(r,2,2);
+ raw_ror_w_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,ror_w_ri,(R2 r, IMM i))
-MIDFUNC(2,ror_l_ri,(R4 r, IMM i))
+ MIDFUNC(2,ror_l_ri,(R4 r, IMM i))
{
- if (!i && !needflags)
+ if (!i && !needflags)
return;
- CLOBBER_ROR;
- r=rmw(r,4,4);
- raw_ror_l_ri(r,i);
- unlock(r);
+ CLOBBER_ROR;
+ r=rmw(r,4,4);
+ raw_ror_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,ror_l_ri,(R4 r, IMM i))
-MIDFUNC(2,ror_l_rr,(R4 d, R1 r))
+ MIDFUNC(2,ror_l_rr,(R4 d, R1 r))
{
- if (isconst(r)) {
- COMPCALL(ror_l_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_ROR;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,4,4);
- raw_ror_l_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(ror_l_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_ROR;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,4,4);
+ raw_ror_l_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,ror_l_rr,(R4 d, R1 r))
-MIDFUNC(2,ror_w_rr,(R2 d, R1 r))
+ MIDFUNC(2,ror_w_rr,(R2 d, R1 r))
{
- if (isconst(r)) {
- COMPCALL(ror_w_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_ROR;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,2,2);
- raw_ror_w_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(ror_w_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_ROR;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,2,2);
+ raw_ror_w_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,ror_w_rr,(R2 d, R1 r))
-MIDFUNC(2,ror_b_rr,(R1 d, R1 r))
+ MIDFUNC(2,ror_b_rr,(R1 d, R1 r))
{
- if (isconst(r)) {
- COMPCALL(ror_b_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
+ if (isconst(r)) {
+ COMPCALL(ror_b_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
- CLOBBER_ROR;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,1,1);
- raw_ror_b_rr(d,r) ;
- unlock(r);
- unlock(d);
+ CLOBBER_ROR;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,1,1);
+ raw_ror_b_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,ror_b_rr,(R1 d, R1 r))
-MIDFUNC(2,shrl_l_rr,(RW4 d, R1 r))
+ MIDFUNC(2,shrl_l_rr,(RW4 d, R1 r))
{
- if (isconst(r)) {
- COMPCALL(shrl_l_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_SHRL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,4,4);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
- }
- raw_shrl_l_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shrl_l_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_SHRL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,4,4);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+ }
+ raw_shrl_l_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shrl_l_rr,(RW4 d, R1 r))
-MIDFUNC(2,shrl_w_rr,(RW2 d, R1 r))
+ MIDFUNC(2,shrl_w_rr,(RW2 d, R1 r))
{ /* Can only do this with r==1, i.e. cl */
- if (isconst(r)) {
- COMPCALL(shrl_w_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_SHRL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,2,2);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_shrl_b\n",r);
- }
- raw_shrl_w_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shrl_w_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_SHRL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,2,2);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_shrl_b\n",r);
+ }
+ raw_shrl_w_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shrl_w_rr,(RW2 d, R1 r))
-MIDFUNC(2,shrl_b_rr,(RW1 d, R1 r))
+ MIDFUNC(2,shrl_b_rr,(RW1 d, R1 r))
{ /* Can only do this with r==1, i.e. cl */
- if (isconst(r)) {
- COMPCALL(shrl_b_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
-
- CLOBBER_SHRL;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,1,1);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_shrl_b\n",r);
- }
- raw_shrl_b_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shrl_b_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+
+ CLOBBER_SHRL;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,1,1);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_shrl_b\n",r);
+ }
+ raw_shrl_b_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shrl_b_rr,(RW1 d, R1 r))
-MIDFUNC(2,shll_l_ri,(RW4 r, IMM i))
+ MIDFUNC(2,shll_l_ri,(RW4 r, IMM i))
{
- if (!i && !needflags)
- return;
- if (isconst(r) && !needflags) {
- live.state[r].val<<=i;
- return;
- }
- CLOBBER_SHLL;
- r=rmw(r,4,4);
- raw_shll_l_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ if (isconst(r) && !needflags) {
+ live.state[r].val<<=i;
+ return;
+ }
+ CLOBBER_SHLL;
+ r=rmw(r,4,4);
+ raw_shll_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shll_l_ri,(RW4 r, IMM i))
-MIDFUNC(2,shll_w_ri,(RW2 r, IMM i))
+ MIDFUNC(2,shll_w_ri,(RW2 r, IMM i))
{
- if (!i && !needflags)
- return;
- CLOBBER_SHLL;
- r=rmw(r,2,2);
- raw_shll_w_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ CLOBBER_SHLL;
+ r=rmw(r,2,2);
+ raw_shll_w_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shll_w_ri,(RW2 r, IMM i))
-MIDFUNC(2,shll_b_ri,(RW1 r, IMM i))
+ MIDFUNC(2,shll_b_ri,(RW1 r, IMM i))
{
- if (!i && !needflags)
- return;
- CLOBBER_SHLL;
- r=rmw(r,1,1);
- raw_shll_b_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ CLOBBER_SHLL;
+ r=rmw(r,1,1);
+ raw_shll_b_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shll_b_ri,(RW1 r, IMM i))
-MIDFUNC(2,shrl_l_ri,(RW4 r, IMM i))
+ MIDFUNC(2,shrl_l_ri,(RW4 r, IMM i))
{
- if (!i && !needflags)
- return;
- if (isconst(r) && !needflags) {
- live.state[r].val>>=i;
- return;
- }
- CLOBBER_SHRL;
- r=rmw(r,4,4);
- raw_shrl_l_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ if (isconst(r) && !needflags) {
+ live.state[r].val>>=i;
+ return;
+ }
+ CLOBBER_SHRL;
+ r=rmw(r,4,4);
+ raw_shrl_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shrl_l_ri,(RW4 r, IMM i))
-MIDFUNC(2,shrl_w_ri,(RW2 r, IMM i))
+ MIDFUNC(2,shrl_w_ri,(RW2 r, IMM i))
{
- if (!i && !needflags)
- return;
- CLOBBER_SHRL;
- r=rmw(r,2,2);
- raw_shrl_w_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ CLOBBER_SHRL;
+ r=rmw(r,2,2);
+ raw_shrl_w_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shrl_w_ri,(RW2 r, IMM i))
-MIDFUNC(2,shrl_b_ri,(RW1 r, IMM i))
+ MIDFUNC(2,shrl_b_ri,(RW1 r, IMM i))
{
- if (!i && !needflags)
- return;
- CLOBBER_SHRL;
- r=rmw(r,1,1);
- raw_shrl_b_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ CLOBBER_SHRL;
+ r=rmw(r,1,1);
+ raw_shrl_b_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shrl_b_ri,(RW1 r, IMM i))
-MIDFUNC(2,shra_l_ri,(RW4 r, IMM i))
+ MIDFUNC(2,shra_l_ri,(RW4 r, IMM i))
{
- if (!i && !needflags)
- return;
- CLOBBER_SHRA;
- r=rmw(r,4,4);
- raw_shra_l_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ CLOBBER_SHRA;
+ r=rmw(r,4,4);
+ raw_shra_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shra_l_ri,(RW4 r, IMM i))
-MIDFUNC(2,shra_w_ri,(RW2 r, IMM i))
+ MIDFUNC(2,shra_w_ri,(RW2 r, IMM i))
{
- if (!i && !needflags)
- return;
- CLOBBER_SHRA;
- r=rmw(r,2,2);
- raw_shra_w_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ CLOBBER_SHRA;
+ r=rmw(r,2,2);
+ raw_shra_w_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shra_w_ri,(RW2 r, IMM i))
-MIDFUNC(2,shra_b_ri,(RW1 r, IMM i))
+ MIDFUNC(2,shra_b_ri,(RW1 r, IMM i))
{
- if (!i && !needflags)
- return;
- CLOBBER_SHRA;
- r=rmw(r,1,1);
- raw_shra_b_ri(r,i);
- unlock(r);
+ if (!i && !needflags)
+ return;
+ CLOBBER_SHRA;
+ r=rmw(r,1,1);
+ raw_shra_b_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,shra_b_ri,(RW1 r, IMM i))
-MIDFUNC(2,shra_l_rr,(RW4 d, R1 r))
+ MIDFUNC(2,shra_l_rr,(RW4 d, R1 r))
{
- if (isconst(r)) {
- COMPCALL(shra_l_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_SHRA;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,4,4);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
- }
- raw_shra_l_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shra_l_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_SHRA;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,4,4);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_rol_b\n",r);
+ }
+ raw_shra_l_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shra_l_rr,(RW4 d, R1 r))
-MIDFUNC(2,shra_w_rr,(RW2 d, R1 r))
+ MIDFUNC(2,shra_w_rr,(RW2 d, R1 r))
{ /* Can only do this with r==1, i.e. cl */
- if (isconst(r)) {
- COMPCALL(shra_w_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
- CLOBBER_SHRA;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,2,2);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_shra_b\n",r);
- }
- raw_shra_w_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shra_w_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+ CLOBBER_SHRA;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,2,2);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_shra_b\n",r);
+ }
+ raw_shra_w_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shra_w_rr,(RW2 d, R1 r))
-MIDFUNC(2,shra_b_rr,(RW1 d, R1 r))
+ MIDFUNC(2,shra_b_rr,(RW1 d, R1 r))
{ /* Can only do this with r==1, i.e. cl */
- if (isconst(r)) {
- COMPCALL(shra_b_ri)(d,(uae_u8)live.state[r].val);
- return;
- }
-
- CLOBBER_SHRA;
- r=readreg_specific(r,1,SHIFTCOUNT_NREG);
- d=rmw(d,1,1);
- Dif (r!=1) {
- jit_abort (L"JIT: Illegal register %d in raw_shra_b\n",r);
- }
- raw_shra_b_rr(d,r) ;
- unlock(r);
- unlock(d);
+ if (isconst(r)) {
+ COMPCALL(shra_b_ri)(d,(uae_u8)live.state[r].val);
+ return;
+ }
+
+ CLOBBER_SHRA;
+ r=readreg_specific(r,1,SHIFTCOUNT_NREG);
+ d=rmw(d,1,1);
+ Dif (r!=1) {
+ jit_abort (L"JIT: Illegal register %d in raw_shra_b\n",r);
+ }
+ raw_shra_b_rr(d,r) ;
+ unlock(r);
+ unlock(d);
}
MENDFUNC(2,shra_b_rr,(RW1 d, R1 r))
-MIDFUNC(2,setcc,(W1 d, IMM cc))
+ MIDFUNC(2,setcc,(W1 d, IMM cc))
{
- CLOBBER_SETCC;
- d=writereg(d,1);
- raw_setcc(d,cc);
- unlock(d);
+ CLOBBER_SETCC;
+ d=writereg(d,1);
+ raw_setcc(d,cc);
+ unlock(d);
}
MENDFUNC(2,setcc,(W1 d, IMM cc))
-MIDFUNC(2,setcc_m,(IMM d, IMM cc))
+ MIDFUNC(2,setcc_m,(IMM d, IMM cc))
{
- CLOBBER_SETCC;
- raw_setcc_m(d,cc);
+ CLOBBER_SETCC;
+ raw_setcc_m(d,cc);
}
MENDFUNC(2,setcc_m,(IMM d, IMM cc))
-MIDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc))
+ MIDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc))
{
- if (d==s)
- return;
- CLOBBER_CMOV;
- s=readreg(s,1);
- d=rmw(d,1,1);
- raw_cmov_b_rr(d,s,cc);
- unlock(s);
- unlock(d);
+ if (d==s)
+ return;
+ CLOBBER_CMOV;
+ s=readreg(s,1);
+ d=rmw(d,1,1);
+ raw_cmov_b_rr(d,s,cc);
+ unlock(s);
+ unlock(d);
}
MENDFUNC(3,cmov_b_rr,(RW1 d, R1 s, IMM cc))
-MIDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc))
+ MIDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc))
{
- if (d==s)
- return;
- CLOBBER_CMOV;
- s=readreg(s,2);
- d=rmw(d,2,2);
- raw_cmov_w_rr(d,s,cc);
- unlock(s);
- unlock(d);
+ if (d==s)
+ return;
+ CLOBBER_CMOV;
+ s=readreg(s,2);
+ d=rmw(d,2,2);
+ raw_cmov_w_rr(d,s,cc);
+ unlock(s);
+ unlock(d);
}
MENDFUNC(3,cmov_w_rr,(RW2 d, R2 s, IMM cc))
-MIDFUNC(3,cmov_l_rr,(RW4 d, R4 s, IMM cc))
+ MIDFUNC(3,cmov_l_rr,(RW4 d, R4 s, IMM cc))
{
- if (d==s)
- return;
- CLOBBER_CMOV;
- s=readreg(s,4);
- d=rmw(d,4,4);
- raw_cmov_l_rr(d,s,cc);
- unlock(s);
- unlock(d);
+ if (d==s)
+ return;
+ CLOBBER_CMOV;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
+ raw_cmov_l_rr(d,s,cc);
+ unlock(s);
+ unlock(d);
}
MENDFUNC(3,cmov_l_rr,(RW4 d, R4 s, IMM cc))
-MIDFUNC(1,setzflg_l,(RW4 r))
+ MIDFUNC(1,setzflg_l,(RW4 r))
{
if (setzflg_uses_bsf) {
CLOBBER_BSF;
else {
Dif (live.flags_in_flags!=VALID) {
jit_abort (L"JIT: setzflg() wanted flags in native flags, they are %d\n",
- live.flags_in_flags);
+ live.flags_in_flags);
}
r=readreg(r,4);
{
- int f=writereg(S11,4);
- int t=writereg(S12,4);
- raw_flags_set_zero(f,r,t);
- unlock(f);
- unlock(r);
- unlock(t);
+ int f=writereg(S11,4);
+ int t=writereg(S12,4);
+ raw_flags_set_zero(f,r,t);
+ unlock(f);
+ unlock(r);
+ unlock(t);
}
}
}
MENDFUNC(1,setzflg_l,(RW4 r))
-MIDFUNC(3,cmov_l_rm,(RW4 d, IMM s, IMM cc))
+ MIDFUNC(3,cmov_l_rm,(RW4 d, IMM s, IMM cc))
{
- CLOBBER_CMOV;
- d=rmw(d,4,4);
- raw_cmov_l_rm(d,s,cc);
- unlock(d);
+ CLOBBER_CMOV;
+ d=rmw(d,4,4);
+ raw_cmov_l_rm(d,s,cc);
+ unlock(d);
}
MENDFUNC(3,cmov_l_rm,(RW4 d, IMM s, IMM cc))
-MIDFUNC(2,bsf_l_rr,(W4 d, R4 s))
+ MIDFUNC(2,bsf_l_rr,(W4 d, R4 s))
{
- CLOBBER_BSF;
- s=readreg(s,4);
- d=writereg(d,4);
- raw_bsf_l_rr(d,s);
- unlock(s);
- unlock(d);
+ CLOBBER_BSF;
+ s=readreg(s,4);
+ d=writereg(d,4);
+ raw_bsf_l_rr(d,s);
+ unlock(s);
+ unlock(d);
}
MENDFUNC(2,bsf_l_rr,(W4 d, R4 s))
-MIDFUNC(2,imul_32_32,(RW4 d, R4 s))
+ MIDFUNC(2,imul_32_32,(RW4 d, R4 s))
{
- CLOBBER_MUL;
- s=readreg(s,4);
- d=rmw(d,4,4);
- raw_imul_32_32(d,s);
- unlock(s);
- unlock(d);
+ CLOBBER_MUL;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
+ raw_imul_32_32(d,s);
+ unlock(s);
+ unlock(d);
}
MENDFUNC(2,imul_32_32,(RW4 d, R4 s))
-MIDFUNC(2,imul_64_32,(RW4 d, RW4 s))
+ MIDFUNC(2,imul_64_32,(RW4 d, RW4 s))
{
- CLOBBER_MUL;
- s=rmw_specific(s,4,4,MUL_NREG2);
- d=rmw_specific(d,4,4,MUL_NREG1);
- raw_imul_64_32(d,s);
- unlock(s);
- unlock(d);
+ CLOBBER_MUL;
+ s=rmw_specific(s,4,4,MUL_NREG2);
+ d=rmw_specific(d,4,4,MUL_NREG1);
+ raw_imul_64_32(d,s);
+ unlock(s);
+ unlock(d);
}
MENDFUNC(2,imul_64_32,(RW4 d, RW4 s))
-MIDFUNC(2,mul_64_32,(RW4 d, RW4 s))
+ MIDFUNC(2,mul_64_32,(RW4 d, RW4 s))
{
- CLOBBER_MUL;
- s=rmw_specific(s,4,4,MUL_NREG2);
- d=rmw_specific(d,4,4,MUL_NREG1);
- raw_mul_64_32(d,s);
- unlock(s);
- unlock(d);
+ CLOBBER_MUL;
+ s=rmw_specific(s,4,4,MUL_NREG2);
+ d=rmw_specific(d,4,4,MUL_NREG1);
+ raw_mul_64_32(d,s);
+ unlock(s);
+ unlock(d);
}
MENDFUNC(2,mul_64_32,(RW4 d, RW4 s))
-MIDFUNC(2,sign_extend_16_rr,(W4 d, R2 s))
+ MIDFUNC(2,sign_extend_16_rr,(W4 d, R2 s))
{
- int isrmw;
+ int isrmw;
- if (isconst(s)) {
- set_const(d,(uae_s32)(uae_s16)live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ set_const(d,(uae_s32)(uae_s16)live.state[s].val);
+ return;
+ }
- CLOBBER_SE16;
- isrmw=(s==d);
- if (!isrmw) {
- s=readreg(s,2);
- d=writereg(d,4);
- }
- else { /* If we try to lock this twice, with different sizes, we
- are int trouble! */
- s=d=rmw(s,4,2);
- }
- raw_sign_extend_16_rr(d,s);
- if (!isrmw) {
- unlock(d);
- unlock(s);
- }
- else {
- unlock(s);
- }
+ CLOBBER_SE16;
+ isrmw=(s==d);
+ if (!isrmw) {
+ s=readreg(s,2);
+ d=writereg(d,4);
+ }
+ else { /* If we try to lock this twice, with different sizes, we
+ are int trouble! */
+ s=d=rmw(s,4,2);
+ }
+ raw_sign_extend_16_rr(d,s);
+ if (!isrmw) {
+ unlock(d);
+ unlock(s);
+ }
+ else {
+ unlock(s);
+ }
}
MENDFUNC(2,sign_extend_16_rr,(W4 d, R2 s))
-MIDFUNC(2,sign_extend_8_rr,(W4 d, R1 s))
+ MIDFUNC(2,sign_extend_8_rr,(W4 d, R1 s))
{
- int isrmw;
+ int isrmw;
- if (isconst(s)) {
- set_const(d,(uae_s32)(uae_s8)live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ set_const(d,(uae_s32)(uae_s8)live.state[s].val);
+ return;
+ }
- isrmw=(s==d);
- CLOBBER_SE8;
- if (!isrmw) {
- s=readreg(s,1);
- d=writereg(d,4);
- }
- else { /* If we try to lock this twice, with different sizes, we
- are int trouble! */
- s=d=rmw(s,4,1);
- }
+ isrmw=(s==d);
+ CLOBBER_SE8;
+ if (!isrmw) {
+ s=readreg(s,1);
+ d=writereg(d,4);
+ }
+ else { /* If we try to lock this twice, with different sizes, we
+ are int trouble! */
+ s=d=rmw(s,4,1);
+ }
- raw_sign_extend_8_rr(d,s);
+ raw_sign_extend_8_rr(d,s);
- if (!isrmw) {
- unlock(d);
- unlock(s);
- }
- else {
- unlock(s);
- }
+ if (!isrmw) {
+ unlock(d);
+ unlock(s);
+ }
+ else {
+ unlock(s);
+ }
}
MENDFUNC(2,sign_extend_8_rr,(W4 d, R1 s))
-MIDFUNC(2,zero_extend_16_rr,(W4 d, R2 s))
+ MIDFUNC(2,zero_extend_16_rr,(W4 d, R2 s))
{
- int isrmw;
+ int isrmw;
- if (isconst(s)) {
- set_const(d,(uae_u32)(uae_u16)live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ set_const(d,(uae_u32)(uae_u16)live.state[s].val);
+ return;
+ }
- isrmw=(s==d);
- CLOBBER_ZE16;
- if (!isrmw) {
- s=readreg(s,2);
- d=writereg(d,4);
- }
- else { /* If we try to lock this twice, with different sizes, we
- are int trouble! */
- s=d=rmw(s,4,2);
- }
- raw_zero_extend_16_rr(d,s);
- if (!isrmw) {
- unlock(d);
- unlock(s);
- }
- else {
- unlock(s);
- }
+ isrmw=(s==d);
+ CLOBBER_ZE16;
+ if (!isrmw) {
+ s=readreg(s,2);
+ d=writereg(d,4);
+ }
+ else { /* If we try to lock this twice, with different sizes, we
+ are int trouble! */
+ s=d=rmw(s,4,2);
+ }
+ raw_zero_extend_16_rr(d,s);
+ if (!isrmw) {
+ unlock(d);
+ unlock(s);
+ }
+ else {
+ unlock(s);
+ }
}
MENDFUNC(2,zero_extend_16_rr,(W4 d, R2 s))
-MIDFUNC(2,zero_extend_8_rr,(W4 d, R1 s))
+ MIDFUNC(2,zero_extend_8_rr,(W4 d, R1 s))
{
- int isrmw;
- if (isconst(s)) {
- set_const(d,(uae_u32)(uae_u8)live.state[s].val);
- return;
- }
+ int isrmw;
+ if (isconst(s)) {
+ set_const(d,(uae_u32)(uae_u8)live.state[s].val);
+ return;
+ }
- isrmw=(s==d);
- CLOBBER_ZE8;
- if (!isrmw) {
- s=readreg(s,1);
- d=writereg(d,4);
- }
- else { /* If we try to lock this twice, with different sizes, we
- are int trouble! */
- s=d=rmw(s,4,1);
- }
+ isrmw=(s==d);
+ CLOBBER_ZE8;
+ if (!isrmw) {
+ s=readreg(s,1);
+ d=writereg(d,4);
+ }
+ else { /* If we try to lock this twice, with different sizes, we
+ are int trouble! */
+ s=d=rmw(s,4,1);
+ }
- raw_zero_extend_8_rr(d,s);
+ raw_zero_extend_8_rr(d,s);
- if (!isrmw) {
- unlock(d);
- unlock(s);
- }
- else {
- unlock(s);
- }
+ if (!isrmw) {
+ unlock(d);
+ unlock(s);
+ }
+ else {
+ unlock(s);
+ }
}
MENDFUNC(2,zero_extend_8_rr,(W4 d, R1 s))
-MIDFUNC(2,mov_b_rr,(W1 d, R1 s))
+ MIDFUNC(2,mov_b_rr,(W1 d, R1 s))
{
- if (d==s)
- return;
- if (isconst(s)) {
- COMPCALL(mov_b_ri)(d,(uae_u8)live.state[s].val);
- return;
- }
+ if (d==s)
+ return;
+ if (isconst(s)) {
+ COMPCALL(mov_b_ri)(d,(uae_u8)live.state[s].val);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,1);
- d=writereg(d,1);
- raw_mov_b_rr(d,s);
- unlock(d);
- unlock(s);
+ CLOBBER_MOV;
+ s=readreg(s,1);
+ d=writereg(d,1);
+ raw_mov_b_rr(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,mov_b_rr,(W1 d, R1 s))
-MIDFUNC(2,mov_w_rr,(W2 d, R2 s))
+ MIDFUNC(2,mov_w_rr,(W2 d, R2 s))
{
- if (d==s)
- return;
- if (isconst(s)) {
- COMPCALL(mov_w_ri)(d,(uae_u16)live.state[s].val);
- return;
- }
+ if (d==s)
+ return;
+ if (isconst(s)) {
+ COMPCALL(mov_w_ri)(d,(uae_u16)live.state[s].val);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,2);
- d=writereg(d,2);
- raw_mov_w_rr(d,s);
- unlock(d);
- unlock(s);
+ CLOBBER_MOV;
+ s=readreg(s,2);
+ d=writereg(d,2);
+ raw_mov_w_rr(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,mov_w_rr,(W2 d, R2 s))
-MIDFUNC(3,mov_l_rrm_indexed,(W4 d,R4 baser, R4 index))
+ MIDFUNC(3,mov_l_rrm_indexed,(W4 d,R4 baser, R4 index))
{
- CLOBBER_MOV;
- baser=readreg(baser,4);
- index=readreg(index,4);
- d=writereg(d,4);
+ CLOBBER_MOV;
+ baser=readreg(baser,4);
+ index=readreg(index,4);
+ d=writereg(d,4);
- raw_mov_l_rrm_indexed(d,baser,index);
- unlock(d);
- unlock(baser);
- unlock(index);
+ raw_mov_l_rrm_indexed(d,baser,index);
+ unlock(d);
+ unlock(baser);
+ unlock(index);
}
MENDFUNC(3,mov_l_rrm_indexed,(W4 d,R4 baser, R4 index))
-MIDFUNC(3,mov_w_rrm_indexed,(W2 d, R4 baser, R4 index))
+ MIDFUNC(3,mov_w_rrm_indexed,(W2 d, R4 baser, R4 index))
{
- CLOBBER_MOV;
- baser=readreg(baser,4);
- index=readreg(index,4);
- d=writereg(d,2);
+ CLOBBER_MOV;
+ baser=readreg(baser,4);
+ index=readreg(index,4);
+ d=writereg(d,2);
- raw_mov_w_rrm_indexed(d,baser,index);
- unlock(d);
- unlock(baser);
- unlock(index);
+ raw_mov_w_rrm_indexed(d,baser,index);
+ unlock(d);
+ unlock(baser);
+ unlock(index);
}
MENDFUNC(3,mov_w_rrm_indexed,(W2 d, R4 baser, R4 index))
-MIDFUNC(3,mov_b_rrm_indexed,(W1 d, R4 baser, R4 index))
+ MIDFUNC(3,mov_b_rrm_indexed,(W1 d, R4 baser, R4 index))
{
- CLOBBER_MOV;
- baser=readreg(baser,4);
- index=readreg(index,4);
- d=writereg(d,1);
+ CLOBBER_MOV;
+ baser=readreg(baser,4);
+ index=readreg(index,4);
+ d=writereg(d,1);
- raw_mov_b_rrm_indexed(d,baser,index);
+ raw_mov_b_rrm_indexed(d,baser,index);
- unlock(d);
- unlock(baser);
- unlock(index);
+ unlock(d);
+ unlock(baser);
+ unlock(index);
}
MENDFUNC(3,mov_b_rrm_indexed,(W1 d, R4 baser, R4 index))
-MIDFUNC(3,mov_l_mrr_indexed,(R4 baser, R4 index, R4 s))
+ MIDFUNC(3,mov_l_mrr_indexed,(R4 baser, R4 index, R4 s))
{
- CLOBBER_MOV;
- baser=readreg(baser,4);
- index=readreg(index,4);
- s=readreg(s,4);
+ CLOBBER_MOV;
+ baser=readreg(baser,4);
+ index=readreg(index,4);
+ s=readreg(s,4);
- Dif (baser==s || index==s)
- jit_abort (L"mov_l_mrr_indexed");
+ Dif (baser==s || index==s)
+ jit_abort (L"mov_l_mrr_indexed");
- raw_mov_l_mrr_indexed(baser,index,s);
- unlock(s);
- unlock(baser);
- unlock(index);
+ raw_mov_l_mrr_indexed(baser,index,s);
+ unlock(s);
+ unlock(baser);
+ unlock(index);
}
MENDFUNC(3,mov_l_mrr_indexed,(R4 baser, R4 index, R4 s))
-MIDFUNC(3,mov_w_mrr_indexed,(R4 baser, R4 index, R2 s))
+ MIDFUNC(3,mov_w_mrr_indexed,(R4 baser, R4 index, R2 s))
{
- CLOBBER_MOV;
- baser=readreg(baser,4);
- index=readreg(index,4);
- s=readreg(s,2);
+ CLOBBER_MOV;
+ baser=readreg(baser,4);
+ index=readreg(index,4);
+ s=readreg(s,2);
- raw_mov_w_mrr_indexed(baser,index,s);
- unlock(s);
- unlock(baser);
- unlock(index);
+ raw_mov_w_mrr_indexed(baser,index,s);
+ unlock(s);
+ unlock(baser);
+ unlock(index);
}
MENDFUNC(3,mov_w_mrr_indexed,(R4 baser, R4 index, R2 s))
-MIDFUNC(3,mov_b_mrr_indexed,(R4 baser, R4 index, R1 s))
+ MIDFUNC(3,mov_b_mrr_indexed,(R4 baser, R4 index, R1 s))
{
- CLOBBER_MOV;
- s=readreg(s,1);
- baser=readreg(baser,4);
- index=readreg(index,4);
+ CLOBBER_MOV;
+ s=readreg(s,1);
+ baser=readreg(baser,4);
+ index=readreg(index,4);
- raw_mov_b_mrr_indexed(baser,index,s);
- unlock(s);
- unlock(baser);
- unlock(index);
+ raw_mov_b_mrr_indexed(baser,index,s);
+ unlock(s);
+ unlock(baser);
+ unlock(index);
}
MENDFUNC(3,mov_b_mrr_indexed,(R4 baser, R4 index, R1 s))
-/* Read a long from base+4*index */
-MIDFUNC(3,mov_l_rm_indexed,(W4 d, IMM base, R4 index))
+ /* Read a long from base+4*index */
+ MIDFUNC(3,mov_l_rm_indexed,(W4 d, IMM base, R4 index))
{
- int indexreg=index;
+ int indexreg=index;
- if (isconst(index)) {
- COMPCALL(mov_l_rm)(d,base+4*live.state[index].val);
- return;
- }
+ if (isconst(index)) {
+ COMPCALL(mov_l_rm)(d,base+4*live.state[index].val);
+ return;
+ }
- CLOBBER_MOV;
- index=readreg_offset(index,4);
- base+=get_offset(indexreg)*4;
- d=writereg(d,4);
+ CLOBBER_MOV;
+ index=readreg_offset(index,4);
+ base+=get_offset(indexreg)*4;
+ d=writereg(d,4);
- raw_mov_l_rm_indexed(d,base,index);
- unlock(index);
- unlock(d);
+ raw_mov_l_rm_indexed(d,base,index);
+ unlock(index);
+ unlock(d);
}
MENDFUNC(3,mov_l_rm_indexed,(W4 d, IMM base, R4 index))
-/* read the long at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_l_rR,(W4 d, R4 s, IMM offset))
+ /* read the long at the address contained in s+offset and store in d */
+ MIDFUNC(3,mov_l_rR,(W4 d, R4 s, IMM offset))
{
- if (isconst(s)) {
- COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
- return;
- }
- CLOBBER_MOV;
- s=readreg(s,4);
- d=writereg(d,4);
+ if (isconst(s)) {
+ COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
+ return;
+ }
+ CLOBBER_MOV;
+ s=readreg(s,4);
+ d=writereg(d,4);
- raw_mov_l_rR(d,s,offset);
- unlock(d);
- unlock(s);
+ raw_mov_l_rR(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_l_rR,(W4 d, R4 s, IMM offset))
-/* read the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_w_rR,(W2 d, R4 s, IMM offset))
+ /* read the word at the address contained in s+offset and store in d */
+ MIDFUNC(3,mov_w_rR,(W2 d, R4 s, IMM offset))
{
- if (isconst(s)) {
- COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
- return;
- }
- CLOBBER_MOV;
- s=readreg(s,4);
- d=writereg(d,2);
+ if (isconst(s)) {
+ COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
+ return;
+ }
+ CLOBBER_MOV;
+ s=readreg(s,4);
+ d=writereg(d,2);
- raw_mov_w_rR(d,s,offset);
- unlock(d);
- unlock(s);
+ raw_mov_w_rR(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_w_rR,(W2 d, R4 s, IMM offset))
-/* read the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_b_rR,(W1 d, R4 s, IMM offset))
+ /* read the word at the address contained in s+offset and store in d */
+ MIDFUNC(3,mov_b_rR,(W1 d, R4 s, IMM offset))
{
- if (isconst(s)) {
- COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
- return;
- }
- CLOBBER_MOV;
- s=readreg(s,4);
- d=writereg(d,1);
+ if (isconst(s)) {
+ COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
+ return;
+ }
+ CLOBBER_MOV;
+ s=readreg(s,4);
+ d=writereg(d,1);
- raw_mov_b_rR(d,s,offset);
- unlock(d);
- unlock(s);
+ raw_mov_b_rR(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_b_rR,(W1 d, R4 s, IMM offset))
-/* read the long at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_l_brR,(W4 d, R4 s, IMM offset))
+ /* read the long at the address contained in s+offset and store in d */
+ MIDFUNC(3,mov_l_brR,(W4 d, R4 s, IMM offset))
{
- int sreg=s;
- if (isconst(s)) {
- COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
- return;
- }
- CLOBBER_MOV;
- s=readreg_offset(s,4);
- offset+=get_offset(sreg);
- d=writereg(d,4);
+ int sreg=s;
+ if (isconst(s)) {
+ COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
+ return;
+ }
+ CLOBBER_MOV;
+ s=readreg_offset(s,4);
+ offset+=get_offset(sreg);
+ d=writereg(d,4);
- raw_mov_l_brR(d,s,offset);
- unlock(d);
- unlock(s);
+ raw_mov_l_brR(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_l_brR,(W4 d, R4 s, IMM offset))
-/* read the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_w_brR,(W2 d, R4 s, IMM offset))
+ /* read the word at the address contained in s+offset and store in d */
+ MIDFUNC(3,mov_w_brR,(W2 d, R4 s, IMM offset))
{
- int sreg=s;
- if (isconst(s)) {
- COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
- return;
- }
- CLOBBER_MOV;
- remove_offset(d,-1);
- s=readreg_offset(s,4);
- offset+=get_offset(sreg);
- d=writereg(d,2);
+ int sreg=s;
+ if (isconst(s)) {
+ COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
+ return;
+ }
+ CLOBBER_MOV;
+ remove_offset(d,-1);
+ s=readreg_offset(s,4);
+ offset+=get_offset(sreg);
+ d=writereg(d,2);
- raw_mov_w_brR(d,s,offset);
- unlock(d);
- unlock(s);
+ raw_mov_w_brR(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_w_brR,(W2 d, R4 s, IMM offset))
-/* read the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_b_brR,(W1 d, R4 s, IMM offset))
+ /* read the word at the address contained in s+offset and store in d */
+ MIDFUNC(3,mov_b_brR,(W1 d, R4 s, IMM offset))
{
- int sreg=s;
- if (isconst(s)) {
- COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
- return;
- }
- CLOBBER_MOV;
- remove_offset(d,-1);
- s=readreg_offset(s,4);
- offset+=get_offset(sreg);
- d=writereg(d,1);
+ int sreg=s;
+ if (isconst(s)) {
+ COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
+ return;
+ }
+ CLOBBER_MOV;
+ remove_offset(d,-1);
+ s=readreg_offset(s,4);
+ offset+=get_offset(sreg);
+ d=writereg(d,1);
- raw_mov_b_brR(d,s,offset);
- unlock(d);
- unlock(s);
+ raw_mov_b_brR(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_b_brR,(W1 d, R4 s, IMM offset))
-MIDFUNC(3,mov_l_Ri,(R4 d, IMM i, IMM offset))
+ MIDFUNC(3,mov_l_Ri,(R4 d, IMM i, IMM offset))
{
- int dreg=d;
- if (isconst(d)) {
- COMPCALL(mov_l_mi)(live.state[d].val+offset,i);
- return;
- }
+ int dreg=d;
+ if (isconst(d)) {
+ COMPCALL(mov_l_mi)(live.state[d].val+offset,i);
+ return;
+ }
- CLOBBER_MOV;
- d=readreg_offset(d,4);
- offset+=get_offset(dreg);
- raw_mov_l_Ri(d,i,offset);
- unlock(d);
+ CLOBBER_MOV;
+ d=readreg_offset(d,4);
+ offset+=get_offset(dreg);
+ raw_mov_l_Ri(d,i,offset);
+ unlock(d);
}
MENDFUNC(3,mov_l_Ri,(R4 d, IMM i, IMM offset))
-MIDFUNC(3,mov_w_Ri,(R4 d, IMM i, IMM offset))
+ MIDFUNC(3,mov_w_Ri,(R4 d, IMM i, IMM offset))
{
- int dreg=d;
- if (isconst(d)) {
- COMPCALL(mov_w_mi)(live.state[d].val+offset,i);
- return;
- }
+ int dreg=d;
+ if (isconst(d)) {
+ COMPCALL(mov_w_mi)(live.state[d].val+offset,i);
+ return;
+ }
- CLOBBER_MOV;
- d=readreg_offset(d,4);
- offset+=get_offset(dreg);
- raw_mov_w_Ri(d,i,offset);
- unlock(d);
+ CLOBBER_MOV;
+ d=readreg_offset(d,4);
+ offset+=get_offset(dreg);
+ raw_mov_w_Ri(d,i,offset);
+ unlock(d);
}
MENDFUNC(3,mov_w_Ri,(R4 d, IMM i, IMM offset))
-MIDFUNC(3,mov_b_Ri,(R4 d, IMM i, IMM offset))
+ MIDFUNC(3,mov_b_Ri,(R4 d, IMM i, IMM offset))
{
- int dreg=d;
- if (isconst(d)) {
- COMPCALL(mov_b_mi)(live.state[d].val+offset,i);
- return;
- }
+ int dreg=d;
+ if (isconst(d)) {
+ COMPCALL(mov_b_mi)(live.state[d].val+offset,i);
+ return;
+ }
- CLOBBER_MOV;
- d=readreg_offset(d,4);
- offset+=get_offset(dreg);
- raw_mov_b_Ri(d,i,offset);
- unlock(d);
+ CLOBBER_MOV;
+ d=readreg_offset(d,4);
+ offset+=get_offset(dreg);
+ raw_mov_b_Ri(d,i,offset);
+ unlock(d);
}
MENDFUNC(3,mov_b_Ri,(R4 d, IMM i, IMM offset))
- /* Warning! OFFSET is byte sized only! */
-MIDFUNC(3,mov_l_Rr,(R4 d, R4 s, IMM offset))
+ /* Warning! OFFSET is byte sized only! */
+ MIDFUNC(3,mov_l_Rr,(R4 d, R4 s, IMM offset))
{
- if (isconst(d)) {
- COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
- return;
- }
- if (isconst(s)) {
- COMPCALL(mov_l_Ri)(d,live.state[s].val,offset);
- return;
- }
+ if (isconst(d)) {
+ COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
+ return;
+ }
+ if (isconst(s)) {
+ COMPCALL(mov_l_Ri)(d,live.state[s].val,offset);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,4);
- d=readreg(d,4);
+ CLOBBER_MOV;
+ s=readreg(s,4);
+ d=readreg(d,4);
- raw_mov_l_Rr(d,s,offset);
- unlock(d);
- unlock(s);
+ raw_mov_l_Rr(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_l_Rr,(R4 d, R4 s, IMM offset))
-MIDFUNC(3,mov_w_Rr,(R4 d, R2 s, IMM offset))
+ MIDFUNC(3,mov_w_Rr,(R4 d, R2 s, IMM offset))
{
- if (isconst(d)) {
- COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
- return;
- }
- if (isconst(s)) {
- COMPCALL(mov_w_Ri)(d,(uae_u16)live.state[s].val,offset);
- return;
- }
+ if (isconst(d)) {
+ COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
+ return;
+ }
+ if (isconst(s)) {
+ COMPCALL(mov_w_Ri)(d,(uae_u16)live.state[s].val,offset);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,2);
- d=readreg(d,4);
- raw_mov_w_Rr(d,s,offset);
- unlock(d);
- unlock(s);
+ CLOBBER_MOV;
+ s=readreg(s,2);
+ d=readreg(d,4);
+ raw_mov_w_Rr(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_w_Rr,(R4 d, R2 s, IMM offset))
-MIDFUNC(3,mov_b_Rr,(R4 d, R1 s, IMM offset))
+ MIDFUNC(3,mov_b_Rr,(R4 d, R1 s, IMM offset))
{
- if (isconst(d)) {
- COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
- return;
- }
- if (isconst(s)) {
- COMPCALL(mov_b_Ri)(d,(uae_u8)live.state[s].val,offset);
- return;
- }
+ if (isconst(d)) {
+ COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
+ return;
+ }
+ if (isconst(s)) {
+ COMPCALL(mov_b_Ri)(d,(uae_u8)live.state[s].val,offset);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,1);
- d=readreg(d,4);
- raw_mov_b_Rr(d,s,offset);
- unlock(d);
- unlock(s);
+ CLOBBER_MOV;
+ s=readreg(s,1);
+ d=readreg(d,4);
+ raw_mov_b_Rr(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_b_Rr,(R4 d, R1 s, IMM offset))
-MIDFUNC(3,lea_l_brr,(W4 d, R4 s, IMM offset))
+ MIDFUNC(3,lea_l_brr,(W4 d, R4 s, IMM offset))
{
- if (isconst(s)) {
- COMPCALL(mov_l_ri)(d,live.state[s].val+offset);
- return;
- }
+ if (isconst(s)) {
+ COMPCALL(mov_l_ri)(d,live.state[s].val+offset);
+ return;
+ }
#if USE_OFFSET
- if (d==s) {
- add_offset(d,offset);
- return;
- }
+ if (d==s) {
+ add_offset(d,offset);
+ return;
+ }
#endif
- CLOBBER_LEA;
- s=readreg(s,4);
- d=writereg(d,4);
- raw_lea_l_brr(d,s,offset);
- unlock(d);
- unlock(s);
+ CLOBBER_LEA;
+ s=readreg(s,4);
+ d=writereg(d,4);
+ raw_lea_l_brr(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,lea_l_brr,(W4 d, R4 s, IMM offset))
-MIDFUNC(5,lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset))
+ MIDFUNC(5,lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset))
{
- CLOBBER_LEA;
- s=readreg(s,4);
- index=readreg(index,4);
- d=writereg(d,4);
+ CLOBBER_LEA;
+ s=readreg(s,4);
+ index=readreg(index,4);
+ d=writereg(d,4);
- raw_lea_l_brr_indexed(d,s,index,factor,offset);
- unlock(d);
- unlock(index);
- unlock(s);
+ raw_lea_l_brr_indexed(d,s,index,factor,offset);
+ unlock(d);
+ unlock(index);
+ unlock(s);
}
MENDFUNC(5,lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset))
-/* write d to the long at the address contained in s+offset */
-MIDFUNC(3,mov_l_bRr,(R4 d, R4 s, IMM offset))
+ /* write d to the long at the address contained in s+offset */
+ MIDFUNC(3,mov_l_bRr,(R4 d, R4 s, IMM offset))
{
- int dreg=d;
- if (isconst(d)) {
- COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
- return;
- }
+ int dreg=d;
+ if (isconst(d)) {
+ COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,4);
- d=readreg_offset(d,4);
- offset+=get_offset(dreg);
+ CLOBBER_MOV;
+ s=readreg(s,4);
+ d=readreg_offset(d,4);
+ offset+=get_offset(dreg);
- raw_mov_l_bRr(d,s,offset);
- unlock(d);
- unlock(s);
+ raw_mov_l_bRr(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_l_bRr,(R4 d, R4 s, IMM offset))
-/* write the word at the address contained in s+offset and store in d */
-MIDFUNC(3,mov_w_bRr,(R4 d, R2 s, IMM offset))
+ /* write the word at the address contained in s+offset and store in d */
+ MIDFUNC(3,mov_w_bRr,(R4 d, R2 s, IMM offset))
{
- int dreg=d;
+ int dreg=d;
- if (isconst(d)) {
- COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
- return;
- }
+ if (isconst(d)) {
+ COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,2);
- d=readreg_offset(d,4);
- offset+=get_offset(dreg);
- raw_mov_w_bRr(d,s,offset);
- unlock(d);
- unlock(s);
+ CLOBBER_MOV;
+ s=readreg(s,2);
+ d=readreg_offset(d,4);
+ offset+=get_offset(dreg);
+ raw_mov_w_bRr(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_w_bRr,(R4 d, R2 s, IMM offset))
-MIDFUNC(3,mov_b_bRr,(R4 d, R1 s, IMM offset))
+ MIDFUNC(3,mov_b_bRr,(R4 d, R1 s, IMM offset))
{
- int dreg=d;
- if (isconst(d)) {
- COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
- return;
- }
+ int dreg=d;
+ if (isconst(d)) {
+ COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,1);
- d=readreg_offset(d,4);
- offset+=get_offset(dreg);
- raw_mov_b_bRr(d,s,offset);
- unlock(d);
- unlock(s);
+ CLOBBER_MOV;
+ s=readreg(s,1);
+ d=readreg_offset(d,4);
+ offset+=get_offset(dreg);
+ raw_mov_b_bRr(d,s,offset);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(3,mov_b_bRr,(R4 d, R1 s, IMM offset))
-MIDFUNC(1,gen_bswap_32,(RW4 r))
+ MIDFUNC(1,gen_bswap_32,(RW4 r))
{
- int reg=r;
+ int reg=r;
- if (isconst(r)) {
- uae_u32 oldv=live.state[r].val;
- live.state[r].val=reverse32(oldv);
- return;
- }
+ if (isconst(r)) {
+ uae_u32 oldv=live.state[r].val;
+ live.state[r].val=reverse32(oldv);
+ return;
+ }
- CLOBBER_SW32;
- r=rmw(r,4,4);
- raw_bswap_32(r);
- unlock(r);
+ CLOBBER_SW32;
+ r=rmw(r,4,4);
+ raw_bswap_32(r);
+ unlock(r);
}
MENDFUNC(1,gen_bswap_32,(RW4 r))
-MIDFUNC(1,gen_bswap_16,(RW2 r))
+ MIDFUNC(1,gen_bswap_16,(RW2 r))
{
- if (isconst(r)) {
- uae_u32 oldv=live.state[r].val;
- live.state[r].val=((oldv>>8)&0xff) | ((oldv<<8)&0xff00) |
- (oldv&0xffff0000);
- return;
- }
+ if (isconst(r)) {
+ uae_u32 oldv=live.state[r].val;
+ live.state[r].val=((oldv>>8)&0xff) | ((oldv<<8)&0xff00) |
+ (oldv&0xffff0000);
+ return;
+ }
- CLOBBER_SW16;
- r=rmw(r,2,2);
+ CLOBBER_SW16;
+ r=rmw(r,2,2);
- raw_bswap_16(r);
- unlock(r);
+ raw_bswap_16(r);
+ unlock(r);
}
MENDFUNC(1,gen_bswap_16,(RW2 r))
-MIDFUNC(2,mov_l_rr,(W4 d, R4 s))
+ MIDFUNC(2,mov_l_rr,(W4 d, R4 s))
{
- int olds;
+ int olds;
- if (d==s) { /* How pointless! */
- return;
- }
- if (isconst(s)) {
- COMPCALL(mov_l_ri)(d,live.state[s].val);
- return;
- }
+ if (d==s) { /* How pointless! */
+ return;
+ }
+ if (isconst(s)) {
+ COMPCALL(mov_l_ri)(d,live.state[s].val);
+ return;
+ }
#if USE_ALIAS
- olds=s;
- disassociate(d);
- s=readreg_offset(s,4);
- live.state[d].realreg=s;
- live.state[d].realind=live.nat[s].nholds;
- live.state[d].val=live.state[olds].val;
- live.state[d].validsize=4;
- live.state[d].dirtysize=4;
- set_status(d,DIRTY);
-
- live.nat[s].holds[live.nat[s].nholds]=d;
- live.nat[s].nholds++;
- log_clobberreg(d);
-
- /* write_log (L"JIT: Added %d to nreg %d(%d), now holds %d regs\n",
- d,s,live.state[d].realind,live.nat[s].nholds); */
- unlock(s);
+ olds=s;
+ disassociate(d);
+ s=readreg_offset(s,4);
+ live.state[d].realreg=s;
+ live.state[d].realind=live.nat[s].nholds;
+ live.state[d].val=live.state[olds].val;
+ live.state[d].validsize=4;
+ live.state[d].dirtysize=4;
+ set_status(d,DIRTY);
+
+ live.nat[s].holds[live.nat[s].nholds]=d;
+ live.nat[s].nholds++;
+ log_clobberreg(d);
+
+ /* write_log (L"JIT: Added %d to nreg %d(%d), now holds %d regs\n",
+ d,s,live.state[d].realind,live.nat[s].nholds); */
+ unlock(s);
#else
- CLOBBER_MOV;
- s=readreg(s,4);
- d=writereg(d,4);
+ CLOBBER_MOV;
+ s=readreg(s,4);
+ d=writereg(d,4);
- raw_mov_l_rr(d,s);
- unlock(d);
- unlock(s);
+ raw_mov_l_rr(d,s);
+ unlock(d);
+ unlock(s);
#endif
}
MENDFUNC(2,mov_l_rr,(W4 d, R4 s))
-MIDFUNC(2,mov_l_mr,(IMM d, R4 s))
+ MIDFUNC(2,mov_l_mr,(IMM d, R4 s))
{
- if (isconst(s)) {
- COMPCALL(mov_l_mi)(d,live.state[s].val);
- return;
- }
- CLOBBER_MOV;
- s=readreg(s,4);
+ if (isconst(s)) {
+ COMPCALL(mov_l_mi)(d,live.state[s].val);
+ return;
+ }
+ CLOBBER_MOV;
+ s=readreg(s,4);
- raw_mov_l_mr(d,s);
- unlock(s);
+ raw_mov_l_mr(d,s);
+ unlock(s);
}
MENDFUNC(2,mov_l_mr,(IMM d, R4 s))
-MIDFUNC(2,mov_w_mr,(IMM d, R2 s))
+ MIDFUNC(2,mov_w_mr,(IMM d, R2 s))
{
- if (isconst(s)) {
- COMPCALL(mov_w_mi)(d,(uae_u16)live.state[s].val);
- return;
- }
- CLOBBER_MOV;
- s=readreg(s,2);
+ if (isconst(s)) {
+ COMPCALL(mov_w_mi)(d,(uae_u16)live.state[s].val);
+ return;
+ }
+ CLOBBER_MOV;
+ s=readreg(s,2);
- raw_mov_w_mr(d,s);
- unlock(s);
+ raw_mov_w_mr(d,s);
+ unlock(s);
}
MENDFUNC(2,mov_w_mr,(IMM d, R2 s))
-MIDFUNC(2,mov_w_rm,(W2 d, IMM s))
+ MIDFUNC(2,mov_w_rm,(W2 d, IMM s))
{
- CLOBBER_MOV;
- d=writereg(d,2);
+ CLOBBER_MOV;
+ d=writereg(d,2);
- raw_mov_w_rm(d,s);
- unlock(d);
+ raw_mov_w_rm(d,s);
+ unlock(d);
}
MENDFUNC(2,mov_w_rm,(W2 d, IMM s))
-MIDFUNC(2,mov_b_mr,(IMM d, R1 s))
+ MIDFUNC(2,mov_b_mr,(IMM d, R1 s))
{
- if (isconst(s)) {
- COMPCALL(mov_b_mi)(d,(uae_u8)live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ COMPCALL(mov_b_mi)(d,(uae_u8)live.state[s].val);
+ return;
+ }
- CLOBBER_MOV;
- s=readreg(s,1);
+ CLOBBER_MOV;
+ s=readreg(s,1);
- raw_mov_b_mr(d,s);
- unlock(s);
+ raw_mov_b_mr(d,s);
+ unlock(s);
}
MENDFUNC(2,mov_b_mr,(IMM d, R1 s))
-MIDFUNC(2,mov_b_rm,(W1 d, IMM s))
+ MIDFUNC(2,mov_b_rm,(W1 d, IMM s))
{
- CLOBBER_MOV;
- d=writereg(d,1);
+ CLOBBER_MOV;
+ d=writereg(d,1);
- raw_mov_b_rm(d,s);
- unlock(d);
+ raw_mov_b_rm(d,s);
+ unlock(d);
}
MENDFUNC(2,mov_b_rm,(W1 d, IMM s))
-MIDFUNC(2,mov_l_ri,(W4 d, IMM s))
+ MIDFUNC(2,mov_l_ri,(W4 d, IMM s))
{
- set_const(d,s);
- return;
+ set_const(d,s);
+ return;
}
MENDFUNC(2,mov_l_ri,(W4 d, IMM s))
-MIDFUNC(2,mov_w_ri,(W2 d, IMM s))
+ MIDFUNC(2,mov_w_ri,(W2 d, IMM s))
{
- CLOBBER_MOV;
- d=writereg(d,2);
+ CLOBBER_MOV;
+ d=writereg(d,2);
- raw_mov_w_ri(d,s);
- unlock(d);
+ raw_mov_w_ri(d,s);
+ unlock(d);
}
MENDFUNC(2,mov_w_ri,(W2 d, IMM s))
-MIDFUNC(2,mov_b_ri,(W1 d, IMM s))
+ MIDFUNC(2,mov_b_ri,(W1 d, IMM s))
{
- CLOBBER_MOV;
- d=writereg(d,1);
+ CLOBBER_MOV;
+ d=writereg(d,1);
- raw_mov_b_ri(d,s);
- unlock(d);
+ raw_mov_b_ri(d,s);
+ unlock(d);
}
MENDFUNC(2,mov_b_ri,(W1 d, IMM s))
-MIDFUNC(2,add_l_mi,(IMM d, IMM s))
+ MIDFUNC(2,add_l_mi,(IMM d, IMM s))
{
- CLOBBER_ADD;
- raw_add_l_mi(d,s) ;
+ CLOBBER_ADD;
+ raw_add_l_mi(d,s) ;
}
MENDFUNC(2,add_l_mi,(IMM d, IMM s))
-MIDFUNC(2,add_w_mi,(IMM d, IMM s))
+ MIDFUNC(2,add_w_mi,(IMM d, IMM s))
{
- CLOBBER_ADD;
- raw_add_w_mi(d,s) ;
+ CLOBBER_ADD;
+ raw_add_w_mi(d,s) ;
}
MENDFUNC(2,add_w_mi,(IMM d, IMM s))
-MIDFUNC(2,add_b_mi,(IMM d, IMM s))
+ MIDFUNC(2,add_b_mi,(IMM d, IMM s))
{
- CLOBBER_ADD;
- raw_add_b_mi(d,s) ;
+ CLOBBER_ADD;
+ raw_add_b_mi(d,s) ;
}
MENDFUNC(2,add_b_mi,(IMM d, IMM s))
-MIDFUNC(2,test_l_ri,(R4 d, IMM i))
+ MIDFUNC(2,test_l_ri,(R4 d, IMM i))
{
- CLOBBER_TEST;
- d=readreg(d,4);
+ CLOBBER_TEST;
+ d=readreg(d,4);
- raw_test_l_ri(d,i);
- unlock(d);
+ raw_test_l_ri(d,i);
+ unlock(d);
}
MENDFUNC(2,test_l_ri,(R4 d, IMM i))
-MIDFUNC(2,test_l_rr,(R4 d, R4 s))
+ MIDFUNC(2,test_l_rr,(R4 d, R4 s))
{
- CLOBBER_TEST;
- d=readreg(d,4);
- s=readreg(s,4);
+ CLOBBER_TEST;
+ d=readreg(d,4);
+ s=readreg(s,4);
- raw_test_l_rr(d,s);;
- unlock(d);
- unlock(s);
+ raw_test_l_rr(d,s);;
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,test_l_rr,(R4 d, R4 s))
-MIDFUNC(2,test_w_rr,(R2 d, R2 s))
+ MIDFUNC(2,test_w_rr,(R2 d, R2 s))
{
- CLOBBER_TEST;
- d=readreg(d,2);
- s=readreg(s,2);
+ CLOBBER_TEST;
+ d=readreg(d,2);
+ s=readreg(s,2);
- raw_test_w_rr(d,s);
- unlock(d);
- unlock(s);
+ raw_test_w_rr(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,test_w_rr,(R2 d, R2 s))
-MIDFUNC(2,test_b_rr,(R1 d, R1 s))
+ MIDFUNC(2,test_b_rr,(R1 d, R1 s))
{
- CLOBBER_TEST;
- d=readreg(d,1);
- s=readreg(s,1);
+ CLOBBER_TEST;
+ d=readreg(d,1);
+ s=readreg(s,1);
- raw_test_b_rr(d,s);
- unlock(d);
- unlock(s);
+ raw_test_b_rr(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,test_b_rr,(R1 d, R1 s))
-MIDFUNC(2,and_l_ri,(RW4 d, IMM i))
+ MIDFUNC(2,and_l_ri,(RW4 d, IMM i))
{
- if (isconst (d) && ! needflags) {
- live.state[d].val &= i;
- return;
- }
+ if (isconst (d) && ! needflags) {
+ live.state[d].val &= i;
+ return;
+ }
- CLOBBER_AND;
- d=rmw(d,4,4);
+ CLOBBER_AND;
+ d=rmw(d,4,4);
- raw_and_l_ri(d,i);
- unlock(d);
+ raw_and_l_ri(d,i);
+ unlock(d);
}
MENDFUNC(2,and_l_ri,(RW4 d, IMM i))
-MIDFUNC(2,and_l,(RW4 d, R4 s))
+ MIDFUNC(2,and_l,(RW4 d, R4 s))
{
- CLOBBER_AND;
- s=readreg(s,4);
- d=rmw(d,4,4);
+ CLOBBER_AND;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
- raw_and_l(d,s);
- unlock(d);
- unlock(s);
+ raw_and_l(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,and_l,(RW4 d, R4 s))
-MIDFUNC(2,and_w,(RW2 d, R2 s))
+ MIDFUNC(2,and_w,(RW2 d, R2 s))
{
- CLOBBER_AND;
- s=readreg(s,2);
- d=rmw(d,2,2);
+ CLOBBER_AND;
+ s=readreg(s,2);
+ d=rmw(d,2,2);
- raw_and_w(d,s);
- unlock(d);
- unlock(s);
+ raw_and_w(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,and_w,(RW2 d, R2 s))
-MIDFUNC(2,and_b,(RW1 d, R1 s))
+ MIDFUNC(2,and_b,(RW1 d, R1 s))
{
- CLOBBER_AND;
- s=readreg(s,1);
- d=rmw(d,1,1);
+ CLOBBER_AND;
+ s=readreg(s,1);
+ d=rmw(d,1,1);
- raw_and_b(d,s);
- unlock(d);
- unlock(s);
+ raw_and_b(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,and_b,(RW1 d, R1 s))
-MIDFUNC(2,or_l_ri,(RW4 d, IMM i))
+ MIDFUNC(2,or_l_ri,(RW4 d, IMM i))
{
- if (isconst(d) && !needflags) {
- live.state[d].val|=i;
- return;
- }
- CLOBBER_OR;
- d=rmw(d,4,4);
+ if (isconst(d) && !needflags) {
+ live.state[d].val|=i;
+ return;
+ }
+ CLOBBER_OR;
+ d=rmw(d,4,4);
- raw_or_l_ri(d,i);
- unlock(d);
+ raw_or_l_ri(d,i);
+ unlock(d);
}
MENDFUNC(2,or_l_ri,(RW4 d, IMM i))
-MIDFUNC(2,or_l,(RW4 d, R4 s))
+ MIDFUNC(2,or_l,(RW4 d, R4 s))
{
- if (isconst(d) && isconst(s) && !needflags) {
- live.state[d].val|=live.state[s].val;
- return;
- }
- CLOBBER_OR;
- s=readreg(s,4);
- d=rmw(d,4,4);
+ if (isconst(d) && isconst(s) && !needflags) {
+ live.state[d].val|=live.state[s].val;
+ return;
+ }
+ CLOBBER_OR;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
- raw_or_l(d,s);
- unlock(d);
- unlock(s);
+ raw_or_l(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,or_l,(RW4 d, R4 s))
-MIDFUNC(2,or_w,(RW2 d, R2 s))
+ MIDFUNC(2,or_w,(RW2 d, R2 s))
{
- CLOBBER_OR;
- s=readreg(s,2);
- d=rmw(d,2,2);
+ CLOBBER_OR;
+ s=readreg(s,2);
+ d=rmw(d,2,2);
- raw_or_w(d,s);
- unlock(d);
- unlock(s);
+ raw_or_w(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,or_w,(RW2 d, R2 s))
-MIDFUNC(2,or_b,(RW1 d, R1 s))
+ MIDFUNC(2,or_b,(RW1 d, R1 s))
{
- CLOBBER_OR;
- s=readreg(s,1);
- d=rmw(d,1,1);
+ CLOBBER_OR;
+ s=readreg(s,1);
+ d=rmw(d,1,1);
- raw_or_b(d,s);
- unlock(d);
- unlock(s);
+ raw_or_b(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,or_b,(RW1 d, R1 s))
-MIDFUNC(2,adc_l,(RW4 d, R4 s))
+ MIDFUNC(2,adc_l,(RW4 d, R4 s))
{
- CLOBBER_ADC;
- s=readreg(s,4);
- d=rmw(d,4,4);
+ CLOBBER_ADC;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
- raw_adc_l(d,s);
+ raw_adc_l(d,s);
- unlock(d);
- unlock(s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,adc_l,(RW4 d, R4 s))
-MIDFUNC(2,adc_w,(RW2 d, R2 s))
+ MIDFUNC(2,adc_w,(RW2 d, R2 s))
{
- CLOBBER_ADC;
- s=readreg(s,2);
- d=rmw(d,2,2);
+ CLOBBER_ADC;
+ s=readreg(s,2);
+ d=rmw(d,2,2);
- raw_adc_w(d,s);
- unlock(d);
- unlock(s);
+ raw_adc_w(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,adc_w,(RW2 d, R2 s))
-MIDFUNC(2,adc_b,(RW1 d, R1 s))
+ MIDFUNC(2,adc_b,(RW1 d, R1 s))
{
- CLOBBER_ADC;
- s=readreg(s,1);
- d=rmw(d,1,1);
+ CLOBBER_ADC;
+ s=readreg(s,1);
+ d=rmw(d,1,1);
- raw_adc_b(d,s);
- unlock(d);
- unlock(s);
+ raw_adc_b(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,adc_b,(RW1 d, R1 s))
-MIDFUNC(2,add_l,(RW4 d, R4 s))
+ MIDFUNC(2,add_l,(RW4 d, R4 s))
{
- if (isconst(s)) {
- COMPCALL(add_l_ri)(d,live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ COMPCALL(add_l_ri)(d,live.state[s].val);
+ return;
+ }
- CLOBBER_ADD;
- s=readreg(s,4);
- d=rmw(d,4,4);
+ CLOBBER_ADD;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
- raw_add_l(d,s);
+ raw_add_l(d,s);
- unlock(d);
- unlock(s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,add_l,(RW4 d, R4 s))
-MIDFUNC(2,add_w,(RW2 d, R2 s))
+ MIDFUNC(2,add_w,(RW2 d, R2 s))
{
- if (isconst(s)) {
- COMPCALL(add_w_ri)(d,(uae_u16)live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ COMPCALL(add_w_ri)(d,(uae_u16)live.state[s].val);
+ return;
+ }
- CLOBBER_ADD;
- s=readreg(s,2);
- d=rmw(d,2,2);
+ CLOBBER_ADD;
+ s=readreg(s,2);
+ d=rmw(d,2,2);
- raw_add_w(d,s);
- unlock(d);
- unlock(s);
+ raw_add_w(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,add_w,(RW2 d, R2 s))
-MIDFUNC(2,add_b,(RW1 d, R1 s))
+ MIDFUNC(2,add_b,(RW1 d, R1 s))
{
- if (isconst(s)) {
- COMPCALL(add_b_ri)(d,(uae_u8)live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ COMPCALL(add_b_ri)(d,(uae_u8)live.state[s].val);
+ return;
+ }
- CLOBBER_ADD;
- s=readreg(s,1);
- d=rmw(d,1,1);
+ CLOBBER_ADD;
+ s=readreg(s,1);
+ d=rmw(d,1,1);
- raw_add_b(d,s);
- unlock(d);
- unlock(s);
+ raw_add_b(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,add_b,(RW1 d, R1 s))
-MIDFUNC(2,sub_l_ri,(RW4 d, IMM i))
+ MIDFUNC(2,sub_l_ri,(RW4 d, IMM i))
{
- if (!i && !needflags)
- return;
- if (isconst(d) && !needflags) {
- live.state[d].val-=i;
- return;
- }
+ if (!i && !needflags)
+ return;
+ if (isconst(d) && !needflags) {
+ live.state[d].val-=i;
+ return;
+ }
#if USE_OFFSET
- if (!needflags) {
- add_offset(d,-(signed)i);
- return;
- }
+ if (!needflags) {
+ add_offset(d,-(signed)i);
+ return;
+ }
#endif
- CLOBBER_SUB;
- d=rmw(d,4,4);
+ CLOBBER_SUB;
+ d=rmw(d,4,4);
- raw_sub_l_ri(d,i);
- unlock(d);
+ raw_sub_l_ri(d,i);
+ unlock(d);
}
MENDFUNC(2,sub_l_ri,(RW4 d, IMM i))
-MIDFUNC(2,sub_w_ri,(RW2 d, IMM i))
+ MIDFUNC(2,sub_w_ri,(RW2 d, IMM i))
{
- if (!i && !needflags)
- return;
+ if (!i && !needflags)
+ return;
- CLOBBER_SUB;
- d=rmw(d,2,2);
+ CLOBBER_SUB;
+ d=rmw(d,2,2);
- raw_sub_w_ri(d,i);
- unlock(d);
+ raw_sub_w_ri(d,i);
+ unlock(d);
}
MENDFUNC(2,sub_w_ri,(RW2 d, IMM i))
-MIDFUNC(2,sub_b_ri,(RW1 d, IMM i))
+ MIDFUNC(2,sub_b_ri,(RW1 d, IMM i))
{
- if (!i && !needflags)
- return;
+ if (!i && !needflags)
+ return;
- CLOBBER_SUB;
- d=rmw(d,1,1);
+ CLOBBER_SUB;
+ d=rmw(d,1,1);
- raw_sub_b_ri(d,i);
+ raw_sub_b_ri(d,i);
- unlock(d);
+ unlock(d);
}
MENDFUNC(2,sub_b_ri,(RW1 d, IMM i))
-MIDFUNC(2,add_l_ri,(RW4 d, IMM i))
+ MIDFUNC(2,add_l_ri,(RW4 d, IMM i))
{
- if (!i && !needflags)
- return;
- if (isconst(d) && !needflags) {
- live.state[d].val+=i;
- return;
- }
+ if (!i && !needflags)
+ return;
+ if (isconst(d) && !needflags) {
+ live.state[d].val+=i;
+ return;
+ }
#if USE_OFFSET
- if (!needflags) {
- add_offset(d,i);
- return;
- }
+ if (!needflags) {
+ add_offset(d,i);
+ return;
+ }
#endif
- CLOBBER_ADD;
- d=rmw(d,4,4);
- raw_add_l_ri(d,i);
- unlock(d);
+ CLOBBER_ADD;
+ d=rmw(d,4,4);
+ raw_add_l_ri(d,i);
+ unlock(d);
}
MENDFUNC(2,add_l_ri,(RW4 d, IMM i))
-MIDFUNC(2,add_w_ri,(RW2 d, IMM i))
+ MIDFUNC(2,add_w_ri,(RW2 d, IMM i))
{
- if (!i && !needflags)
- return;
+ if (!i && !needflags)
+ return;
- CLOBBER_ADD;
- d=rmw(d,2,2);
+ CLOBBER_ADD;
+ d=rmw(d,2,2);
- raw_add_w_ri(d,i);
- unlock(d);
+ raw_add_w_ri(d,i);
+ unlock(d);
}
MENDFUNC(2,add_w_ri,(RW2 d, IMM i))
-MIDFUNC(2,add_b_ri,(RW1 d, IMM i))
+ MIDFUNC(2,add_b_ri,(RW1 d, IMM i))
{
- if (!i && !needflags)
- return;
+ if (!i && !needflags)
+ return;
- CLOBBER_ADD;
- d=rmw(d,1,1);
+ CLOBBER_ADD;
+ d=rmw(d,1,1);
- raw_add_b_ri(d,i);
+ raw_add_b_ri(d,i);
- unlock(d);
+ unlock(d);
}
MENDFUNC(2,add_b_ri,(RW1 d, IMM i))
-MIDFUNC(2,sbb_l,(RW4 d, R4 s))
+ MIDFUNC(2,sbb_l,(RW4 d, R4 s))
{
- CLOBBER_SBB;
- s=readreg(s,4);
- d=rmw(d,4,4);
+ CLOBBER_SBB;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
- raw_sbb_l(d,s);
- unlock(d);
- unlock(s);
+ raw_sbb_l(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,sbb_l,(RW4 d, R4 s))
-MIDFUNC(2,sbb_w,(RW2 d, R2 s))
+ MIDFUNC(2,sbb_w,(RW2 d, R2 s))
{
- CLOBBER_SBB;
- s=readreg(s,2);
- d=rmw(d,2,2);
+ CLOBBER_SBB;
+ s=readreg(s,2);
+ d=rmw(d,2,2);
- raw_sbb_w(d,s);
- unlock(d);
- unlock(s);
+ raw_sbb_w(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,sbb_w,(RW2 d, R2 s))
-MIDFUNC(2,sbb_b,(RW1 d, R1 s))
+ MIDFUNC(2,sbb_b,(RW1 d, R1 s))
{
- CLOBBER_SBB;
- s=readreg(s,1);
- d=rmw(d,1,1);
+ CLOBBER_SBB;
+ s=readreg(s,1);
+ d=rmw(d,1,1);
- raw_sbb_b(d,s);
- unlock(d);
- unlock(s);
+ raw_sbb_b(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,sbb_b,(RW1 d, R1 s))
-MIDFUNC(2,sub_l,(RW4 d, R4 s))
+ MIDFUNC(2,sub_l,(RW4 d, R4 s))
{
- if (isconst(s)) {
- COMPCALL(sub_l_ri)(d,live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ COMPCALL(sub_l_ri)(d,live.state[s].val);
+ return;
+ }
- CLOBBER_SUB;
- s=readreg(s,4);
- d=rmw(d,4,4);
+ CLOBBER_SUB;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
- raw_sub_l(d,s);
- unlock(d);
- unlock(s);
+ raw_sub_l(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,sub_l,(RW4 d, R4 s))
-MIDFUNC(2,sub_w,(RW2 d, R2 s))
+ MIDFUNC(2,sub_w,(RW2 d, R2 s))
{
- if (isconst(s)) {
- COMPCALL(sub_w_ri)(d,(uae_u16)live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ COMPCALL(sub_w_ri)(d,(uae_u16)live.state[s].val);
+ return;
+ }
- CLOBBER_SUB;
- s=readreg(s,2);
- d=rmw(d,2,2);
+ CLOBBER_SUB;
+ s=readreg(s,2);
+ d=rmw(d,2,2);
- raw_sub_w(d,s);
- unlock(d);
- unlock(s);
+ raw_sub_w(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,sub_w,(RW2 d, R2 s))
-MIDFUNC(2,sub_b,(RW1 d, R1 s))
+ MIDFUNC(2,sub_b,(RW1 d, R1 s))
{
- if (isconst(s)) {
- COMPCALL(sub_b_ri)(d,(uae_u8)live.state[s].val);
- return;
- }
+ if (isconst(s)) {
+ COMPCALL(sub_b_ri)(d,(uae_u8)live.state[s].val);
+ return;
+ }
- CLOBBER_SUB;
- s=readreg(s,1);
- d=rmw(d,1,1);
+ CLOBBER_SUB;
+ s=readreg(s,1);
+ d=rmw(d,1,1);
- raw_sub_b(d,s);
- unlock(d);
- unlock(s);
+ raw_sub_b(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,sub_b,(RW1 d, R1 s))
-MIDFUNC(2,cmp_l,(R4 d, R4 s))
+ MIDFUNC(2,cmp_l,(R4 d, R4 s))
{
- CLOBBER_CMP;
- s=readreg(s,4);
- d=readreg(d,4);
+ CLOBBER_CMP;
+ s=readreg(s,4);
+ d=readreg(d,4);
- raw_cmp_l(d,s);
- unlock(d);
- unlock(s);
+ raw_cmp_l(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,cmp_l,(R4 d, R4 s))
-MIDFUNC(2,cmp_l_ri,(R4 r, IMM i))
+ MIDFUNC(2,cmp_l_ri,(R4 r, IMM i))
{
- CLOBBER_CMP;
- r=readreg(r,4);
+ CLOBBER_CMP;
+ r=readreg(r,4);
- raw_cmp_l_ri(r,i);
- unlock(r);
+ raw_cmp_l_ri(r,i);
+ unlock(r);
}
MENDFUNC(2,cmp_l_ri,(R4 r, IMM i))
-MIDFUNC(2,cmp_w,(R2 d, R2 s))
+ MIDFUNC(2,cmp_w,(R2 d, R2 s))
{
- CLOBBER_CMP;
- s=readreg(s,2);
- d=readreg(d,2);
+ CLOBBER_CMP;
+ s=readreg(s,2);
+ d=readreg(d,2);
- raw_cmp_w(d,s);
- unlock(d);
- unlock(s);
+ raw_cmp_w(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,cmp_w,(R2 d, R2 s))
-MIDFUNC(2,cmp_b,(R1 d, R1 s))
+ MIDFUNC(2,cmp_b,(R1 d, R1 s))
{
- CLOBBER_CMP;
- s=readreg(s,1);
- d=readreg(d,1);
+ CLOBBER_CMP;
+ s=readreg(s,1);
+ d=readreg(d,1);
- raw_cmp_b(d,s);
- unlock(d);
- unlock(s);
+ raw_cmp_b(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,cmp_b,(R1 d, R1 s))
-MIDFUNC(2,xor_l,(RW4 d, R4 s))
+ MIDFUNC(2,xor_l,(RW4 d, R4 s))
{
- CLOBBER_XOR;
- s=readreg(s,4);
- d=rmw(d,4,4);
+ CLOBBER_XOR;
+ s=readreg(s,4);
+ d=rmw(d,4,4);
- raw_xor_l(d,s);
- unlock(d);
- unlock(s);
+ raw_xor_l(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,xor_l,(RW4 d, R4 s))
-MIDFUNC(2,xor_w,(RW2 d, R2 s))
+ MIDFUNC(2,xor_w,(RW2 d, R2 s))
{
- CLOBBER_XOR;
- s=readreg(s,2);
- d=rmw(d,2,2);
+ CLOBBER_XOR;
+ s=readreg(s,2);
+ d=rmw(d,2,2);
- raw_xor_w(d,s);
- unlock(d);
- unlock(s);
+ raw_xor_w(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,xor_w,(RW2 d, R2 s))
-MIDFUNC(2,xor_b,(RW1 d, R1 s))
+ MIDFUNC(2,xor_b,(RW1 d, R1 s))
{
- CLOBBER_XOR;
- s=readreg(s,1);
- d=rmw(d,1,1);
+ CLOBBER_XOR;
+ s=readreg(s,1);
+ d=rmw(d,1,1);
- raw_xor_b(d,s);
- unlock(d);
- unlock(s);
+ raw_xor_b(d,s);
+ unlock(d);
+ unlock(s);
}
MENDFUNC(2,xor_b,(RW1 d, R1 s))
-MIDFUNC(5,call_r_11,(W4 out1, R4 r, R4 in1, IMM osize, IMM isize))
+ MIDFUNC(5,call_r_11,(W4 out1, R4 r, R4 in1, IMM osize, IMM isize))
{
- clobber_flags();
- remove_all_offsets();
- if (osize==4) {
- if (out1!=in1 && out1!=r) {
- COMPCALL(forget_about)(out1);
+ clobber_flags();
+ remove_all_offsets();
+ if (osize==4) {
+ if (out1!=in1 && out1!=r) {
+ COMPCALL(forget_about)(out1);
+ }
+ }
+ else {
+ tomem_c(out1);
}
- }
- else {
- tomem_c(out1);
- }
- in1=readreg_specific(in1,isize,REG_PAR1);
- r=readreg(r,4);
- prepare_for_call_1(); /* This should ensure that there won't be
- any need for swapping nregs in prepare_for_call_2
- */
+ in1=readreg_specific(in1,isize,REG_PAR1);
+ r=readreg(r,4);
+ prepare_for_call_1(); /* This should ensure that there won't be
+ any need for swapping nregs in prepare_for_call_2
+ */
#if USE_NORMAL_CALLING_CONVENTION
- raw_push_l_r(in1);
+ raw_push_l_r(in1);
#endif
- unlock(in1);
- unlock(r);
+ unlock(in1);
+ unlock(r);
- prepare_for_call_2();
- raw_call_r(r);
+ prepare_for_call_2();
+ raw_call_r(r);
#if USE_NORMAL_CALLING_CONVENTION
- raw_inc_sp(4);
+ raw_inc_sp(4);
#endif
- live.nat[REG_RESULT].holds[0]=out1;
- live.nat[REG_RESULT].nholds=1;
- live.nat[REG_RESULT].touched=touchcnt++;
+ live.nat[REG_RESULT].holds[0]=out1;
+ live.nat[REG_RESULT].nholds=1;
+ live.nat[REG_RESULT].touched=touchcnt++;
- live.state[out1].realreg=REG_RESULT;
- live.state[out1].realind=0;
- live.state[out1].val=0;
- live.state[out1].validsize=osize;
- live.state[out1].dirtysize=osize;
- set_status(out1,DIRTY);
+ live.state[out1].realreg=REG_RESULT;
+ live.state[out1].realind=0;
+ live.state[out1].val=0;
+ live.state[out1].validsize=osize;
+ live.state[out1].dirtysize=osize;
+ set_status(out1,DIRTY);
}
MENDFUNC(5,call_r_11,(W4 out1, R4 r, R4 in1, IMM osize, IMM isize))
-MIDFUNC(5,call_r_02,(R4 r, R4 in1, R4 in2, IMM isize1, IMM isize2))
+ MIDFUNC(5,call_r_02,(R4 r, R4 in1, R4 in2, IMM isize1, IMM isize2))
{
- clobber_flags();
- remove_all_offsets();
- in1=readreg_specific(in1,isize1,REG_PAR1);
- in2=readreg_specific(in2,isize2,REG_PAR2);
- r=readreg(r,4);
- prepare_for_call_1(); /* This should ensure that there won't be
- any need for swapping nregs in prepare_for_call_2
- */
+ clobber_flags();
+ remove_all_offsets();
+ in1=readreg_specific(in1,isize1,REG_PAR1);
+ in2=readreg_specific(in2,isize2,REG_PAR2);
+ r=readreg(r,4);
+ prepare_for_call_1(); /* This should ensure that there won't be
+ any need for swapping nregs in prepare_for_call_2
+ */
#if USE_NORMAL_CALLING_CONVENTION
- raw_push_l_r(in2);
- raw_push_l_r(in1);
+ raw_push_l_r(in2);
+ raw_push_l_r(in1);
#endif
- unlock(r);
- unlock(in1);
- unlock(in2);
- prepare_for_call_2();
- raw_call_r(r);
+ unlock(r);
+ unlock(in1);
+ unlock(in2);
+ prepare_for_call_2();
+ raw_call_r(r);
#if USE_NORMAL_CALLING_CONVENTION
- raw_inc_sp(8);
+ raw_inc_sp(8);
#endif
}
MENDFUNC(5,call_r_02,(R4 r, R4 in1, R4 in2, IMM isize1, IMM isize2))
-MIDFUNC(1,forget_about,(W4 r))
+ MIDFUNC(1,forget_about,(W4 r))
{
- if (isinreg(r))
- disassociate(r);
- live.state[r].val=0;
- set_status(r,UNDEF);
+ if (isinreg(r))
+ disassociate(r);
+ live.state[r].val=0;
+ set_status(r,UNDEF);
}
MENDFUNC(1,forget_about,(W4 r))
-MIDFUNC(0,nop,(void))
+ MIDFUNC(0,nop,(void))
{
- raw_nop();
+ raw_nop();
}
MENDFUNC(0,nop,(void))
-MIDFUNC(1,f_forget_about,(FW r))
+ MIDFUNC(1,f_forget_about,(FW r))
{
- if (f_isinreg(r))
- f_disassociate(r);
- live.fate[r].status=UNDEF;
+ if (f_isinreg(r))
+ f_disassociate(r);
+ live.fate[r].status=UNDEF;
}
MENDFUNC(1,f_forget_about,(FW r))
-MIDFUNC(1,fmov_pi,(FW r))
+ MIDFUNC(1,fmov_pi,(FW r))
{
- r=f_writereg(r);
- raw_fmov_pi(r);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_pi(r);
+ f_unlock(r);
}
MENDFUNC(1,fmov_pi,(FW r))
-MIDFUNC(1,fmov_log10_2,(FW r))
+ MIDFUNC(1,fmov_log10_2,(FW r))
{
- r=f_writereg(r);
- raw_fmov_log10_2(r);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_log10_2(r);
+ f_unlock(r);
}
MENDFUNC(1,fmov_log10_2,(FW r))
-MIDFUNC(1,fmov_log2_e,(FW r))
+ MIDFUNC(1,fmov_log2_e,(FW r))
{
- r=f_writereg(r);
- raw_fmov_log2_e(r);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_log2_e(r);
+ f_unlock(r);
}
MENDFUNC(1,fmov_log2_e,(FW r))
-MIDFUNC(1,fmov_loge_2,(FW r))
+ MIDFUNC(1,fmov_loge_2,(FW r))
{
- r=f_writereg(r);
- raw_fmov_loge_2(r);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_loge_2(r);
+ f_unlock(r);
}
MENDFUNC(1,fmov_loge_2,(FW r))
-MIDFUNC(1,fmov_1,(FW r))
+ MIDFUNC(1,fmov_1,(FW r))
{
- r=f_writereg(r);
- raw_fmov_1(r);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_1(r);
+ f_unlock(r);
}
MENDFUNC(1,fmov_1,(FW r))
-MIDFUNC(1,fmov_0,(FW r))
+ MIDFUNC(1,fmov_0,(FW r))
{
- r=f_writereg(r);
- raw_fmov_0(r);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_0(r);
+ f_unlock(r);
}
MENDFUNC(1,fmov_0,(FW r))
-MIDFUNC(2,fmov_rm,(FW r, MEMR m))
+ MIDFUNC(2,fmov_rm,(FW r, MEMR m))
{
- r=f_writereg(r);
- raw_fmov_rm(r,m);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_rm(r,m);
+ f_unlock(r);
}
MENDFUNC(2,fmov_rm,(FW r, MEMR m))
-MIDFUNC(2,fmovi_rm,(FW r, MEMR m))
+ MIDFUNC(2,fmovi_rm,(FW r, MEMR m))
{
- r=f_writereg(r);
- raw_fmovi_rm(r,m);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmovi_rm(r,m);
+ f_unlock(r);
}
MENDFUNC(2,fmovi_rm,(FW r, MEMR m))
-MIDFUNC(3,fmovi_mrb,(MEMW m, FR r, double *bounds))
+ MIDFUNC(3,fmovi_mrb,(MEMW m, FR r, double *bounds))
{
- r=f_readreg(r);
- raw_fmovi_mrb(m,r,bounds);
- f_unlock(r);
+ r=f_readreg(r);
+ raw_fmovi_mrb(m,r,bounds);
+ f_unlock(r);
}
MENDFUNC(3,fmovi_mrb,(MEMW m, FR r, double *bounds))
-MIDFUNC(2,fmovs_rm,(FW r, MEMR m))
+ MIDFUNC(2,fmovs_rm,(FW r, MEMR m))
{
- r=f_writereg(r);
- raw_fmovs_rm(r,m);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmovs_rm(r,m);
+ f_unlock(r);
}
MENDFUNC(2,fmovs_rm,(FW r, MEMR m))
-MIDFUNC(2,fmovs_mr,(MEMW m, FR r))
+ MIDFUNC(2,fmovs_mr,(MEMW m, FR r))
{
- r=f_readreg(r);
- raw_fmovs_mr(m,r);
- f_unlock(r);
+ r=f_readreg(r);
+ raw_fmovs_mr(m,r);
+ f_unlock(r);
}
MENDFUNC(2,fmovs_mr,(MEMW m, FR r))
-MIDFUNC(1,fcuts_r,(FRW r))
+ MIDFUNC(1,fcuts_r,(FRW r))
{
- r=f_rmw(r);
- raw_fcuts_r(r);
- f_unlock(r);
+ r=f_rmw(r);
+ raw_fcuts_r(r);
+ f_unlock(r);
}
MENDFUNC(1,fcuts_r,(FRW r))
-MIDFUNC(1,fcut_r,(FRW r))
+ MIDFUNC(1,fcut_r,(FRW r))
{
- r=f_rmw(r);
- raw_fcut_r(r);
- f_unlock(r);
+ r=f_rmw(r);
+ raw_fcut_r(r);
+ f_unlock(r);
}
MENDFUNC(1,fcut_r,(FRW r))
-MIDFUNC(2,fmovl_ri,(FW r, IMMS i))
+ MIDFUNC(2,fmovl_ri,(FW r, IMMS i))
{
- r=f_writereg(r);
- raw_fmovl_ri(r,i);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmovl_ri(r,i);
+ f_unlock(r);
}
MENDFUNC(2,fmovl_ri,(FW r, IMMS i))
-MIDFUNC(2,fmovs_ri,(FW r, IMM i))
+ MIDFUNC(2,fmovs_ri,(FW r, IMM i))
{
- r=f_writereg(r);
- raw_fmovs_ri(r,i);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmovs_ri(r,i);
+ f_unlock(r);
}
MENDFUNC(2,fmovs_ri,(FW r, IMM i))
-MIDFUNC(3,fmov_ri,(FW r, IMM i1, IMM i2))
+ MIDFUNC(3,fmov_ri,(FW r, IMM i1, IMM i2))
{
- r=f_writereg(r);
- raw_fmov_ri(r,i1,i2);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_ri(r,i1,i2);
+ f_unlock(r);
}
MENDFUNC(3,fmov_ri,(FW r, IMM i1, IMM i2))
-MIDFUNC(4,fmov_ext_ri,(FW r, IMM i1, IMM i2, IMM i3))
+ MIDFUNC(4,fmov_ext_ri,(FW r, IMM i1, IMM i2, IMM i3))
{
- r=f_writereg(r);
- raw_fmov_ext_ri(r,i1,i2,i3);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_ext_ri(r,i1,i2,i3);
+ f_unlock(r);
}
MENDFUNC(4,fmov_ext_ri,(FW r, IMM i1, IMM i2, IMM i3))
-MIDFUNC(2,fmov_ext_mr,(MEMW m, FR r))
+ MIDFUNC(2,fmov_ext_mr,(MEMW m, FR r))
{
- r=f_readreg(r);
- raw_fmov_ext_mr(m,r);
- f_unlock(r);
+ r=f_readreg(r);
+ raw_fmov_ext_mr(m,r);
+ f_unlock(r);
}
MENDFUNC(2,fmov_ext_mr,(MEMW m, FR r))
-MIDFUNC(2,fmov_mr,(MEMW m, FR r))
+ MIDFUNC(2,fmov_mr,(MEMW m, FR r))
{
- r=f_readreg(r);
- raw_fmov_mr(m,r);
- f_unlock(r);
+ r=f_readreg(r);
+ raw_fmov_mr(m,r);
+ f_unlock(r);
}
MENDFUNC(2,fmov_mr,(MEMW m, FR r))
-MIDFUNC(2,fmov_ext_rm,(FW r, MEMR m))
+ MIDFUNC(2,fmov_ext_rm,(FW r, MEMR m))
{
- r=f_writereg(r);
- raw_fmov_ext_rm(r,m);
- f_unlock(r);
+ r=f_writereg(r);
+ raw_fmov_ext_rm(r,m);
+ f_unlock(r);
}
MENDFUNC(2,fmov_ext_rm,(FW r, MEMR m))
-MIDFUNC(2,fmov_rr,(FW d, FR s))
+ MIDFUNC(2,fmov_rr,(FW d, FR s))
{
- if (d==s) { /* How pointless! */
- return;
- }
+ if (d==s) { /* How pointless! */
+ return;
+ }
#if USE_F_ALIAS
- f_disassociate(d);
- s=f_readreg(s);
- live.fate[d].realreg=s;
- live.fate[d].realind=live.fat[s].nholds;
- live.fate[d].status=DIRTY;
- live.fat[s].holds[live.fat[s].nholds]=d;
- live.fat[s].nholds++;
- f_unlock(s);
+ f_disassociate(d);
+ s=f_readreg(s);
+ live.fate[d].realreg=s;
+ live.fate[d].realind=live.fat[s].nholds;
+ live.fate[d].status=DIRTY;
+ live.fat[s].holds[live.fat[s].nholds]=d;
+ live.fat[s].nholds++;
+ f_unlock(s);
#else
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fmov_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fmov_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
#endif
}
MENDFUNC(2,fmov_rr,(FW d, FR s))
-MIDFUNC(2,fldcw_m_indexed,(R4 index, IMM base))
+ MIDFUNC(2,fldcw_m_indexed,(R4 index, IMM base))
{
- index=readreg(index,4);
+ index=readreg(index,4);
- raw_fldcw_m_indexed(index,base);
- unlock(index);
+ raw_fldcw_m_indexed(index,base);
+ unlock(index);
}
MENDFUNC(2,fldcw_m_indexed,(R4 index, IMM base))
-MIDFUNC(1,ftst_r,(FR r))
+ MIDFUNC(1,ftst_r,(FR r))
{
- r=f_readreg(r);
- raw_ftst_r(r);
- f_unlock(r);
+ r=f_readreg(r);
+ raw_ftst_r(r);
+ f_unlock(r);
}
MENDFUNC(1,ftst_r,(FR r))
-MIDFUNC(0,dont_care_fflags,(void))
+ MIDFUNC(0,dont_care_fflags,(void))
{
- f_disassociate(FP_RESULT);
+ f_disassociate(FP_RESULT);
}
MENDFUNC(0,dont_care_fflags,(void))
-MIDFUNC(2,fsqrt_rr,(FW d, FR s))
+ MIDFUNC(2,fsqrt_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fsqrt_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fsqrt_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fsqrt_rr,(FW d, FR s))
-MIDFUNC(2,fabs_rr,(FW d, FR s))
+ MIDFUNC(2,fabs_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fabs_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fabs_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fabs_rr,(FW d, FR s))
-MIDFUNC(2,frndint_rr,(FW d, FR s))
+ MIDFUNC(2,frndint_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_frndint_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_frndint_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,frndint_rr,(FW d, FR s))
-MIDFUNC(2,fgetexp_rr,(FW d, FR s))
+ MIDFUNC(2,fgetexp_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fgetexp_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fgetexp_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fgetexp_rr,(FW d, FR s))
-MIDFUNC(2,fgetman_rr,(FW d, FR s))
+ MIDFUNC(2,fgetman_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fgetman_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fgetman_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fgetman_rr,(FW d, FR s))
-MIDFUNC(2,fsin_rr,(FW d, FR s))
+ MIDFUNC(2,fsin_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fsin_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fsin_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fsin_rr,(FW d, FR s))
-MIDFUNC(2,fcos_rr,(FW d, FR s))
+ MIDFUNC(2,fcos_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fcos_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fcos_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fcos_rr,(FW d, FR s))
-MIDFUNC(2,ftan_rr,(FW d, FR s))
+ MIDFUNC(2,ftan_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_ftan_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_ftan_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,ftan_rr,(FW d, FR s))
-MIDFUNC(3,fsincos_rr,(FW d, FW c, FR s))
+ MIDFUNC(3,fsincos_rr,(FW d, FW c, FR s))
{
- s=f_readreg(s); /* s for source */
- d=f_writereg(d); /* d for sine */
- c=f_writereg(c); /* c for cosine */
- raw_fsincos_rr(d,c,s);
- f_unlock(s);
- f_unlock(d);
- f_unlock(c);
+ s=f_readreg(s); /* s for source */
+ d=f_writereg(d); /* d for sine */
+ c=f_writereg(c); /* c for cosine */
+ raw_fsincos_rr(d,c,s);
+ f_unlock(s);
+ f_unlock(d);
+ f_unlock(c);
}
MENDFUNC(3,fsincos_rr,(FW d, FW c, FR s))
-MIDFUNC(2,fscale_rr,(FRW d, FR s))
+ MIDFUNC(2,fscale_rr,(FRW d, FR s))
{
- s=f_readreg(s);
- d=f_rmw(d);
- raw_fscale_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_rmw(d);
+ raw_fscale_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fscale_rr,(FRW d, FR s))
-MIDFUNC(2,ftwotox_rr,(FW d, FR s))
+ MIDFUNC(2,ftwotox_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_ftwotox_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_ftwotox_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,ftwotox_rr,(FW d, FR s))
-MIDFUNC(2,fetox_rr,(FW d, FR s))
+ MIDFUNC(2,fetox_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fetox_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fetox_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fetox_rr,(FW d, FR s))
-MIDFUNC(2,fetoxM1_rr,(FW d, FR s))
+ MIDFUNC(2,fetoxM1_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fetoxM1_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fetoxM1_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fetoxM1_rr,(FW d, FR s))
-MIDFUNC(2,ftentox_rr,(FW d, FR s))
+ MIDFUNC(2,ftentox_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_ftentox_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_ftentox_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,ftentox_rr,(FW d, FR s))
-MIDFUNC(2,flog2_rr,(FW d, FR s))
+ MIDFUNC(2,flog2_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_flog2_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_flog2_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,flog2_rr,(FW d, FR s))
-MIDFUNC(2,flogN_rr,(FW d, FR s))
+ MIDFUNC(2,flogN_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_flogN_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_flogN_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,flogN_rr,(FW d, FR s))
-MIDFUNC(2,flogNP1_rr,(FW d, FR s))
+ MIDFUNC(2,flogNP1_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_flogNP1_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_flogNP1_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,flogNP1_rr,(FW d, FR s))
-MIDFUNC(2,flog10_rr,(FW d, FR s))
+ MIDFUNC(2,flog10_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_flog10_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_flog10_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,flog10_rr,(FW d, FR s))
-MIDFUNC(2,fasin_rr,(FW d, FR s))
+ MIDFUNC(2,fasin_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fasin_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fasin_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fasin_rr,(FW d, FR s))
-MIDFUNC(2,facos_rr,(FW d, FR s))
+ MIDFUNC(2,facos_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_facos_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_facos_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,facos_rr,(FW d, FR s))
-MIDFUNC(2,fatan_rr,(FW d, FR s))
+ MIDFUNC(2,fatan_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fatan_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fatan_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fatan_rr,(FW d, FR s))
-MIDFUNC(2,fatanh_rr,(FW d, FR s))
+ MIDFUNC(2,fatanh_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fatanh_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fatanh_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fatanh_rr,(FW d, FR s))
-MIDFUNC(2,fsinh_rr,(FW d, FR s))
+ MIDFUNC(2,fsinh_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fsinh_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fsinh_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fsinh_rr,(FW d, FR s))
-MIDFUNC(2,fcosh_rr,(FW d, FR s))
+ MIDFUNC(2,fcosh_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fcosh_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fcosh_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fcosh_rr,(FW d, FR s))
-MIDFUNC(2,ftanh_rr,(FW d, FR s))
+ MIDFUNC(2,ftanh_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_ftanh_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_ftanh_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,ftanh_rr,(FW d, FR s))
-MIDFUNC(2,fneg_rr,(FW d, FR s))
+ MIDFUNC(2,fneg_rr,(FW d, FR s))
{
- s=f_readreg(s);
- d=f_writereg(d);
- raw_fneg_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_writereg(d);
+ raw_fneg_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fneg_rr,(FW d, FR s))
-MIDFUNC(2,fadd_rr,(FRW d, FR s))
+ MIDFUNC(2,fadd_rr,(FRW d, FR s))
{
- s=f_readreg(s);
- d=f_rmw(d);
- raw_fadd_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_rmw(d);
+ raw_fadd_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fadd_rr,(FRW d, FR s))
-MIDFUNC(2,fsub_rr,(FRW d, FR s))
+ MIDFUNC(2,fsub_rr,(FRW d, FR s))
{
- s=f_readreg(s);
- d=f_rmw(d);
- raw_fsub_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_rmw(d);
+ raw_fsub_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fsub_rr,(FRW d, FR s))
-MIDFUNC(2,fcmp_rr,(FR d, FR s))
+ MIDFUNC(2,fcmp_rr,(FR d, FR s))
{
- d=f_readreg(d);
- s=f_readreg(s);
- raw_fcmp_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ d=f_readreg(d);
+ s=f_readreg(s);
+ raw_fcmp_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fcmp_rr,(FR d, FR s))
-MIDFUNC(2,fdiv_rr,(FRW d, FR s))
+ MIDFUNC(2,fdiv_rr,(FRW d, FR s))
{
- s=f_readreg(s);
- d=f_rmw(d);
- raw_fdiv_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_rmw(d);
+ raw_fdiv_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fdiv_rr,(FRW d, FR s))
-MIDFUNC(2,frem_rr,(FRW d, FR s))
+ MIDFUNC(2,frem_rr,(FRW d, FR s))
{
- s=f_readreg(s);
- d=f_rmw(d);
- raw_frem_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_rmw(d);
+ raw_frem_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,frem_rr,(FRW d, FR s))
-MIDFUNC(2,frem1_rr,(FRW d, FR s))
+ MIDFUNC(2,frem1_rr,(FRW d, FR s))
{
- s=f_readreg(s);
- d=f_rmw(d);
- raw_frem1_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_rmw(d);
+ raw_frem1_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,frem1_rr,(FRW d, FR s))
-MIDFUNC(2,fmul_rr,(FRW d, FR s))
+ MIDFUNC(2,fmul_rr,(FRW d, FR s))
{
- s=f_readreg(s);
- d=f_rmw(d);
- raw_fmul_rr(d,s);
- f_unlock(s);
- f_unlock(d);
+ s=f_readreg(s);
+ d=f_rmw(d);
+ raw_fmul_rr(d,s);
+ f_unlock(s);
+ f_unlock(d);
}
MENDFUNC(2,fmul_rr,(FRW d, FR s))
-/********************************************************************
- * Support functions exposed to gencomp. CREATE time *
- ********************************************************************/
+ /********************************************************************
+ * Support functions exposed to gencomp. CREATE time *
+ ********************************************************************/
-int kill_rodent(int r)
+ int kill_rodent(int r)
{
- return KILLTHERAT &&
- have_rat_stall &&
- (live.state[r].status==INMEM ||
- live.state[r].status==CLEAN ||
- live.state[r].status==ISCONST ||
- live.state[r].dirtysize==4);
+ return KILLTHERAT &&
+ have_rat_stall &&
+ (live.state[r].status==INMEM ||
+ live.state[r].status==CLEAN ||
+ live.state[r].status==ISCONST ||
+ live.state[r].dirtysize==4);
}
uae_u32 get_const(int r)
{
#if USE_OPTIMIZER
- if (!reg_alloc_run)
+ if (!reg_alloc_run)
#endif
- Dif (!isconst(r)) {
- jit_abort (L"JIT: Register %d should be constant, but isn't\n",r);
+ Dif (!isconst(r)) {
+ jit_abort (L"JIT: Register %d should be constant, but isn't\n",r);
}
- return live.state[r].val;
+ return live.state[r].val;
}
void sync_m68k_pc(void)
{
- if (m68k_pc_offset) {
- add_l_ri(PC_P,m68k_pc_offset);
- comp_pc_p+=m68k_pc_offset;
- m68k_pc_offset=0;
- }
+ if (m68k_pc_offset) {
+ add_l_ri(PC_P,m68k_pc_offset);
+ comp_pc_p+=m68k_pc_offset;
+ m68k_pc_offset=0;
+ }
}
/********************************************************************
- * Support functions exposed to newcpu *
- ********************************************************************/
+* Support functions exposed to newcpu *
+********************************************************************/
uae_u32 scratch[VREGS];
fptype fscratch[VFREGS];
void init_comp(void)
{
- int i;
- uae_u8* cb=can_byte;
- uae_u8* cw=can_word;
- uae_u8* au=always_used;
-
- for (i=0;i<VREGS;i++) {
- live.state[i].realreg=-1;
- live.state[i].needflush=NF_SCRATCH;
- live.state[i].val=0;
- set_status(i,UNDEF);
- }
-
- for (i=0;i<VFREGS;i++) {
- live.fate[i].status=UNDEF;
- live.fate[i].realreg=-1;
- live.fate[i].needflush=NF_SCRATCH;
- }
-
- for (i=0;i<VREGS;i++) {
- if (i<16) { /* First 16 registers map to 68k registers */
- live.state[i].mem=((uae_u32*)®s)+i;
- live.state[i].needflush=NF_TOMEM;
- set_status(i,INMEM);
- }
- else
- live.state[i].mem=scratch+i;
- }
- live.state[PC_P].mem=(uae_u32*)&(regs.pc_p);
- live.state[PC_P].needflush=NF_TOMEM;
- set_const(PC_P,(uae_u32)comp_pc_p);
-
- live.state[FLAGX].mem=&(regflags.x);
- live.state[FLAGX].needflush=NF_TOMEM;
- set_status(FLAGX,INMEM);
-
- live.state[FLAGTMP].mem=&(regflags.cznv);
- live.state[FLAGTMP].needflush=NF_TOMEM;
- set_status(FLAGTMP,INMEM);
-
- live.state[NEXT_HANDLER].needflush=NF_HANDLER;
- set_status(NEXT_HANDLER,UNDEF);
-
- for (i=0;i<VFREGS;i++) {
- if (i<8) { /* First 8 registers map to 68k FPU registers */
- live.fate[i].mem=(uae_u32*)(((fptype*)regs.fp)+i);
- live.fate[i].needflush=NF_TOMEM;
- live.fate[i].status=INMEM;
- }
- else if (i==FP_RESULT) {
- live.fate[i].mem=(uae_u32*)(®s.fp_result);
- live.fate[i].needflush=NF_TOMEM;
- live.fate[i].status=INMEM;
- }
- else
- live.fate[i].mem=(uae_u32*)(fscratch+i);
- }
-
- for (i=0;i<N_REGS;i++) {
- live.nat[i].touched=0;
- live.nat[i].nholds=0;
- live.nat[i].locked=0;
- if (*cb==i) {
- live.nat[i].canbyte=1; cb++;
- } else live.nat[i].canbyte=0;
- if (*cw==i) {
- live.nat[i].canword=1; cw++;
- } else live.nat[i].canword=0;
- if (*au==i) {
- live.nat[i].locked=1; au++;
- }
- }
-
- for (i=0;i<N_FREGS;i++) {
- live.fat[i].touched=0;
- live.fat[i].nholds=0;
- live.fat[i].locked=0;
- }
-
- touchcnt=1;
- m68k_pc_offset=0;
- live.flags_in_flags=TRASH;
- live.flags_on_stack=VALID;
- live.flags_are_important=1;
-
- raw_fp_init();
-}
+ int i;
+ uae_u8* cb=can_byte;
+ uae_u8* cw=can_word;
+ uae_u8* au=always_used;
+
+ for (i=0;i<VREGS;i++) {
+ live.state[i].realreg=-1;
+ live.state[i].needflush=NF_SCRATCH;
+ live.state[i].val=0;
+ set_status(i,UNDEF);
+ }
+
+ for (i=0;i<VFREGS;i++) {
+ live.fate[i].status=UNDEF;
+ live.fate[i].realreg=-1;
+ live.fate[i].needflush=NF_SCRATCH;
+ }
+
+ for (i=0;i<VREGS;i++) {
+ if (i<16) { /* First 16 registers map to 68k registers */
+ live.state[i].mem=((uae_u32*)®s)+i;
+ live.state[i].needflush=NF_TOMEM;
+ set_status(i,INMEM);
+ }
+ else
+ live.state[i].mem=scratch+i;
+ }
+ live.state[PC_P].mem=(uae_u32*)&(regs.pc_p);
+ live.state[PC_P].needflush=NF_TOMEM;
+ set_const(PC_P,(uae_u32)comp_pc_p);
+
+ live.state[FLAGX].mem=&(regflags.x);
+ live.state[FLAGX].needflush=NF_TOMEM;
+ set_status(FLAGX,INMEM);
+
+ live.state[FLAGTMP].mem=&(regflags.cznv);
+ live.state[FLAGTMP].needflush=NF_TOMEM;
+ set_status(FLAGTMP,INMEM);
+
+ live.state[NEXT_HANDLER].needflush=NF_HANDLER;
+ set_status(NEXT_HANDLER,UNDEF);
+
+ for (i=0;i<VFREGS;i++) {
+ if (i<8) { /* First 8 registers map to 68k FPU registers */
+ live.fate[i].mem=(uae_u32*)(((fptype*)regs.fp)+i);
+ live.fate[i].needflush=NF_TOMEM;
+ live.fate[i].status=INMEM;
+ }
+ else if (i==FP_RESULT) {
+ live.fate[i].mem=(uae_u32*)(®s.fp_result);
+ live.fate[i].needflush=NF_TOMEM;
+ live.fate[i].status=INMEM;
+ }
+ else
+ live.fate[i].mem=(uae_u32*)(fscratch+i);
+ }
+
+ for (i=0;i<N_REGS;i++) {
+ live.nat[i].touched=0;
+ live.nat[i].nholds=0;
+ live.nat[i].locked=0;
+ if (*cb==i) {
+ live.nat[i].canbyte=1; cb++;
+ } else live.nat[i].canbyte=0;
+ if (*cw==i) {
+ live.nat[i].canword=1; cw++;
+ } else live.nat[i].canword=0;
+ if (*au==i) {
+ live.nat[i].locked=1; au++;
+ }
+ }
+
+ for (i=0;i<N_FREGS;i++) {
+ live.fat[i].touched=0;
+ live.fat[i].nholds=0;
+ live.fat[i].locked=0;
+ }
+
+ touchcnt=1;
+ m68k_pc_offset=0;
+ live.flags_in_flags=TRASH;
+ live.flags_on_stack=VALID;
+ live.flags_are_important=1;
+
+ raw_fp_init();
+}
static void vinton(int i, uae_s8* vton, int depth)
{
- int n;
- int rr;
-
- Dif (vton[i]==-1) {
- jit_abort (L"JIT: Asked to load register %d, but nowhere to go\n",i);
- }
- n=vton[i];
- Dif (live.nat[n].nholds>1)
- jit_abort (L"vinton");
- if (live.nat[n].nholds && depth<N_REGS) {
- vinton(live.nat[n].holds[0],vton,depth+1);
- }
- if (!isinreg(i))
- return; /* Oops --- got rid of that one in the recursive calls */
- rr=live.state[i].realreg;
- if (rr!=n)
- mov_nregs(n,rr);
+ int n;
+ int rr;
+
+ Dif (vton[i]==-1) {
+ jit_abort (L"JIT: Asked to load register %d, but nowhere to go\n",i);
+ }
+ n=vton[i];
+ Dif (live.nat[n].nholds>1)
+ jit_abort (L"vinton");
+ if (live.nat[n].nholds && depth<N_REGS) {
+ vinton(live.nat[n].holds[0],vton,depth+1);
+ }
+ if (!isinreg(i))
+ return; /* Oops --- got rid of that one in the recursive calls */
+ rr=live.state[i].realreg;
+ if (rr!=n)
+ mov_nregs(n,rr);
}
#if USE_MATCHSTATE
/* This is going to be, amongst other things, a more elaborate version of
- flush() */
+flush() */
STATIC_INLINE void match_states(smallstate* s)
{
- uae_s8 vton[VREGS];
- uae_s8 ndone[N_REGS];
- int i;
- int again=0;
-
- for (i=0;i<VREGS;i++)
- vton[i]=-1;
-
- for (i=0;i<N_REGS;i++)
- if (s->nat[i].validsize)
- vton[s->nat[i].holds]=i;
-
- flush_flags(); /* low level */
- sync_m68k_pc(); /* mid level */
-
- /* We don't do FREGS yet, so this is raw flush() code */
- for (i=0;i<VFREGS;i++) {
- if (live.fate[i].needflush==NF_SCRATCH ||
- live.fate[i].status==CLEAN) {
- f_disassociate(i);
- }
- }
- for (i=0;i<VFREGS;i++) {
- if (live.fate[i].needflush==NF_TOMEM &&
- live.fate[i].status==DIRTY) {
- f_evict(i);
- }
- }
- raw_fp_cleanup_drop();
-
- /* Now comes the fun part. First, we need to remove all offsets */
- for (i=0;i<VREGS;i++)
- if (!isconst(i) && live.state[i].val)
- remove_offset(i,-1);
-
- /* Next, we evict everything that does not end up in registers,
- write back overly dirty registers, and write back constants */
- for (i=0;i<VREGS;i++) {
- switch (live.state[i].status) {
- case ISCONST:
- if (i!=PC_P)
- writeback_const(i);
- break;
- case DIRTY:
- if (vton[i]==-1) {
- evict(i);
- break;
- }
- if (live.state[i].dirtysize>s->nat[vton[i]].dirtysize)
- tomem(i);
- /* Fall-through! */
- case CLEAN:
- if (vton[i]==-1 ||
- live.state[i].validsize<s->nat[vton[i]].validsize)
- evict(i);
- else
- make_exclusive(i,0,-1);
- break;
- case INMEM:
- break;
- case UNDEF:
- break;
- default:
- write_log (L"JIT: Weird status: %d\n",live.state[i].status);
- abort();
- }
- }
-
- /* Quick consistency check */
- for (i=0;i<VREGS;i++) {
- if (isinreg(i)) {
- int n=live.state[i].realreg;
-
- if (live.nat[n].nholds!=1) {
- write_log (L"JIT: Register %d isn't alone in nreg %d\n",
- i,n);
- abort();
- }
- if (vton[i]==-1) {
- write_log (L"JIT: Register %d is still in register, shouldn't be\n",
- i);
- abort();
- }
- }
- }
-
- /* Now we need to shuffle things around so the VREGs are in the
- right N_REGs. */
- for (i=0;i<VREGS;i++) {
- if (isinreg(i) && vton[i]!=live.state[i].realreg)
- vinton(i,vton,0);
- }
-
- /* And now we may need to load some registers from memory */
- for (i=0;i<VREGS;i++) {
- int n=vton[i];
- if (n==-1) {
- Dif (isinreg(i)) {
- write_log (L"JIT: Register %d unexpectedly in nreg %d\n",
- i,live.state[i].realreg);
- abort();
- }
+ uae_s8 vton[VREGS];
+ uae_s8 ndone[N_REGS];
+ int i;
+ int again=0;
+
+ for (i=0;i<VREGS;i++)
+ vton[i]=-1;
+
+ for (i=0;i<N_REGS;i++)
+ if (s->nat[i].validsize)
+ vton[s->nat[i].holds]=i;
+
+ flush_flags(); /* low level */
+ sync_m68k_pc(); /* mid level */
+
+ /* We don't do FREGS yet, so this is raw flush() code */
+ for (i=0;i<VFREGS;i++) {
+ if (live.fate[i].needflush==NF_SCRATCH ||
+ live.fate[i].status==CLEAN) {
+ f_disassociate(i);
+ }
}
- else {
- switch(live.state[i].status) {
- case CLEAN:
- case DIRTY:
- Dif (n!=live.state[i].realreg)
- abort();
- break;
- case INMEM:
- Dif (live.nat[n].nholds) {
- write_log (L"JIT: natreg %d holds %d vregs, should be empty\n",
- n,live.nat[n].nholds);
+ for (i=0;i<VFREGS;i++) {
+ if (live.fate[i].needflush==NF_TOMEM &&
+ live.fate[i].status==DIRTY) {
+ f_evict(i);
}
- raw_mov_l_rm(n,(uae_u32)live.state[i].mem);
- live.state[i].validsize=4;
- live.state[i].dirtysize=0;
- live.state[i].realreg=n;
- live.state[i].realind=0;
- live.state[i].val=0;
- live.state[i].is_swapped=0;
- live.nat[n].nholds=1;
- live.nat[n].holds[0]=i;
-
- set_status(i,CLEAN);
- break;
- case ISCONST:
- if (i!=PC_P) {
- write_log (L"JIT: Got constant in matchstate for reg %d. Bad!\n",i);
- abort();
+ }
+ raw_fp_cleanup_drop();
+
+ /* Now comes the fun part. First, we need to remove all offsets */
+ for (i=0;i<VREGS;i++)
+ if (!isconst(i) && live.state[i].val)
+ remove_offset(i,-1);
+
+ /* Next, we evict everything that does not end up in registers,
+ write back overly dirty registers, and write back constants */
+ for (i=0;i<VREGS;i++) {
+ switch (live.state[i].status) {
+ case ISCONST:
+ if (i!=PC_P)
+ writeback_const(i);
+ break;
+ case DIRTY:
+ if (vton[i]==-1) {
+ evict(i);
+ break;
+ }
+ if (live.state[i].dirtysize>s->nat[vton[i]].dirtysize)
+ tomem(i);
+ /* Fall-through! */
+ case CLEAN:
+ if (vton[i]==-1 ||
+ live.state[i].validsize<s->nat[vton[i]].validsize)
+ evict(i);
+ else
+ make_exclusive(i,0,-1);
+ break;
+ case INMEM:
+ break;
+ case UNDEF:
+ break;
+ default:
+ write_log (L"JIT: Weird status: %d\n",live.state[i].status);
+ abort();
}
- break;
- case UNDEF:
- break;
- }
- }
- }
-
- /* One last consistency check, and adjusting the states in live
- to those in s */
- for (i=0;i<VREGS;i++) {
- int n=vton[i];
- switch(live.state[i].status) {
- case INMEM:
- if (n!=-1)
- abort();
- break;
- case ISCONST:
- if (i!=PC_P)
- abort();
- break;
- case CLEAN:
- case DIRTY:
- if (n==-1)
- abort();
- if (live.state[i].dirtysize>s->nat[n].dirtysize)
- abort;
- if (live.state[i].validsize<s->nat[n].validsize)
- abort;
- live.state[i].dirtysize=s->nat[n].dirtysize;
- live.state[i].validsize=s->nat[n].validsize;
- if (live.state[i].dirtysize)
- set_status(i,DIRTY);
- break;
- case UNDEF:
- break;
- }
- if (n!=-1)
- live.nat[n].touched=touchcnt++;
- }
+ }
+
+ /* Quick consistency check */
+ for (i=0;i<VREGS;i++) {
+ if (isinreg(i)) {
+ int n=live.state[i].realreg;
+
+ if (live.nat[n].nholds!=1) {
+ write_log (L"JIT: Register %d isn't alone in nreg %d\n",
+ i,n);
+ abort();
+ }
+ if (vton[i]==-1) {
+ write_log (L"JIT: Register %d is still in register, shouldn't be\n",
+ i);
+ abort();
+ }
+ }
+ }
+
+ /* Now we need to shuffle things around so the VREGs are in the
+ right N_REGs. */
+ for (i=0;i<VREGS;i++) {
+ if (isinreg(i) && vton[i]!=live.state[i].realreg)
+ vinton(i,vton,0);
+ }
+
+ /* And now we may need to load some registers from memory */
+ for (i=0;i<VREGS;i++) {
+ int n=vton[i];
+ if (n==-1) {
+ Dif (isinreg(i)) {
+ write_log (L"JIT: Register %d unexpectedly in nreg %d\n",
+ i,live.state[i].realreg);
+ abort();
+ }
+ }
+ else {
+ switch(live.state[i].status) {
+ case CLEAN:
+ case DIRTY:
+ Dif (n!=live.state[i].realreg)
+ abort();
+ break;
+ case INMEM:
+ Dif (live.nat[n].nholds) {
+ write_log (L"JIT: natreg %d holds %d vregs, should be empty\n",
+ n,live.nat[n].nholds);
+ }
+ raw_mov_l_rm(n,(uae_u32)live.state[i].mem);
+ live.state[i].validsize=4;
+ live.state[i].dirtysize=0;
+ live.state[i].realreg=n;
+ live.state[i].realind=0;
+ live.state[i].val=0;
+ live.state[i].is_swapped=0;
+ live.nat[n].nholds=1;
+ live.nat[n].holds[0]=i;
+
+ set_status(i,CLEAN);
+ break;
+ case ISCONST:
+ if (i!=PC_P) {
+ write_log (L"JIT: Got constant in matchstate for reg %d. Bad!\n",i);
+ abort();
+ }
+ break;
+ case UNDEF:
+ break;
+ }
+ }
+ }
+
+ /* One last consistency check, and adjusting the states in live
+ to those in s */
+ for (i=0;i<VREGS;i++) {
+ int n=vton[i];
+ switch(live.state[i].status) {
+ case INMEM:
+ if (n!=-1)
+ abort();
+ break;
+ case ISCONST:
+ if (i!=PC_P)
+ abort();
+ break;
+ case CLEAN:
+ case DIRTY:
+ if (n==-1)
+ abort();
+ if (live.state[i].dirtysize>s->nat[n].dirtysize)
+ abort;
+ if (live.state[i].validsize<s->nat[n].validsize)
+ abort;
+ live.state[i].dirtysize=s->nat[n].dirtysize;
+ live.state[i].validsize=s->nat[n].validsize;
+ if (live.state[i].dirtysize)
+ set_status(i,DIRTY);
+ break;
+ case UNDEF:
+ break;
+ }
+ if (n!=-1)
+ live.nat[n].touched=touchcnt++;
+ }
}
#else
STATIC_INLINE void match_states(smallstate* s)
{
- flush(1);
+ flush(1);
}
#endif
/* Only do this if you really mean it! The next call should be to init!*/
void flush(int save_regs)
{
- int i;
+ int i;
- log_flush();
- flush_flags(); /* low level */
- sync_m68k_pc(); /* mid level */
+ log_flush();
+ flush_flags(); /* low level */
+ sync_m68k_pc(); /* mid level */
- if (save_regs) {
- for (i=0;i<VFREGS;i++) {
- if (live.fate[i].needflush==NF_SCRATCH ||
- live.fate[i].status==CLEAN) {
- f_disassociate(i);
- }
- }
- for (i=0;i<VREGS;i++) {
- if (live.state[i].needflush==NF_TOMEM) {
- switch(live.state[i].status) {
- case INMEM:
- if (live.state[i].val) {
- raw_add_l_mi((uae_u32)live.state[i].mem,live.state[i].val);
- live.state[i].val=0;
- }
- break;
- case CLEAN:
- case DIRTY:
- remove_offset(i,-1); tomem(i); break;
- case ISCONST:
- if (i!=PC_P)
- writeback_const(i);
- break;
- default: break;
+ if (save_regs) {
+ for (i=0;i<VFREGS;i++) {
+ if (live.fate[i].needflush==NF_SCRATCH ||
+ live.fate[i].status==CLEAN) {
+ f_disassociate(i);
+ }
+ }
+ for (i=0;i<VREGS;i++) {
+ if (live.state[i].needflush==NF_TOMEM) {
+ switch(live.state[i].status) {
+ case INMEM:
+ if (live.state[i].val) {
+ raw_add_l_mi((uae_u32)live.state[i].mem,live.state[i].val);
+ live.state[i].val=0;
+ }
+ break;
+ case CLEAN:
+ case DIRTY:
+ remove_offset(i,-1); tomem(i); break;
+ case ISCONST:
+ if (i!=PC_P)
+ writeback_const(i);
+ break;
+ default: break;
+ }
+ Dif (live.state[i].val && i!=PC_P) {
+ write_log (L"JIT: Register %d still has val %x\n",
+ i,live.state[i].val);
+ }
+ }
}
- Dif (live.state[i].val && i!=PC_P) {
- write_log (L"JIT: Register %d still has val %x\n",
- i,live.state[i].val);
+ for (i=0;i<VFREGS;i++) {
+ if (live.fate[i].needflush==NF_TOMEM &&
+ live.fate[i].status==DIRTY) {
+ f_evict(i);
+ }
}
- }
+ raw_fp_cleanup_drop();
}
- for (i=0;i<VFREGS;i++) {
- if (live.fate[i].needflush==NF_TOMEM &&
- live.fate[i].status==DIRTY) {
- f_evict(i);
- }
+ if (needflags) {
+ write_log (L"JIT: Warning! flush with needflags=1!\n");
}
- raw_fp_cleanup_drop();
- }
- if (needflags) {
- write_log (L"JIT: Warning! flush with needflags=1!\n");
- }
- lopt_emit_all();
+ lopt_emit_all();
}
static void flush_keepflags(void)
{
- int i;
-
- for (i=0;i<VFREGS;i++) {
- if (live.fate[i].needflush==NF_SCRATCH ||
- live.fate[i].status==CLEAN) {
- f_disassociate(i);
- }
- }
- for (i=0;i<VREGS;i++) {
- if (live.state[i].needflush==NF_TOMEM) {
- switch(live.state[i].status) {
- case INMEM:
- /* Can't adjust the offset here --- that needs "add" */
- break;
- case CLEAN:
- case DIRTY:
- remove_offset(i,-1); tomem(i); break;
- case ISCONST:
- if (i!=PC_P)
- writeback_const(i);
- break;
- default: break;
- }
- }
- }
- for (i=0;i<VFREGS;i++) {
- if (live.fate[i].needflush==NF_TOMEM &&
- live.fate[i].status==DIRTY) {
- f_evict(i);
- }
- }
- raw_fp_cleanup_drop();
- lopt_emit_all();
+ int i;
+
+ for (i=0;i<VFREGS;i++) {
+ if (live.fate[i].needflush==NF_SCRATCH ||
+ live.fate[i].status==CLEAN) {
+ f_disassociate(i);
+ }
+ }
+ for (i=0;i<VREGS;i++) {
+ if (live.state[i].needflush==NF_TOMEM) {
+ switch(live.state[i].status) {
+ case INMEM:
+ /* Can't adjust the offset here --- that needs "add" */
+ break;
+ case CLEAN:
+ case DIRTY:
+ remove_offset(i,-1); tomem(i); break;
+ case ISCONST:
+ if (i!=PC_P)
+ writeback_const(i);
+ break;
+ default: break;
+ }
+ }
+ }
+ for (i=0;i<VFREGS;i++) {
+ if (live.fate[i].needflush==NF_TOMEM &&
+ live.fate[i].status==DIRTY) {
+ f_evict(i);
+ }
+ }
+ raw_fp_cleanup_drop();
+ lopt_emit_all();
}
void freescratch(void)
{
- int i;
- for (i=0;i<N_REGS;i++)
- if (live.nat[i].locked && i!=4)
- write_log (L"JIT: Warning! %d is locked\n",i);
+ int i;
+ for (i=0;i<N_REGS;i++)
+ if (live.nat[i].locked && i!=4)
+ write_log (L"JIT: Warning! %d is locked\n",i);
- for (i=0;i<VREGS;i++)
- if (live.state[i].needflush==NF_SCRATCH) {
- forget_about(i);
- }
+ for (i=0;i<VREGS;i++)
+ if (live.state[i].needflush==NF_SCRATCH) {
+ forget_about(i);
+ }
- for (i=0;i<VFREGS;i++)
- if (live.fate[i].needflush==NF_SCRATCH) {
- f_forget_about(i);
- }
+ for (i=0;i<VFREGS;i++)
+ if (live.fate[i].needflush==NF_SCRATCH) {
+ f_forget_about(i);
+ }
}
/********************************************************************
- * Support functions, internal *
- ********************************************************************/
+* Support functions, internal *
+********************************************************************/
static void align_target(uae_u32 a)
{
- lopt_emit_all();
- /* Fill with NOPs --- makes debugging with gdb easier */
- while ((uae_u32)target&(a-1))
- *target++=0x90;
+ lopt_emit_all();
+ /* Fill with NOPs --- makes debugging with gdb easier */
+ while ((uae_u32)target&(a-1))
+ *target++=0x90;
}
extern uae_u8* kickmemory;
STATIC_INLINE int isinrom(uae_u32 addr)
{
- return (addr>=(uae_u32)kickmemory &&
- addr<(uae_u32)kickmemory+8*65536);
+ return (addr>=(uae_u32)kickmemory &&
+ addr<(uae_u32)kickmemory+8*65536);
}
static void flush_all(void)
{
- int i;
+ int i;
- log_flush();
- for (i=0;i<VREGS;i++)
- if (live.state[i].status==DIRTY) {
- if (!call_saved[live.state[i].realreg]) {
- tomem(i);
- }
- }
- for (i=0;i<VFREGS;i++)
- if (f_isinreg(i))
- f_evict(i);
- raw_fp_cleanup_drop();
+ log_flush();
+ for (i=0;i<VREGS;i++)
+ if (live.state[i].status==DIRTY) {
+ if (!call_saved[live.state[i].realreg]) {
+ tomem(i);
+ }
+ }
+ for (i=0;i<VFREGS;i++)
+ if (f_isinreg(i))
+ f_evict(i);
+ raw_fp_cleanup_drop();
}
/* 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 should be a bit more selective here */
+ flush_all(); /* If there are registers that don't get clobbered,
+ * we should be a bit more selective here */
}
/* 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;
- for (i=0;i<N_REGS;i++)
- if (!call_saved[i] && live.nat[i].nholds>0)
- free_nreg(i);
+ int i;
+ for (i=0;i<N_REGS;i++)
+ if (!call_saved[i] && live.nat[i].nholds>0)
+ free_nreg(i);
- for (i=0;i<N_FREGS;i++)
- if (live.fat[i].nholds>0)
- f_free_nreg(i);
+ for (i=0;i<N_FREGS;i++)
+ if (live.fat[i].nholds>0)
+ f_free_nreg(i);
- live.flags_in_flags=TRASH; /* Note: We assume we already rescued the
- flags at the very start of the call_r
- functions! */
+ live.flags_in_flags=TRASH; /* Note: We assume we already rescued the
+ flags at the very start of the call_r
+ functions! */
}
/********************************************************************
- * 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)
{
- next_pc_p=not_taken;
- taken_pc_p=taken;
- branch_cc=cond;
+ next_pc_p=not_taken;
+ taken_pc_p=taken;
+ branch_cc=cond;
}
static uae_u32 get_handler_address(uae_u32 addr)
{
- uae_u32 cl=cacheline(addr);
- blockinfo* bi=get_blockinfo_addr_new((void*)addr,0);
+ uae_u32 cl=cacheline(addr);
+ blockinfo* bi=get_blockinfo_addr_new((void*)addr,0);
#if USE_OPTIMIZER
- if (!bi && reg_alloc_run)
- return 0;
+ if (!bi && reg_alloc_run)
+ return 0;
#endif
- return (uae_u32)&(bi->direct_handler_to_use);
+ return (uae_u32)&(bi->direct_handler_to_use);
}
static uae_u32 get_handler(uae_u32 addr)
{
- uae_u32 cl=cacheline(addr);
- blockinfo* bi=get_blockinfo_addr_new((void*)addr,0);
+ uae_u32 cl=cacheline(addr);
+ blockinfo* bi=get_blockinfo_addr_new((void*)addr,0);
#if USE_OPTIMIZER
- if (!bi && reg_alloc_run)
- return 0;
+ if (!bi && reg_alloc_run)
+ return 0;
#endif
- return (uae_u32)bi->direct_handler_to_use;
+ return (uae_u32)bi->direct_handler_to_use;
}
static void load_handler(int reg, uae_u32 addr)
{
- mov_l_rm(reg,get_handler_address(addr));
+ mov_l_rm(reg,get_handler_address(addr));
}
/* This version assumes that it is writing *real* memory, and *will* fail
- * if that assumption is wrong! No branches, no second chances, just
- * straight go-for-it attitude */
+* if that assumption is wrong! No branches, no second chances, just
+* straight go-for-it attitude */
static void writemem_real(int address, int source, int offset, int size, int tmp, int clobber)
{
- int f=tmp;
+ int f=tmp;
#ifdef NATMEM_OFFSET
- if (canbang) { /* Woohoo! go directly at the memory! */
- if (clobber)
- f=source;
- switch(size) {
- case 1: mov_b_bRr(address,source,NATMEM_OFFSETX); break;
- case 2: mov_w_rr(f,source); gen_bswap_16(f); mov_w_bRr(address,f,NATMEM_OFFSETX); break;
- case 4: mov_l_rr(f,source); gen_bswap_32(f); mov_l_bRr(address,f,NATMEM_OFFSETX); break;
+ if (canbang) { /* Woohoo! go directly at the memory! */
+ if (clobber)
+ f=source;
+ switch(size) {
+ case 1: mov_b_bRr(address,source,NATMEM_OFFSETX); break;
+ case 2: mov_w_rr(f,source); gen_bswap_16(f); mov_w_bRr(address,f,NATMEM_OFFSETX); break;
+ case 4: mov_l_rr(f,source); gen_bswap_32(f); mov_l_bRr(address,f,NATMEM_OFFSETX); break;
+ }
+ forget_about(tmp);
+ forget_about(f);
+ return;
}
- forget_about(tmp);
- forget_about(f);
- return;
- }
#endif
- mov_l_rr(f,address);
- shrl_l_ri(f,16); /* The index into the baseaddr table */
- mov_l_rm_indexed(f,(uae_u32)(baseaddr),f);
-
- if (address==source) { /* IBrowse does this! */
- if (size > 1) {
- add_l(f,address); /* f now holds the final address */
- switch (size) {
- case 2: gen_bswap_16(source); mov_w_Rr(f,source,0);
- gen_bswap_16(source); return;
- case 4: gen_bswap_32(source); mov_l_Rr(f,source,0);
- gen_bswap_32(source); return;
- }
- }
- }
- switch (size) { /* f now holds the offset */
+ mov_l_rr(f,address);
+ shrl_l_ri(f,16); /* The index into the baseaddr table */
+ mov_l_rm_indexed(f,(uae_u32)(baseaddr),f);
+
+ if (address==source) { /* IBrowse does this! */
+ if (size > 1) {
+ add_l(f,address); /* f now holds the final address */
+ switch (size) {
+ case 2: gen_bswap_16(source); mov_w_Rr(f,source,0);
+ gen_bswap_16(source); return;
+ case 4: gen_bswap_32(source); mov_l_Rr(f,source,0);
+ gen_bswap_32(source); return;
+ }
+ }
+ }
+ switch (size) { /* f now holds the offset */
case 1: mov_b_mrr_indexed(address,f,source); break;
case 2: gen_bswap_16(source); mov_w_mrr_indexed(address,f,source);
gen_bswap_16(source); break; /* base, index, source */
case 4: gen_bswap_32(source); mov_l_mrr_indexed(address,f,source);
gen_bswap_32(source); break;
- }
+ }
}
STATIC_INLINE void writemem(int address, int source, int offset, int size, int tmp)
{
- int f=tmp;
+ int f=tmp;
- mov_l_rr(f,address);
- shrl_l_ri(f,16); /* The index into the mem bank table */
- mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
- /* Now f holds a pointer to the actual membank */
- mov_l_rR(f,f,offset);
- /* Now f holds the address of the b/w/lput function */
- call_r_02(f,address,source,4,size);
- forget_about(tmp);
+ mov_l_rr(f,address);
+ shrl_l_ri(f,16); /* The index into the mem bank table */
+ mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
+ /* Now f holds a pointer to the actual membank */
+ mov_l_rR(f,f,offset);
+ /* Now f holds the address of the b/w/lput function */
+ call_r_02(f,address,source,4,size);
+ forget_about(tmp);
}
void writebyte(int address, int source, int tmp)
{
- int distrust;
- switch (currprefs.comptrustbyte) {
- case 0: distrust=0; break;
- case 1: distrust=1; break;
- case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
- case 3: distrust=!have_done_picasso; break;
- default: abort();
- }
+ int distrust;
+ switch (currprefs.comptrustbyte) {
+ case 0: distrust=0; break;
+ case 1: distrust=1; break;
+ case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+ case 3: distrust=!have_done_picasso; break;
+ default: abort();
+ }
- if ((special_mem&S_WRITE) || distrust)
- writemem_special(address,source,20,1,tmp);
- else
- writemem_real(address,source,20,1,tmp,0);
+ if ((special_mem&S_WRITE) || distrust)
+ writemem_special(address,source,20,1,tmp);
+ else
+ writemem_real(address,source,20,1,tmp,0);
}
STATIC_INLINE void writeword_general(int address, int source, int tmp,
- int clobber)
-{
- int distrust;
- switch (currprefs.comptrustword) {
- case 0: distrust=0; break;
- case 1: distrust=1; break;
- case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
- case 3: distrust=!have_done_picasso; break;
- default: abort();
- }
+ int clobber)
+{
+ int distrust;
+ switch (currprefs.comptrustword) {
+ case 0: distrust=0; break;
+ case 1: distrust=1; break;
+ case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+ case 3: distrust=!have_done_picasso; break;
+ default: abort();
+ }
- if ((special_mem&S_WRITE) || distrust)
- writemem_special(address,source,16,2,tmp);
- else
- writemem_real(address,source,16,2,tmp,clobber);
+ if ((special_mem&S_WRITE) || distrust)
+ writemem_special(address,source,16,2,tmp);
+ else
+ writemem_real(address,source,16,2,tmp,clobber);
}
void writeword_clobber(int address, int source, int tmp)
{
- writeword_general(address,source,tmp,1);
+ writeword_general(address,source,tmp,1);
}
void writeword(int address, int source, int tmp)
{
- writeword_general(address,source,tmp,0);
+ writeword_general(address,source,tmp,0);
}
STATIC_INLINE void writelong_general(int address, int source, int tmp,
- int clobber)
-{
- int distrust;
- switch (currprefs.comptrustlong) {
- case 0: distrust=0; break;
- case 1: distrust=1; break;
- case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
- case 3: distrust=!have_done_picasso; break;
- default: abort();
- }
+ int clobber)
+{
+ int distrust;
+ switch (currprefs.comptrustlong) {
+ case 0: distrust=0; break;
+ case 1: distrust=1; break;
+ case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+ case 3: distrust=!have_done_picasso; break;
+ default: abort();
+ }
- if ((special_mem&S_WRITE) || distrust)
- writemem_special(address,source,12,4,tmp);
- else
- writemem_real(address,source,12,4,tmp,clobber);
+ if ((special_mem&S_WRITE) || distrust)
+ writemem_special(address,source,12,4,tmp);
+ else
+ writemem_real(address,source,12,4,tmp,clobber);
}
void writelong_clobber(int address, int source, int tmp)
{
- writelong_general(address,source,tmp,1);
+ writelong_general(address,source,tmp,1);
}
void writelong(int address, int source, int tmp)
{
- writelong_general(address,source,tmp,0);
+ writelong_general(address,source,tmp,0);
}
/* This version assumes that it is reading *real* memory, and *will* fail
- * if that assumption is wrong! No branches, no second chances, just
- * straight go-for-it attitude */
+* if that assumption is wrong! No branches, no second chances, just
+* straight go-for-it attitude */
static void readmem_real(int address, int dest, int offset, int size, int tmp)
{
- int f=tmp;
+ int f=tmp;
- if (size==4 && address!=dest)
- f=dest;
+ if (size==4 && address!=dest)
+ f=dest;
#ifdef NATMEM_OFFSET
- if (canbang) { /* Woohoo! go directly at the memory! */
- switch(size) {
- case 1: mov_b_brR(dest,address,NATMEM_OFFSETX); break;
- case 2: mov_w_brR(dest,address,NATMEM_OFFSETX); gen_bswap_16(dest); break;
- case 4: mov_l_brR(dest,address,NATMEM_OFFSETX); gen_bswap_32(dest); break;
+ if (canbang) { /* Woohoo! go directly at the memory! */
+ switch(size) {
+ case 1: mov_b_brR(dest,address,NATMEM_OFFSETX); break;
+ case 2: mov_w_brR(dest,address,NATMEM_OFFSETX); gen_bswap_16(dest); break;
+ case 4: mov_l_brR(dest,address,NATMEM_OFFSETX); gen_bswap_32(dest); break;
+ }
+ forget_about(tmp);
+ return;
}
- forget_about(tmp);
- return;
- }
#endif
- mov_l_rr(f,address);
- shrl_l_ri(f,16); /* The index into the baseaddr table */
- mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
- /* f now holds the offset */
+ mov_l_rr(f,address);
+ shrl_l_ri(f,16); /* The index into the baseaddr table */
+ mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
+ /* f now holds the offset */
- switch(size) {
- case 1: mov_b_rrm_indexed(dest,address,f); break;
- case 2: mov_w_rrm_indexed(dest,address,f); gen_bswap_16(dest); break;
- case 4: mov_l_rrm_indexed(dest,address,f); gen_bswap_32(dest); break;
- }
- forget_about(tmp);
+ switch(size) {
+ case 1: mov_b_rrm_indexed(dest,address,f); break;
+ case 2: mov_w_rrm_indexed(dest,address,f); gen_bswap_16(dest); break;
+ case 4: mov_l_rrm_indexed(dest,address,f); gen_bswap_32(dest); break;
+ }
+ forget_about(tmp);
}
STATIC_INLINE void readmem(int address, int dest, int offset, int size, int tmp)
{
- int f=tmp;
+ int f=tmp;
- mov_l_rr(f,address);
- shrl_l_ri(f,16); /* The index into the mem bank table */
- mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
- /* Now f holds a pointer to the actual membank */
- mov_l_rR(f,f,offset);
- /* Now f holds the address of the b/w/lget function */
- call_r_11(dest,f,address,size,4);
- forget_about(tmp);
+ mov_l_rr(f,address);
+ shrl_l_ri(f,16); /* The index into the mem bank table */
+ mov_l_rm_indexed(f,(uae_u32)mem_banks,f);
+ /* Now f holds a pointer to the actual membank */
+ mov_l_rR(f,f,offset);
+ /* Now f holds the address of the b/w/lget function */
+ call_r_11(dest,f,address,size,4);
+ forget_about(tmp);
}
void readbyte(int address, int dest, int tmp)
{
- int distrust;
- switch (currprefs.comptrustbyte) {
- case 0: distrust=0; break;
- case 1: distrust=1; break;
- case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
- case 3: distrust=!have_done_picasso; break;
- default: abort();
- }
+ int distrust;
+ switch (currprefs.comptrustbyte) {
+ case 0: distrust=0; break;
+ case 1: distrust=1; break;
+ case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+ case 3: distrust=!have_done_picasso; break;
+ default: abort();
+ }
- if ((special_mem&S_READ) || distrust)
- readmem_special(address,dest,8,1,tmp);
- else
- readmem_real(address,dest,8,1,tmp);
+ if ((special_mem&S_READ) || distrust)
+ readmem_special(address,dest,8,1,tmp);
+ else
+ readmem_real(address,dest,8,1,tmp);
}
void readword(int address, int dest, int tmp)
{
- int distrust;
- switch (currprefs.comptrustword) {
- case 0: distrust=0; break;
- case 1: distrust=1; break;
- case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
- case 3: distrust=!have_done_picasso; break;
- default: abort();
- }
+ int distrust;
+ switch (currprefs.comptrustword) {
+ case 0: distrust=0; break;
+ case 1: distrust=1; break;
+ case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+ case 3: distrust=!have_done_picasso; break;
+ default: abort();
+ }
- if ((special_mem&S_READ) || distrust)
- readmem_special(address,dest,4,2,tmp);
- else
- readmem_real(address,dest,4,2,tmp);
+ if ((special_mem&S_READ) || distrust)
+ readmem_special(address,dest,4,2,tmp);
+ else
+ readmem_real(address,dest,4,2,tmp);
}
void readlong(int address, int dest, int tmp)
{
- int distrust;
- switch (currprefs.comptrustlong) {
- case 0: distrust=0; break;
- case 1: distrust=1; break;
- case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
- case 3: distrust=!have_done_picasso; break;
- default: abort();
- }
+ int distrust;
+ switch (currprefs.comptrustlong) {
+ case 0: distrust=0; break;
+ case 1: distrust=1; break;
+ case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+ case 3: distrust=!have_done_picasso; break;
+ default: abort();
+ }
- if ((special_mem&S_READ) || distrust)
- readmem_special(address,dest,0,4,tmp);
- else
- readmem_real(address,dest,0,4,tmp);
+ if ((special_mem&S_READ) || distrust)
+ readmem_special(address,dest,0,4,tmp);
+ else
+ readmem_real(address,dest,0,4,tmp);
}
/* This one might appear a bit odd... */
STATIC_INLINE void get_n_addr_old(int address, int dest, int tmp)
{
- readmem(address,dest,24,4,tmp);
+ readmem(address,dest,24,4,tmp);
}
STATIC_INLINE void get_n_addr_real(int address, int dest, int tmp)
{
- int f=tmp;
- if (address!=dest)
- f=dest;
+ int f=tmp;
+ if (address!=dest)
+ f=dest;
#ifdef NATMEM_OFFSET
- if (canbang) {
- lea_l_brr(dest,address,NATMEM_OFFSETX);
- forget_about(tmp);
- return;
- }
+ if (canbang) {
+ lea_l_brr(dest,address,NATMEM_OFFSETX);
+ forget_about(tmp);
+ return;
+ }
#endif
- mov_l_rr(f,address);
- mov_l_rr(dest,address); // gb-- nop if dest==address
- shrl_l_ri(f,16);
- mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
- add_l(dest,f);
- forget_about(tmp);
+ mov_l_rr(f,address);
+ mov_l_rr(dest,address); // gb-- nop if dest==address
+ shrl_l_ri(f,16);
+ mov_l_rm_indexed(f,(uae_u32)baseaddr,f);
+ add_l(dest,f);
+ forget_about(tmp);
}
void get_n_addr(int address, int dest, int tmp)
{
- int distrust;
- switch (currprefs.comptrustnaddr) {
- case 0: distrust=0; break;
- case 1: distrust=1; break;
- case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
- case 3: distrust=!have_done_picasso; break;
- default: abort();
- }
+ int distrust;
+ switch (currprefs.comptrustnaddr) {
+ case 0: distrust=0; break;
+ case 1: distrust=1; break;
+ case 2: distrust=((start_pc&0xF80000)==0xF80000); break;
+ case 3: distrust=!have_done_picasso; break;
+ default: abort();
+ }
- if (special_mem || distrust)
- get_n_addr_old(address,dest,tmp);
- else
- get_n_addr_real(address,dest,tmp);
+ if (special_mem || distrust)
+ get_n_addr_old(address,dest,tmp);
+ else
+ get_n_addr_real(address,dest,tmp);
}
void get_n_addr_jmp(int address, int dest, int tmp)
{
#if 0 /* For this, we need to get the same address as the rest of UAE
- would --- otherwise we end up translating everything twice */
- get_n_addr(address,dest,tmp);
+would --- otherwise we end up translating everything twice */
+ get_n_addr(address,dest,tmp);
#else
- int f=tmp;
- if (address!=dest)
- f=dest;
- mov_l_rr(f,address);
- shrl_l_ri(f,16); /* The index into the baseaddr bank table */
- mov_l_rm_indexed(dest,(uae_u32)baseaddr,f);
- add_l(dest,address);
- and_l_ri (dest, ~1);
- forget_about(tmp);
+ int f=tmp;
+ if (address!=dest)
+ f=dest;
+ mov_l_rr(f,address);
+ shrl_l_ri(f,16); /* The index into the baseaddr bank table */
+ mov_l_rm_indexed(dest,(uae_u32)baseaddr,f);
+ add_l(dest,address);
+ and_l_ri (dest, ~1);
+ forget_about(tmp);
#endif
}
/* base, target and tmp are registers, but dp is the actual opcode extension word */
void calc_disp_ea_020(int base, uae_u32 dp, int target, int tmp)
{
- int reg = (dp >> 12) & 15;
- int regd_shift=(dp >> 9) & 3;
-
- if (dp & 0x100) {
- int ignorebase=(dp&0x80);
- int ignorereg=(dp&0x40);
- int addbase=0;
- int outer=0;
-
- if ((dp & 0x30) == 0x20) addbase = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
- if ((dp & 0x30) == 0x30) addbase = comp_get_ilong((m68k_pc_offset+=4)-4);
-
- if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
- if ((dp & 0x3) == 0x3) outer = comp_get_ilong((m68k_pc_offset+=4)-4);
-
- if ((dp & 0x4) == 0) { /* add regd *before* the get_long */
- if (!ignorereg) {
- if ((dp & 0x800) == 0)
- sign_extend_16_rr(target,reg);
- else
- mov_l_rr(target,reg);
- shll_l_ri(target,regd_shift);
- }
- else
- mov_l_ri(target,0);
-
- /* target is now regd */
- if (!ignorebase)
- add_l(target,base);
- add_l_ri(target,addbase);
- if (dp&0x03) readlong(target,target,tmp);
- } else { /* do the getlong first, then add regd */
- if (!ignorebase) {
- mov_l_rr(target,base);
- add_l_ri(target,addbase);
- }
- else
- mov_l_ri(target,addbase);
- if (dp&0x03) readlong(target,target,tmp);
-
- if (!ignorereg) {
- if ((dp & 0x800) == 0)
- sign_extend_16_rr(tmp,reg);
- else
- mov_l_rr(tmp,reg);
- shll_l_ri(tmp,regd_shift);
- /* tmp is now regd */
- add_l(target,tmp);
- }
- }
- add_l_ri(target,outer);
- }
- else { /* 68000 version */
- if ((dp & 0x800) == 0) { /* Sign extend */
- sign_extend_16_rr(target,reg);
- lea_l_brr_indexed(target,base,target,regd_shift,(uae_s32)(uae_s8)dp);
+ int reg = (dp >> 12) & 15;
+ int regd_shift=(dp >> 9) & 3;
+
+ if (dp & 0x100) {
+ int ignorebase=(dp&0x80);
+ int ignorereg=(dp&0x40);
+ int addbase=0;
+ int outer=0;
+
+ if ((dp & 0x30) == 0x20) addbase = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
+ if ((dp & 0x30) == 0x30) addbase = comp_get_ilong((m68k_pc_offset+=4)-4);
+
+ if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
+ if ((dp & 0x3) == 0x3) outer = comp_get_ilong((m68k_pc_offset+=4)-4);
+
+ if ((dp & 0x4) == 0) { /* add regd *before* the get_long */
+ if (!ignorereg) {
+ if ((dp & 0x800) == 0)
+ sign_extend_16_rr(target,reg);
+ else
+ mov_l_rr(target,reg);
+ shll_l_ri(target,regd_shift);
+ }
+ else
+ mov_l_ri(target,0);
+
+ /* target is now regd */
+ if (!ignorebase)
+ add_l(target,base);
+ add_l_ri(target,addbase);
+ if (dp&0x03) readlong(target,target,tmp);
+ } else { /* do the getlong first, then add regd */
+ if (!ignorebase) {
+ mov_l_rr(target,base);
+ add_l_ri(target,addbase);
+ }
+ else
+ mov_l_ri(target,addbase);
+ if (dp&0x03) readlong(target,target,tmp);
+
+ if (!ignorereg) {
+ if ((dp & 0x800) == 0)
+ sign_extend_16_rr(tmp,reg);
+ else
+ mov_l_rr(tmp,reg);
+ shll_l_ri(tmp,regd_shift);
+ /* tmp is now regd */
+ add_l(target,tmp);
+ }
+ }
+ add_l_ri(target,outer);
}
- else {
- lea_l_brr_indexed(target,base,reg,regd_shift,(uae_s32)(uae_s8)dp);
+ else { /* 68000 version */
+ if ((dp & 0x800) == 0) { /* Sign extend */
+ sign_extend_16_rr(target,reg);
+ lea_l_brr_indexed(target,base,target,regd_shift,(uae_s32)(uae_s8)dp);
+ }
+ else {
+ lea_l_brr_indexed(target,base,reg,regd_shift,(uae_s32)(uae_s8)dp);
+ }
}
- }
- forget_about(tmp);
+ forget_about(tmp);
}
STATIC_INLINE unsigned int cft_map (unsigned int f)
{
- return ((f >> 8) & 255) | ((f & 255) << 8);
+ return ((f >> 8) & 255) | ((f & 255) << 8);
}
void set_cache_state(int enabled)
{
- if (enabled!=letit)
- flush_icache_hard(0, 3);
- letit=enabled;
+ if (enabled!=letit)
+ flush_icache_hard(0, 3);
+ letit=enabled;
}
int get_cache_state(void)
{
- return letit;
+ return letit;
}
uae_u32 get_jitted_size(void)
{
- if (compiled_code)
- return current_compile_p-compiled_code;
- return 0;
+ if (compiled_code)
+ return current_compile_p-compiled_code;
+ return 0;
}
void alloc_cache(void)
{
- if (compiled_code) {
- flush_icache_hard(0, 3);
- cache_free(compiled_code);
- }
- if (veccode == NULL)
- veccode = cache_alloc (256);
- if (popallspace == NULL)
- popallspace = cache_alloc (1024);
- compiled_code = NULL;
- if (currprefs.cachesize == 0)
- return;
+ if (compiled_code) {
+ flush_icache_hard(0, 3);
+ cache_free(compiled_code);
+ }
+ if (veccode == NULL)
+ veccode = cache_alloc (256);
+ if (popallspace == NULL)
+ popallspace = cache_alloc (1024);
+ compiled_code = NULL;
+ if (currprefs.cachesize == 0)
+ return;
- while (!compiled_code && currprefs.cachesize) {
- compiled_code=cache_alloc(currprefs.cachesize*1024);
- if (!compiled_code)
- currprefs.cachesize/=2;
- }
- if (compiled_code) {
- max_compile_start=compiled_code+currprefs.cachesize*1024-BYTES_PER_INST;
- current_compile_p=compiled_code;
- }
+ while (!compiled_code && currprefs.cachesize) {
+ compiled_code=cache_alloc(currprefs.cachesize*1024);
+ if (!compiled_code)
+ currprefs.cachesize/=2;
+ }
+ if (compiled_code) {
+ max_compile_start=compiled_code+currprefs.cachesize*1024-BYTES_PER_INST;
+ current_compile_p=compiled_code;
+ }
}
static void calc_checksum(blockinfo* bi, uae_u32* c1, uae_u32* c2)
{
- uae_u32 k1=0;
- uae_u32 k2=0;
- uae_s32 len=bi->len;
- uae_u32 tmp=bi->min_pcp;
- uae_u32* pos;
+ uae_u32 k1=0;
+ uae_u32 k2=0;
+ uae_s32 len=bi->len;
+ uae_u32 tmp=bi->min_pcp;
+ uae_u32* pos;
- len+=(tmp&3);
- tmp&=(~3);
- pos=(uae_u32*)tmp;
+ len+=(tmp&3);
+ tmp&=(~3);
+ pos=(uae_u32*)tmp;
- if (len<0 || len>MAX_CHECKSUM_LEN) {
- *c1=0;
- *c2=0;
- }
- else {
- while (len>0) {
- k1+=*pos;
- k2^=*pos;
- pos++;
- len-=4;
+ if (len<0 || len>MAX_CHECKSUM_LEN) {
+ *c1=0;
+ *c2=0;
+ }
+ else {
+ while (len>0) {
+ k1+=*pos;
+ k2^=*pos;
+ pos++;
+ len-=4;
+ }
+ *c1=k1;
+ *c2=k2;
}
- *c1=k1;
- *c2=k2;
- }
}
static void show_checksum(blockinfo* bi)
{
- uae_u32 k1=0;
- uae_u32 k2=0;
- uae_s32 len=bi->len;
- uae_u32 tmp=(uae_u32)bi->pc_p;
- uae_u32* pos;
+ uae_u32 k1=0;
+ uae_u32 k2=0;
+ uae_s32 len=bi->len;
+ uae_u32 tmp=(uae_u32)bi->pc_p;
+ uae_u32* pos;
- len+=(tmp&3);
- tmp&=(~3);
- pos=(uae_u32*)tmp;
+ len+=(tmp&3);
+ tmp&=(~3);
+ pos=(uae_u32*)tmp;
- if (len<0 || len>MAX_CHECKSUM_LEN) {
- return;
- }
- else {
- while (len>0) {
- write_log (L"%08x ",*pos);
- pos++;
- len-=4;
+ if (len<0 || len>MAX_CHECKSUM_LEN) {
+ return;
+ }
+ else {
+ while (len>0) {
+ write_log (L"%08x ",*pos);
+ pos++;
+ len-=4;
+ }
+ write_log (L" bla\n");
}
- write_log (L" bla\n");
- }
}
int check_for_cache_miss(void)
{
- blockinfo* bi=get_blockinfo_addr(regs.pc_p);
+ blockinfo* bi=get_blockinfo_addr(regs.pc_p);
- if (bi) {
- int cl=cacheline(regs.pc_p);
- if (bi!=cache_tags[cl+1].bi) {
- raise_in_cl_list(bi);
- return 1;
+ if (bi) {
+ int cl=cacheline(regs.pc_p);
+ if (bi!=cache_tags[cl+1].bi) {
+ raise_in_cl_list(bi);
+ return 1;
+ }
}
- }
- return 0;
+ return 0;
}
static void recompile_block(void)
{
- /* An existing block's countdown code has expired. We need to make
- sure that execute_normal doesn't refuse to recompile due to a
- perceived cache miss... */
- blockinfo* bi=get_blockinfo_addr(regs.pc_p);
+ /* An existing block's countdown code has expired. We need to make
+ sure that execute_normal doesn't refuse to recompile due to a
+ perceived cache miss... */
+ blockinfo* bi=get_blockinfo_addr(regs.pc_p);
- Dif (!bi)
- jit_abort (L"recompile_block");
- raise_in_cl_list(bi);
- execute_normal();
- return;
+ Dif (!bi)
+ jit_abort (L"recompile_block");
+ raise_in_cl_list(bi);
+ execute_normal();
+ return;
}
static void cache_miss(void)
{
- blockinfo* bi=get_blockinfo_addr(regs.pc_p);
- uae_u32 cl=cacheline(regs.pc_p);
- blockinfo* bi2=get_blockinfo(cl);
+ blockinfo* bi=get_blockinfo_addr(regs.pc_p);
+ uae_u32 cl=cacheline(regs.pc_p);
+ blockinfo* bi2=get_blockinfo(cl);
- if (!bi) {
- execute_normal(); /* Compile this block now */
+ if (!bi) {
+ execute_normal(); /* Compile this block now */
+ return;
+ }
+ Dif (!bi2 || bi==bi2) {
+ jit_abort (L"Unexplained cache miss %p %p\n",bi,bi2);
+ }
+ raise_in_cl_list(bi);
return;
- }
- Dif (!bi2 || bi==bi2) {
- jit_abort (L"Unexplained cache miss %p %p\n",bi,bi2);
- }
- raise_in_cl_list(bi);
- return;
}
static void check_checksum(void)
{
- blockinfo* bi=get_blockinfo_addr(regs.pc_p);
- uae_u32 cl=cacheline(regs.pc_p);
- blockinfo* bi2=get_blockinfo(cl);
+ blockinfo* bi=get_blockinfo_addr(regs.pc_p);
+ uae_u32 cl=cacheline(regs.pc_p);
+ blockinfo* bi2=get_blockinfo(cl);
- uae_u32 c1,c2;
+ uae_u32 c1,c2;
- checksum_count++;
- /* These are not the droids you are looking for... */
- if (!bi) {
- /* Whoever is the primary target is in a dormant state, but
- calling it was accidental, and we should just compile this
- new block */
- execute_normal();
- return;
- }
- if (bi!=bi2) {
- /* The block was hit accidentally, but it does exist. Cache miss */
- cache_miss();
- return;
- }
-
- if (bi->c1 || bi->c2)
- calc_checksum(bi,&c1,&c2);
- else {
- c1=c2=1; /* Make sure it doesn't match */
- }
- if (c1==bi->c1 && c2==bi->c2) {
- /* This block is still OK. So we reactivate. Of course, that
- means we have to move it into the needs-to-be-flushed list */
- bi->handler_to_use=bi->handler;
- set_dhtu(bi,bi->direct_handler);
-
- /* write_log (L"JIT: reactivate %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
+ checksum_count++;
+ /* These are not the droids you are looking for... */
+ if (!bi) {
+ /* Whoever is the primary target is in a dormant state, but
+ calling it was accidental, and we should just compile this
+ new block */
+ execute_normal();
+ return;
+ }
+ if (bi!=bi2) {
+ /* The block was hit accidentally, but it does exist. Cache miss */
+ cache_miss();
+ return;
+ }
+
+ if (bi->c1 || bi->c2)
+ calc_checksum(bi,&c1,&c2);
+ else {
+ c1=c2=1; /* Make sure it doesn't match */
+ }
+ if (c1==bi->c1 && c2==bi->c2) {
+ /* This block is still OK. So we reactivate. Of course, that
+ means we have to move it into the needs-to-be-flushed list */
+ bi->handler_to_use=bi->handler;
+ set_dhtu(bi,bi->direct_handler);
+
+ /* write_log (L"JIT: reactivate %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
c1,c2,bi->c1,bi->c2);*/
- remove_from_list(bi);
- add_to_active(bi);
- raise_in_cl_list(bi);
- }
- else {
- /* This block actually changed. We need to invalidate it,
- and set it up to be recompiled */
- /* write_log (L"JIT: discard %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
- c1,c2,bi->c1,bi->c2); */
- invalidate_block(bi);
- raise_in_cl_list(bi);
- execute_normal();
- }
+ remove_from_list(bi);
+ add_to_active(bi);
+ raise_in_cl_list(bi);
+ }
+ else {
+ /* This block actually changed. We need to invalidate it,
+ and set it up to be recompiled */
+ /* write_log (L"JIT: discard %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
+ c1,c2,bi->c1,bi->c2); */
+ invalidate_block(bi);
+ raise_in_cl_list(bi);
+ execute_normal();
+ }
}
STATIC_INLINE void create_popalls(void)
{
- int i,r;
+ int i,r;
- current_compile_p=popallspace;
- set_target(current_compile_p);
+ current_compile_p=popallspace;
+ set_target(current_compile_p);
#if USE_PUSH_POP
- /* If we can't use gcc inline assembly, we need to pop some
- registers before jumping back to the various get-out routines.
- This generates the code for it.
- */
- popall_do_nothing=current_compile_p;
- for (i=0;i<N_REGS;i++) {
- if (need_to_preserve[i])
- raw_pop_l_r(i);
- }
- raw_jmp((uae_u32)do_nothing);
- align_target(32);
-
- popall_execute_normal=get_target();
- for (i=0;i<N_REGS;i++) {
- if (need_to_preserve[i])
- raw_pop_l_r(i);
- }
- raw_jmp((uae_u32)execute_normal);
- align_target(32);
-
- popall_cache_miss=get_target();
- for (i=0;i<N_REGS;i++) {
- if (need_to_preserve[i])
- raw_pop_l_r(i);
- }
- raw_jmp((uae_u32)cache_miss);
- align_target(32);
-
- popall_recompile_block=get_target();
- for (i=0;i<N_REGS;i++) {
- if (need_to_preserve[i])
- raw_pop_l_r(i);
- }
- raw_jmp((uae_u32)recompile_block);
- align_target(32);
-
- popall_exec_nostats=get_target();
- for (i=0;i<N_REGS;i++) {
- if (need_to_preserve[i])
- raw_pop_l_r(i);
- }
- raw_jmp((uae_u32)exec_nostats);
- align_target(32);
-
- popall_check_checksum=get_target();
- for (i=0;i<N_REGS;i++) {
- if (need_to_preserve[i])
- raw_pop_l_r(i);
- }
- raw_jmp((uae_u32)check_checksum);
- align_target(32);
-
- current_compile_p=get_target();
+ /* If we can't use gcc inline assembly, we need to pop some
+ registers before jumping back to the various get-out routines.
+ This generates the code for it.
+ */
+ popall_do_nothing=current_compile_p;
+ for (i=0;i<N_REGS;i++) {
+ if (need_to_preserve[i])
+ raw_pop_l_r(i);
+ }
+ raw_jmp((uae_u32)do_nothing);
+ align_target(32);
+
+ popall_execute_normal=get_target();
+ for (i=0;i<N_REGS;i++) {
+ if (need_to_preserve[i])
+ raw_pop_l_r(i);
+ }
+ raw_jmp((uae_u32)execute_normal);
+ align_target(32);
+
+ popall_cache_miss=get_target();
+ for (i=0;i<N_REGS;i++) {
+ if (need_to_preserve[i])
+ raw_pop_l_r(i);
+ }
+ raw_jmp((uae_u32)cache_miss);
+ align_target(32);
+
+ popall_recompile_block=get_target();
+ for (i=0;i<N_REGS;i++) {
+ if (need_to_preserve[i])
+ raw_pop_l_r(i);
+ }
+ raw_jmp((uae_u32)recompile_block);
+ align_target(32);
+
+ popall_exec_nostats=get_target();
+ for (i=0;i<N_REGS;i++) {
+ if (need_to_preserve[i])
+ raw_pop_l_r(i);
+ }
+ raw_jmp((uae_u32)exec_nostats);
+ align_target(32);
+
+ popall_check_checksum=get_target();
+ for (i=0;i<N_REGS;i++) {
+ if (need_to_preserve[i])
+ raw_pop_l_r(i);
+ }
+ raw_jmp((uae_u32)check_checksum);
+ align_target(32);
+
+ current_compile_p=get_target();
#else
- popall_exec_nostats=exec_nostats;
- popall_execute_normal=execute_normal;
- popall_cache_miss=cache_miss;
- popall_recompile_block=recompile_block;
- popall_do_nothing=do_nothing;
- popall_check_checksum=check_checksum;
+ popall_exec_nostats=exec_nostats;
+ popall_execute_normal=execute_normal;
+ popall_cache_miss=cache_miss;
+ popall_recompile_block=recompile_block;
+ popall_do_nothing=do_nothing;
+ popall_check_checksum=check_checksum;
#endif
- /* And now, the code to do the matching pushes and then jump
- into a handler routine */
- pushall_call_handler=get_target();
+ /* And now, the code to do the matching pushes and then jump
+ into a handler routine */
+ pushall_call_handler=get_target();
#if USE_PUSH_POP
- for (i=N_REGS;i--;) {
- if (need_to_preserve[i])
- raw_push_l_r(i);
- }
+ for (i=N_REGS;i--;) {
+ if (need_to_preserve[i])
+ raw_push_l_r(i);
+ }
#endif
- r=REG_PC_TMP;
- raw_mov_l_rm(r,(uae_u32)®s.pc_p);
- raw_and_l_ri(r,TAGMASK);
- raw_jmp_m_indexed((uae_u32)cache_tags,r,4);
+ r=REG_PC_TMP;
+ raw_mov_l_rm(r,(uae_u32)®s.pc_p);
+ raw_and_l_ri(r,TAGMASK);
+ raw_jmp_m_indexed((uae_u32)cache_tags,r,4);
}
STATIC_INLINE void reset_lists(void)
{
- int i;
+ int i;
- for (i=0;i<MAX_HOLD_BI;i++)
- hold_bi[i]=NULL;
- active=NULL;
- dormant=NULL;
+ for (i=0;i<MAX_HOLD_BI;i++)
+ hold_bi[i]=NULL;
+ active=NULL;
+ dormant=NULL;
}
static void prepare_block(blockinfo* bi)
{
- int i;
+ int i;
- set_target(current_compile_p);
- align_target(32);
- bi->direct_pen=(cpuop_func*)get_target();
- raw_mov_l_rm(0,(uae_u32)&(bi->pc_p));
- raw_mov_l_mr((uae_u32)®s.pc_p,0);
- raw_jmp((uae_u32)popall_execute_normal);
+ set_target(current_compile_p);
+ align_target(32);
+ bi->direct_pen=(cpuop_func*)get_target();
+ raw_mov_l_rm(0,(uae_u32)&(bi->pc_p));
+ raw_mov_l_mr((uae_u32)®s.pc_p,0);
+ raw_jmp((uae_u32)popall_execute_normal);
- align_target(32);
- bi->direct_pcc=(cpuop_func*)get_target();
- raw_mov_l_rm(0,(uae_u32)&(bi->pc_p));
- raw_mov_l_mr((uae_u32)®s.pc_p,0);
- raw_jmp((uae_u32)popall_check_checksum);
+ align_target(32);
+ bi->direct_pcc=(cpuop_func*)get_target();
+ raw_mov_l_rm(0,(uae_u32)&(bi->pc_p));
+ raw_mov_l_mr((uae_u32)®s.pc_p,0);
+ raw_jmp((uae_u32)popall_check_checksum);
- align_target(32);
- current_compile_p=get_target();
+ align_target(32);
+ current_compile_p=get_target();
- bi->deplist=NULL;
- for (i=0;i<2;i++) {
- bi->dep[i].prev_p=NULL;
- bi->dep[i].next=NULL;
- }
- bi->env=default_ss;
- bi->status=BI_NEW;
- bi->havestate=0;
- //bi->env=empty_ss;
+ bi->deplist=NULL;
+ for (i=0;i<2;i++) {
+ bi->dep[i].prev_p=NULL;
+ bi->dep[i].next=NULL;
+ }
+ bi->env=default_ss;
+ bi->status=BI_NEW;
+ bi->havestate=0;
+ //bi->env=empty_ss;
}
void compemu_reset(void)
{
- set_cache_state(0);
+ set_cache_state(0);
}
void build_comp(void)
{
- int i;
- int jumpcount=0;
- unsigned long opcode;
- const struct comptbl* tbl=op_smalltbl_0_comp_ff;
- const struct comptbl* nftbl=op_smalltbl_0_comp_nf;
- int count;
+ int i;
+ int jumpcount=0;
+ unsigned long opcode;
+ const struct comptbl* tbl=op_smalltbl_0_comp_ff;
+ const struct comptbl* nftbl=op_smalltbl_0_comp_nf;
+ int count;
#ifdef NOFLAGS_SUPPORT
- struct comptbl *nfctbl = (currprefs.cpu_level >= 5 ? op_smalltbl_0_nf
- : currprefs.cpu_level == 4 ? op_smalltbl_1_nf
- : (currprefs.cpu_level == 2 || currprefs.cpu_level == 3) ? op_smalltbl_2_nf
- : currprefs.cpu_level == 1 ? op_smalltbl_3_nf
- : ! currprefs.cpu_compatible ? op_smalltbl_4_nf
- : op_smalltbl_5_nf);
+ struct comptbl *nfctbl = (currprefs.cpu_level >= 5 ? op_smalltbl_0_nf
+ : currprefs.cpu_level == 4 ? op_smalltbl_1_nf
+ : (currprefs.cpu_level == 2 || currprefs.cpu_level == 3) ? op_smalltbl_2_nf
+ : currprefs.cpu_level == 1 ? op_smalltbl_3_nf
+ : ! currprefs.cpu_compatible ? op_smalltbl_4_nf
+ : op_smalltbl_5_nf);
#endif
- raw_init_cpu();
+ raw_init_cpu();
#ifdef NATMEM_OFFSET
- write_log (L"JIT: Setting signal handler\n");
+ write_log (L"JIT: Setting signal handler\n");
#ifndef _WIN32
- signal(SIGSEGV,vec);
+ signal(SIGSEGV,vec);
#endif
#endif
- write_log (L"JIT: Building Compiler function table\n");
- for (opcode = 0; opcode < 65536; opcode++) {
+ write_log (L"JIT: Building Compiler function table\n");
+ for (opcode = 0; opcode < 65536; opcode++) {
#ifdef NOFLAGS_SUPPORT
- nfcpufunctbl[opcode] = op_illg;
+ nfcpufunctbl[opcode] = op_illg;
#endif
- compfunctbl[opcode] = NULL;
- nfcompfunctbl[opcode] = NULL;
- prop[opcode].use_flags = 0x1f;
- prop[opcode].set_flags = 0x1f;
- prop[opcode].is_jump=1;
- }
-
- for (i = 0; tbl[i].opcode < 65536; i++) {
- int isjmp=(tbl[i].specific&1);
- int isaddx=(tbl[i].specific&8);
- int iscjmp=(tbl[i].specific&16);
-
- prop[tbl[i].opcode].is_jump=isjmp;
- prop[tbl[i].opcode].is_const_jump=iscjmp;
- prop[tbl[i].opcode].is_addx=isaddx;
- compfunctbl[tbl[i].opcode] = tbl[i].handler;
- }
- for (i = 0; nftbl[i].opcode < 65536; i++) {
- nfcompfunctbl[nftbl[i].opcode] = nftbl[i].handler;
+ compfunctbl[opcode] = NULL;
+ nfcompfunctbl[opcode] = NULL;
+ prop[opcode].use_flags = 0x1f;
+ prop[opcode].set_flags = 0x1f;
+ prop[opcode].is_jump=1;
+ }
+
+ for (i = 0; tbl[i].opcode < 65536; i++) {
+ int isjmp=(tbl[i].specific&1);
+ int isaddx=(tbl[i].specific&8);
+ int iscjmp=(tbl[i].specific&16);
+
+ prop[tbl[i].opcode].is_jump=isjmp;
+ prop[tbl[i].opcode].is_const_jump=iscjmp;
+ prop[tbl[i].opcode].is_addx=isaddx;
+ compfunctbl[tbl[i].opcode] = tbl[i].handler;
+ }
+ for (i = 0; nftbl[i].opcode < 65536; i++) {
+ nfcompfunctbl[nftbl[i].opcode] = nftbl[i].handler;
#ifdef NOFLAGS_SUPPORT
- nfcpufunctbl[nftbl[i].opcode] = nfctbl[i].handler;
+ nfcpufunctbl[nftbl[i].opcode] = nfctbl[i].handler;
#endif
- }
+ }
#ifdef NOFLAGS_SUPPORT
- for (i = 0; nfctbl[i].handler; i++) {
- nfcpufunctbl[nfctbl[i].opcode] = nfctbl[i].handler;
- }
+ for (i = 0; nfctbl[i].handler; i++) {
+ nfcpufunctbl[nfctbl[i].opcode] = nfctbl[i].handler;
+ }
#endif
- for (opcode = 0; opcode < 65536; opcode++) {
- compop_func *f;
- compop_func *nff;
+ for (opcode = 0; opcode < 65536; opcode++) {
+ compop_func *f;
+ compop_func *nff;
#ifdef NOFLAGS_SUPPORT
- compop_func *nfcf;
+ compop_func *nfcf;
#endif
- int isjmp,isaddx,iscjmp;
- int lvl;
-
- lvl = (currprefs.cpu_model - 68000) / 10;
- if (lvl > 4)
- lvl--;
- if (table68k[opcode].mnemo == i_ILLG || table68k[opcode].clev > lvl)
- continue;
-
- if (table68k[opcode].handler != -1) {
- f = compfunctbl[table68k[opcode].handler];
- nff = nfcompfunctbl[table68k[opcode].handler];
+ int isjmp,isaddx,iscjmp;
+ int lvl;
+
+ lvl = (currprefs.cpu_model - 68000) / 10;
+ if (lvl > 4)
+ lvl--;
+ if (table68k[opcode].mnemo == i_ILLG || table68k[opcode].clev > lvl)
+ continue;
+
+ if (table68k[opcode].handler != -1) {
+ f = compfunctbl[table68k[opcode].handler];
+ nff = nfcompfunctbl[table68k[opcode].handler];
#ifdef NOFLAGS_SUPPORT
- nfcf = nfcpufunctbl[table68k[opcode].handler];
+ nfcf = nfcpufunctbl[table68k[opcode].handler];
#endif
- isjmp=prop[table68k[opcode].handler].is_jump;
- iscjmp=prop[table68k[opcode].handler].is_const_jump;
- isaddx=prop[table68k[opcode].handler].is_addx;
- prop[opcode].is_jump=isjmp;
- prop[opcode].is_const_jump=iscjmp;
- prop[opcode].is_addx=isaddx;
- compfunctbl[opcode] = f;
- nfcompfunctbl[opcode] = nff;
+ isjmp=prop[table68k[opcode].handler].is_jump;
+ iscjmp=prop[table68k[opcode].handler].is_const_jump;
+ isaddx=prop[table68k[opcode].handler].is_addx;
+ prop[opcode].is_jump=isjmp;
+ prop[opcode].is_const_jump=iscjmp;
+ prop[opcode].is_addx=isaddx;
+ compfunctbl[opcode] = f;
+ nfcompfunctbl[opcode] = nff;
#ifdef NOFLAGS_SUPPORT
- Dif (nfcf == op_illg)
- abort();
- nfcpufunctbl[opcode] = nfcf;
+ Dif (nfcf == op_illg)
+ abort();
+ nfcpufunctbl[opcode] = nfcf;
#endif
+ }
+ prop[opcode].set_flags =table68k[opcode].flagdead;
+ prop[opcode].use_flags =table68k[opcode].flaglive;
+ /* Unconditional jumps don't evaluate condition codes, so they
+ don't actually use any flags themselves */
+ if (prop[opcode].is_const_jump)
+ prop[opcode].use_flags=0;
}
- prop[opcode].set_flags =table68k[opcode].flagdead;
- prop[opcode].use_flags =table68k[opcode].flaglive;
- /* Unconditional jumps don't evaluate condition codes, so they
- don't actually use any flags themselves */
- if (prop[opcode].is_const_jump)
- prop[opcode].use_flags=0;
- }
#ifdef NOFLAGS_SUPPORT
- for (i = 0; nfctbl[i].handler != NULL; i++) {
- if (nfctbl[i].specific)
- nfcpufunctbl[tbl[i].opcode] = nfctbl[i].handler;
- }
+ for (i = 0; nfctbl[i].handler != NULL; i++) {
+ if (nfctbl[i].specific)
+ nfcpufunctbl[tbl[i].opcode] = nfctbl[i].handler;
+ }
#endif
- count=0;
- for (opcode = 0; opcode < 65536; opcode++) {
- if (compfunctbl[opcode])
- count++;
- }
- write_log (L"JIT: Supposedly %d compileable opcodes!\n",count);
-
- /* Initialise state */
- alloc_cache();
- create_popalls();
- reset_lists();
-
- for (i=0;i<TAGSIZE;i+=2) {
- cache_tags[i].handler=(cpuop_func*)popall_execute_normal;
- cache_tags[i+1].bi=NULL;
- }
- compemu_reset();
-
- for (i=0;i<N_REGS;i++) {
- empty_ss.nat[i].holds=-1;
- empty_ss.nat[i].validsize=0;
- empty_ss.nat[i].dirtysize=0;
- }
- default_ss=empty_ss;
+ count=0;
+ for (opcode = 0; opcode < 65536; opcode++) {
+ if (compfunctbl[opcode])
+ count++;
+ }
+ write_log (L"JIT: Supposedly %d compileable opcodes!\n",count);
+
+ /* Initialise state */
+ alloc_cache();
+ create_popalls();
+ reset_lists();
+
+ for (i=0;i<TAGSIZE;i+=2) {
+ cache_tags[i].handler=(cpuop_func*)popall_execute_normal;
+ cache_tags[i+1].bi=NULL;
+ }
+ compemu_reset();
+
+ for (i=0;i<N_REGS;i++) {
+ empty_ss.nat[i].holds=-1;
+ empty_ss.nat[i].validsize=0;
+ empty_ss.nat[i].dirtysize=0;
+ }
+ default_ss=empty_ss;
#if 0
- default_ss.nat[6].holds=11;
- default_ss.nat[6].validsize=4;
- default_ss.nat[5].holds=12;
- default_ss.nat[5].validsize=4;
+ default_ss.nat[6].holds=11;
+ default_ss.nat[6].validsize=4;
+ default_ss.nat[5].holds=12;
+ default_ss.nat[5].validsize=4;
#endif
}
static void flush_icache_hard(uae_u32 ptr, int n)
{
- blockinfo* bi;
+ blockinfo* bi;
- hard_flush_count++;
+ hard_flush_count++;
#if 0
- write_log (L"JIT: Flush Icache_hard(%d/%x/%p), %u instruction bytes\n",
- n,regs.pc,regs.pc_p,current_compile_p-compiled_code);
+ write_log (L"JIT: Flush Icache_hard(%d/%x/%p), %u instruction bytes\n",
+ n,regs.pc,regs.pc_p,current_compile_p-compiled_code);
#endif
- bi=active;
- while(bi) {
- cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal;
- cache_tags[cacheline(bi->pc_p)+1].bi=NULL;
- bi=bi->next;
- }
- bi=dormant;
- while(bi) {
- cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal;
- cache_tags[cacheline(bi->pc_p)+1].bi=NULL;
- bi=bi->next;
- }
-
- reset_lists();
- if (!compiled_code)
- return;
- current_compile_p=compiled_code;
- set_special(0); /* To get out of compiled code */
+ bi=active;
+ while(bi) {
+ cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal;
+ cache_tags[cacheline(bi->pc_p)+1].bi=NULL;
+ bi=bi->next;
+ }
+ bi=dormant;
+ while(bi) {
+ cache_tags[cacheline(bi->pc_p)].handler=(cpuop_func*)popall_execute_normal;
+ cache_tags[cacheline(bi->pc_p)+1].bi=NULL;
+ bi=bi->next;
+ }
+
+ reset_lists();
+ if (!compiled_code)
+ return;
+ current_compile_p=compiled_code;
+ set_special(0); /* To get out of compiled code */
}
/* "Soft flushing" --- instead of actually throwing everything away,
- we simply mark everything as "needs to be checked".
+we simply mark everything as "needs to be checked".
*/
void flush_icache(uaecptr ptr, int n)
{
- blockinfo* bi;
- blockinfo* bi2;
+ blockinfo* bi;
+ blockinfo* bi2;
- if (currprefs.comp_hardflush) {
- flush_icache_hard(ptr, n);
- return;
- }
- soft_flush_count++;
- if (!active)
- return;
+ if (currprefs.comp_hardflush) {
+ flush_icache_hard(ptr, n);
+ return;
+ }
+ soft_flush_count++;
+ if (!active)
+ return;
- bi=active;
- while (bi) {
- uae_u32 cl=cacheline(bi->pc_p);
- if (!bi->handler) {
- /* invalidated block */
- if (bi==cache_tags[cl+1].bi)
- cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
- bi->handler_to_use=(cpuop_func*)popall_execute_normal;
- set_dhtu(bi,bi->direct_pen);
- } else {
- if (bi==cache_tags[cl+1].bi)
- cache_tags[cl].handler=(cpuop_func*)popall_check_checksum;
- bi->handler_to_use=(cpuop_func*)popall_check_checksum;
- set_dhtu(bi,bi->direct_pcc);
+ bi=active;
+ while (bi) {
+ uae_u32 cl=cacheline(bi->pc_p);
+ if (!bi->handler) {
+ /* invalidated block */
+ if (bi==cache_tags[cl+1].bi)
+ cache_tags[cl].handler=(cpuop_func*)popall_execute_normal;
+ bi->handler_to_use=(cpuop_func*)popall_execute_normal;
+ set_dhtu(bi,bi->direct_pen);
+ } else {
+ if (bi==cache_tags[cl+1].bi)
+ cache_tags[cl].handler=(cpuop_func*)popall_check_checksum;
+ bi->handler_to_use=(cpuop_func*)popall_check_checksum;
+ set_dhtu(bi,bi->direct_pcc);
+ }
+ bi2=bi;
+ bi=bi->next;
}
- bi2=bi;
- bi=bi->next;
- }
- /* bi2 is now the last entry in the active list */
- bi2->next=dormant;
- if (dormant)
- dormant->prev_p=&(bi2->next);
+ /* bi2 is now the last entry in the active list */
+ bi2->next=dormant;
+ if (dormant)
+ dormant->prev_p=&(bi2->next);
- dormant=active;
- active->prev_p=&dormant;
- active=NULL;
+ dormant=active;
+ active->prev_p=&dormant;
+ active=NULL;
}
static void catastrophe(void)
{
- jit_abort (L"catastprophe");
+ jit_abort (L"catastprophe");
}
int failure;
void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
{
- if (letit && compiled_code && currprefs.cpu_model>=68020) {
+ if (letit && compiled_code && currprefs.cpu_model>=68020) {
+
+ /* OK, here we need to 'compile' a block */
+ int i;
+ int r;
+ int was_comp=0;
+ uae_u8 liveflags[MAXRUN+1];
+ uae_u32 max_pcp=(uae_u32)pc_hist[0].location;
+ uae_u32 min_pcp=max_pcp;
+ uae_u32 cl=cacheline(pc_hist[0].location);
+ void* specflags=(void*)®s.spcflags;
+ blockinfo* bi=NULL;
+ blockinfo* bi2;
+ int extra_len=0;
+
+ compile_count++;
+ if (current_compile_p>=max_compile_start)
+ flush_icache_hard(0, 3);
+
+ alloc_blockinfos();
+
+ bi=get_blockinfo_addr_new(pc_hist[0].location,0);
+ bi2=get_blockinfo(cl);
+
+ optlev=bi->optlevel;
+ if (bi->handler) {
+ Dif (bi!=bi2) {
+ /* I don't think it can happen anymore. Shouldn't, in
+ any case. So let's make sure... */
+ jit_abort (L"JIT: WOOOWOO count=%d, ol=%d %p %p\n",
+ bi->count,bi->optlevel,bi->handler_to_use,
+ cache_tags[cl].handler);
+ }
+
+ Dif (bi->count!=-1 && bi->status!=BI_TARGETTED) {
+ /* What the heck? We are not supposed to be here! */
+ jit_abort (L"BI_TARGETTED");
+ }
+ }
+ if (bi->count==-1) {
+ optlev++;
+ while (!currprefs.optcount[optlev])
+ optlev++;
+ bi->count=currprefs.optcount[optlev]-1;
+ }
+ current_block_pc_p=(uae_u32)pc_hist[0].location;
+
+ remove_deps(bi); /* We are about to create new code */
+ bi->optlevel=optlev;
+ bi->pc_p=(uae_u8*)pc_hist[0].location;
+
+ liveflags[blocklen]=0x1f; /* All flags needed afterwards */
+ i=blocklen;
+ while (i--) {
+ uae_u16* currpcp=pc_hist[i].location;
+ int op=cft_map(*currpcp);
+
+ if ((uae_u32)currpcp<min_pcp)
+ min_pcp=(uae_u32)currpcp;
+ if ((uae_u32)currpcp>max_pcp)
+ max_pcp=(uae_u32)currpcp;
+
+ if (currprefs.compnf) {
+ liveflags[i]=((liveflags[i+1]&
+ (~prop[op].set_flags))|
+ prop[op].use_flags);
+ if (prop[op].is_addx && (liveflags[i+1]&FLAG_Z)==0)
+ liveflags[i]&= ~FLAG_Z;
+ }
+ else {
+ liveflags[i]=0x1f;
+ }
+ }
- /* OK, here we need to 'compile' a block */
- int i;
- int r;
- int was_comp=0;
- uae_u8 liveflags[MAXRUN+1];
- uae_u32 max_pcp=(uae_u32)pc_hist[0].location;
- uae_u32 min_pcp=max_pcp;
- uae_u32 cl=cacheline(pc_hist[0].location);
- void* specflags=(void*)®s.spcflags;
- blockinfo* bi=NULL;
- blockinfo* bi2;
- int extra_len=0;
-
- compile_count++;
- if (current_compile_p>=max_compile_start)
- flush_icache_hard(0, 3);
-
- alloc_blockinfos();
-
- bi=get_blockinfo_addr_new(pc_hist[0].location,0);
- bi2=get_blockinfo(cl);
-
- optlev=bi->optlevel;
- if (bi->handler) {
- Dif (bi!=bi2) {
- /* I don't think it can happen anymore. Shouldn't, in
- any case. So let's make sure... */
- jit_abort (L"JIT: WOOOWOO count=%d, ol=%d %p %p\n",
- bi->count,bi->optlevel,bi->handler_to_use,
- cache_tags[cl].handler);
- }
-
- Dif (bi->count!=-1 && bi->status!=BI_TARGETTED) {
- /* What the heck? We are not supposed to be here! */
- jit_abort (L"BI_TARGETTED");
- }
- }
- if (bi->count==-1) {
- optlev++;
- while (!currprefs.optcount[optlev])
- optlev++;
- bi->count=currprefs.optcount[optlev]-1;
- }
- current_block_pc_p=(uae_u32)pc_hist[0].location;
-
- remove_deps(bi); /* We are about to create new code */
- bi->optlevel=optlev;
- bi->pc_p=(uae_u8*)pc_hist[0].location;
-
- liveflags[blocklen]=0x1f; /* All flags needed afterwards */
- i=blocklen;
- while (i--) {
- uae_u16* currpcp=pc_hist[i].location;
- int op=cft_map(*currpcp);
-
- if ((uae_u32)currpcp<min_pcp)
- min_pcp=(uae_u32)currpcp;
- if ((uae_u32)currpcp>max_pcp)
- max_pcp=(uae_u32)currpcp;
-
- if (currprefs.compnf) {
- liveflags[i]=((liveflags[i+1]&
- (~prop[op].set_flags))|
- prop[op].use_flags);
- if (prop[op].is_addx && (liveflags[i+1]&FLAG_Z)==0)
- liveflags[i]&= ~FLAG_Z;
- }
- else {
- liveflags[i]=0x1f;
- }
- }
-
- bi->needed_flags=liveflags[0];
-
- /* This is the non-direct handler */
- align_target(32);
- set_target(get_target()+1);
- align_target(16);
- /* Now aligned at n*32+16 */
+ bi->needed_flags=liveflags[0];
- bi->handler=
- bi->handler_to_use=(cpuop_func*)get_target();
- raw_cmp_l_mi((uae_u32)®s.pc_p,(uae_u32)pc_hist[0].location);
- raw_jnz((uae_u32)popall_cache_miss);
- /* This was 16 bytes on the x86, so now aligned on (n+1)*32 */
+ /* This is the non-direct handler */
+ align_target(32);
+ set_target(get_target()+1);
+ align_target(16);
+ /* Now aligned at n*32+16 */
- was_comp=0;
+ bi->handler=
+ bi->handler_to_use=(cpuop_func*)get_target();
+ raw_cmp_l_mi((uae_u32)®s.pc_p,(uae_u32)pc_hist[0].location);
+ raw_jnz((uae_u32)popall_cache_miss);
+ /* This was 16 bytes on the x86, so now aligned on (n+1)*32 */
+
+ was_comp=0;
#if USE_MATCHSTATE
- comp_pc_p=(uae_u8*)pc_hist[0].location;
- init_comp();
- match_states(&(bi->env));
- was_comp=1;
+ comp_pc_p=(uae_u8*)pc_hist[0].location;
+ init_comp();
+ match_states(&(bi->env));
+ was_comp=1;
#endif
- bi->direct_handler=(cpuop_func*)get_target();
- set_dhtu(bi,bi->direct_handler);
- current_block_start_target=(uae_u32)get_target();
+ bi->direct_handler=(cpuop_func*)get_target();
+ set_dhtu(bi,bi->direct_handler);
+ current_block_start_target=(uae_u32)get_target();
- if (bi->count>=0) { /* Need to generate countdown code */
- raw_mov_l_mi((uae_u32)®s.pc_p,(uae_u32)pc_hist[0].location);
- raw_sub_l_mi((uae_u32)&(bi->count),1);
- raw_jl((uae_u32)popall_recompile_block);
- }
- if (optlev==0) { /* No need to actually translate */
- /* Execute normally without keeping stats */
- raw_mov_l_mi((uae_u32)®s.pc_p,(uae_u32)pc_hist[0].location);
- raw_jmp((uae_u32)popall_exec_nostats);
- }
- else {
- reg_alloc_run=0;
- next_pc_p=0;
- taken_pc_p=0;
- branch_cc=0;
-
- log_startblock();
- for (i=0;i<blocklen &&
- get_target_noopt()<max_compile_start;i++) {
- cpuop_func **cputbl;
- compop_func **comptbl;
- uae_u16 opcode;
-
- opcode=cft_map((uae_u16)*pc_hist[i].location);
- special_mem=pc_hist[i].specmem;
- needed_flags=(liveflags[i+1] & prop[opcode].set_flags);
- if (!needed_flags && currprefs.compnf) {
+ if (bi->count>=0) { /* Need to generate countdown code */
+ raw_mov_l_mi((uae_u32)®s.pc_p,(uae_u32)pc_hist[0].location);
+ raw_sub_l_mi((uae_u32)&(bi->count),1);
+ raw_jl((uae_u32)popall_recompile_block);
+ }
+ if (optlev==0) { /* No need to actually translate */
+ /* Execute normally without keeping stats */
+ raw_mov_l_mi((uae_u32)®s.pc_p,(uae_u32)pc_hist[0].location);
+ raw_jmp((uae_u32)popall_exec_nostats);
+ }
+ else {
+ reg_alloc_run=0;
+ next_pc_p=0;
+ taken_pc_p=0;
+ branch_cc=0;
+
+ log_startblock();
+ for (i=0;i<blocklen &&
+ get_target_noopt()<max_compile_start;i++) {
+ cpuop_func **cputbl;
+ compop_func **comptbl;
+ uae_u16 opcode;
+
+ opcode=cft_map((uae_u16)*pc_hist[i].location);
+ special_mem=pc_hist[i].specmem;
+ needed_flags=(liveflags[i+1] & prop[opcode].set_flags);
+ if (!needed_flags && currprefs.compnf) {
#ifdef NOFLAGS_SUPPORT
- cputbl=nfcpufunctbl;
+ cputbl=nfcpufunctbl;
#else
- cputbl=cpufunctbl;
+ cputbl=cpufunctbl;
#endif
- comptbl=nfcompfunctbl;
- }
- else {
- cputbl=cpufunctbl;
- comptbl=compfunctbl;
- }
-
- if (comptbl[opcode] && optlev>1) {
- failure=0;
- if (!was_comp) {
- comp_pc_p=(uae_u8*)pc_hist[i].location;
- init_comp();
- }
- was_comp++;
-
- comptbl[opcode](opcode);
- freescratch();
- if (!(liveflags[i+1] & FLAG_CZNV)) {
- /* We can forget about flags */
- dont_care_flags();
- }
+ comptbl=nfcompfunctbl;
+ }
+ else {
+ cputbl=cpufunctbl;
+ comptbl=compfunctbl;
+ }
+
+ if (comptbl[opcode] && optlev>1) {
+ failure=0;
+ if (!was_comp) {
+ comp_pc_p=(uae_u8*)pc_hist[i].location;
+ init_comp();
+ }
+ was_comp++;
+
+ comptbl[opcode](opcode);
+ freescratch();
+ if (!(liveflags[i+1] & FLAG_CZNV)) {
+ /* We can forget about flags */
+ dont_care_flags();
+ }
#if INDIVIDUAL_INST
- flush(1);
- nop();
- flush(1);
- was_comp=0;
+ flush(1);
+ nop();
+ flush(1);
+ was_comp=0;
#endif
- }
- else
- failure=1;
- if (failure) {
- if (was_comp) {
- flush(1);
- was_comp=0;
- }
- raw_mov_l_ri(REG_PAR1,(uae_u32)opcode);
- raw_mov_l_ri(REG_PAR2,(uae_u32)®s);
+ }
+ else
+ failure=1;
+ if (failure) {
+ if (was_comp) {
+ flush(1);
+ was_comp=0;
+ }
+ raw_mov_l_ri(REG_PAR1,(uae_u32)opcode);
+ raw_mov_l_ri(REG_PAR2,(uae_u32)®s);
#if USE_NORMAL_CALLING_CONVENTION
- raw_push_l_r(REG_PAR2);
- raw_push_l_r(REG_PAR1);
+ raw_push_l_r(REG_PAR2);
+ raw_push_l_r(REG_PAR1);
#endif
- raw_mov_l_mi((uae_u32)®s.pc_p,
- (uae_u32)pc_hist[i].location);
- raw_call((uae_u32)cputbl[opcode]);
- //raw_add_l_mi((uae_u32)&oink,1); // FIXME
+ raw_mov_l_mi((uae_u32)®s.pc_p,
+ (uae_u32)pc_hist[i].location);
+ raw_call((uae_u32)cputbl[opcode]);
+ //raw_add_l_mi((uae_u32)&oink,1); // FIXME
#if USE_NORMAL_CALLING_CONVENTION
- raw_inc_sp(8);
+ raw_inc_sp(8);
#endif
- /*if (needed_flags)
- raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode+65536);
- else
- raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode);
- */
-
- if (i<blocklen-1) {
- uae_s8* branchadd;
-
- raw_mov_l_rm(0,(uae_u32)specflags);
- raw_test_l_rr(0,0);
- raw_jz_b_oponly();
- branchadd=(uae_s8*)get_target();
- emit_byte(0);
- raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
- raw_jmp((uae_u32)popall_do_nothing);
- *branchadd=(uae_u32)get_target()-(uae_u32)branchadd-1;
- }
- }
- }
+ /*if (needed_flags)
+ raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode+65536);
+ else
+ raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode);
+ */
+
+ if (i<blocklen-1) {
+ uae_s8* branchadd;
+
+ raw_mov_l_rm(0,(uae_u32)specflags);
+ raw_test_l_rr(0,0);
+ raw_jz_b_oponly();
+ branchadd=(uae_s8*)get_target();
+ emit_byte(0);
+ raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+ raw_jmp((uae_u32)popall_do_nothing);
+ *branchadd=(uae_u32)get_target()-(uae_u32)branchadd-1;
+ }
+ }
+ }
#if 0 /* This isn't completely kosher yet; It really needs to be
- be integrated into a general inter-block-dependency scheme */
- if (next_pc_p && taken_pc_p &&
- was_comp && taken_pc_p==current_block_pc_p) {
- blockinfo* bi1=get_blockinfo_addr_new((void*)next_pc_p,0);
- blockinfo* bi2=get_blockinfo_addr_new((void*)taken_pc_p,0);
- uae_u8 x=bi1->needed_flags;
-
- if (x==0xff || 1) { /* To be on the safe side */
- uae_u16* next=(uae_u16*)next_pc_p;
- uae_u16 op=cft_map(*next);
-
- x=0x1f;
- x&=(~prop[op].set_flags);
- x|=prop[op].use_flags;
- }
-
- x|=bi2->needed_flags;
- if (!(x & FLAG_CZNV)) {
- /* We can forget about flags */
- dont_care_flags();
- extra_len+=2; /* The next instruction now is part of this
- block */
- }
-
- }
+ be integrated into a general inter-block-dependency scheme */
+ if (next_pc_p && taken_pc_p &&
+ was_comp && taken_pc_p==current_block_pc_p) {
+ blockinfo* bi1=get_blockinfo_addr_new((void*)next_pc_p,0);
+ blockinfo* bi2=get_blockinfo_addr_new((void*)taken_pc_p,0);
+ uae_u8 x=bi1->needed_flags;
+
+ if (x==0xff || 1) { /* To be on the safe side */
+ uae_u16* next=(uae_u16*)next_pc_p;
+ uae_u16 op=cft_map(*next);
+
+ x=0x1f;
+ x&=(~prop[op].set_flags);
+ x|=prop[op].use_flags;
+ }
+
+ x|=bi2->needed_flags;
+ if (!(x & FLAG_CZNV)) {
+ /* We can forget about flags */
+ dont_care_flags();
+ extra_len+=2; /* The next instruction now is part of this
+ block */
+ }
+
+ }
#endif
- if (next_pc_p) { /* A branch was registered */
- uae_u32 t1=next_pc_p;
- uae_u32 t2=taken_pc_p;
- int cc=branch_cc;
-
- uae_u32* branchadd;
- uae_u32* tba;
- bigstate tmp;
- blockinfo* tbi;
-
- if (taken_pc_p<next_pc_p) {
- /* backward branch. Optimize for the "taken" case ---
- which means the raw_jcc should fall through when
- the 68k branch is taken. */
- t1=taken_pc_p;
- t2=next_pc_p;
- cc=branch_cc^1;
- }
+ if (next_pc_p) { /* A branch was registered */
+ uae_u32 t1=next_pc_p;
+ uae_u32 t2=taken_pc_p;
+ int cc=branch_cc;
+
+ uae_u32* branchadd;
+ uae_u32* tba;
+ bigstate tmp;
+ blockinfo* tbi;
+
+ if (taken_pc_p<next_pc_p) {
+ /* backward branch. Optimize for the "taken" case ---
+ which means the raw_jcc should fall through when
+ the 68k branch is taken. */
+ t1=taken_pc_p;
+ t2=next_pc_p;
+ cc=branch_cc^1;
+ }
#if !USE_MATCHSTATE
- flush_keepflags();
+ flush_keepflags();
#endif
- tmp=live; /* ouch! This is big... */
- raw_jcc_l_oponly(cc);
- branchadd=(uae_u32*)get_target();
- emit_long(0);
- /* predicted outcome */
- tbi=get_blockinfo_addr_new((void*)t1,1);
- match_states(&(tbi->env));
- //flush(1); /* Can only get here if was_comp==1 */
- raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
- raw_jcc_l_oponly(9);
- tba=(uae_u32*)get_target();
- emit_long(get_handler(t1)-((uae_u32)tba+4));
- raw_mov_l_mi((uae_u32)®s.pc_p,t1);
- raw_jmp((uae_u32)popall_do_nothing);
- create_jmpdep(bi,0,tba,t1);
-
- align_target(16);
- /* not-predicted outcome */
- *branchadd=(uae_u32)get_target()-((uae_u32)branchadd+4);
- live=tmp; /* Ouch again */
- tbi=get_blockinfo_addr_new((void*)t2,1);
- match_states(&(tbi->env));
-
- //flush(1); /* Can only get here if was_comp==1 */
- raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
- raw_jcc_l_oponly(9);
- tba=(uae_u32*)get_target();
- emit_long(get_handler(t2)-((uae_u32)tba+4));
- raw_mov_l_mi((uae_u32)®s.pc_p,t2);
- raw_jmp((uae_u32)popall_do_nothing);
- create_jmpdep(bi,1,tba,t2);
- }
- else
- {
- if (was_comp) {
- flush(1);
+ tmp=live; /* ouch! This is big... */
+ raw_jcc_l_oponly(cc);
+ branchadd=(uae_u32*)get_target();
+ emit_long(0);
+ /* predicted outcome */
+ tbi=get_blockinfo_addr_new((void*)t1,1);
+ match_states(&(tbi->env));
+ //flush(1); /* Can only get here if was_comp==1 */
+ raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+ raw_jcc_l_oponly(9);
+ tba=(uae_u32*)get_target();
+ emit_long(get_handler(t1)-((uae_u32)tba+4));
+ raw_mov_l_mi((uae_u32)®s.pc_p,t1);
+ raw_jmp((uae_u32)popall_do_nothing);
+ create_jmpdep(bi,0,tba,t1);
+
+ align_target(16);
+ /* not-predicted outcome */
+ *branchadd=(uae_u32)get_target()-((uae_u32)branchadd+4);
+ live=tmp; /* Ouch again */
+ tbi=get_blockinfo_addr_new((void*)t2,1);
+ match_states(&(tbi->env));
+
+ //flush(1); /* Can only get here if was_comp==1 */
+ raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+ raw_jcc_l_oponly(9);
+ tba=(uae_u32*)get_target();
+ emit_long(get_handler(t2)-((uae_u32)tba+4));
+ raw_mov_l_mi((uae_u32)®s.pc_p,t2);
+ raw_jmp((uae_u32)popall_do_nothing);
+ create_jmpdep(bi,1,tba,t2);
+ }
+ else
+ {
+ if (was_comp) {
+ flush(1);
+ }
+
+ /* Let's find out where next_handler is... */
+ if (was_comp && isinreg(PC_P)) {
+ int r2;
+
+ r=live.state[PC_P].realreg;
+
+ if (r==0)
+ r2=1;
+ else
+ r2=0;
+
+ raw_and_l_ri(r,TAGMASK);
+ raw_mov_l_ri(r2,(uae_u32)popall_do_nothing);
+ raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+ raw_cmov_l_rm_indexed(r2,(uae_u32)cache_tags,r,9);
+ raw_jmp_r(r2);
+ }
+ else if (was_comp && isconst(PC_P)) {
+ uae_u32 v=live.state[PC_P].val;
+ uae_u32* tba;
+ blockinfo* tbi;
+
+ tbi=get_blockinfo_addr_new((void*)v,1);
+ match_states(&(tbi->env));
+
+ raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+ raw_jcc_l_oponly(9);
+ tba=(uae_u32*)get_target();
+ emit_long(get_handler(v)-((uae_u32)tba+4));
+ raw_mov_l_mi((uae_u32)®s.pc_p,v);
+ raw_jmp((uae_u32)popall_do_nothing);
+ create_jmpdep(bi,0,tba,v);
+ }
+ else {
+ int r2;
+
+ r=REG_PC_TMP;
+ raw_mov_l_rm(r,(uae_u32)®s.pc_p);
+ if (r==0)
+ r2=1;
+ else
+ r2=0;
+
+ raw_and_l_ri(r,TAGMASK);
+ raw_mov_l_ri(r2,(uae_u32)popall_do_nothing);
+ raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
+ raw_cmov_l_rm_indexed(r2,(uae_u32)cache_tags,r,9);
+ raw_jmp_r(r2);
+ }
+ }
}
- /* Let's find out where next_handler is... */
- if (was_comp && isinreg(PC_P)) {
- int r2;
-
- r=live.state[PC_P].realreg;
-
- if (r==0)
- r2=1;
- else
- r2=0;
-
- raw_and_l_ri(r,TAGMASK);
- raw_mov_l_ri(r2,(uae_u32)popall_do_nothing);
- raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
- raw_cmov_l_rm_indexed(r2,(uae_u32)cache_tags,r,9);
- raw_jmp_r(r2);
- }
- else if (was_comp && isconst(PC_P)) {
- uae_u32 v=live.state[PC_P].val;
- uae_u32* tba;
- blockinfo* tbi;
-
- tbi=get_blockinfo_addr_new((void*)v,1);
- match_states(&(tbi->env));
-
- raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
- raw_jcc_l_oponly(9);
- tba=(uae_u32*)get_target();
- emit_long(get_handler(v)-((uae_u32)tba+4));
- raw_mov_l_mi((uae_u32)®s.pc_p,v);
- raw_jmp((uae_u32)popall_do_nothing);
- create_jmpdep(bi,0,tba,v);
- }
+ if (next_pc_p+extra_len>=max_pcp &&
+ next_pc_p+extra_len<max_pcp+LONGEST_68K_INST)
+ max_pcp=next_pc_p+extra_len; /* extra_len covers flags magic */
+ else
+ max_pcp+=LONGEST_68K_INST;
+ bi->len=max_pcp-min_pcp;
+ bi->min_pcp=min_pcp;
+
+ remove_from_list(bi);
+ if (isinrom(min_pcp) && isinrom(max_pcp))
+ add_to_dormant(bi); /* No need to checksum it on cache flush.
+ Please don't start changing ROMs in
+ flight! */
else {
- int r2;
-
- r=REG_PC_TMP;
- raw_mov_l_rm(r,(uae_u32)®s.pc_p);
- if (r==0)
- r2=1;
- else
- r2=0;
-
- raw_and_l_ri(r,TAGMASK);
- raw_mov_l_ri(r2,(uae_u32)popall_do_nothing);
- raw_sub_l_mi((uae_u32)&countdown,scaled_cycles(totcycles));
- raw_cmov_l_rm_indexed(r2,(uae_u32)cache_tags,r,9);
- raw_jmp_r(r2);
+ calc_checksum(bi,&(bi->c1),&(bi->c2));
+ add_to_active(bi);
}
- }
- }
- if (next_pc_p+extra_len>=max_pcp &&
- next_pc_p+extra_len<max_pcp+LONGEST_68K_INST)
- max_pcp=next_pc_p+extra_len; /* extra_len covers flags magic */
- else
- max_pcp+=LONGEST_68K_INST;
- bi->len=max_pcp-min_pcp;
- bi->min_pcp=min_pcp;
+ log_dump();
+ align_target(32);
+ current_compile_p=get_target();
- remove_from_list(bi);
- if (isinrom(min_pcp) && isinrom(max_pcp))
- add_to_dormant(bi); /* No need to checksum it on cache flush.
- Please don't start changing ROMs in
- flight! */
- else {
- calc_checksum(bi,&(bi->c1),&(bi->c2));
- add_to_active(bi);
- }
+ raise_in_cl_list(bi);
+ bi->nexthandler=current_compile_p;
- log_dump();
- align_target(32);
- current_compile_p=get_target();
+ /* We will flush soon, anyway, so let's do it now */
+ if (current_compile_p>=max_compile_start)
+ flush_icache_hard(0, 3);
- raise_in_cl_list(bi);
- bi->nexthandler=current_compile_p;
-
- /* We will flush soon, anyway, so let's do it now */
- if (current_compile_p>=max_compile_start)
- flush_icache_hard(0, 3);
-
- do_extra_cycles(totcycles); /* for the compilation time */
- }
+ do_extra_cycles(totcycles); /* for the compilation time */
+ }
}
#endif
ULONG ahiac_AntiClickSamples; /* AntiClick samples (V6) */
struct Hook *ahiac_PreTimerFunc; /* A Hook wrapper for ahiac_PreTimer (V6) */
struct Hook *ahiac_PostTimerFunc; /* A Hook wrapper for ahiac_PostTimer (V6) */
+}
#endif
#define ahiac_AudioCtrl 0
#define ahiac_PreTimerFunc ahiac_AntiClickSamples + 4
#define ahiac_PostTimerFunc ahiac_PreTimerFunc + 4
- /* AHIsub_AllocAudio return flags */
+/* AHIsub_AllocAudio return flags */
#define AHISF_ERROR (1<<0)
#define AHISF_MIXING (1<<1)
#define AHISF_TIMING (1<<2)
#define AHISB_CANPOSTPROCESS (6)
#define AHISB_KNOWMULTICHANNEL (7)
- /* AHIsub_Start() and AHIsub_Stop() flags */
+/* AHIsub_Start() and AHIsub_Stop() flags */
#define AHISF_PLAY (1<<0)
#define AHISF_RECORD (1<<1)
#define AHISB_PLAY (0)
#define AHISB_RECORD (1)
- /* ahiac_Flags */
+/* ahiac_Flags */
#define AHIACF_VOL (1<<0)
#define AHIACF_PAN (1<<1)
#define AHIACF_STEREO (1<<2)
#define AHI_TagBase (0x80000000)
#define AHI_TagBaseR (AHI_TagBase|0x8000)
- /* AHI_AllocAudioA tags */
+/* AHI_AllocAudioA tags */
#define AHIA_AudioID (AHI_TagBase+1) /* Desired audio mode */
#define AHIA_MixFreq (AHI_TagBase+2) /* Suggested mixing frequency */
#define AHIA_Channels (AHI_TagBase+3) /* Suggested number of channels */
#define AHIA_UserData (AHI_TagBase+11) /* What to put in ahiac_UserData */
#define AHIA_AntiClickSamples (AHI_TagBase+13) /* # of samples to smooth (V6) */
- /* AHI_ControlAudioA tags */
+/* AHI_ControlAudioA tags */
#define AHIC_Play (AHI_TagBase+80) /* Boolean */
#define AHIC_Record (AHI_TagBase+81) /* Boolean */
#define AHIC_MonitorVolume (AHI_TagBase+82)
#define AHIC_MonitorVolume_Query (AHI_TagBase+83) /* ti_Data is pointer to Fixed (LONG) */
#define AHIC_MixFreq_Query (AHI_TagBase+84) /* ti_Data is pointer to ULONG */
- /* --- New for V2, they will be ignored by V1 --- */
+/* --- New for V2, they will be ignored by V1 --- */
#define AHIC_InputGain (AHI_TagBase+85)
#define AHIC_InputGain_Query (AHI_TagBase+86) /* ti_Data is pointer to Fixed (LONG) */
#define AHIC_OutputVolume (AHI_TagBase+87)
#define AHIC_Output (AHI_TagBase+91)
#define AHIC_Output_Query (AHI_TagBase+92) /* ti_Data is pointer to ULONG */
- /* AHI_GetAudioAttrsA tags */
+/* AHI_GetAudioAttrsA tags */
#define AHIDB_AudioID (AHI_TagBase+100)
#define AHIDB_Driver (AHI_TagBaseR+101) /* Pointer to name of driver */
#define AHIDB_Flags (AHI_TagBase+102) /* Private! */
#define AHIDB_MaxPlaySamples (AHI_TagBase+126) /* It's sample *frames* */
#define AHIDB_MaxRecordSamples (AHI_TagBase+127) /* It's sample *frames* */
#define AHIDB_FullDuplex (AHI_TagBase+129) /* Boolean */
- /* --- New for V2, they will be ignored by V1 --- */
+/* --- New for V2, they will be ignored by V1 --- */
#define AHIDB_MinMonitorVolume (AHI_TagBase+130)
#define AHIDB_MaxMonitorVolume (AHI_TagBase+131)
#define AHIDB_MinInputGain (AHI_TagBase+132)
#define AHIDB_Outputs (AHI_TagBase+139)
#define AHIDB_OutputArg (AHI_TagBase+140) /* ti_Data is input index */
#define AHIDB_Output (AHI_TagBase+141)
- /* --- New for V4, they will be ignored by V2 and earlier --- */
+/* --- New for V4, they will be ignored by V2 and earlier --- */
#define AHIDB_Data (AHI_TagBaseR+142) /* Private! */
#define AHIDB_DriverBaseName (AHI_TagBaseR+143) /* Private! */
- /* --- New for V6, they will be ignored by V4 and earlier --- */
+/* --- New for V6, they will be ignored by V4 and earlier --- */
#define AHIDB_MultiChannel (AHI_TagBase+144) /* Boolean */
- /* Sound Types */
+/* Sound Types */
#define AHIST_NOTYPE (~0UL) /* Private */
#define AHIST_SAMPLE (0UL) /* 8 or 16 bit sample */
#define AHIST_DYNAMICSAMPLE (1UL) /* Dynamic sample */
#define AHIST_INPUT (1UL<<29) /* The input from your sampler */
#define AHIST_BW (1UL<<30) /* Private */
- /* Sample types */
- /* Note that only AHIST_M8S, AHIST_S8S, AHIST_M16S and AHIST_S16S
- (plus AHIST_M32S, AHIST_S32S and AHIST_L7_1 in V6)
- are supported by AHI_LoadSound(). */
+/* Sample types */
+/* Note that only AHIST_M8S, AHIST_S8S, AHIST_M16S and AHIST_S16S
+(plus AHIST_M32S, AHIST_S32S and AHIST_L7_1 in V6)
+are supported by AHI_LoadSound(). */
#define AHIST_M8S (0UL) /* Mono, 8 bit signed (BYTE) */
#define AHIST_M16S (1UL) /* Mono, 16 bit signed (WORD) */
#define AHIST_S8S (2UL) /* Stereo, 8 bit signed (2×BYTE) */
#define AHIST_M8U (4UL) /* OBSOLETE! */
#define AHIST_L7_1 (0x00c3000aUL) /* 7.1, 32 bit signed (8×LONG) */
- /* Error codes */
+/* Error codes */
#define AHIE_OK (0UL) /* No error */
#define AHIE_NOMEM (1UL) /* Out of memory */
#define AHIE_BADSOUNDTYPE (2UL) /* Unknown sound type */
#define AHIE_UNKNOWN (5UL) /* Error, but unknown */
#define AHIE_HALFDUPLEX (6UL) /* CMD_WRITE/CMD_READ failure */
- struct dssample {
- int num;
- int ch;
- int bitspersample;
- int bytespersample;
- int dynamic;
- uae_u32 addr;
- uae_u32 len;
- uae_u32 type;
- uae_u32 sampletype;
- ALuint al_buffer[2];
- };
-
- struct chsample {
- int frequency;
- int volume;
- int panning;
- int backwards;
- struct dssample *ds;
- int srcplayoffset;
- int srcplaylen;
- };
-
- struct dschannel {
- int num;
- struct chsample cs;
- struct chsample csnext;
- int channelsignal;
- int dsplaying;
- ALuint al_source;
- int samplecounter;
- int buffertoggle;
- int maxplaysamples;
- int totalsamples;
- int waitforack;
- };
-
- struct DSAHI {
- uae_u32 audioctrl;
- int chout;
- int bits24;
- int bitspersampleout;
- int bytespersampleout;
- int channellength;
- int mixlength;
- int input;
- int output;
- int channels;
- int sounds;
- int playerfreq;
- uae_u32 audioid;
- int enabledisable;
- struct dssample *sample;
- struct dschannel *channel;
- int playing, recording;
- evt evttime;
- uae_u32 signalchannelmask;
-
- ALCdevice *al_dev, *al_recorddev;
- ALCcontext *al_ctx;
- int al_bufferformat;
- uae_u8 *tmpbuffer;
- int tmpbuffer_size;
- int dsrecording;
- int record_samples;
- int record_ch;
- int record_bytespersample;
- int record_wait;
- int maxplaysamples;
- };
-
- static struct DSAHI dsahi[1];
+struct dssample {
+ int num;
+ int ch;
+ int bitspersample;
+ int bytespersample;
+ int dynamic;
+ uae_u32 addr;
+ uae_u32 len;
+ uae_u32 type;
+ uae_u32 sampletype;
+ ALuint al_buffer[2];
+};
+
+struct chsample {
+ int frequency;
+ int volume;
+ int panning;
+ int backwards;
+ struct dssample *ds;
+ int srcplayoffset;
+ int srcplaylen;
+};
+
+struct dschannel {
+ int num;
+ struct chsample cs;
+ struct chsample csnext;
+ int channelsignal;
+ int dsplaying;
+ ALuint al_source;
+ int samplecounter;
+ int buffertoggle;
+ int maxplaysamples;
+ int totalsamples;
+ int waitforack;
+};
+
+struct DSAHI {
+ uae_u32 audioctrl;
+ int chout;
+ int bits24;
+ int bitspersampleout;
+ int bytespersampleout;
+ int channellength;
+ int mixlength;
+ int input;
+ int output;
+ int channels;
+ int sounds;
+ int playerfreq;
+ uae_u32 audioid;
+ int enabledisable;
+ struct dssample *sample;
+ struct dschannel *channel;
+ int playing, recording;
+ evt evttime;
+ uae_u32 signalchannelmask;
+
+ ALCdevice *al_dev, *al_recorddev;
+ ALCcontext *al_ctx;
+ int al_bufferformat;
+ uae_u8 *tmpbuffer;
+ int tmpbuffer_size;
+ int dsrecording;
+ int record_samples;
+ int record_ch;
+ int record_bytespersample;
+ int record_wait;
+ int maxplaysamples;
+};
+
+static struct DSAHI dsahi[1];
#define GETAHI (&dsahi[get_long(get_long(audioctrl + ahiac_DriverData) + pub_Index)])
#define GETSAMPLE (dsahip && sound >= 0 && sound < UAE_MAXSOUNDS ? &dsahip->sample[sound] : NULL)
#define GETCHANNEL (dsahip && channel >= 0 && channel < UAE_MAXCHANNELS ? &dsahip->channel[channel] : NULL)
- static int default_freq = 44100;
- static int cansurround;
- static uae_u32 xahi_author, xahi_copyright, xahi_version;
- static uae_u32 xahi_output[MAX_SOUND_DEVICES], xahi_output_num;
- static uae_u32 xahi_input[MAX_SOUND_DEVICES], xahi_input_num;
- static int ahi_paused;
- static int ahi_active;
+static int default_freq = 44100;
+static int cansurround;
+static uae_u32 xahi_author, xahi_copyright, xahi_version;
+static uae_u32 xahi_output[MAX_SOUND_DEVICES], xahi_output_num;
+static uae_u32 xahi_input[MAX_SOUND_DEVICES], xahi_input_num;
+static int ahi_paused;
+static int ahi_active;
#define TAG_DONE (0L) /* terminates array of TagItems. ti_Data unused */
#define TAG_IGNORE (1L) /* ignore this item, not end of array */
#define TAG_SKIP (3L) /* skip this and the next ti_Data items */
#define TAG_USER ((uae_u32)(1L << 31))
- static uae_u32 gettag (uae_u32 *tagpp, uae_u32 *datap)
- {
- uae_u32 tagp = *tagpp;
- for (;;) {
- uae_u32 tag = get_long (tagp);
- uae_u32 data = get_long (tagp + 4);
- switch (tag)
- {
- case TAG_DONE:
- return 0;
- case TAG_IGNORE:
- tagp += 8;
- break;
- case TAG_MORE:
- tagp = data;
- break;
- case TAG_SKIP:
- tagp += data * 8;
- break;
- default:
- tagp += 8;
- *tagpp = tagp;
- *datap = data;
- return tag;
- }
+static uae_u32 gettag (uae_u32 *tagpp, uae_u32 *datap)
+{
+ uae_u32 tagp = *tagpp;
+ for (;;) {
+ uae_u32 tag = get_long (tagp);
+ uae_u32 data = get_long (tagp + 4);
+ switch (tag)
+ {
+ case TAG_DONE:
+ return 0;
+ case TAG_IGNORE:
+ tagp += 8;
+ break;
+ case TAG_MORE:
+ tagp = data;
+ break;
+ case TAG_SKIP:
+ tagp += data * 8;
+ break;
+ default:
+ tagp += 8;
+ *tagpp = tagp;
+ *datap = data;
+ return tag;
}
}
+}
- static int sendsignal (struct DSAHI *dsahip)
- {
- uae_u32 audioctrl = dsahip->audioctrl;
- uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
- uae_u32 channelinfo;
- uae_u32 task, signalmask;
- uae_s16 taskmode = get_word (puaebase + pub_TaskMode);
- uae_s16 funcmode = get_word (puaebase + pub_FuncMode);
- task = get_long (puaebase + pub_FuncTask);
- signalmask = get_long (puaebase + pub_WaitMask);
-
- if ((!dsahip->playing && !dsahip->recording) || ahi_paused)
- return 0;
- if (taskmode <= 0)
- return 0;
- if (dsahip->enabledisable) {
- // allocate Amiga-side recordingbuffer
- funcmode &= FUNCMODE_RECORDALLOC;
- put_word (puaebase + pub_FuncMode, funcmode);
- }
+static int sendsignal (struct DSAHI *dsahip)
+{
+ uae_u32 audioctrl = dsahip->audioctrl;
+ uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
+ uae_u32 channelinfo;
+ uae_u32 task, signalmask;
+ uae_s16 taskmode = get_word (puaebase + pub_TaskMode);
+ uae_s16 funcmode = get_word (puaebase + pub_FuncMode);
+ task = get_long (puaebase + pub_FuncTask);
+ signalmask = get_long (puaebase + pub_WaitMask);
+
+ if ((!dsahip->playing && !dsahip->recording) || ahi_paused)
+ return 0;
+ if (taskmode <= 0)
+ return 0;
+ if (dsahip->enabledisable) {
+ // allocate Amiga-side recordingbuffer
+ funcmode &= FUNCMODE_RECORDALLOC;
+ put_word (puaebase + pub_FuncMode, funcmode);
+ }
- channelinfo = get_long (puaebase + pub_ChannelInfo);
- if (channelinfo) {
- int i, ch;
- ch = get_word (channelinfo + ahieci_Channels);
- if (ch > UAE_MAXCHANNELS)
- ch = UAE_MAXCHANNELS;
- for (i = 0; i < ch; i++) {
- struct dschannel *dc = &dsahip->channel[i];
- int v;
- alGetSourcei (dc->al_source, AL_SAMPLE_OFFSET, &v);
- put_long (channelinfo + ahieci_Offset + i * 4, v + dc->samplecounter * dc->maxplaysamples);
- }
+ channelinfo = get_long (puaebase + pub_ChannelInfo);
+ if (channelinfo) {
+ int i, ch;
+ ch = get_word (channelinfo + ahieci_Channels);
+ if (ch > UAE_MAXCHANNELS)
+ ch = UAE_MAXCHANNELS;
+ for (i = 0; i < ch; i++) {
+ struct dschannel *dc = &dsahip->channel[i];
+ int v;
+ alGetSourcei (dc->al_source, AL_SAMPLE_OFFSET, &v);
+ put_long (channelinfo + ahieci_Offset + i * 4, v + dc->samplecounter * dc->maxplaysamples);
}
-
- uae_Signal (task, signalmask);
- return 1;
}
- static int setchannelevent (struct DSAHI *dsahip, struct dschannel *dc)
- {
- uae_u32 audioctrl = dsahip->audioctrl;
- uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
- int ch = dc - &dsahip->channel[0];
- uae_u32 mask;
+ uae_Signal (task, signalmask);
+ return 1;
+}
- if (!dsahip->playing || ahi_paused || !dc->al_source || !get_long (audioctrl + ahiac_SoundFunc))
- return 0;
- mask = get_long (puaebase + pub_ChannelSignal);
- if (mask & (1 << ch))
- return 0;
- dc->channelsignal = 1;
- put_long (puaebase + pub_ChannelSignal, mask | (1 << ch));
- sendsignal (dsahip);
- return 1;
- }
+static int setchannelevent (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ uae_u32 audioctrl = dsahip->audioctrl;
+ uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
+ int ch = dc - &dsahip->channel[0];
+ uae_u32 mask;
- static void evtfunc (uae_u32 v)
- {
- if (ahi_active) {
- struct DSAHI *dsahip = &dsahi[v];
- uae_u32 audioctrl = dsahip->audioctrl;
- uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
-
- put_word (puaebase + pub_FuncMode, get_word (puaebase + pub_FuncMode) | FUNCMODE_PLAY);
- if (sendsignal (dsahip)) {
- event2_newevent2 (dsahip->evttime, v, evtfunc);
- } else {
- dsahip->evttime = 0;
- }
- }
- }
+ if (!dsahip->playing || ahi_paused || !dc->al_source || !get_long (audioctrl + ahiac_SoundFunc))
+ return 0;
+ mask = get_long (puaebase + pub_ChannelSignal);
+ if (mask & (1 << ch))
+ return 0;
+ dc->channelsignal = 1;
+ put_long (puaebase + pub_ChannelSignal, mask | (1 << ch));
+ sendsignal (dsahip);
+ return 1;
+}
- static void setevent (struct DSAHI *dsahip)
- {
+static void evtfunc (uae_u32 v)
+{
+ if (ahi_active) {
+ struct DSAHI *dsahip = &dsahi[v];
uae_u32 audioctrl = dsahip->audioctrl;
- uae_u32 freq = get_long (audioctrl + ahiac_PlayerFreq);
- double f;
- uae_u32 cycles;
- evt t;
+ uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
- f = ((double)(freq >> 16)) + ((double)(freq & 0xffff)) / 65536.0;
- if (f < 1)
- return;
- cycles = maxhpos * maxvpos_nom * vblank_hz;
- t = (evt)(cycles / f);
- if (dsahip->evttime == t)
- return;
- write_log (L"AHI: playerfunc freq = %.2fHz\n", f);
- dsahip->evttime = t;
- if (t < 10)
- return;
- event2_newevent2 (t, dsahip - &dsahi[0], evtfunc);
+ put_word (puaebase + pub_FuncMode, get_word (puaebase + pub_FuncMode) | FUNCMODE_PLAY);
+ if (sendsignal (dsahip)) {
+ event2_newevent2 (dsahip->evttime, v, evtfunc);
+ } else {
+ dsahip->evttime = 0;
+ }
}
+}
- static void alClear (void)
- {
- alGetError ();
- }
- static int alError (const TCHAR *format,...)
- {
- TCHAR buffer[1000];
- va_list parms;
- int err;
+static void setevent (struct DSAHI *dsahip)
+{
+ uae_u32 audioctrl = dsahip->audioctrl;
+ uae_u32 freq = get_long (audioctrl + ahiac_PlayerFreq);
+ double f;
+ uae_u32 cycles;
+ evt t;
+
+ f = ((double)(freq >> 16)) + ((double)(freq & 0xffff)) / 65536.0;
+ if (f < 1)
+ return;
+ cycles = maxhpos * maxvpos_nom * vblank_hz;
+ t = (evt)(cycles / f);
+ if (dsahip->evttime == t)
+ return;
+ write_log (L"AHI: playerfunc freq = %.2fHz\n", f);
+ dsahip->evttime = t;
+ if (t < 10)
+ return;
+ event2_newevent2 (t, dsahip - &dsahi[0], evtfunc);
+}
+
+static void alClear (void)
+{
+ alGetError ();
+}
+static int alError (const TCHAR *format,...)
+{
+ TCHAR buffer[1000];
+ va_list parms;
+ int err;
- err = alGetError ();
- if (err == AL_NO_ERROR)
- return 0;
- va_start (parms, format);
- _vsntprintf (buffer, sizeof buffer -1, format, parms);
- _stprintf (buffer + _tcslen (buffer), L": ERR=%x\n", err);
- write_log (L"%s", buffer);
- return err;
- }
+ err = alGetError ();
+ if (err == AL_NO_ERROR)
+ return 0;
+ va_start (parms, format);
+ _vsntprintf (buffer, sizeof buffer -1, format, parms);
+ _stprintf (buffer + _tcslen (buffer), L": ERR=%x\n", err);
+ write_log (L"%s", buffer);
+ return err;
+}
+
+static void ds_freechannel (struct DSAHI *ahidsp, struct dschannel *dc)
+{
+ if (!dc)
+ return;
+ alDeleteSources (1, &dc->al_source);
+ memset (dc, 0, sizeof (struct dschannel));
+ dc->al_source = -1;
+}
+
+static void ds_freesample (struct DSAHI *ahidsp, struct dssample *ds)
+{
+ if (!ds)
+ return;
+ alDeleteBuffers (2, ds->al_buffer);
+ memset (ds, 0, sizeof (struct dssample));
+ ds->al_buffer[0] = -1;
+ ds->al_buffer[1] = -1;
+}
+
+static void ds_free (struct DSAHI *dsahip)
+{
+ int i;
- static void ds_freechannel (struct DSAHI *ahidsp, struct dschannel *dc)
- {
- if (!dc)
- return;
- alDeleteSources (1, &dc->al_source);
- memset (dc, 0, sizeof (struct dschannel));
- dc->al_source = -1;
+ if (!ahi_active)
+ return;
+ for (i = 0; i < dsahip->channels; i++) {
+ struct dschannel *dc = &dsahip->channel[i];
+ ds_freechannel (dsahip, dc);
}
-
- static void ds_freesample (struct DSAHI *ahidsp, struct dssample *ds)
- {
- if (!ds)
- return;
- alDeleteBuffers (2, ds->al_buffer);
- memset (ds, 0, sizeof (struct dssample));
- ds->al_buffer[0] = -1;
- ds->al_buffer[1] = -1;
+ for (i = 0; i < dsahip->sounds; i++) {
+ struct dssample *ds = &dsahip->sample[i];
+ ds_freesample (dsahip, ds);
}
+ alcMakeContextCurrent (NULL);
+ alcDestroyContext (dsahip->al_ctx);
+ dsahip->al_ctx = 0;
+ alcCloseDevice (dsahip->al_dev);
+ dsahip->al_dev = 0;
+ if (ahi_debug && ahi_active)
+ write_log (L"AHI: OpenAL freed\n");
+ ahi_active = 0;
+}
+
+static void ds_free_record (struct DSAHI *dsahip)
+{
+ if (dsahip->al_recorddev)
+ alcCaptureCloseDevice (dsahip->al_recorddev);
+ dsahip->al_recorddev = NULL;
+}
- static void ds_free (struct DSAHI *dsahip)
- {
- int i;
+static int ds_init_record (struct DSAHI *dsahip)
+{
+ uae_u32 pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
+ int freq = get_long (dsahip->audioctrl + ahiac_MixFreq);
+ struct sound_device *sd;
+ int device;
+ char *s;
- if (!ahi_active)
- return;
- for (i = 0; i < dsahip->channels; i++) {
- struct dschannel *dc = &dsahip->channel[i];
- ds_freechannel (dsahip, dc);
- }
- for (i = 0; i < dsahip->sounds; i++) {
- struct dssample *ds = &dsahip->sample[i];
- ds_freesample (dsahip, ds);
+ if (!freq)
+ return 0;
+ device = dsahip->input;
+ sd = record_devices;
+ for (;;) {
+ if (sd->type == SOUND_DEVICE_AL) {
+ if (device <= 0)
+ break;
+ device--;
}
- alcMakeContextCurrent (NULL);
- alcDestroyContext (dsahip->al_ctx);
- dsahip->al_ctx = 0;
- alcCloseDevice (dsahip->al_dev);
- dsahip->al_dev = 0;
- if (ahi_debug && ahi_active)
- write_log (L"AHI: OpenAL freed\n");
- ahi_active = 0;
- }
-
- static void ds_free_record (struct DSAHI *dsahip)
- {
- if (dsahip->al_recorddev)
- alcCaptureCloseDevice (dsahip->al_recorddev);
- dsahip->al_recorddev = NULL;
+ sd++;
+ if (sd->name == NULL)
+ return 0;
}
+ dsahip->record_samples = UAE_RECORDSAMPLES;
+ dsahip->record_ch = 2;
+ dsahip->record_bytespersample = 2;
+ alClear ();
+ s = ua (sd->alname);
+ dsahip->al_recorddev = alcCaptureOpenDevice (s, freq, AL_FORMAT_STEREO16, dsahip->record_samples);
+ xfree (s);
+ if (dsahip->al_recorddev == NULL)
+ goto error;
+ return 1;
+error:
+ if (ahi_debug)
+ write_log (L"AHI: OPENAL recording initialization failed\n");
+ return 0;
+}
- static int ds_init_record (struct DSAHI *dsahip)
- {
- uae_u32 pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
- int freq = get_long (dsahip->audioctrl + ahiac_MixFreq);
- struct sound_device *sd;
- int device;
- char *s;
-
- if (!freq)
- return 0;
- device = dsahip->input;
- sd = record_devices;
- for (;;) {
- if (sd->type == SOUND_DEVICE_AL) {
- if (device <= 0)
- break;
- device--;
- }
- sd++;
- if (sd->name == NULL)
- return 0;
+static int ds_init (struct DSAHI *dsahip)
+{
+ int freq = 44100;
+ int v;
+ struct sound_device *sd;
+ int device;
+ char *s;
+
+ device = dsahip->output;
+ sd = sound_devices;
+ for (;;) {
+ if (sd->type == SOUND_DEVICE_AL) {
+ if (device <= 0)
+ break;
+ device--;
}
- dsahip->record_samples = UAE_RECORDSAMPLES;
- dsahip->record_ch = 2;
- dsahip->record_bytespersample = 2;
- alClear ();
- s = ua (sd->alname);
- dsahip->al_recorddev = alcCaptureOpenDevice (s, freq, AL_FORMAT_STEREO16, dsahip->record_samples);
- xfree (s);
- if (dsahip->al_recorddev == NULL)
- goto error;
- return 1;
-error:
- if (ahi_debug)
- write_log (L"AHI: OPENAL recording initialization failed\n");
- return 0;
+ sd++;
+ if (sd->name == NULL)
+ return 0;
}
-
- static int ds_init (struct DSAHI *dsahip)
- {
- int freq = 44100;
- int v;
- struct sound_device *sd;
- int device;
- char *s;
-
- device = dsahip->output;
- sd = sound_devices;
- for (;;) {
- if (sd->type == SOUND_DEVICE_AL) {
- if (device <= 0)
- break;
- device--;
- }
- sd++;
- if (sd->name == NULL)
- return 0;
+ s = ua (sd->alname);
+ dsahip->al_dev = alcOpenDevice (s);
+ xfree (s);
+ if (!dsahip->al_dev)
+ goto error;
+ dsahip->al_ctx = alcCreateContext (dsahip->al_dev, NULL);
+ if (!dsahip->al_ctx)
+ goto error;
+ alcMakeContextCurrent (dsahip->al_ctx);
+
+ dsahip->chout = 2;
+ dsahip->al_bufferformat = AL_FORMAT_STEREO16;
+ cansurround = 0;
+ if ((dsahip->audioid & 0xff) == 2) {
+ if (v = alGetEnumValue ("AL_FORMAT_QUAD16")) {
+ dsahip->chout = 4;
+ cansurround = 1;
+ dsahip->al_bufferformat = v;
}
- s = ua (sd->alname);
- dsahip->al_dev = alcOpenDevice (s);
- xfree (s);
- if (!dsahip->al_dev)
- goto error;
- dsahip->al_ctx = alcCreateContext (dsahip->al_dev, NULL);
- if (!dsahip->al_ctx)
- goto error;
- alcMakeContextCurrent (dsahip->al_ctx);
-
- dsahip->chout = 2;
- dsahip->al_bufferformat = AL_FORMAT_STEREO16;
- cansurround = 0;
- if ((dsahip->audioid & 0xff) == 2) {
- if (v = alGetEnumValue ("AL_FORMAT_QUAD16")) {
- dsahip->chout = 4;
- cansurround = 1;
- dsahip->al_bufferformat = v;
- }
- if (v = alGetEnumValue ("AL_FORMAT_51CHN16")) {
- dsahip->chout = 6;
- cansurround = 1;
- dsahip->al_bufferformat = v;
- }
+ if (v = alGetEnumValue ("AL_FORMAT_51CHN16")) {
+ dsahip->chout = 6;
+ cansurround = 1;
+ dsahip->al_bufferformat = v;
}
- dsahip->bitspersampleout = dsahip->bits24 ? 24 : 16;
- dsahip->bytespersampleout = dsahip->bitspersampleout / 8;
- dsahip->channellength = 65536 * dsahip->chout * dsahip->bytespersampleout;
- if (ahi_debug)
- write_log (L"AHI: CH=%d BLEN=%d\n",
- dsahip->chout, dsahip->channellength);
-
- dsahip->tmpbuffer_size = 1000000;
- dsahip->tmpbuffer = xmalloc (uae_u8, dsahip->tmpbuffer_size);
- if (ahi_debug)
- write_log (L"AHI: OpenAL initialized: %s\n", sound_devices[dsahip->output].name);
-
- return 1;
-error:
- if (ahi_debug)
- write_log (L"AHI: OpenAL initialization failed\n");
- ds_free (dsahip);
- return 0;
}
+ dsahip->bitspersampleout = dsahip->bits24 ? 24 : 16;
+ dsahip->bytespersampleout = dsahip->bitspersampleout / 8;
+ dsahip->channellength = 65536 * dsahip->chout * dsahip->bytespersampleout;
+ if (ahi_debug)
+ write_log (L"AHI: CH=%d BLEN=%d\n",
+ dsahip->chout, dsahip->channellength);
+
+ dsahip->tmpbuffer_size = 1000000;
+ dsahip->tmpbuffer = xmalloc (uae_u8, dsahip->tmpbuffer_size);
+ if (ahi_debug)
+ write_log (L"AHI: OpenAL initialized: %s\n", sound_devices[dsahip->output].name);
+
+ return 1;
+error:
+ if (ahi_debug)
+ write_log (L"AHI: OpenAL initialization failed\n");
+ ds_free (dsahip);
+ return 0;
+}
- static int ds_reinit (struct DSAHI *dsahip)
- {
- ds_free (dsahip);
- return ds_init (dsahip);
- }
+static int ds_reinit (struct DSAHI *dsahip)
+{
+ ds_free (dsahip);
+ return ds_init (dsahip);
+}
- static void ds_setvolume (struct DSAHI *dsahip, struct dschannel *dc)
- {
- if (dc->al_source != -1) {
- if (abs (dc->cs.volume) != abs (dc->csnext.volume)) {
- float vol = ((float)(abs (dc->csnext.volume))) / 65536.0;
- alClear ();
- alSourcef (dc->al_source, AL_GAIN, vol);
- alError (L"AHI: SetVolume(%d,%d)", dc->num, vol);
- }
- if (abs (dc->cs.panning) != abs (dc->csnext.panning)) {
- ;// pan = (abs (dc->csnext.panning) - 0x8000) * DSBPAN_RIGHT / 32768;
- }
+static void ds_setvolume (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ if (dc->al_source != -1) {
+ if (abs (dc->cs.volume) != abs (dc->csnext.volume)) {
+ float vol = ((float)(abs (dc->csnext.volume))) / 65536.0;
+ alClear ();
+ alSourcef (dc->al_source, AL_GAIN, vol);
+ alError (L"AHI: SetVolume(%d,%d)", dc->num, vol);
+ }
+ if (abs (dc->cs.panning) != abs (dc->csnext.panning)) {
+ ;// pan = (abs (dc->csnext.panning) - 0x8000) * DSBPAN_RIGHT / 32768;
}
- dc->cs.volume = dc->csnext.volume;
- dc->cs.panning = dc->csnext.panning;
}
+ dc->cs.volume = dc->csnext.volume;
+ dc->cs.panning = dc->csnext.panning;
+}
- static void ds_setfreq (struct DSAHI *dsahip, struct dschannel *dc)
- {
- if (dc->dsplaying && dc->cs.frequency != dc->csnext.frequency && dc->csnext.frequency > 0 && dc->al_source != -1) {
- //alClear ();
- //alSourcei (dc->al_source, AL_FREQUENCY, dc->csnext.frequency);
- //alError (L"AHI: SetFrequency(%d,%d)", dc->num, dc->csnext.frequency);
- }
- dc->cs.frequency = dc->csnext.frequency;
+static void ds_setfreq (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ if (dc->dsplaying && dc->cs.frequency != dc->csnext.frequency && dc->csnext.frequency > 0 && dc->al_source != -1) {
+ //alClear ();
+ //alSourcei (dc->al_source, AL_FREQUENCY, dc->csnext.frequency);
+ //alError (L"AHI: SetFrequency(%d,%d)", dc->num, dc->csnext.frequency);
}
+ dc->cs.frequency = dc->csnext.frequency;
+}
- static int ds_allocchannel (struct DSAHI *dsahip, struct dschannel *dc)
- {
- if (dc->al_source != -1)
- return 1;
- alClear ();
- alGenSources (1, &dc->al_source);
- if (alError (L"alGenSources()"))
- goto error;
- dc->cs.frequency = -1;
- dc->cs.volume = -1;
- dc->cs.panning = -1;
- ds_setvolume (dsahip, dc);
- ds_setfreq (dsahip, dc);
- if (ahi_debug)
- write_log (L"AHI: allocated OpenAL source for channel %d. vol=%d pan=%d freq=%d\n",
- dc->num, dc->cs.volume, dc->cs.panning, dc->cs.frequency);
+static int ds_allocchannel (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ if (dc->al_source != -1)
return 1;
+ alClear ();
+ alGenSources (1, &dc->al_source);
+ if (alError (L"alGenSources()"))
+ goto error;
+ dc->cs.frequency = -1;
+ dc->cs.volume = -1;
+ dc->cs.panning = -1;
+ ds_setvolume (dsahip, dc);
+ ds_setfreq (dsahip, dc);
+ if (ahi_debug)
+ write_log (L"AHI: allocated OpenAL source for channel %d. vol=%d pan=%d freq=%d\n",
+ dc->num, dc->cs.volume, dc->cs.panning, dc->cs.frequency);
+ return 1;
error:
- ds_freechannel (dsahip, dc);
- return 0;
- }
+ ds_freechannel (dsahip, dc);
+ return 0;
+}
#define MAKEXCH makexch (dsahip, dc, dst, i, och2, l, r)
- STATIC_INLINE void makexch (struct DSAHI *dsahip, struct dschannel *dc, uae_u8 *dst, int idx, int och2, uae_s32 l, uae_s32 r)
- {
- if (dsahip->bits24) {
- } else {
- uae_s16 *dst2 = (uae_s16*)(&dst[idx * och2]);
- l >>= 8;
- r >>= 8;
- if (dc->cs.volume < 0) {
- l = -l;
- r = -r;
- }
- dst2[0] = l;
- dst2[1] = r;
- if (dsahip->chout <= 2)
- return;
- dst2[4] = dst2[0];
- dst2[5] = dst2[1];
- if (dc->cs.panning < 0) {
- // surround only
- dst2[2] = 0; // center
- dst2[3] = (dst2[0] + dst2[1]) / 4; // lfe
- dst2[0] = dst2[1] = 0;
- return;
- }
- dst2[2] = dst2[3] = (dst2[0] + dst2[1]) / 4;
- if (dsahip->chout <= 6)
- return;
- dst2[6] = dst2[4];
- dst2[7] = dst2[5];
+STATIC_INLINE void makexch (struct DSAHI *dsahip, struct dschannel *dc, uae_u8 *dst, int idx, int och2, uae_s32 l, uae_s32 r)
+{
+ if (dsahip->bits24) {
+ } else {
+ uae_s16 *dst2 = (uae_s16*)(&dst[idx * och2]);
+ l >>= 8;
+ r >>= 8;
+ if (dc->cs.volume < 0) {
+ l = -l;
+ r = -r;
}
+ dst2[0] = l;
+ dst2[1] = r;
+ if (dsahip->chout <= 2)
+ return;
+ dst2[4] = dst2[0];
+ dst2[5] = dst2[1];
+ if (dc->cs.panning < 0) {
+ // surround only
+ dst2[2] = 0; // center
+ dst2[3] = (dst2[0] + dst2[1]) / 4; // lfe
+ dst2[0] = dst2[1] = 0;
+ return;
+ }
+ dst2[2] = dst2[3] = (dst2[0] + dst2[1]) / 4;
+ if (dsahip->chout <= 6)
+ return;
+ dst2[6] = dst2[4];
+ dst2[7] = dst2[5];
}
+}
- /* sample conversion routines */
- static int copysampledata (struct DSAHI *dsahip, struct dschannel *dc, struct dssample *ds, uae_u8 **psrcp, uae_u8 *srce, uae_u8 *srcp, void *dstp, int dstlen)
+/* sample conversion routines */
+static int copysampledata (struct DSAHI *dsahip, struct dschannel *dc, struct dssample *ds, uae_u8 **psrcp, uae_u8 *srce, uae_u8 *srcp, void *dstp, int dstlen)
+{
+ int i;
+ uae_u8 *src = *psrcp;
+ uae_u8 *dst = (uae_u8*)dstp;
+ int och = dsahip->chout;
+ int och2 = och * 2;
+ int ich = ds->ch;
+ int len;
+
+ len = dstlen;
+ switch (ds->sampletype)
{
- int i;
- uae_u8 *src = *psrcp;
- uae_u8 *dst = (uae_u8*)dstp;
- int och = dsahip->chout;
- int och2 = och * 2;
- int ich = ds->ch;
- int len;
-
- len = dstlen;
- switch (ds->sampletype)
- {
- case AHIST_M8S:
- for (i = 0; i < len; i++) {
- uae_u32 l = (src[0] << 16) | (src[0] << 8) | src[0] ;
- uae_u32 r = (src[0] << 16) | (src[0] << 8) | src[0];
- src += 1;
- if (src >= srce)
- src = srcp;
- MAKEXCH;
- }
- break;
- case AHIST_S8S:
- for (i = 0; i < len; i++) {
- uae_u32 l = (src[0] << 16) | (src[0] << 8) | src[0] ;
- uae_u32 r = (src[1] << 16) | (src[1] << 8) | src[1];
- src += 2;
- if (src >= srce)
- src = srcp;
- MAKEXCH;
- }
- break;
- case AHIST_M16S:
- for (i = 0; i < len; i++) {
- uae_u32 l = (src[0] << 16) | (src[1] << 8) | src[1];
- uae_u32 r = (src[0] << 16) | (src[1] << 8) | src[1];
- src += 2;
- if (src >= srce)
- src = srcp;
- MAKEXCH;
- }
- break;
- case AHIST_S16S:
- for (i = 0; i < len; i++) {
- uae_u32 l = (src[0] << 16) | (src[1] << 8) | src[1];
- uae_u32 r = (src[2] << 16) | (src[3] << 8) | src[3];
- src += 4;
- if (src >= srce)
- src = srcp;
- MAKEXCH;
- }
- break;
- case AHIST_M32S:
+ case AHIST_M8S:
+ for (i = 0; i < len; i++) {
+ uae_u32 l = (src[0] << 16) | (src[0] << 8) | src[0] ;
+ uae_u32 r = (src[0] << 16) | (src[0] << 8) | src[0];
+ src += 1;
+ if (src >= srce)
+ src = srcp;
+ MAKEXCH;
+ }
+ break;
+ case AHIST_S8S:
+ for (i = 0; i < len; i++) {
+ uae_u32 l = (src[0] << 16) | (src[0] << 8) | src[0] ;
+ uae_u32 r = (src[1] << 16) | (src[1] << 8) | src[1];
+ src += 2;
+ if (src >= srce)
+ src = srcp;
+ MAKEXCH;
+ }
+ break;
+ case AHIST_M16S:
+ for (i = 0; i < len; i++) {
+ uae_u32 l = (src[0] << 16) | (src[1] << 8) | src[1];
+ uae_u32 r = (src[0] << 16) | (src[1] << 8) | src[1];
+ src += 2;
+ if (src >= srce)
+ src = srcp;
+ MAKEXCH;
+ }
+ break;
+ case AHIST_S16S:
+ for (i = 0; i < len; i++) {
+ uae_u32 l = (src[0] << 16) | (src[1] << 8) | src[1];
+ uae_u32 r = (src[2] << 16) | (src[3] << 8) | src[3];
+ src += 4;
+ if (src >= srce)
+ src = srcp;
+ MAKEXCH;
+ }
+ break;
+ case AHIST_M32S:
+ for (i = 0; i < len; i++) {
+ uae_u32 l = (src[3] << 16) | (src[2] << 8) | src[1];
+ uae_u32 r = (src[3] << 16) | (src[2] << 8) | src[1];
+ src += 4;
+ if (src >= srce)
+ src = srcp;
+ MAKEXCH;
+ }
+ break;
+ case AHIST_S32S:
+ for (i = 0; i < len; i++) {
+ uae_u32 l = (src[3] << 16) | (src[2] << 8) | src[1];
+ uae_u32 r = (src[7] << 16) | (src[6] << 8) | src[5];
+ src += 8;
+ if (src >= srce)
+ src = srcp;
+ MAKEXCH;
+ }
+ break;
+ case AHIST_L7_1:
+ if (och == 8) {
for (i = 0; i < len; i++) {
- uae_u32 l = (src[3] << 16) | (src[2] << 8) | src[1];
- uae_u32 r = (src[3] << 16) | (src[2] << 8) | src[1];
- src += 4;
+ if (dsahip->bits24) {
+ uae_u32 fl = (src[0 * 4 + 3] << 16) | (src[0 * 4 + 2] << 8) | src[0 * 4 + 1];
+ uae_u32 fr = (src[1 * 4 + 3] << 16) | (src[1 * 4 + 2] << 8) | src[1 * 4 + 1];
+ uae_u32 cc = (src[6 * 4 + 3] << 16) | (src[6 * 4 + 2] << 8) | src[6 * 4 + 1];
+ uae_u32 lf = (src[7 * 4 + 3] << 16) | (src[7 * 4 + 2] << 8) | src[7 * 4 + 1];
+ uae_u32 bl = (src[2 * 4 + 3] << 16) | (src[2 * 4 + 2] << 8) | src[2 * 4 + 1];
+ uae_u32 br = (src[3 * 4 + 3] << 16) | (src[3 * 4 + 2] << 8) | src[3 * 4 + 1];
+ uae_u32 sl = (src[4 * 4 + 3] << 16) | (src[4 * 4 + 2] << 8) | src[4 * 4 + 1];
+ uae_u32 sr = (src[5 * 4 + 3] << 16) | (src[5 * 4 + 2] << 8) | src[5 * 4 + 1];
+ uae_s32 *dst2 = (uae_s32*)(&dst[i * och2]);
+ dst2[0] = fl;
+ dst2[1] = fr;
+ dst2[2] = cc;
+ dst2[3] = lf;
+ dst2[4] = bl;
+ dst2[5] = br;
+ dst2[6] = sl;
+ dst2[7] = sr;
+ } else {
+ uae_u16 fl = (src[0 * 4 + 3] << 8) | src[0 * 4 + 2];
+ uae_u16 fr = (src[1 * 4 + 3] << 8) | src[1 * 4 + 2];
+ uae_u16 cc = (src[6 * 4 + 3] << 8) | src[6 * 4 + 2];
+ uae_u16 lf = (src[7 * 4 + 3] << 8) | src[7 * 4 + 2];
+ uae_u16 bl = (src[2 * 4 + 3] << 8) | src[2 * 4 + 2];
+ uae_u16 br = (src[3 * 4 + 3] << 8) | src[3 * 4 + 2];
+ uae_u16 sl = (src[4 * 4 + 3] << 8) | src[4 * 4 + 2];
+ uae_u16 sr = (src[5 * 4 + 3] << 8) | src[5 * 4 + 2];
+ uae_s16 *dst2 = (uae_s16*)(&dst[i * och2]);
+ dst2[0] = fl;
+ dst2[1] = fr;
+ dst2[2] = cc;
+ dst2[3] = lf;
+ dst2[4] = bl;
+ dst2[5] = br;
+ dst2[6] = sl;
+ dst2[7] = sr;
+ }
+ dst += och2;
+ src += 8 * 4;
if (src >= srce)
src = srcp;
- MAKEXCH;
}
- break;
- case AHIST_S32S:
+ } else if (och == 6) { /* 7.1 -> 5.1 */
for (i = 0; i < len; i++) {
- uae_u32 l = (src[3] << 16) | (src[2] << 8) | src[1];
- uae_u32 r = (src[7] << 16) | (src[6] << 8) | src[5];
- src += 8;
+ if (dsahip->bits24) {
+ uae_s32 *dst2 = (uae_s32*)(&dst[i * och2]);
+ uae_u32 fl = (src[0 * 4 + 3] << 16) | (src[0 * 4 + 2] << 8) | src[0 * 4 + 1];
+ uae_u32 fr = (src[1 * 4 + 3] << 16) | (src[1 * 4 + 2] << 8) | src[1 * 4 + 1];
+ uae_u32 cc = (src[6 * 4 + 3] << 16) | (src[6 * 4 + 2] << 8) | src[6 * 4 + 1];
+ uae_u32 lf = (src[7 * 4 + 3] << 16) | (src[7 * 4 + 2] << 8) | src[7 * 4 + 1];
+ uae_u32 bl = (src[2 * 4 + 3] << 16) | (src[2 * 4 + 2] << 8) | src[2 * 4 + 1];
+ uae_u32 br = (src[3 * 4 + 3] << 16) | (src[3 * 4 + 2] << 8) | src[3 * 4 + 1];
+ uae_u32 sl = (src[4 * 4 + 3] << 16) | (src[4 * 4 + 2] << 8) | src[4 * 4 + 1];
+ uae_u32 sr = (src[5 * 4 + 3] << 16) | (src[5 * 4 + 2] << 8) | src[5 * 4 + 1];
+ } else {
+ uae_s16 *dst2 = (uae_s16*)(&dst[i * och2]);
+ uae_u16 fl = (src[0 * 4 + 3] << 8) | src[0 * 4 + 2];
+ uae_u16 fr = (src[1 * 4 + 3] << 8) | src[1 * 4 + 2];
+ uae_u16 cc = (src[6 * 4 + 3] << 8) | src[6 * 4 + 2];
+ uae_u16 lf = (src[7 * 4 + 3] << 8) | src[7 * 4 + 2];
+ uae_u16 bl = (src[2 * 4 + 3] << 8) | src[2 * 4 + 2];
+ uae_u16 br = (src[3 * 4 + 3] << 8) | src[3 * 4 + 2];
+ uae_u16 sl = (src[4 * 4 + 3] << 8) | src[4 * 4 + 2];
+ uae_u16 sr = (src[5 * 4 + 3] << 8) | src[5 * 4 + 2];
+ dst2[0] = fl;
+ dst2[1] = fr;
+ dst2[2] = cc;
+ dst2[3] = lf;
+ dst2[4] = (bl + sl) / 2;
+ dst2[5] = (br + sr) / 2;
+ }
+ dst += och2;
+ src += 8 * 4;
if (src >= srce)
src = srcp;
- MAKEXCH;
- }
- break;
- case AHIST_L7_1:
- if (och == 8) {
- for (i = 0; i < len; i++) {
- if (dsahip->bits24) {
- uae_u32 fl = (src[0 * 4 + 3] << 16) | (src[0 * 4 + 2] << 8) | src[0 * 4 + 1];
- uae_u32 fr = (src[1 * 4 + 3] << 16) | (src[1 * 4 + 2] << 8) | src[1 * 4 + 1];
- uae_u32 cc = (src[6 * 4 + 3] << 16) | (src[6 * 4 + 2] << 8) | src[6 * 4 + 1];
- uae_u32 lf = (src[7 * 4 + 3] << 16) | (src[7 * 4 + 2] << 8) | src[7 * 4 + 1];
- uae_u32 bl = (src[2 * 4 + 3] << 16) | (src[2 * 4 + 2] << 8) | src[2 * 4 + 1];
- uae_u32 br = (src[3 * 4 + 3] << 16) | (src[3 * 4 + 2] << 8) | src[3 * 4 + 1];
- uae_u32 sl = (src[4 * 4 + 3] << 16) | (src[4 * 4 + 2] << 8) | src[4 * 4 + 1];
- uae_u32 sr = (src[5 * 4 + 3] << 16) | (src[5 * 4 + 2] << 8) | src[5 * 4 + 1];
- uae_s32 *dst2 = (uae_s32*)(&dst[i * och2]);
- dst2[0] = fl;
- dst2[1] = fr;
- dst2[2] = cc;
- dst2[3] = lf;
- dst2[4] = bl;
- dst2[5] = br;
- dst2[6] = sl;
- dst2[7] = sr;
- } else {
- uae_u16 fl = (src[0 * 4 + 3] << 8) | src[0 * 4 + 2];
- uae_u16 fr = (src[1 * 4 + 3] << 8) | src[1 * 4 + 2];
- uae_u16 cc = (src[6 * 4 + 3] << 8) | src[6 * 4 + 2];
- uae_u16 lf = (src[7 * 4 + 3] << 8) | src[7 * 4 + 2];
- uae_u16 bl = (src[2 * 4 + 3] << 8) | src[2 * 4 + 2];
- uae_u16 br = (src[3 * 4 + 3] << 8) | src[3 * 4 + 2];
- uae_u16 sl = (src[4 * 4 + 3] << 8) | src[4 * 4 + 2];
- uae_u16 sr = (src[5 * 4 + 3] << 8) | src[5 * 4 + 2];
- uae_s16 *dst2 = (uae_s16*)(&dst[i * och2]);
- dst2[0] = fl;
- dst2[1] = fr;
- dst2[2] = cc;
- dst2[3] = lf;
- dst2[4] = bl;
- dst2[5] = br;
- dst2[6] = sl;
- dst2[7] = sr;
- }
- dst += och2;
- src += 8 * 4;
- if (src >= srce)
- src = srcp;
- }
- } else if (och == 6) { /* 7.1 -> 5.1 */
- for (i = 0; i < len; i++) {
- if (dsahip->bits24) {
- uae_s32 *dst2 = (uae_s32*)(&dst[i * och2]);
- uae_u32 fl = (src[0 * 4 + 3] << 16) | (src[0 * 4 + 2] << 8) | src[0 * 4 + 1];
- uae_u32 fr = (src[1 * 4 + 3] << 16) | (src[1 * 4 + 2] << 8) | src[1 * 4 + 1];
- uae_u32 cc = (src[6 * 4 + 3] << 16) | (src[6 * 4 + 2] << 8) | src[6 * 4 + 1];
- uae_u32 lf = (src[7 * 4 + 3] << 16) | (src[7 * 4 + 2] << 8) | src[7 * 4 + 1];
- uae_u32 bl = (src[2 * 4 + 3] << 16) | (src[2 * 4 + 2] << 8) | src[2 * 4 + 1];
- uae_u32 br = (src[3 * 4 + 3] << 16) | (src[3 * 4 + 2] << 8) | src[3 * 4 + 1];
- uae_u32 sl = (src[4 * 4 + 3] << 16) | (src[4 * 4 + 2] << 8) | src[4 * 4 + 1];
- uae_u32 sr = (src[5 * 4 + 3] << 16) | (src[5 * 4 + 2] << 8) | src[5 * 4 + 1];
- } else {
- uae_s16 *dst2 = (uae_s16*)(&dst[i * och2]);
- uae_u16 fl = (src[0 * 4 + 3] << 8) | src[0 * 4 + 2];
- uae_u16 fr = (src[1 * 4 + 3] << 8) | src[1 * 4 + 2];
- uae_u16 cc = (src[6 * 4 + 3] << 8) | src[6 * 4 + 2];
- uae_u16 lf = (src[7 * 4 + 3] << 8) | src[7 * 4 + 2];
- uae_u16 bl = (src[2 * 4 + 3] << 8) | src[2 * 4 + 2];
- uae_u16 br = (src[3 * 4 + 3] << 8) | src[3 * 4 + 2];
- uae_u16 sl = (src[4 * 4 + 3] << 8) | src[4 * 4 + 2];
- uae_u16 sr = (src[5 * 4 + 3] << 8) | src[5 * 4 + 2];
- dst2[0] = fl;
- dst2[1] = fr;
- dst2[2] = cc;
- dst2[3] = lf;
- dst2[4] = (bl + sl) / 2;
- dst2[5] = (br + sr) / 2;
- }
- dst += och2;
- src += 8 * 4;
- if (src >= srce)
- src = srcp;
- }
}
- break;
}
- *psrcp = src;
- return dstlen * och2;
+ break;
}
+ *psrcp = src;
+ return dstlen * och2;
+}
- static void dorecord (struct DSAHI *dsahip)
- {
- uae_u32 pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
- uae_u32 recordbuf;
- int bytes;
-
- if (dsahip->al_recorddev == NULL)
- return;
- if (dsahip->record_wait && !get_word (pbase + pub_RecordHookDone))
- return;
- dsahip->record_wait = 0;
- bytes = dsahip->record_samples * dsahip->record_ch * dsahip->record_bytespersample;
- recordbuf = get_long (pbase + pub_RecordBuffer);
- if (recordbuf == 0 || !valid_address (recordbuf, bytes))
- return;
- alClear ();
- alcCaptureSamples (dsahip->al_recorddev, (void*)recordbuf, dsahip->record_samples);
- if (alGetError () != AL_NO_ERROR)
- return;
- put_word (pbase + pub_RecordHookDone, 0);
- dsahip->record_wait = 1;
- put_word (pbase + pub_FuncMode, get_word (pbase + pub_FuncMode) | FUNCMODE_RECORD);
- sendsignal (dsahip);
- }
+static void dorecord (struct DSAHI *dsahip)
+{
+ uae_u32 pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
+ uae_u32 recordbuf;
+ int bytes;
+
+ if (dsahip->al_recorddev == NULL)
+ return;
+ if (dsahip->record_wait && !get_word (pbase + pub_RecordHookDone))
+ return;
+ dsahip->record_wait = 0;
+ bytes = dsahip->record_samples * dsahip->record_ch * dsahip->record_bytespersample;
+ recordbuf = get_long (pbase + pub_RecordBuffer);
+ if (recordbuf == 0 || !valid_address (recordbuf, bytes))
+ return;
+ alClear ();
+ alcCaptureSamples (dsahip->al_recorddev, (void*)recordbuf, dsahip->record_samples);
+ if (alGetError () != AL_NO_ERROR)
+ return;
+ put_word (pbase + pub_RecordHookDone, 0);
+ dsahip->record_wait = 1;
+ put_word (pbase + pub_FuncMode, get_word (pbase + pub_FuncMode) | FUNCMODE_RECORD);
+ sendsignal (dsahip);
+}
+
+
+static void al_setloop (struct dschannel *dc, int state)
+{
+ alClear ();
+ alSourcei (dc->al_source, AL_LOOPING, state ? AL_TRUE : AL_FALSE);
+ alError (L"AHI: ds_play() alSourcei(AL_LOOPING)");
+}
+static void al_startplay (struct dschannel *dc)
+{
+ alClear ();
+ alSourcePlay (dc->al_source);
+ alError (L"AHI: ds_play() alSourcePlay");
+}
- static void al_setloop (struct dschannel *dc, int state)
- {
- alClear ();
- alSourcei (dc->al_source, AL_LOOPING, state ? AL_TRUE : AL_FALSE);
- alError (L"AHI: ds_play() alSourcei(AL_LOOPING)");
- }
+static void preparesample_single (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ uae_u8 *p, *ps, *pe;
+ struct dssample *ds;
+ int slen, dlen;
+
+ dc->samplecounter = -1;
+ dc->buffertoggle = 0;
+
+ ds = dc->cs.ds;
+ ps = p = get_real_address (ds->addr);
+ pe = ps + ds->len * ds->bytespersample * ds->ch;
+
+ slen = ds->len;
+ p += dc->cs.srcplayoffset * ds->bytespersample * ds->ch;
+ dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
+ alClear ();
+ alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
+ alError (L"AHI: preparesample_single:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
+ alClear ();
+ alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
+ alError (L"AHI: al_initsample_single:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
+ if (ahi_debug > 2)
+ write_log (L"AHI: sample queued %d: %d/%d\n",
+ dc->num, dc->samplecounter, dc->totalsamples);
+}
+
+
+static void preparesample_multi (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ uae_u8 *p, *ps, *pe;
+ struct dssample *ds;
+ int slen, dlen;
+
+ ds = dc->cs.ds;
+ ps = p = get_real_address (ds->addr);
+ pe = ps + ds->len * ds->bytespersample * ds->ch;
+
+ slen = dc->maxplaysamples;
+ if (dc->samplecounter == dc->totalsamples - 1)
+ slen = ds->len - dc->maxplaysamples * (dc->totalsamples - 1);
+
+ p += (dc->maxplaysamples * dc->samplecounter + dc->cs.srcplayoffset) * ds->bytespersample * ds->ch;
+ dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
+ alClear ();
+ alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
+ alError (L"AHI: preparesample:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
+ alClear ();
+ alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
+ alError (L"AHI: al_initsample:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
+ if (ahi_debug > 2)
+ write_log (L"AHI: sample queued %d: %d/%d\n",
+ dc->num, dc->samplecounter, dc->totalsamples);
+ dc->samplecounter++;
+ dc->buffertoggle ^= 1;
+}
+
+/* called when sample is started for the first time */
+static void al_initsample (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ uae_u32 audioctrl = dsahip->audioctrl;
+ struct dssample *ds;
+ int single = 0;
+
+ alSourceStop (dc->al_source);
+ alClear ();
+ alSourcei (dc->al_source, AL_BUFFER, AL_NONE);
+ alError (L"AHI: al_initsample:AL_BUFFER=AL_NONE");
+
+ memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
+ dc->csnext.ds = NULL;
+ dc->waitforack = 0;
+ ds = dc->cs.ds;
+ if (ds == NULL)
+ return;
+
+ if (get_long (audioctrl + ahiac_SoundFunc)) {
+ dc->samplecounter = 0;
+ if (ds->dynamic) {
+ dc->maxplaysamples = dsahip->maxplaysamples / 2;
+ if (dc->maxplaysamples > ds->len / 2)
+ dc->maxplaysamples = ds->len / 2;
+ } else {
+ dc->maxplaysamples = ds->len / 2;
+ }
+ if (dc->maxplaysamples > dsahip->tmpbuffer_size)
+ dc->maxplaysamples = dsahip->tmpbuffer_size;
- static void al_startplay (struct dschannel *dc)
- {
- alClear ();
- alSourcePlay (dc->al_source);
- alError (L"AHI: ds_play() alSourcePlay");
+ dc->totalsamples = ds->len / dc->maxplaysamples;
+ if (dc->totalsamples <= 1)
+ dc->totalsamples = 2;
+ /* queue first half */
+ preparesample_multi (dsahip, dc);
+ /* queue second half */
+ preparesample_multi (dsahip, dc);
+ } else {
+ single = 1;
+ preparesample_single (dsahip, dc);
}
+ al_setloop (dc, single);
- static void preparesample_single (struct DSAHI *dsahip, struct dschannel *dc)
- {
- uae_u8 *p, *ps, *pe;
- struct dssample *ds;
- int slen, dlen;
-
- dc->samplecounter = -1;
- dc->buffertoggle = 0;
-
- ds = dc->cs.ds;
- ps = p = get_real_address (ds->addr);
- pe = ps + ds->len * ds->bytespersample * ds->ch;
-
- slen = ds->len;
- p += dc->cs.srcplayoffset * ds->bytespersample * ds->ch;
- dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
- alClear ();
- alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
- alError (L"AHI: preparesample_single:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
- alClear ();
- alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
- alError (L"AHI: al_initsample_single:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
- if (ahi_debug > 2)
- write_log (L"AHI: sample queued %d: %d/%d\n",
- dc->num, dc->samplecounter, dc->totalsamples);
+ if (dc->dsplaying) {
+ dc->dsplaying = 1;
+ al_startplay (dc);
+ setchannelevent (dsahip, dc);
}
+}
+/* called when previous sample is still playing */
+static void al_queuesample (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ int v, restart;
- static void preparesample_multi (struct DSAHI *dsahip, struct dschannel *dc)
- {
- uae_u8 *p, *ps, *pe;
- struct dssample *ds;
- int slen, dlen;
-
- ds = dc->cs.ds;
- ps = p = get_real_address (ds->addr);
- pe = ps + ds->len * ds->bytespersample * ds->ch;
-
- slen = dc->maxplaysamples;
- if (dc->samplecounter == dc->totalsamples - 1)
- slen = ds->len - dc->maxplaysamples * (dc->totalsamples - 1);
-
- p += (dc->maxplaysamples * dc->samplecounter + dc->cs.srcplayoffset) * ds->bytespersample * ds->ch;
- dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
- alClear ();
- alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
- alError (L"AHI: preparesample:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
- alClear ();
- alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
- alError (L"AHI: al_initsample:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
- if (ahi_debug > 2)
- write_log (L"AHI: sample queued %d: %d/%d\n",
- dc->num, dc->samplecounter, dc->totalsamples);
- dc->samplecounter++;
- dc->buffertoggle ^= 1;
+ if (!dc->cs.ds)
+ return;
+ if (dc->cs.ds->num < 0) {
+ dc->cs.ds = NULL;
+ return;
}
-
- /* called when sample is started for the first time */
- static void al_initsample (struct DSAHI *dsahip, struct dschannel *dc)
- {
- uae_u32 audioctrl = dsahip->audioctrl;
- struct dssample *ds;
- int single = 0;
-
- alSourceStop (dc->al_source);
+ restart = 0;
+ if (dc->dsplaying) {
alClear ();
- alSourcei (dc->al_source, AL_BUFFER, AL_NONE);
- alError (L"AHI: al_initsample:AL_BUFFER=AL_NONE");
-
- memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
- dc->csnext.ds = NULL;
- dc->waitforack = 0;
- ds = dc->cs.ds;
- if (ds == NULL)
- return;
-
- if (get_long (audioctrl + ahiac_SoundFunc)) {
- dc->samplecounter = 0;
- if (ds->dynamic) {
- dc->maxplaysamples = dsahip->maxplaysamples / 2;
- if (dc->maxplaysamples > ds->len / 2)
- dc->maxplaysamples = ds->len / 2;
- } else {
- dc->maxplaysamples = ds->len / 2;
- }
- if (dc->maxplaysamples > dsahip->tmpbuffer_size)
- dc->maxplaysamples = dsahip->tmpbuffer_size;
-
- dc->totalsamples = ds->len / dc->maxplaysamples;
- if (dc->totalsamples <= 1)
- dc->totalsamples = 2;
- /* queue first half */
- preparesample_multi (dsahip, dc);
- /* queue second half */
+ alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
+ alError (L"AHI: queuesample AL_SOURCE_STATE");
+ if (v != AL_PLAYING) {
+ alClear ();
+ alSourceRewind (dc->al_source);
+ alError (L"AHI: queuesample:restart");
+ restart = 1;
+ if (ahi_debug > 2)
+ write_log (L"AHI: queuesample, play restart\n");
preparesample_multi (dsahip, dc);
- } else {
- single = 1;
- preparesample_single (dsahip, dc);
- }
- al_setloop (dc, single);
-
- if (dc->dsplaying) {
- dc->dsplaying = 1;
- al_startplay (dc);
- setchannelevent (dsahip, dc);
}
}
+ preparesample_multi (dsahip, dc);
+ if (dc->dsplaying)
+ dc->dsplaying = 1;
+ if (restart)
+ al_startplay (dc);
+ if (ahi_debug > 2)
+ write_log (L"AHI: sample %d queued to channel %d\n", dc->cs.ds->num, dc->num);
+}
- /* called when previous sample is still playing */
- static void al_queuesample (struct DSAHI *dsahip, struct dschannel *dc)
- {
- int v, restart;
-
- if (!dc->cs.ds)
- return;
- if (dc->cs.ds->num < 0) {
- dc->cs.ds = NULL;
- return;
- }
- restart = 0;
- if (dc->dsplaying) {
- alClear ();
- alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
- alError (L"AHI: queuesample AL_SOURCE_STATE");
- if (v != AL_PLAYING) {
- alClear ();
- alSourceRewind (dc->al_source);
- alError (L"AHI: queuesample:restart");
- restart = 1;
- if (ahi_debug > 2)
- write_log (L"AHI: queuesample, play restart\n");
- preparesample_multi (dsahip, dc);
- }
- }
- preparesample_multi (dsahip, dc);
- if (dc->dsplaying)
- dc->dsplaying = 1;
- if (restart)
- al_startplay (dc);
- if (ahi_debug > 2)
- write_log (L"AHI: sample %d queued to channel %d\n", dc->cs.ds->num, dc->num);
+static int unqueuebuffers (struct dschannel *dc)
+{
+ int v, cnt = 0;
+ for (;;) {
+ ALuint tmp;
+ alClear ();
+ alGetSourcei (dc->al_source, AL_BUFFERS_PROCESSED, &v);
+ if (alError (L"AHI: hsync AL_BUFFERS_PROCESSED %d", dc->num))
+ return cnt;
+ if (v == 0)
+ return cnt;
+ alSourceUnqueueBuffers (dc->al_source, 1, &tmp);
+ cnt++;
}
+}
- static int unqueuebuffers (struct dschannel *dc)
- {
- int v, cnt = 0;
- for (;;) {
- ALuint tmp;
- alClear ();
- alGetSourcei (dc->al_source, AL_BUFFERS_PROCESSED, &v);
- if (alError (L"AHI: hsync AL_BUFFERS_PROCESSED %d", dc->num))
- return cnt;
- if (v == 0)
- return cnt;
- alSourceUnqueueBuffers (dc->al_source, 1, &tmp);
- cnt++;
+void ahi_hsync (void)
+{
+ struct DSAHI *dsahip = &dsahi[0];
+ static int cnt;
+ uae_u32 pbase;
+ int i, flags;
+
+ if (ahi_paused || !ahi_active)
+ return;
+ pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
+ if (cnt >= 0)
+ cnt--;
+ if (cnt < 0) {
+ if (dsahip->dsrecording && dsahip->enabledisable == 0) {
+ dorecord (dsahip);
+ cnt = 100;
}
}
-
- void ahi_hsync (void)
- {
- struct DSAHI *dsahip = &dsahi[0];
- static int cnt;
- uae_u32 pbase;
- int i, flags;
-
- if (ahi_paused || !ahi_active)
- return;
- pbase = get_long (dsahip->audioctrl + ahiac_DriverData);
- if (cnt >= 0)
- cnt--;
- if (cnt < 0) {
- if (dsahip->dsrecording && dsahip->enabledisable == 0) {
- dorecord (dsahip);
- cnt = 100;
+ if (!dsahip->playing)
+ return;
+ flags = get_long (pbase + pub_ChannelSignalAck);
+ for (i = 0; i < UAE_MAXCHANNELS; i++) {
+ int v, removed;
+ struct dschannel *dc = &dsahip->channel[i];
+ uae_u32 mask = 1 << (dc - &dsahip->channel[0]);
+
+ if (dc->dsplaying != 1 || dc->al_source == -1)
+ continue;
+
+ removed = unqueuebuffers (dc);
+ v = 0;
+ alClear ();
+ alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
+ alError (L"AHI: hsync AL_SOURCE_STATE");
+ if (v != AL_PLAYING) {
+ if (dc->cs.ds) {
+ setchannelevent (dsahip, dc);
+ if (ahi_debug)
+ write_log (L"AHI: ********* channel %d stopped state=%d!\n", dc->num, v);
+ removed = 1;
+ dc->dsplaying = 2;
+ dc->waitforack = 0;
}
}
- if (!dsahip->playing)
- return;
- flags = get_long (pbase + pub_ChannelSignalAck);
- for (i = 0; i < UAE_MAXCHANNELS; i++) {
- int v, removed;
- struct dschannel *dc = &dsahip->channel[i];
- uae_u32 mask = 1 << (dc - &dsahip->channel[0]);
-
- if (dc->dsplaying != 1 || dc->al_source == -1)
- continue;
-
- removed = unqueuebuffers (dc);
- v = 0;
- alClear ();
- alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
- alError (L"AHI: hsync AL_SOURCE_STATE");
- if (v != AL_PLAYING) {
- if (dc->cs.ds) {
- setchannelevent (dsahip, dc);
- if (ahi_debug)
- write_log (L"AHI: ********* channel %d stopped state=%d!\n", dc->num, v);
- removed = 1;
- dc->dsplaying = 2;
- dc->waitforack = 0;
- }
- }
- if (!dc->waitforack && dc->samplecounter >= 0 && removed) {
- int evt = 0;
+ if (!dc->waitforack && dc->samplecounter >= 0 && removed) {
+ int evt = 0;
+ if (ahi_debug > 2)
+ write_log (L"sample end channel %d: %d/%d\n", dc->num, dc->samplecounter, dc->totalsamples);
+ if (dc->samplecounter >= dc->totalsamples) {
+ evt = 1;
if (ahi_debug > 2)
- write_log (L"sample end channel %d: %d/%d\n", dc->num, dc->samplecounter, dc->totalsamples);
- if (dc->samplecounter >= dc->totalsamples) {
- evt = 1;
- if (ahi_debug > 2)
- write_log (L"sample finished channel %d: %d\n", dc->num, dc->totalsamples);
- dc->samplecounter = 0;
- if (dc->csnext.ds) {
- memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
- dc->csnext.ds = NULL;
- }
- }
- if (evt) {
- flags &= ~mask;
- if (setchannelevent (dsahip, dc))
- dc->waitforack = 1;
+ write_log (L"sample finished channel %d: %d\n", dc->num, dc->totalsamples);
+ dc->samplecounter = 0;
+ if (dc->csnext.ds) {
+ memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
+ dc->csnext.ds = NULL;
}
- if (!dc->waitforack)
- al_queuesample (dsahip, dc);
}
- if (dc->waitforack && (flags & mask)) {
- al_queuesample (dsahip, dc);
- dc->waitforack = 0;
+ if (evt) {
flags &= ~mask;
+ if (setchannelevent (dsahip, dc))
+ dc->waitforack = 1;
}
+ if (!dc->waitforack)
+ al_queuesample (dsahip, dc);
}
- put_long (pbase + pub_ChannelSignalAck, flags);
- }
-
- static void ds_record (struct DSAHI *dsahip, int start)
- {
- alClear ();
- if (start) {
- if (!dsahip->dsrecording)
- alcCaptureStart (dsahip->al_recorddev);
- dsahip->dsrecording = 1;
- } else {
- alcCaptureStop (dsahip->al_recorddev);
- dsahip->dsrecording = 0;
+ if (dc->waitforack && (flags & mask)) {
+ al_queuesample (dsahip, dc);
+ dc->waitforack = 0;
+ flags &= ~mask;
}
- alError (L"AHI: alcCapture%s failed", start ? "Start" : "Stop");
}
+ put_long (pbase + pub_ChannelSignalAck, flags);
+}
- static void ds_stop (struct DSAHI *dsahip, struct dschannel *dc)
- {
- dc->dsplaying = 0;
- if (dc->al_source == -1)
- return;
- if (ahi_debug)
- write_log (L"AHI: ds_stop(%d)\n", dc->num);
- alClear ();
- alSourceStop (dc->al_source);
- alError (L"AHI: alSourceStop");
- unqueuebuffers (dc);
+static void ds_record (struct DSAHI *dsahip, int start)
+{
+ alClear ();
+ if (start) {
+ if (!dsahip->dsrecording)
+ alcCaptureStart (dsahip->al_recorddev);
+ dsahip->dsrecording = 1;
+ } else {
+ alcCaptureStop (dsahip->al_recorddev);
+ dsahip->dsrecording = 0;
}
+ alError (L"AHI: alcCapture%s failed", start ? "Start" : "Stop");
+}
- static void ds_play (struct DSAHI *dsahip, struct dschannel *dc)
- {
- if (dc->dsplaying) {
- dc->dsplaying = 1;
- return;
- }
+static void ds_stop (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ dc->dsplaying = 0;
+ if (dc->al_source == -1)
+ return;
+ if (ahi_debug)
+ write_log (L"AHI: ds_stop(%d)\n", dc->num);
+ alClear ();
+ alSourceStop (dc->al_source);
+ alError (L"AHI: alSourceStop");
+ unqueuebuffers (dc);
+}
+
+static void ds_play (struct DSAHI *dsahip, struct dschannel *dc)
+{
+ if (dc->dsplaying) {
dc->dsplaying = 1;
- if (dc->cs.frequency == 0)
- return;
+ return;
+ }
+ dc->dsplaying = 1;
+ if (dc->cs.frequency == 0)
+ return;
+ if (dc->al_source == -1)
+ return;
+ if (ahi_debug)
+ write_log (L"AHI: ds_play(%d)\n", dc->num);
+ al_startplay (dc);
+}
+
+void ahi2_pause_sound (int paused)
+{
+ int i;
+ struct DSAHI *dsahip = &dsahi[0];
+
+ ahi_paused = paused;
+ if (!dsahip->playing && !dsahip->recording)
+ return;
+ for (i = 0; i < UAE_MAXCHANNELS; i++) {
+ struct dschannel *dc = &dsahip->channel[i];
if (dc->al_source == -1)
- return;
- if (ahi_debug)
- write_log (L"AHI: ds_play(%d)\n", dc->num);
- al_startplay (dc);
+ continue;
+ if (paused) {
+ ds_stop (dsahip, dc);
+ } else {
+ ds_play (dsahip, dc);
+ setchannelevent (dsahip, dc);
+ }
}
+}
- void ahi2_pause_sound (int paused)
- {
- int i;
- struct DSAHI *dsahip = &dsahi[0];
+static uae_u32 init (TrapContext *ctx)
+{
+ int i, j;
+
+ enumerate_sound_devices ();
+ xahi_author = ds (L"Toni Wilen");
+ xahi_copyright = ds (L"GPL");
+ xahi_version = ds (L"uae2 0.2 (xx.xx.2008)\r\n");
+ j = 0;
+ for (i = 0; sound_devices[i].name; i++) {
+ if (sound_devices[i].type == SOUND_DEVICE_AL)
+ xahi_output[j++] = ds (sound_devices[i].name);
+ }
+ xahi_output_num = j;
+ j = 0;
+ for (i = 0; record_devices[i].name; i++) {
+ if (record_devices[i].type == SOUND_DEVICE_AL)
+ xahi_input[j++] = ds (record_devices[i].name);
+ }
+ xahi_input_num = j;
+ return 1;
+}
- ahi_paused = paused;
- if (!dsahip->playing && !dsahip->recording)
- return;
- for (i = 0; i < UAE_MAXCHANNELS; i++) {
- struct dschannel *dc = &dsahip->channel[i];
- if (dc->al_source == -1)
- continue;
- if (paused) {
- ds_stop (dsahip, dc);
- } else {
- ds_play (dsahip, dc);
- setchannelevent (dsahip, dc);
- }
- }
+static uae_u32 AHIsub_AllocAudio (TrapContext *ctx)
+{
+ int i;
+ uae_u32 tags = m68k_areg (regs, 1);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
+ uae_u32 tag, data, v, ver, size;
+ uae_u32 ret = AHISF_KNOWSTEREO | AHISF_KNOWHIFI;
+ struct DSAHI *dsahip = &dsahi[0];
+
+ if (ahi_debug)
+ write_log (L"AHI: AllocAudio(%08x,%08x)\n", tags, audioctrl);
+
+ ver = get_long (pbase + pub_Version);
+ size = get_long (pbase + pub_SizeOf);
+ if (ver != AHI_STRUCT_VERSION) {
+ gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio\nVersion mismatch %d<>%d.", ver, AHI_STRUCT_VERSION);
+ return AHISF_ERROR;
+ }
+ if (size < pub_End) {
+ gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio.\nInternal structure size %d<>%d.", size, pub_End);
+ return AHISF_ERROR;
}
- static uae_u32 init (TrapContext *ctx)
- {
- int i, j;
-
- enumerate_sound_devices ();
- xahi_author = ds (L"Toni Wilen");
- xahi_copyright = ds (L"GPL");
- xahi_version = ds (L"uae2 0.2 (xx.xx.2008)\r\n");
- j = 0;
- for (i = 0; sound_devices[i].name; i++) {
- if (sound_devices[i].type == SOUND_DEVICE_AL)
- xahi_output[j++] = ds (sound_devices[i].name);
- }
- xahi_output_num = j;
- j = 0;
- for (i = 0; record_devices[i].name; i++) {
- if (record_devices[i].type == SOUND_DEVICE_AL)
- xahi_input[j++] = ds (record_devices[i].name);
- }
- xahi_input_num = j;
- return 1;
+ v = get_long (pbase + pub_Index);
+ if (v != -1) {
+ write_log (L"AHI: corrupted memory\n");
+ return AHISF_ERROR;
}
+ put_long (pbase + pub_Index, dsahip - dsahi);
+ dsahip->audioctrl = audioctrl;
- static uae_u32 AHIsub_AllocAudio (TrapContext *ctx)
- {
- int i;
- uae_u32 tags = m68k_areg (regs, 1);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
- uae_u32 tag, data, v, ver, size;
- uae_u32 ret = AHISF_KNOWSTEREO | AHISF_KNOWHIFI;
- struct DSAHI *dsahip = &dsahi[0];
+ dsahip->maxplaysamples = UAE_MAXPLAYSAMPLES;
+ dsahip->sounds = UAE_MAXSOUNDS;
+ dsahip->channels = UAE_MAXCHANNELS;
+ dsahip->audioid = 0x003b0001;
+ while ((tag = gettag (&tags, &data))) {
if (ahi_debug)
- write_log (L"AHI: AllocAudio(%08x,%08x)\n", tags, audioctrl);
-
- ver = get_long (pbase + pub_Version);
- size = get_long (pbase + pub_SizeOf);
- if (ver != AHI_STRUCT_VERSION) {
- gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio\nVersion mismatch %d<>%d.", ver, AHI_STRUCT_VERSION);
- return AHISF_ERROR;
- }
- if (size < pub_End) {
- gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio.\nInternal structure size %d<>%d.", size, pub_End);
- return AHISF_ERROR;
- }
-
- v = get_long (pbase + pub_Index);
- if (v != -1) {
- write_log (L"AHI: corrupted memory\n");
- return AHISF_ERROR;
- }
- put_long (pbase + pub_Index, dsahip - dsahi);
- dsahip->audioctrl = audioctrl;
-
- dsahip->maxplaysamples = UAE_MAXPLAYSAMPLES;
- dsahip->sounds = UAE_MAXSOUNDS;
- dsahip->channels = UAE_MAXCHANNELS;
-
- dsahip->audioid = 0x003b0001;
- while ((tag = gettag (&tags, &data))) {
- if (ahi_debug)
- write_log (L"- TAG %08x=%d: %08x=%u\n", tag, tag & 0x7fff, data, data);
- switch (tag)
- {
- case AHIA_AudioID:
- dsahip->audioid = data;
- break;
- }
+ write_log (L"- TAG %08x=%d: %08x=%u\n", tag, tag & 0x7fff, data, data);
+ switch (tag)
+ {
+ case AHIA_AudioID:
+ dsahip->audioid = data;
+ break;
}
+ }
- if ((dsahip->audioid >> 16) != 0x3b)
- return AHISF_ERROR;
+ if ((dsahip->audioid >> 16) != 0x3b)
+ return AHISF_ERROR;
- if (dsahip->sounds < 0 || dsahip->sounds > 1000)
- return AHISF_ERROR;
+ if (dsahip->sounds < 0 || dsahip->sounds > 1000)
+ return AHISF_ERROR;
- if (!ds_init (dsahip))
- return AHISF_ERROR;
+ if (!ds_init (dsahip))
+ return AHISF_ERROR;
- if (xahi_input_num)
- ret |= AHISF_CANRECORD;
- if (cansurround)
- ret |= AHISF_KNOWMULTICHANNEL;
+ if (xahi_input_num)
+ ret |= AHISF_CANRECORD;
+ if (cansurround)
+ ret |= AHISF_KNOWMULTICHANNEL;
- dsahip->sample = xcalloc (struct dssample, dsahip->sounds);
- dsahip->channel = xcalloc (struct dschannel, dsahip->channels);
- for (i = 0; i < dsahip->channels; i++) {
- struct dschannel *dc = &dsahip->channel[i];
- dc->num = i;
- dc->al_source = -1;
- }
- for (i = 0; i < dsahip->sounds; i++) {
- struct dssample *ds = &dsahip->sample[i];
- ds->num = -1;
- ds->al_buffer[0] = -1;
- ds->al_buffer[1] = -1;
- }
- ahi_active = 1;
- return ret;
+ dsahip->sample = xcalloc (struct dssample, dsahip->sounds);
+ dsahip->channel = xcalloc (struct dschannel, dsahip->channels);
+ for (i = 0; i < dsahip->channels; i++) {
+ struct dschannel *dc = &dsahip->channel[i];
+ dc->num = i;
+ dc->al_source = -1;
}
-
- static void AHIsub_Disable (TrapContext *ctx)
- {
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- if (ahi_debug > 1)
- write_log (L"AHI: Disable(%08x)\n", audioctrl);
- dsahip->enabledisable++;
+ for (i = 0; i < dsahip->sounds; i++) {
+ struct dssample *ds = &dsahip->sample[i];
+ ds->num = -1;
+ ds->al_buffer[0] = -1;
+ ds->al_buffer[1] = -1;
}
+ ahi_active = 1;
+ return ret;
+}
- static void AHIsub_Enable (TrapContext *ctx)
- {
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- if (ahi_debug > 1)
- write_log (L"AHI: Enable(%08x)\n", audioctrl);
- dsahip->enabledisable--;
- if (dsahip->enabledisable == 0 && dsahip->playing)
- setevent (dsahip);
- }
+static void AHIsub_Disable (TrapContext *ctx)
+{
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ if (ahi_debug > 1)
+ write_log (L"AHI: Disable(%08x)\n", audioctrl);
+ dsahip->enabledisable++;
+}
+
+static void AHIsub_Enable (TrapContext *ctx)
+{
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ if (ahi_debug > 1)
+ write_log (L"AHI: Enable(%08x)\n", audioctrl);
+ dsahip->enabledisable--;
+ if (dsahip->enabledisable == 0 && dsahip->playing)
+ setevent (dsahip);
+}
- static void AHIsub_FreeAudio (TrapContext *ctx)
- {
- uae_u32 audioctrl = m68k_areg (regs, 2);
- uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
- struct DSAHI *dsahip = GETAHI;
- if (ahi_debug)
- write_log (L"AHI: FreeAudio(%08x)\n", audioctrl);
- if (ahi_active == 0)
- return;
- ahi_active = 0;
- put_long (pbase + pub_Index, -1);
- if (dsahip) {
- ds_free (dsahip);
- ds_free_record (dsahip);
- xfree (dsahip->channel);
- xfree (dsahip->sample);
- memset (dsahip, 0, sizeof (struct DSAHI));
- }
+static void AHIsub_FreeAudio (TrapContext *ctx)
+{
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
+ struct DSAHI *dsahip = GETAHI;
+ if (ahi_debug)
+ write_log (L"AHI: FreeAudio(%08x)\n", audioctrl);
+ if (ahi_active == 0)
+ return;
+ ahi_active = 0;
+ put_long (pbase + pub_Index, -1);
+ if (dsahip) {
+ ds_free (dsahip);
+ ds_free_record (dsahip);
+ xfree (dsahip->channel);
+ xfree (dsahip->sample);
+ memset (dsahip, 0, sizeof (struct DSAHI));
}
+}
- static uae_u32 frequencies[] = { 48000, 44100 };
+static uae_u32 frequencies[] = { 48000, 44100 };
#define MAX_FREQUENCIES (sizeof (frequencies) / sizeof (uae_u32))
- static uae_u32 getattr2 (struct DSAHI *dsahip, uae_u32 attribute, uae_u32 argument, uae_u32 def)
- {
- int i;
-
- switch (attribute)
- {
- case AHIDB_Bits:
- return 32;
- case AHIDB_Frequencies:
- return MAX_FREQUENCIES;
- case AHIDB_Frequency:
- if (argument < 0 || argument >= MAX_FREQUENCIES)
- argument = 0;
- return frequencies[argument];
- case AHIDB_Index:
- if (argument <= frequencies[0])
- return 0;
- if (argument >= frequencies[MAX_FREQUENCIES - 1])
- return MAX_FREQUENCIES - 1;
- for (i = 1; i < MAX_FREQUENCIES; i++) {
- if (frequencies[i] > argument) {
- if (argument - frequencies[i - 1] < frequencies[i] - argument)
- return i - 1;
- else
- return i;
- }
- }
- return 0;
- case AHIDB_Author:
- return xahi_author;
- case AHIDB_Copyright:
- return xahi_copyright;
- case AHIDB_Version:
- return xahi_version;
- case AHIDB_Record:
- return -1;
- case AHIDB_Realtime:
- return -1;
- case AHIDB_MinOutputVolume:
- return 0x00000;
- case AHIDB_MaxOutputVolume:
- return 0x10000;
- case AHIDB_Outputs:
- return xahi_output_num;
- case AHIDB_Output:
- if (argument >= 0 && argument < xahi_output_num)
- return xahi_output[argument];
- return 0;
- case AHIDB_Inputs:
- return xahi_input_num;
- case AHIDB_Input:
- if (argument >= 0 && argument < xahi_input_num)
- return xahi_input[argument];
- return 0;
- case AHIDB_Volume:
- return -1;
- case AHIDB_Panning:
- return -1;
- case AHIDB_HiFi:
- return -1;
- case AHIDB_MultiChannel:
- return cansurround ? -1 : 0;
- case AHIDB_MaxChannels:
- return UAE_MAXCHANNELS;
- case AHIDB_FullDuplex:
- return -1;
- case AHIDB_MaxRecordSamples:
- return UAE_RECORDSAMPLES;
- case AHIDB_MaxPlaySamples:
- if (def < dsahip->maxplaysamples)
- def = dsahip->maxplaysamples;
- return def;
- default:
- return def;
- }
- }
-
- static uae_u32 AHIsub_GetAttr (TrapContext *ctx)
- {
- uae_u32 attribute = m68k_dreg (regs, 0);
- uae_u32 argument = m68k_dreg (regs, 1);
- uae_u32 def = m68k_dreg (regs, 2);
- uae_u32 taglist = m68k_areg (regs, 1);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- uae_u32 v;
-
- v = getattr2 (dsahip, attribute, argument, def);
- if (ahi_debug)
- write_log (L"AHI: GetAttr(%08x=%d,%08x,%08x)=%08x\n", attribute, attribute & 0x7fff, argument, def, v);
-
- return v;
- }
+static uae_u32 getattr2 (struct DSAHI *dsahip, uae_u32 attribute, uae_u32 argument, uae_u32 def)
+{
+ int i;
- static uae_u32 AHIsub_HardwareControl (TrapContext *ctx)
+ switch (attribute)
{
- uae_u32 attribute = m68k_dreg (regs, 0);
- uae_u32 argument = m68k_dreg (regs, 1);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- if (ahi_debug)
- write_log (L"AHI: HardwareControl(%08x=%d,%08x,%08x)\n", attribute, attribute & 0x7fff, argument, audioctrl);
- switch (attribute)
- {
- case AHIC_Input:
- if (dsahip->input != argument) {
- dsahip->input = argument;
- if (dsahip->al_dev) {
- ds_free_record (dsahip);
- ds_init_record (dsahip);
- if (dsahip->recording)
- ds_record (dsahip, 1);
- }
- }
- break;
- case AHIC_Input_Query:
- return dsahip->input;
- case AHIC_Output:
- if (dsahip->output != argument) {
- dsahip->output = argument;
- if (dsahip->al_dev)
- ds_reinit (dsahip);
+ case AHIDB_Bits:
+ return 32;
+ case AHIDB_Frequencies:
+ return MAX_FREQUENCIES;
+ case AHIDB_Frequency:
+ if (argument < 0 || argument >= MAX_FREQUENCIES)
+ argument = 0;
+ return frequencies[argument];
+ case AHIDB_Index:
+ if (argument <= frequencies[0])
+ return 0;
+ if (argument >= frequencies[MAX_FREQUENCIES - 1])
+ return MAX_FREQUENCIES - 1;
+ for (i = 1; i < MAX_FREQUENCIES; i++) {
+ if (frequencies[i] > argument) {
+ if (argument - frequencies[i - 1] < frequencies[i] - argument)
+ return i - 1;
+ else
+ return i;
}
- break;
- case AHIC_Output_Query:
- return dsahip->output;
}
return 0;
- }
-
- static uae_u32 AHIsub_Start (TrapContext *ctx)
- {
- uae_u32 flags = m68k_dreg (regs, 0);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- int i;
-
- if (ahi_debug)
- write_log (L"AHI: Play(%08x,%08x)\n",
- flags, audioctrl);
- if ((flags & AHISF_PLAY) && !dsahip->playing) {
- dsahip->playing = 1;
- setevent (dsahip);
- for (i = 0; i < dsahip->channels; i++) {
- struct dschannel *dc = &dsahip->channel[i];
- ds_play (dsahip, dc);
- }
- }
- if ((flags & AHISF_RECORD) && !dsahip->recording) {
- dsahip->recording = 1;
- ds_init_record (dsahip);
- ds_record (dsahip, 1);
- }
+ case AHIDB_Author:
+ return xahi_author;
+ case AHIDB_Copyright:
+ return xahi_copyright;
+ case AHIDB_Version:
+ return xahi_version;
+ case AHIDB_Record:
+ return -1;
+ case AHIDB_Realtime:
+ return -1;
+ case AHIDB_MinOutputVolume:
+ return 0x00000;
+ case AHIDB_MaxOutputVolume:
+ return 0x10000;
+ case AHIDB_Outputs:
+ return xahi_output_num;
+ case AHIDB_Output:
+ if (argument >= 0 && argument < xahi_output_num)
+ return xahi_output[argument];
+ return 0;
+ case AHIDB_Inputs:
+ return xahi_input_num;
+ case AHIDB_Input:
+ if (argument >= 0 && argument < xahi_input_num)
+ return xahi_input[argument];
return 0;
+ case AHIDB_Volume:
+ return -1;
+ case AHIDB_Panning:
+ return -1;
+ case AHIDB_HiFi:
+ return -1;
+ case AHIDB_MultiChannel:
+ return cansurround ? -1 : 0;
+ case AHIDB_MaxChannels:
+ return UAE_MAXCHANNELS;
+ case AHIDB_FullDuplex:
+ return -1;
+ case AHIDB_MaxRecordSamples:
+ return UAE_RECORDSAMPLES;
+ case AHIDB_MaxPlaySamples:
+ if (def < dsahip->maxplaysamples)
+ def = dsahip->maxplaysamples;
+ return def;
+ default:
+ return def;
}
+}
- static uae_u32 AHIsub_Stop (TrapContext *ctx)
+static uae_u32 AHIsub_GetAttr (TrapContext *ctx)
+{
+ uae_u32 attribute = m68k_dreg (regs, 0);
+ uae_u32 argument = m68k_dreg (regs, 1);
+ uae_u32 def = m68k_dreg (regs, 2);
+ uae_u32 taglist = m68k_areg (regs, 1);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ uae_u32 v;
+
+ v = getattr2 (dsahip, attribute, argument, def);
+ if (ahi_debug)
+ write_log (L"AHI: GetAttr(%08x=%d,%08x,%08x)=%08x\n", attribute, attribute & 0x7fff, argument, def, v);
+
+ return v;
+}
+
+static uae_u32 AHIsub_HardwareControl (TrapContext *ctx)
+{
+ uae_u32 attribute = m68k_dreg (regs, 0);
+ uae_u32 argument = m68k_dreg (regs, 1);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ if (ahi_debug)
+ write_log (L"AHI: HardwareControl(%08x=%d,%08x,%08x)\n", attribute, attribute & 0x7fff, argument, audioctrl);
+ switch (attribute)
{
- uae_u32 flags = m68k_dreg (regs, 0);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- int i;
-
- if (ahi_debug)
- write_log (L"AHI: Stop(%08x,%08x)\n",
- flags, audioctrl);
- if ((flags & AHISF_PLAY) && dsahip->playing) {
- dsahip->playing = 0;
- for (i = 0; i < dsahip->channels; i++) {
- struct dschannel *dc = &dsahip->channel[i];
- ds_stop (dsahip, dc);
+ case AHIC_Input:
+ if (dsahip->input != argument) {
+ dsahip->input = argument;
+ if (dsahip->al_dev) {
+ ds_free_record (dsahip);
+ ds_init_record (dsahip);
+ if (dsahip->recording)
+ ds_record (dsahip, 1);
}
}
- if ((flags & AHISF_RECORD) && dsahip->recording) {
- dsahip->recording = 0;
- ds_record (dsahip, 0);
- ds_free_record (dsahip);
+ break;
+ case AHIC_Input_Query:
+ return dsahip->input;
+ case AHIC_Output:
+ if (dsahip->output != argument) {
+ dsahip->output = argument;
+ if (dsahip->al_dev)
+ ds_reinit (dsahip);
}
- return 0;
+ break;
+ case AHIC_Output_Query:
+ return dsahip->output;
}
+ return 0;
+}
- static uae_u32 AHIsub_Update (TrapContext *ctx)
- {
- uae_u32 flags = m68k_dreg (regs, 0);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- if (ahi_debug)
- write_log (L"AHI: Update(%08x,%08x)\n", flags, audioctrl);
+static uae_u32 AHIsub_Start (TrapContext *ctx)
+{
+ uae_u32 flags = m68k_dreg (regs, 0);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ int i;
+
+ if (ahi_debug)
+ write_log (L"AHI: Play(%08x,%08x)\n",
+ flags, audioctrl);
+ if ((flags & AHISF_PLAY) && !dsahip->playing) {
+ dsahip->playing = 1;
setevent (dsahip);
- return 0;
+ for (i = 0; i < dsahip->channels; i++) {
+ struct dschannel *dc = &dsahip->channel[i];
+ ds_play (dsahip, dc);
+ }
}
+ if ((flags & AHISF_RECORD) && !dsahip->recording) {
+ dsahip->recording = 1;
+ ds_init_record (dsahip);
+ ds_record (dsahip, 1);
+ }
+ return 0;
+}
- static uae_u32 AHIsub_SetVol (TrapContext *ctx)
- {
- uae_u16 channel = m68k_dreg (regs, 0);
- uae_s32 volume = m68k_dreg (regs, 1);
- uae_s32 pan = m68k_dreg (regs, 2);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- uae_u32 flags = m68k_dreg (regs, 3);
- struct DSAHI *dsahip = GETAHI;
- struct dschannel *dc = GETCHANNEL;
-
- if (ahi_debug > 1)
- write_log (L"AHI: SetVol(%d,%d,%d,%08x,%08x)\n",
- channel, volume, pan, audioctrl, flags);
- if (dc) {
- if (volume < -65535)
- volume = -65535;
- if (volume > 65535)
- volume = 65535;
- if (pan < -65535)
- pan = -65535;
- if (pan > 65535)
- pan = 65535;
- dc->csnext.volume = volume;
- dc->csnext.panning = pan;
- if (flags & AHISF_IMM) {
- ds_setvolume (dsahip, dc);
- }
+static uae_u32 AHIsub_Stop (TrapContext *ctx)
+{
+ uae_u32 flags = m68k_dreg (regs, 0);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ int i;
+
+ if (ahi_debug)
+ write_log (L"AHI: Stop(%08x,%08x)\n",
+ flags, audioctrl);
+ if ((flags & AHISF_PLAY) && dsahip->playing) {
+ dsahip->playing = 0;
+ for (i = 0; i < dsahip->channels; i++) {
+ struct dschannel *dc = &dsahip->channel[i];
+ ds_stop (dsahip, dc);
}
- return 0;
}
+ if ((flags & AHISF_RECORD) && dsahip->recording) {
+ dsahip->recording = 0;
+ ds_record (dsahip, 0);
+ ds_free_record (dsahip);
+ }
+ return 0;
+}
- static uae_u32 AHIsub_SetFreq (TrapContext *ctx)
- {
- uae_u16 channel = m68k_dreg (regs, 0);
- uae_u32 frequency = m68k_dreg (regs, 1);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- uae_u32 flags = m68k_dreg (regs, 3);
- struct DSAHI *dsahip = GETAHI;
- struct dschannel *dc = GETCHANNEL;
-
- if (ahi_debug > 1)
- write_log (L"AHI: SetFreq(%d,%d,%08x,%08x)\n",
- channel, frequency, audioctrl, flags);
- if (dc) {
- dc->csnext.frequency = frequency;
- if (flags & AHISF_IMM) {
- ds_setfreq (dsahip, dc);
- ds_play (dsahip, dc);
- }
+static uae_u32 AHIsub_Update (TrapContext *ctx)
+{
+ uae_u32 flags = m68k_dreg (regs, 0);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ if (ahi_debug)
+ write_log (L"AHI: Update(%08x,%08x)\n", flags, audioctrl);
+ setevent (dsahip);
+ return 0;
+}
+
+static uae_u32 AHIsub_SetVol (TrapContext *ctx)
+{
+ uae_u16 channel = m68k_dreg (regs, 0);
+ uae_s32 volume = m68k_dreg (regs, 1);
+ uae_s32 pan = m68k_dreg (regs, 2);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ uae_u32 flags = m68k_dreg (regs, 3);
+ struct DSAHI *dsahip = GETAHI;
+ struct dschannel *dc = GETCHANNEL;
+
+ if (ahi_debug > 1)
+ write_log (L"AHI: SetVol(%d,%d,%d,%08x,%08x)\n",
+ channel, volume, pan, audioctrl, flags);
+ if (dc) {
+ if (volume < -65535)
+ volume = -65535;
+ if (volume > 65535)
+ volume = 65535;
+ if (pan < -65535)
+ pan = -65535;
+ if (pan > 65535)
+ pan = 65535;
+ dc->csnext.volume = volume;
+ dc->csnext.panning = pan;
+ if (flags & AHISF_IMM) {
+ ds_setvolume (dsahip, dc);
}
- return 0;
}
+ return 0;
+}
- static uae_u32 AHIsub_SetSound (TrapContext *ctx)
- {
- uae_u16 channel = m68k_dreg (regs, 0);
- uae_u16 sound = m68k_dreg (regs, 1);
- uae_u32 offset = m68k_dreg (regs, 2);
- int length = m68k_dreg (regs, 3);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- uae_u32 flags = m68k_dreg (regs, 4);
- struct DSAHI *dsahip = GETAHI;
- struct dssample *ds = GETSAMPLE;
- struct dschannel *dc = GETCHANNEL;
-
- if (ahi_debug > 1)
- write_log (L"AHI: SetSound(%d,%d,%08x,%d,%08x,%08x)\n",
- channel, sound, offset, length, audioctrl, flags);
- if (dc == NULL)
- return AHIE_UNKNOWN;
- if (sound == 0xffff) {
- if (flags & AHISF_IMM) {
- dc->cs.ds = NULL;
- dc->csnext.ds = NULL;
- }
- return 0;
+static uae_u32 AHIsub_SetFreq (TrapContext *ctx)
+{
+ uae_u16 channel = m68k_dreg (regs, 0);
+ uae_u32 frequency = m68k_dreg (regs, 1);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ uae_u32 flags = m68k_dreg (regs, 3);
+ struct DSAHI *dsahip = GETAHI;
+ struct dschannel *dc = GETCHANNEL;
+
+ if (ahi_debug > 1)
+ write_log (L"AHI: SetFreq(%d,%d,%08x,%08x)\n",
+ channel, frequency, audioctrl, flags);
+ if (dc) {
+ dc->csnext.frequency = frequency;
+ if (flags & AHISF_IMM) {
+ ds_setfreq (dsahip, dc);
+ ds_play (dsahip, dc);
}
- if (ds == NULL || ds->num < 0)
- return AHIE_UNKNOWN;
- ds_allocchannel (dsahip, dc);
- dc->cs.backwards = length < 0;
- length = abs (length);
- if (length == 0)
- length = ds->len;
- if (length > ds->len)
- length = ds->len;
- dc->csnext.ds = ds;
- dc->csnext.srcplaylen = length;
- dc->csnext.srcplayoffset = offset;
- if (flags & AHISF_IMM)
+ }
+ return 0;
+}
+
+static uae_u32 AHIsub_SetSound (TrapContext *ctx)
+{
+ uae_u16 channel = m68k_dreg (regs, 0);
+ uae_u16 sound = m68k_dreg (regs, 1);
+ uae_u32 offset = m68k_dreg (regs, 2);
+ int length = m68k_dreg (regs, 3);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ uae_u32 flags = m68k_dreg (regs, 4);
+ struct DSAHI *dsahip = GETAHI;
+ struct dssample *ds = GETSAMPLE;
+ struct dschannel *dc = GETCHANNEL;
+
+ if (ahi_debug > 1)
+ write_log (L"AHI: SetSound(%d,%d,%08x,%d,%08x,%08x)\n",
+ channel, sound, offset, length, audioctrl, flags);
+ if (dc == NULL)
+ return AHIE_UNKNOWN;
+ if (sound == 0xffff) {
+ if (flags & AHISF_IMM) {
dc->cs.ds = NULL;
- ds_setfreq (dsahip, dc);
- ds_setvolume (dsahip, dc);
- if (dc->cs.ds == NULL)
- al_initsample (dsahip, dc);
+ dc->csnext.ds = NULL;
+ }
return 0;
}
-
- static uae_u32 AHIsub_SetEffect (TrapContext *ctx)
+ if (ds == NULL || ds->num < 0)
+ return AHIE_UNKNOWN;
+ ds_allocchannel (dsahip, dc);
+ dc->cs.backwards = length < 0;
+ length = abs (length);
+ if (length == 0)
+ length = ds->len;
+ if (length > ds->len)
+ length = ds->len;
+ dc->csnext.ds = ds;
+ dc->csnext.srcplaylen = length;
+ dc->csnext.srcplayoffset = offset;
+ if (flags & AHISF_IMM)
+ dc->cs.ds = NULL;
+ ds_setfreq (dsahip, dc);
+ ds_setvolume (dsahip, dc);
+ if (dc->cs.ds == NULL)
+ al_initsample (dsahip, dc);
+ return 0;
+}
+
+static uae_u32 AHIsub_SetEffect (TrapContext *ctx)
+{
+ uae_u32 effect = m68k_areg (regs, 0);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ uae_u32 effectype = get_long (effect);
+ uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
+ struct DSAHI *dsahip = GETAHI;
+
+ if (ahi_debug)
+ write_log (L"AHI: SetEffect(%08x (%08x),%08x)\n", effect, effectype, audioctrl);
+ switch (effectype)
{
- uae_u32 effect = m68k_areg (regs, 0);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- uae_u32 effectype = get_long (effect);
- uae_u32 puaebase = get_long (audioctrl + ahiac_DriverData);
- struct DSAHI *dsahip = GETAHI;
-
- if (ahi_debug)
- write_log (L"AHI: SetEffect(%08x (%08x),%08x)\n", effect, effectype, audioctrl);
- switch (effectype)
- {
- case AHIET_CHANNELINFO:
- put_long (puaebase + pub_ChannelInfo, effect);
- break;
- case AHIET_CHANNELINFO | AHIET_CANCEL:
- put_long (puaebase + pub_ChannelInfo, 0);
- break;
- case AHIET_MASTERVOLUME:
- write_log (L"AHI: SetEffect(MasterVolume=%08x)\n", get_long (effect + 4));
- case AHIET_MASTERVOLUME | AHIET_CANCEL:
- break;
- default:
- return AHIE_UNKNOWN;
- }
- return AHIE_OK;
+ case AHIET_CHANNELINFO:
+ put_long (puaebase + pub_ChannelInfo, effect);
+ break;
+ case AHIET_CHANNELINFO | AHIET_CANCEL:
+ put_long (puaebase + pub_ChannelInfo, 0);
+ break;
+ case AHIET_MASTERVOLUME:
+ write_log (L"AHI: SetEffect(MasterVolume=%08x)\n", get_long (effect + 4));
+ case AHIET_MASTERVOLUME | AHIET_CANCEL:
+ break;
+ default:
+ return AHIE_UNKNOWN;
}
+ return AHIE_OK;
+}
- static uae_u32 AHIsub_LoadSound (TrapContext *ctx)
+static uae_u32 AHIsub_LoadSound (TrapContext *ctx)
+{
+ uae_u16 sound = m68k_dreg (regs, 0);
+ uae_u32 type = m68k_dreg (regs, 1);
+ uae_u32 info = m68k_areg (regs, 0);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ uae_u32 ret = AHIE_BADSOUNDTYPE;
+ int sampletype = get_long (info + ahisi_Type);
+ uae_u32 addr = get_long (info + ahisi_Address);
+ uae_u32 len = get_long (info + ahisi_Length);
+ struct dssample *ds = GETSAMPLE;
+ int ch;
+ int bps;
+
+ if (ahi_debug > 1)
+ write_log (L"AHI: LoadSound(%d,%d,%08x,%08x,SMP=%d,ADDR=%08x,LEN=%d)\n",
+ sound, type, info, audioctrl, sampletype, addr, len);
+
+ if (!ds)
+ return AHIE_BADSOUNDTYPE;
+
+ ds->num = sound;
+ if (!cansurround && sampletype == AHIST_L7_1)
+ return AHIE_BADSOUNDTYPE;
+ ds->addr = addr;
+ ds->sampletype = sampletype;
+ ds->type = type;
+ ds->len = len;
+ ds->dynamic = type == AHIST_DYNAMICSAMPLE;
+
+ switch (sampletype)
{
- uae_u16 sound = m68k_dreg (regs, 0);
- uae_u32 type = m68k_dreg (regs, 1);
- uae_u32 info = m68k_areg (regs, 0);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- uae_u32 ret = AHIE_BADSOUNDTYPE;
- int sampletype = get_long (info + ahisi_Type);
- uae_u32 addr = get_long (info + ahisi_Address);
- uae_u32 len = get_long (info + ahisi_Length);
- struct dssample *ds = GETSAMPLE;
- int ch;
- int bps;
-
- if (ahi_debug > 1)
- write_log (L"AHI: LoadSound(%d,%d,%08x,%08x,SMP=%d,ADDR=%08x,LEN=%d)\n",
- sound, type, info, audioctrl, sampletype, addr, len);
-
- if (!ds)
- return AHIE_BADSOUNDTYPE;
-
- ds->num = sound;
- if (!cansurround && sampletype == AHIST_L7_1)
- return AHIE_BADSOUNDTYPE;
- ds->addr = addr;
- ds->sampletype = sampletype;
- ds->type = type;
- ds->len = len;
- ds->dynamic = type == AHIST_DYNAMICSAMPLE;
-
- switch (sampletype)
- {
- case AHIST_M8S:
- case AHIST_M16S:
- case AHIST_M32S:
- ch = 1;
- break;
- case AHIST_S8S:
- case AHIST_S16S:
- case AHIST_S32S:
- ch = 2;
- break;
- case AHIST_L7_1:
- ch = 8;
- break;
- default:
- return 0;
- }
- switch (sampletype)
- {
- case AHIST_M8S:
- case AHIST_S8S:
- bps = 8;
- break;
- case AHIST_M16S:
- case AHIST_S16S:
- bps = 16;
- break;
- case AHIST_M32S:
- case AHIST_S32S:
- case AHIST_L7_1:
- bps = 24;
- break;
- default:
- return 0;
- }
- ds->bitspersample = bps;
- ds->ch = ch;
- ds->bytespersample = bps / 8;
- if (ds->al_buffer[0] == -1) {
- alClear ();
- alGenBuffers (2, ds->al_buffer);
- if (alError (L"AHI: alGenBuffers"))
- return AHIE_NOMEM;
- if (ahi_debug > 1)
- write_log (L"AHI:LoadSound:allocated OpenAL buffer\n");
- }
- return AHIE_OK;
+ case AHIST_M8S:
+ case AHIST_M16S:
+ case AHIST_M32S:
+ ch = 1;
+ break;
+ case AHIST_S8S:
+ case AHIST_S16S:
+ case AHIST_S32S:
+ ch = 2;
+ break;
+ case AHIST_L7_1:
+ ch = 8;
+ break;
+ default:
+ return 0;
}
-
- static uae_u32 AHIsub_UnloadSound (TrapContext *ctx)
+ switch (sampletype)
{
- uae_u16 sound = m68k_dreg (regs, 0);
- uae_u32 audioctrl = m68k_areg (regs, 2);
- struct DSAHI *dsahip = GETAHI;
- struct dssample *ds = GETSAMPLE;
-
+ case AHIST_M8S:
+ case AHIST_S8S:
+ bps = 8;
+ break;
+ case AHIST_M16S:
+ case AHIST_S16S:
+ bps = 16;
+ break;
+ case AHIST_M32S:
+ case AHIST_S32S:
+ case AHIST_L7_1:
+ bps = 24;
+ break;
+ default:
+ return 0;
+ }
+ ds->bitspersample = bps;
+ ds->ch = ch;
+ ds->bytespersample = bps / 8;
+ if (ds->al_buffer[0] == -1) {
+ alClear ();
+ alGenBuffers (2, ds->al_buffer);
+ if (alError (L"AHI: alGenBuffers"))
+ return AHIE_NOMEM;
if (ahi_debug > 1)
- write_log (L"AHI: UnloadSound(%d,%08x)\n",
- sound, audioctrl);
- ds->num = -1;
- return AHIE_OK;
+ write_log (L"AHI:LoadSound:allocated OpenAL buffer\n");
}
+ return AHIE_OK;
+}
- static uae_u32 REGPARAM2 ahi_demux (TrapContext *ctx)
- {
- uae_u32 ret = 0;
- uae_u32 sp = m68k_areg (regs, 7);
- uae_u32 offset = get_long (sp + 4);
-
- if (0 && ahi_debug)
- write_log (L"AHI: %d\n", offset);
+static uae_u32 AHIsub_UnloadSound (TrapContext *ctx)
+{
+ uae_u16 sound = m68k_dreg (regs, 0);
+ uae_u32 audioctrl = m68k_areg (regs, 2);
+ struct DSAHI *dsahip = GETAHI;
+ struct dssample *ds = GETSAMPLE;
+
+ if (ahi_debug > 1)
+ write_log (L"AHI: UnloadSound(%d,%08x)\n",
+ sound, audioctrl);
+ ds->num = -1;
+ return AHIE_OK;
+}
+
+static uae_u32 REGPARAM2 ahi_demux (TrapContext *ctx)
+{
+ uae_u32 ret = 0;
+ uae_u32 sp = m68k_areg (regs, 7);
+ uae_u32 offset = get_long (sp + 4);
- switch (offset)
- {
- case 0xffffffff:
- ret = init (ctx);
- break;
- case 0:
- ret = AHIsub_AllocAudio (ctx);
- break;
- case 1:
- AHIsub_FreeAudio (ctx);
- break;
- case 2:
- AHIsub_Disable (ctx);
- break;
- case 3:
- AHIsub_Enable (ctx);
- break;
- case 4:
- ret = AHIsub_Start (ctx);
- break;
- case 5:
- ret = AHIsub_Update (ctx);
- break;
- case 6:
- ret = AHIsub_Stop (ctx);
- break;
- case 7:
- ret = AHIsub_SetVol (ctx);
- break;
- case 8:
- ret = AHIsub_SetFreq (ctx);
- break;
- case 9:
- ret = AHIsub_SetSound (ctx);
- break;
- case 10:
- ret = AHIsub_SetEffect (ctx);
- break;
- case 11:
- ret = AHIsub_LoadSound (ctx);
- break;
- case 12:
- ret = AHIsub_UnloadSound (ctx);
- break;
- case 13:
- ret = AHIsub_GetAttr (ctx);
- break;
- case 14:
- ret = AHIsub_HardwareControl (ctx);
- break;
- }
- return ret;
- }
+ if (0 && ahi_debug)
+ write_log (L"AHI: %d\n", offset);
- void init_ahi_v2 (void)
+ switch (offset)
{
- uaecptr a = here ();
- org (rtarea_base + 0xFFC8);
- calltrap (deftrapres (ahi_demux, 0, L"ahi_v2"));
- dw (RTS);
- org (a);
+ case 0xffffffff:
+ ret = init (ctx);
+ break;
+ case 0:
+ ret = AHIsub_AllocAudio (ctx);
+ break;
+ case 1:
+ AHIsub_FreeAudio (ctx);
+ break;
+ case 2:
+ AHIsub_Disable (ctx);
+ break;
+ case 3:
+ AHIsub_Enable (ctx);
+ break;
+ case 4:
+ ret = AHIsub_Start (ctx);
+ break;
+ case 5:
+ ret = AHIsub_Update (ctx);
+ break;
+ case 6:
+ ret = AHIsub_Stop (ctx);
+ break;
+ case 7:
+ ret = AHIsub_SetVol (ctx);
+ break;
+ case 8:
+ ret = AHIsub_SetFreq (ctx);
+ break;
+ case 9:
+ ret = AHIsub_SetSound (ctx);
+ break;
+ case 10:
+ ret = AHIsub_SetEffect (ctx);
+ break;
+ case 11:
+ ret = AHIsub_LoadSound (ctx);
+ break;
+ case 12:
+ ret = AHIsub_UnloadSound (ctx);
+ break;
+ case 13:
+ ret = AHIsub_GetAttr (ctx);
+ break;
+ case 14:
+ ret = AHIsub_HardwareControl (ctx);
+ break;
}
+ return ret;
+}
- void free_ahi_v2 (void)
- {
- ds_free_record (&dsahi[0]);
- ds_free (&dsahi[0]);
- }
+void init_ahi_v2 (void)
+{
+ uaecptr a = here ();
+ org (rtarea_base + 0xFFC8);
+ calltrap (deftrapres (ahi_demux, 0, L"ahi_v2"));
+ dw (RTS);
+ org (a);
+}
+
+void free_ahi_v2 (void)
+{
+ ds_free_record (&dsahi[0]);
+ ds_free (&dsahi[0]);
+}
#endif