mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-14 19:08:32 +08:00
Dynrec: Convert the rest of the processor support code using the same C++ template trick, hope for the best, should not break anything (let me know if it does!)
This commit is contained in:
@@ -822,7 +822,7 @@ static INLINE void gen_lea(HostReg dest_reg,Bitu scale,Bits imm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// helper function for gen_call_function_raw and gen_call_function_setup
|
// helper function for gen_call_function_raw and gen_call_function_setup
|
||||||
static void gen_call_function_helper(void * func) {
|
template <typename T> static void gen_call_function_helper(const T func) {
|
||||||
Bit8u *datapos;
|
Bit8u *datapos;
|
||||||
|
|
||||||
datapos = cache_reservedata();
|
datapos = cache_reservedata();
|
||||||
@@ -848,7 +848,7 @@ static void gen_call_function_helper(void * func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate a call to a parameterless function
|
// generate a call to a parameterless function
|
||||||
static void INLINE gen_call_function_raw(void * func) {
|
template <typename T> static void INLINE gen_call_function_raw(const T func) {
|
||||||
cache_checkinstr(12);
|
cache_checkinstr(12);
|
||||||
gen_call_function_helper(func);
|
gen_call_function_helper(func);
|
||||||
}
|
}
|
||||||
@@ -856,7 +856,7 @@ static void INLINE gen_call_function_raw(void * func) {
|
|||||||
// generate a call to a function with paramcount parameters
|
// generate a call to a function with paramcount parameters
|
||||||
// note: the parameters are loaded in the architecture specific way
|
// note: the parameters are loaded in the architecture specific way
|
||||||
// using the gen_load_param_ functions below
|
// using the gen_load_param_ functions below
|
||||||
static Bit32u INLINE gen_call_function_setup(void * func,Bitu paramcount,bool fastcall=false) {
|
template <typename T> template <typename T> static Bit32u INLINE gen_call_function_setup(const T func,Bitu paramcount,bool fastcall=false) {
|
||||||
cache_checkinstr(12);
|
cache_checkinstr(12);
|
||||||
Bit32u proc_addr = (Bit32u)cache.pos;
|
Bit32u proc_addr = (Bit32u)cache.pos;
|
||||||
gen_call_function_helper(func);
|
gen_call_function_helper(func);
|
||||||
|
@@ -822,7 +822,7 @@ static INLINE void gen_lea(HostReg dest_reg,Bitu scale,Bits imm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// helper function for gen_call_function_raw and gen_call_function_setup
|
// helper function for gen_call_function_raw and gen_call_function_setup
|
||||||
static void gen_call_function_helper(void * func) {
|
template <typename T> static void gen_call_function_helper(const T func) {
|
||||||
Bit8u *datapos;
|
Bit8u *datapos;
|
||||||
|
|
||||||
datapos = cache_reservedata();
|
datapos = cache_reservedata();
|
||||||
@@ -850,7 +850,7 @@ static void gen_call_function_helper(void * func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate a call to a parameterless function
|
// generate a call to a parameterless function
|
||||||
static void INLINE gen_call_function_raw(void * func) {
|
template <typename T> static void INLINE gen_call_function_raw(const T func) {
|
||||||
cache_checkinstr(18);
|
cache_checkinstr(18);
|
||||||
gen_call_function_helper(func);
|
gen_call_function_helper(func);
|
||||||
}
|
}
|
||||||
@@ -858,7 +858,7 @@ static void INLINE gen_call_function_raw(void * func) {
|
|||||||
// generate a call to a function with paramcount parameters
|
// generate a call to a function with paramcount parameters
|
||||||
// note: the parameters are loaded in the architecture specific way
|
// note: the parameters are loaded in the architecture specific way
|
||||||
// using the gen_load_param_ functions below
|
// using the gen_load_param_ functions below
|
||||||
static Bit32u INLINE gen_call_function_setup(void * func,Bitu paramcount,bool fastcall=false) {
|
template <typename T> static Bit32u INLINE gen_call_function_setup(const T func,Bitu paramcount,bool fastcall=false) {
|
||||||
cache_checkinstr(18);
|
cache_checkinstr(18);
|
||||||
Bit32u proc_addr = (Bit32u)cache.pos;
|
Bit32u proc_addr = (Bit32u)cache.pos;
|
||||||
gen_call_function_helper(func);
|
gen_call_function_helper(func);
|
||||||
|
@@ -664,7 +664,7 @@ static INLINE void gen_lea(HostReg dest_reg,Bitu scale,Bits imm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate a call to a parameterless function
|
// generate a call to a parameterless function
|
||||||
static void INLINE gen_call_function_raw(void * func) {
|
template <typename T> static void INLINE gen_call_function_raw(const T func) {
|
||||||
if (((Bit32u)cache.pos & 0x03) == 0) {
|
if (((Bit32u)cache.pos & 0x03) == 0) {
|
||||||
cache_addw( LDR_PC_IMM(templo1, 4) ); // ldr templo1, [pc, #4]
|
cache_addw( LDR_PC_IMM(templo1, 4) ); // ldr templo1, [pc, #4]
|
||||||
cache_addw( ADD_LO_PC_IMM(templo2, 8) ); // adr templo2, after_call (add templo2, pc, #8)
|
cache_addw( ADD_LO_PC_IMM(templo2, 8) ); // adr templo2, after_call (add templo2, pc, #8)
|
||||||
@@ -690,7 +690,7 @@ static void INLINE gen_call_function_raw(void * func) {
|
|||||||
// generate a call to a function with paramcount parameters
|
// generate a call to a function with paramcount parameters
|
||||||
// note: the parameters are loaded in the architecture specific way
|
// note: the parameters are loaded in the architecture specific way
|
||||||
// using the gen_load_param_ functions below
|
// using the gen_load_param_ functions below
|
||||||
static Bit32u INLINE gen_call_function_setup(void * func,Bitu paramcount,bool fastcall=false) {
|
template <typename T> static Bit32u INLINE gen_call_function_setup(const T func,Bitu paramcount,bool fastcall=false) {
|
||||||
Bit32u proc_addr = (Bit32u)cache.pos;
|
Bit32u proc_addr = (Bit32u)cache.pos;
|
||||||
gen_call_function_raw(func);
|
gen_call_function_raw(func);
|
||||||
return proc_addr;
|
return proc_addr;
|
||||||
|
@@ -757,7 +757,7 @@ static INLINE void gen_lea(HostReg dest_reg,Bitu scale,Bits imm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate a call to a parameterless function
|
// generate a call to a parameterless function
|
||||||
static void INLINE gen_call_function_raw(void * func) {
|
template <typename T> static void INLINE gen_call_function_raw(const T func) {
|
||||||
cache_addd( MOVZ64(temp1, ((Bit64u)func) & 0xffff, 0) ); // movz dest_reg, #(func & 0xffff)
|
cache_addd( MOVZ64(temp1, ((Bit64u)func) & 0xffff, 0) ); // movz dest_reg, #(func & 0xffff)
|
||||||
cache_addd( MOVK64(temp1, (((Bit64u)func) >> 16) & 0xffff, 16) ); // movk dest_reg, #((func >> 16) & 0xffff), lsl #16
|
cache_addd( MOVK64(temp1, (((Bit64u)func) >> 16) & 0xffff, 16) ); // movk dest_reg, #((func >> 16) & 0xffff), lsl #16
|
||||||
cache_addd( MOVK64(temp1, (((Bit64u)func) >> 32) & 0xffff, 32) ); // movk dest_reg, #((func >> 32) & 0xffff), lsl #32
|
cache_addd( MOVK64(temp1, (((Bit64u)func) >> 32) & 0xffff, 32) ); // movk dest_reg, #((func >> 32) & 0xffff), lsl #32
|
||||||
@@ -768,7 +768,7 @@ static void INLINE gen_call_function_raw(void * func) {
|
|||||||
// generate a call to a function with paramcount parameters
|
// generate a call to a function with paramcount parameters
|
||||||
// note: the parameters are loaded in the architecture specific way
|
// note: the parameters are loaded in the architecture specific way
|
||||||
// using the gen_load_param_ functions below
|
// using the gen_load_param_ functions below
|
||||||
static DRC_PTR_SIZE_IM INLINE gen_call_function_setup(void * func,Bitu paramcount,bool fastcall=false) {
|
template <typename T> static DRC_PTR_SIZE_IM INLINE gen_call_function_setup(const T func,Bitu paramcount,bool fastcall=false) {
|
||||||
DRC_PTR_SIZE_IM proc_addr = (DRC_PTR_SIZE_IM)cache.pos;
|
DRC_PTR_SIZE_IM proc_addr = (DRC_PTR_SIZE_IM)cache.pos;
|
||||||
gen_call_function_raw(func);
|
gen_call_function_raw(func);
|
||||||
return proc_addr;
|
return proc_addr;
|
||||||
|
@@ -386,7 +386,7 @@ static INLINE void gen_lea(HostReg dest_reg,Bitu scale,Bits imm) {
|
|||||||
#define DELAY cache_addd(0) // nop
|
#define DELAY cache_addd(0) // nop
|
||||||
|
|
||||||
// generate a call to a parameterless function
|
// generate a call to a parameterless function
|
||||||
static void INLINE gen_call_function_raw(void * func) {
|
template <typename T> static void INLINE gen_call_function_raw(const T func) {
|
||||||
#if C_DEBUG
|
#if C_DEBUG
|
||||||
if ((cache.pos ^ func) & 0xf0000000) LOG_MSG("jump overflow\n");
|
if ((cache.pos ^ func) & 0xf0000000) LOG_MSG("jump overflow\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -398,7 +398,7 @@ static void INLINE gen_call_function_raw(void * func) {
|
|||||||
// generate a call to a function with paramcount parameters
|
// generate a call to a function with paramcount parameters
|
||||||
// note: the parameters are loaded in the architecture specific way
|
// note: the parameters are loaded in the architecture specific way
|
||||||
// using the gen_load_param_ functions below
|
// using the gen_load_param_ functions below
|
||||||
static Bit32u INLINE gen_call_function_setup(void * func,Bitu paramcount,bool fastcall=false) {
|
template <typename T> static Bit32u INLINE gen_call_function_setup(const T func,Bitu paramcount,bool fastcall=false) {
|
||||||
Bit32u proc_addr = (Bit32u)cache.pos;
|
Bit32u proc_addr = (Bit32u)cache.pos;
|
||||||
gen_call_function_raw(func);
|
gen_call_function_raw(func);
|
||||||
return proc_addr;
|
return proc_addr;
|
||||||
|
Reference in New Issue
Block a user