Skip to content

Commit

Permalink
Small cleanup of gen_intermediate_code(_internal), by Laurent Desnogues.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4891 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
ths committed Jul 18, 2008
1 parent d1b5c20 commit 2cfc5f1
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 72 deletions.
4 changes: 2 additions & 2 deletions exec-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ typedef void (GenOpFunc3)(long, long, long);
extern FILE *logfile;
extern int loglevel;

int gen_intermediate_code(CPUState *env, struct TranslationBlock *tb);
int gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb);
void gen_intermediate_code(CPUState *env, struct TranslationBlock *tb);
void gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb);
void gen_pc_load(CPUState *env, struct TranslationBlock *tb,
unsigned long searched_pc, int pc_pos, void *puc);

Expand Down
16 changes: 7 additions & 9 deletions target-alpha/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1970,9 +1970,9 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)
return ret;
}

static always_inline int gen_intermediate_code_internal (CPUState *env,
TranslationBlock *tb,
int search_pc)
static always_inline void gen_intermediate_code_internal (CPUState *env,
TranslationBlock *tb,
int search_pc)
{
#if defined ALPHA_DEBUG_DISAS
static int insn_count;
Expand Down Expand Up @@ -2086,18 +2086,16 @@ static always_inline int gen_intermediate_code_internal (CPUState *env,
fprintf(logfile, "\n");
}
#endif

return 0;
}

int gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)
void gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 0);
gen_intermediate_code_internal(env, tb, 0);
}

int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
gen_intermediate_code_internal(env, tb, 1);
}

CPUAlphaState * cpu_alpha_init (const char *cpu_model)
Expand Down
15 changes: 7 additions & 8 deletions target-arm/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -8544,9 +8544,9 @@ static void disas_thumb_insn(CPUState *env, DisasContext *s)
/* generate intermediate code in gen_opc_buf and gen_opparam_buf for
basic block 'tb'. If search_pc is TRUE, also generate PC
information for each intermediate instruction. */
static inline int gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
static inline void gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext dc1, *dc = &dc1;
uint16_t *gen_opc_end;
Expand Down Expand Up @@ -8787,17 +8787,16 @@ static inline int gen_intermediate_code_internal(CPUState *env,
tb->size = dc->pc - pc_start;
tb->icount = num_insns;
}
return 0;
}

int gen_intermediate_code(CPUState *env, TranslationBlock *tb)
void gen_intermediate_code(CPUState *env, TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 0);
gen_intermediate_code_internal(env, tb, 0);
}

int gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
void gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
gen_intermediate_code_internal(env, tb, 1);
}

static const char *cpu_mode_names[16] = {
Expand Down
11 changes: 5 additions & 6 deletions target-cris/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -3022,7 +3022,7 @@ static void check_breakpoint(CPUState *env, DisasContext *dc)
*/

/* generate intermediate code for basic block 'tb'. */
static int
static void
gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,
int search_pc)
{
Expand Down Expand Up @@ -3233,17 +3233,16 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,
dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
}
#endif
return 0;
}

int gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)
void gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 0);
gen_intermediate_code_internal(env, tb, 0);
}

int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
gen_intermediate_code_internal(env, tb, 1);
}

void cpu_dump_state (CPUState *env, FILE *f,
Expand Down
15 changes: 7 additions & 8 deletions target-i386/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -7148,9 +7148,9 @@ void optimize_flags_init(void)
/* generate intermediate code in gen_opc_buf and gen_opparam_buf for
basic block 'tb'. If search_pc is TRUE, also generate PC
information for each intermediate instruction. */
static inline int gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
static inline void gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext dc1, *dc = &dc1;
target_ulong pc_ptr;
Expand Down Expand Up @@ -7321,17 +7321,16 @@ static inline int gen_intermediate_code_internal(CPUState *env,
tb->size = pc_ptr - pc_start;
tb->icount = num_insns;
}
return 0;
}

int gen_intermediate_code(CPUState *env, TranslationBlock *tb)
void gen_intermediate_code(CPUState *env, TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 0);
gen_intermediate_code_internal(env, tb, 0);
}

int gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
void gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
gen_intermediate_code_internal(env, tb, 1);
}

void gen_pc_load(CPUState *env, TranslationBlock *tb,
Expand Down
11 changes: 5 additions & 6 deletions target-m68k/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2911,7 +2911,7 @@ static void disas_m68k_insn(CPUState * env, DisasContext *s)
}

/* generate intermediate code for basic block 'tb'. */
static inline int
static inline void
gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,
int search_pc)
{
Expand Down Expand Up @@ -3039,17 +3039,16 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb,

//optimize_flags();
//expand_target_qops();
return 0;
}

