generalized use of GOTO_TB() macro

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1207 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2005-01-09 00:07:04 +00:00
parent 8636b5d873
commit ae063a68dc
3 changed files with 27 additions and 47 deletions

View File

@ -322,7 +322,7 @@ TranslationBlock *tb_find_pc(unsigned long pc_ptr);
#if defined(__powerpc__) #if defined(__powerpc__)
/* we patch the jump instruction directly */ /* we patch the jump instruction directly */
#define JUMP_TB(opname, tbparam, n, eip)\ #define GOTO_TB(opname, tbparam, n)\
do {\ do {\
asm volatile (ASM_DATA_SECTION\ asm volatile (ASM_DATA_SECTION\
ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\ ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
@ -330,20 +330,12 @@ do {\
ASM_PREVIOUS_SECTION \ ASM_PREVIOUS_SECTION \
"b " ASM_NAME(__op_jmp) #n "\n"\ "b " ASM_NAME(__op_jmp) #n "\n"\
"1:\n");\ "1:\n");\
T0 = (long)(tbparam) + (n);\
EIP = (int32_t)eip;\
EXIT_TB();\
} while (0)
#define JUMP_TB2(opname, tbparam, n)\
do {\
asm volatile ("b " ASM_NAME(__op_jmp) #n "\n");\
} while (0) } while (0)
#elif defined(__i386__) && defined(USE_DIRECT_JUMP) #elif defined(__i386__) && defined(USE_DIRECT_JUMP)
/* we patch the jump instruction directly */ /* we patch the jump instruction directly */
#define GOTO_TB(opname, n)\ #define GOTO_TB(opname, tbparam, n)\
do {\ do {\
asm volatile (".section .data\n"\ asm volatile (".section .data\n"\
ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\ ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
@ -353,48 +345,30 @@ do {\
"1:\n");\ "1:\n");\
} while (0) } while (0)
#define JUMP_TB(opname, tbparam, n, eip)\
do {\
asm volatile (".section .data\n"\
ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\
".long 1f\n"\
ASM_PREVIOUS_SECTION \
"jmp " ASM_NAME(__op_jmp) #n "\n"\
"1:\n");\
T0 = (long)(tbparam) + (n);\
EIP = (int32_t)eip;\
EXIT_TB();\
} while (0)
#define JUMP_TB2(opname, tbparam, n)\
do {\
asm volatile ("jmp " ASM_NAME(__op_jmp) #n "\n");\
} while (0)
#else #else
/* jump to next block operations (more portable code, does not need /* jump to next block operations (more portable code, does not need
cache flushing, but slower because of indirect jump) */ cache flushing, but slower because of indirect jump) */
#define JUMP_TB(opname, tbparam, n, eip)\ #define GOTO_TB(opname, tbparam, n)\
do {\ do {\
static void __attribute__((unused)) *__op_label ## n = &&label ## n;\
static void __attribute__((unused)) *dummy ## n = &&dummy_label ## n;\ static void __attribute__((unused)) *dummy ## n = &&dummy_label ## n;\
static void __attribute__((unused)) *__op_label ## n = &&label ## n;\
goto *(void *)(((TranslationBlock *)tbparam)->tb_next[n]);\ goto *(void *)(((TranslationBlock *)tbparam)->tb_next[n]);\
label ## n:\ label ## n: ;\
T0 = (long)(tbparam) + (n);\ dummy_label ## n: ;\
EIP = (int32_t)eip;\
dummy_label ## n:\
EXIT_TB();\
} while (0)
/* second jump to same destination 'n' */
#define JUMP_TB2(opname, tbparam, n)\
do {\
goto *(void *)(((TranslationBlock *)tbparam)->tb_next[n - 2]);\
} while (0) } while (0)
#endif #endif
/* XXX: will be suppressed */
#define JUMP_TB(opname, tbparam, n, eip)\
do {\
GOTO_TB(opname, tbparam, n);\
T0 = (long)(tbparam) + (n);\
EIP = (int32_t)eip;\
EXIT_TB();\
} while (0)
extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4]; extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4]; extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
extern void *io_mem_opaque[IO_MEM_NB_ENTRIES]; extern void *io_mem_opaque[IO_MEM_NB_ENTRIES];

View File

@ -1262,12 +1262,12 @@ void OPPROTO op_clts(void)
void OPPROTO op_goto_tb0(void) void OPPROTO op_goto_tb0(void)
{ {
GOTO_TB(op_goto_tb0, 0); GOTO_TB(op_goto_tb0, PARAM1, 0);
} }
void OPPROTO op_goto_tb1(void) void OPPROTO op_goto_tb1(void)
{ {
GOTO_TB(op_goto_tb1, 1); GOTO_TB(op_goto_tb1, PARAM1, 1);
} }
void OPPROTO op_jmp_label(void) void OPPROTO op_jmp_label(void)

View File

@ -61,6 +61,12 @@ static uint32_t *gen_opparam_ptr;
static int x86_64_hregs; static int x86_64_hregs;
#endif #endif
#ifdef USE_DIRECT_JUMP
#define TBPARAM(x)
#else
#define TBPARAM(x) (long)(x)
#endif
typedef struct DisasContext { typedef struct DisasContext {
/* current insn context */ /* current insn context */
int override; /* -1 if no override */ int override; /* -1 if no override */
@ -1782,13 +1788,13 @@ static inline void gen_jcc(DisasContext *s, int b,
l1 = gen_new_label(); l1 = gen_new_label();
func(l1); func(l1);
gen_op_goto_tb0(); gen_op_goto_tb0(TBPARAM(tb));
gen_jmp_im(next_eip); gen_jmp_im(next_eip);
gen_op_movl_T0_im((long)tb + 0); gen_op_movl_T0_im((long)tb + 0);
gen_op_exit_tb(); gen_op_exit_tb();
gen_set_label(l1); gen_set_label(l1);
gen_op_goto_tb1(); gen_op_goto_tb1(TBPARAM(tb));
gen_jmp_im(val); gen_jmp_im(val);
gen_op_movl_T0_im((long)tb + 1); gen_op_movl_T0_im((long)tb + 1);
gen_op_exit_tb(); gen_op_exit_tb();
@ -2179,9 +2185,9 @@ static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num)
if (s->cc_op != CC_OP_DYNAMIC) if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op); gen_op_set_cc_op(s->cc_op);
if (tb_num) if (tb_num)
gen_op_goto_tb1(); gen_op_goto_tb1(TBPARAM(tb));
else else
gen_op_goto_tb0(); gen_op_goto_tb0(TBPARAM(tb));
gen_jmp_im(eip); gen_jmp_im(eip);
gen_op_movl_T0_im((long)tb + tb_num); gen_op_movl_T0_im((long)tb + tb_num);
gen_op_exit_tb(); gen_op_exit_tb();