Move gen_opc_ptr and gen_opparam_ptr into tcg context
PATCH 1/1 Move gen_opc_ptr and gen_opparam_ptr into tcg context
Hello,
this patch moves gen_opc_ptr and gen_opparam_ptr into tcg context. This modification was "asked for" in tcg.c. It seems not to alter speed (I took care putting the 2 new structure elements at the beginning of the context).
Laurent
translate.c +3 -3
@@ -2012,7 +2012,7 @@ } }if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;while (lj < j)
@@ -2066,9 +2066,9 @@/* Generate the return instruction */ tcg_gen_exit_tb (0 );gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf; lj++;while (lj <= j) gen_opc_instr_start[lj++] =0 ;
translate.c +4 -4
@@ -8646,7 +8646,7 @@ } }if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;while (lj < j)
@@ -8693,7 +8693,7 @@* Also stop translation when a page boundary is reached. This * ensures prefetch aborts occur at the right place. */ num_insns ++; - }while (!dc->is_jmp && gen_opc_ptr < gen_opc_end && + }while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && !env->singlestep_enabled && dc->pc < next_page_start && num_insns < max_insns);
@@ -8773,7 +8773,7 @@ done_generating:gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) {
@@ -8784,7 +8784,7 @@ }#endif if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf; lj++;while (lj <= j) gen_opc_instr_start[lj++] =0 ;
translate.c +5 -5
@@ -3108,7 +3108,7 @@check_breakpoint (env, dc);if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;while (lj < j)
@@ -3165,7 +3165,7 @@delay slots dont break. */ if (!(tb->pc &1 ) && env->singlestep_enabled)break ; - }while (!dc->is_jmp && gen_opc_ptr < gen_opc_end + }while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && (dc->pc < next_page_start) && num_insns < max_insns);
@@ -3214,9 +3214,9 @@ } }gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf; lj++;while (lj <= j) gen_opc_instr_start[lj++] =0 ;
@@ -3231,7 +3231,7 @@fprintf (logfile,"IN: %s\n" ,lookup_symbol (pc_start));target_disas (logfile, pc_start, dc->pc - pc_start,0 );fprintf (logfile,"\nisize=%d osize=%zd\n" , - dc->pc - pc_start, gen_opc_ptr - gen_opc_buf); + dc->pc - pc_start, tcg_ctx.gen_opc_ptr - gen_opc_buf); }#endif }
translate.c +4 -4
@@ -7247,7 +7247,7 @@ } }if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;while (lj < j)
@@ -7278,7 +7278,7 @@break ; }/* if too long translation, stop generation too */ -if (gen_opc_ptr >= gen_opc_end || +if (tcg_ctx.gen_opc_ptr >= gen_opc_end || (pc_ptr - pc_start) >= (TARGET_PAGE_SIZE -32 ) || num_insns >= max_insns) {gen_jmp_im (pc_ptr - dc->cs_base);
@@ -7289,10 +7289,10 @@if (tb->cflags &CF_LAST_IO )gen_io_end ();gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;/* we don't forget to fill the last values */ if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf; lj++;while (lj <= j) gen_opc_instr_start[lj++] =0 ;
translate.c +4 -4
@@ -2962,7 +2962,7 @@break ; }if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;while (lj < j)
@@ -2984,7 +2984,7 @@* IRQ raising bits. */ if (dc->is_mem && env->nb_watchpoints)break ; - }while (!dc->is_jmp && gen_opc_ptr < gen_opc_end && + }while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && !env->singlestep_enabled && (pc_offset) < (TARGET_PAGE_SIZE -32 ) && num_insns < max_insns);
@@ -3017,7 +3017,7 @@ } }gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;#ifdef DEBUG_DISAS if (loglevel &CPU_LOG_TB_IN_ASM ) {
@@ -3028,7 +3028,7 @@ }#endif if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf; lj++;while (lj <= j) gen_opc_instr_start[lj++] =0 ;
translate.c +4 -4
@@ -8514,7 +8514,7 @@ }if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;while (lj < j)
@@ -8538,7 +8538,7 @@if ((ctx.pc & (TARGET_PAGE_SIZE -1 )) ==0 )break ; -if (gen_opc_ptr >= gen_opc_end) +if (tcg_ctx.gen_opc_ptr >= gen_opc_end)break ;if (num_insns >= max_insns)
@@ -8573,9 +8573,9 @@ } done_generating:gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;if (search_pc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf; lj++;while (lj <= j) gen_opc_instr_start[lj++] =0 ;
translate.c +5 -5
@@ -209,7 +209,7 @@if (set_fprf !=0 ) {/* This case might be optimized later */ #if defined(OPTIMIZE_FPRF_UPDATE ) - *gen_fprf_ptr++ = gen_opc_ptr; + *gen_fprf_ptr++ = tcg_ctx.gen_opc_ptr;#endif gen_op_compute_fprf (1 );if (unlikely (set_rc))
@@ -6233,7 +6233,7 @@gen_icount_start ();/* Set env in case of segfault during code fetch */ -while (ctx.exception ==POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) { +while (ctx.exception ==POWERPC_EXCP_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) {if (unlikely (env->nb_breakpoints >0 )) {for (j =0 ; j < env->nb_breakpoints; j++) {if (env->breakpoints[j] == ctx.nip) {
@@ -6244,7 +6244,7 @@ } }if (unlikely (search_pc)) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;while (lj < j)
@@ -6355,9 +6355,9 @@tcg_gen_exit_tb (0 ); }gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;if (unlikely (search_pc)) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf; lj++;while (lj <= j) gen_opc_instr_start[lj++] =0 ;
translate.c +4 -4
@@ -1234,7 +1234,7 @@if (max_insns ==0 ) max_insns =CF_COUNT_MASK ;gen_icount_start (); -while (ctx.bstate ==BS_NONE && gen_opc_ptr < gen_opc_end) { +while (ctx.bstate ==BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) {if (env->nb_breakpoints >0 ) {for (i =0 ; i < env->nb_breakpoints; i++) {if (ctx.pc == env->breakpoints[i]) {
@@ -1247,7 +1247,7 @@ } }if (search_pc) { - i = gen_opc_ptr - gen_opc_buf; + i = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (ii < i) { ii++;while (ii < i)
@@ -1304,9 +1304,9 @@ }gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;if (search_pc) { - i = gen_opc_ptr - gen_opc_buf; + i = tcg_ctx.gen_opc_ptr - gen_opc_buf; ii++;while (ii <= i) gen_opc_instr_start[ii++] =0 ;
translate.c +4 -4
@@ -4787,7 +4787,7 @@if (spc) {if (loglevel >0 )fprintf (logfile,"Search PC...\n" ); - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf;if (lj < j) { lj++;while (lj < j)
@@ -4820,7 +4820,7 @@tcg_gen_exit_tb (0 );break ; } - }while ((gen_opc_ptr < gen_opc_end) && + }while ((tcg_ctx.gen_opc_ptr < gen_opc_end) && (dc->pc - pc_start) < (TARGET_PAGE_SIZE -32 ) && num_insns < max_insns);
@@ -4846,9 +4846,9 @@ } }gen_icount_end (tb, num_insns); - *gen_opc_ptr = INDEX_op_end; + *tcg_ctx.gen_opc_ptr = INDEX_op_end;if (spc) { - j = gen_opc_ptr - gen_opc_buf; + j = tcg_ctx.gen_opc_ptr - gen_opc_buf; lj++;while (lj <= j) gen_opc_instr_start[lj++] =0 ;
gen-icount.h +1 -1
@@ -21,7 +21,7 @@#endif tcg_gen_ld_i32(count, cpu_env, offsetof(CPUState, icount_decr.u32));/* This is a horrid hack to allow fixing up the value later. */ - icount_arg = gen_opparam_ptr +1 ; + icount_arg = tcg_ctx.gen_opparam_ptr +1 ;tcg_gen_subi_i32 (count, count,0xdeadbeef );tcg_gen_brcondi_i32 (TCG_COND_LT , count,0 , icount_label);
tcg-op.h +62 -62
193 lines not on this page · raw message
tcg.c +15 -19
@@ -66,10 +66,6 @@TCGRegSet tcg_target_available_regs[2 ];TCGRegSet tcg_target_call_clobber_regs; -/* XXX: move that inside the context */ -uint16_t *gen_opc_ptr; -TCGArg *gen_opparam_ptr; -static inline void tcg_out8 (TCGContext *s,uint8_t v) { *s->code_ptr++ = v;
@@ -270,8 +266,8 @@ s->nb_labels =0 ; s->current_frame_offset = s->frame_start; - gen_opc_ptr = gen_opc_buf; - gen_opparam_ptr = gen_opparam_buf; + s->gen_opc_ptr = gen_opc_buf; + s->gen_opparam_ptr = gen_opparam_buf; }static inline void tcg_temp_alloc (TCGContext *s,int n)
@@ -518,19 +514,19 @@ unsigned int nb_params, const TCGv *params) { int i; - *gen_opc_ptr++ = INDEX_op_call; - *gen_opparam_ptr++ = (nb_rets <<16 ) | (nb_params +1 ); + *s->gen_opc_ptr++ = INDEX_op_call; + *s->gen_opparam_ptr++ = (nb_rets <<16 ) | (nb_params +1 );for (i =0 ; i < nb_rets; i++) { - *gen_opparam_ptr++ =GET_TCGV (rets[i]); + *s->gen_opparam_ptr++ =GET_TCGV (rets[i]); }for (i =0 ; i < nb_params; i++) { - *gen_opparam_ptr++ =GET_TCGV (params[i]); + *s->gen_opparam_ptr++ =GET_TCGV (params[i]); } - *gen_opparam_ptr++ =GET_TCGV (func); + *s->gen_opparam_ptr++ =GET_TCGV (func); - *gen_opparam_ptr++ = flags; + *s->gen_opparam_ptr++ = flags;/* total parameters, needed to go backward in the instruction stream */ - *gen_opparam_ptr++ =1 + nb_rets + nb_params +3 ; + *s->gen_opparam_ptr++ =1 + nb_rets + nb_params +3 ; }
@@ -755,7 +751,7 @@ first_insn =1 ; opc_ptr = gen_opc_buf; args = gen_opparam_buf; -while (opc_ptr < gen_opc_ptr) { +while (opc_ptr < s->gen_opc_ptr) { c = *opc_ptr++; def = &tcg_op_defs[c];if (c == INDEX_op_debug_insn_start) {
@@ -1033,9 +1029,9 @@uint8_t *dead_temps;unsigned int dead_iargs; - gen_opc_ptr++;/* skip end */ + s->gen_opc_ptr++;/* skip end */ - nb_ops = gen_opc_ptr - gen_opc_buf; + nb_ops = s->gen_opc_ptr - gen_opc_buf;/* XXX: make it really dynamic */ s->op_dead_iargs =tcg_malloc (OPC_BUF_SIZE *sizeof (uint16_t ));
@@ -1043,7 +1039,7 @@ dead_temps =tcg_malloc (s->nb_temps);memset (dead_temps,1 , s->nb_temps); - args = gen_opparam_ptr; + args = s->gen_opparam_ptr; op_index = nb_ops -1 ;while (op_index >=0 ) { op = gen_opc_buf[op_index];
@@ -1184,7 +1180,7 @@void tcg_liveness_analysis (TCGContext *s) {int nb_ops; - nb_ops = gen_opc_ptr - gen_opc_buf; + nb_ops = s->gen_opc_ptr - gen_opc_buf; s->op_dead_iargs =tcg_malloc (nb_ops *sizeof (uint16_t ));memset (s->op_dead_iargs,0 , nb_ops *sizeof (uint16_t ));
@@ -1979,7 +1975,7 @@#ifdef CONFIG_PROFILER {int n; - n = (gen_opc_ptr - gen_opc_buf); + n = (s->gen_opc_ptr - gen_opc_buf); s->op_count += n;if (n > s->op_count_max) s->op_count_max = n;
tcg.h +3 -2
@@ -209,6 +209,9 @@typedef struct TCGContext TCGContext ;struct TCGContext { +uint16_t *gen_opc_ptr; +TCGArg *gen_opparam_ptr; +uint8_t *pool_cur, *pool_end;TCGPool *pool_first, *pool_current;TCGLabel *labels;
@@ -267,8 +270,6 @@ };extern TCGContext tcg_ctx; -extern uint16_t *gen_opc_ptr; -extern TCGArg *gen_opparam_ptr;extern uint16_t gen_opc_buf[];extern TCGArg gen_opparam_buf[];
dyngen.c +2 -2
@@ -2623,9 +2623,9 @@fprintf (outfile,")\n" );fprintf (outfile,"{\n" );for (i =0 ; i < nb_args; i++) { -fprintf (outfile," *gen_opparam_ptr++ = param%d;\n" , i +1 ); +fprintf (outfile," *tcg_ctx.gen_opparam_ptr++ = param%d;\n" , i +1 ); } -fprintf (outfile," *gen_opc_ptr++ = INDEX_%s;\n" , name); +fprintf (outfile," *tcg_ctx.gen_opc_ptr++ = INDEX_%s;\n" , name);fprintf (outfile,"}\n\n" ); } }