int gen_intermediate_code(CPUState *env, TranslationBlock *tb)
void gen_intermediate_code(CPUState *env, TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 0);
gen_intermediate_code_internal(env, tb, 0);
}

int gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
void gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
gen_intermediate_code_internal(env, tb, 1);
}

void cpu_dump_state(CPUState *env, FILE *f,
Expand Down
12 changes: 5 additions & 7 deletions target-mips/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -8453,7 +8453,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
}
}

static inline int
static inline void
gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
int search_pc)
{
Expand Down Expand Up @@ -8598,18 +8598,16 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
fprintf(logfile, "---------------- %d %08x\n", ctx.bstate, ctx.hflags);
}
#endif

return 0;
}

int gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)
void gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 0);
gen_intermediate_code_internal(env, tb, 0);
}

int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
gen_intermediate_code_internal(env, tb, 1);
}

void fpu_dump_state(CPUState *env, FILE *f,
Expand Down
15 changes: 7 additions & 8 deletions target-ppc/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -6171,9 +6171,9 @@ void cpu_dump_statistics (CPUState *env, FILE*f,
}

/*****************************************************************************/
static always_inline int gen_intermediate_code_internal (CPUState *env,
TranslationBlock *tb,
int search_pc)
static always_inline void gen_intermediate_code_internal (CPUState *env,
TranslationBlock *tb,
int search_pc)
{
DisasContext ctx, *ctxp = &ctx;
opc_handler_t **table, *handler;
Expand Down Expand Up @@ -6379,17 +6379,16 @@ static always_inline int gen_intermediate_code_internal (CPUState *env,
fprintf(logfile, "\n");
}
#endif
return 0;
}

int gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)
void gen_intermediate_code (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 0);
gen_intermediate_code_internal(env, tb, 0);
}

int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
gen_intermediate_code_internal(env, tb, 1);
}

void gen_pc_load(CPUState *env, TranslationBlock *tb,
Expand Down
11 changes: 5 additions & 6 deletions target-sh4/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ void decode_opc(DisasContext * ctx)
}
}

static inline int
static inline void
gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb,
int search_pc)
{
Expand Down Expand Up @@ -1326,17 +1326,16 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb,
fprintf(logfile, "\n");
}
#endif
return 0;
}

int gen_intermediate_code(CPUState * env, struct TranslationBlock *tb)
void gen_intermediate_code(CPUState * env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 0);
gen_intermediate_code_internal(env, tb, 0);
}

int gen_intermediate_code_pc(CPUState * env, struct TranslationBlock *tb)
void gen_intermediate_code_pc(CPUState * env, struct TranslationBlock *tb)
{
return gen_intermediate_code_internal(env, tb, 1);
gen_intermediate_code_internal(env, tb, 1);
}

void gen_pc_load(CPUState *env, TranslationBlock *tb,
Expand Down
13 changes: 6 additions & 7 deletions target-sparc/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -4724,8 +4724,8 @@ static void disas_sparc_insn(DisasContext * dc)
#endif
}

static inline int gen_intermediate_code_internal(TranslationBlock * tb,
int spc, CPUSPARCState *env)
static inline void gen_intermediate_code_internal(TranslationBlock * tb,
int spc, CPUSPARCState *env)
{
target_ulong pc_start, last_pc;
uint16_t *gen_opc_end;
Expand Down Expand Up @@ -4869,17 +4869,16 @@ static inline int gen_intermediate_code_internal(TranslationBlock * tb,
fprintf(logfile, "\n");
}
#endif
return 0;
}

int gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb)
void gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb)
{
return gen_intermediate_code_internal(tb, 0, env);
gen_intermediate_code_internal(tb, 0, env);
}

int gen_intermediate_code_pc(CPUSPARCState * env, TranslationBlock * tb)
void gen_intermediate_code_pc(CPUSPARCState * env, TranslationBlock * tb)
{
return gen_intermediate_code_internal(tb, 1, env);
gen_intermediate_code_internal(tb, 1, env);
}

void gen_intermediate_code_init(CPUSPARCState *env)
Expand Down
8 changes: 3 additions & 5 deletions translate-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)
#endif
tcg_func_start(s);

if (gen_intermediate_code(env, tb) < 0)
return -1;

gen_intermediate_code(env, tb);

/* generate machine code */
gen_code_buf = tb->tc_ptr;
tb->tb_next_offset[0] = 0xffff;
Expand Down Expand Up @@ -156,8 +155,7 @@ int cpu_restore_state(TranslationBlock *tb,
#endif
tcg_func_start(s);

if (gen_intermediate_code_pc(env, tb) < 0)
return -1;
gen_intermediate_code_pc(env, tb);

if (use_icount) {
/* Reset the cycle counter to the start of the block. */
Expand Down

0 comments on commit 2cfc5f1

Please sign in to comment.