From patchwork Tue Oct 23 06:21:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Voevodin X-Patchwork-Id: 193368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0BED62C0180 for ; Tue, 23 Oct 2012 17:32:53 +1100 (EST) Received: from localhost ([::1]:51676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQY2k-0000Na-AG for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2012 02:32:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQY1g-0006Kr-3u for qemu-devel@nongnu.org; Tue, 23 Oct 2012 02:31:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQY1V-0004Qj-9y for qemu-devel@nongnu.org; Tue, 23 Oct 2012 02:31:43 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:37527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQY1U-0004QS-Sv for qemu-devel@nongnu.org; Tue, 23 Oct 2012 02:31:33 -0400 Received: from eusync4.samsung.com (mailout4.w1.samsung.com [210.118.77.14]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MCC001J61OSDOA0@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 23 Oct 2012 07:22:04 +0100 (BST) Received: from evvoevodinPC.rnd.samsung.ru ([106.109.8.9]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MCC008ZX1NMAD70@eusync4.samsung.com> for qemu-devel@nongnu.org; Tue, 23 Oct 2012 07:21:31 +0100 (BST) From: Evgeny Voevodin To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2012 10:21:16 +0400 Message-id: <1350973278-2236-6-git-send-email-e.voevodin@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1350973278-2236-1-git-send-email-e.voevodin@samsung.com> References: <1350973278-2236-1-git-send-email-e.voevodin@samsung.com> X-TM-AS-MML: No X-detected-operating-system: by eggs.gnu.org: Solaris 10 (1203?) X-Received-From: 210.118.77.14 Cc: Evgeny Voevodin , blauwirbel@gmail.com, kyungmin.park@samsung.com, edgar.iglesias@gmail.com, aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH v2 5/7] TCG: Use gen_opc_buf from context instead of global variable. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Evgeny Voevodin --- target-alpha/translate.c | 6 ++-- target-arm/translate.c | 6 ++-- target-cris/translate.c | 9 +++--- target-i386/translate.c | 6 ++-- target-lm32/translate.c | 9 +++--- target-m68k/translate.c | 6 ++-- target-microblaze/translate.c | 9 +++--- target-mips/translate.c | 6 ++-- target-openrisc/translate.c | 9 +++--- target-ppc/translate.c | 6 ++-- target-s390x/translate.c | 6 ++-- target-sh4/translate.c | 6 ++-- target-sparc/translate.c | 6 ++-- target-unicore32/translate.c | 6 ++-- target-xtensa/translate.c | 4 +-- tcg/optimize.c | 62 ++++++++++++++++++++--------------------- tcg/tcg.c | 30 ++++++++++---------- 17 files changed, 98 insertions(+), 94 deletions(-) diff --git a/target-alpha/translate.c b/target-alpha/translate.c index 751d457..7454ebd 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -3373,7 +3373,7 @@ static inline void gen_intermediate_code_internal(CPUAlphaState *env, int max_insns; pc_start = tb->pc; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; ctx.tb = tb; ctx.env = env; @@ -3406,7 +3406,7 @@ static inline void gen_intermediate_code_internal(CPUAlphaState *env, } } if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -3465,7 +3465,7 @@ static inline void gen_intermediate_code_internal(CPUAlphaState *env, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; diff --git a/target-arm/translate.c b/target-arm/translate.c index 41b1671..3c82a0d 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -9718,7 +9718,7 @@ static inline void gen_intermediate_code_internal(CPUARMState *env, dc->tb = tb; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; @@ -9825,7 +9825,7 @@ static inline void gen_intermediate_code_internal(CPUARMState *env, } } if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -9965,7 +9965,7 @@ done_generating: } #endif if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; diff --git a/target-cris/translate.c b/target-cris/translate.c index 9bec8b5..587df16 100644 --- a/target-cris/translate.c +++ b/target-cris/translate.c @@ -3202,7 +3202,7 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb, dc->env = env; dc->tb = tb; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->ppc = pc_start; @@ -3266,7 +3266,7 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb, check_breakpoint(env, dc); if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -3401,7 +3401,7 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; @@ -3416,7 +3416,8 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb, log_target_disas(pc_start, dc->pc - pc_start, dc->env->pregs[PR_VR]); qemu_log("\nisize=%d osize=%td\n", - dc->pc - pc_start, tcg_cur_ctx->gen_opc_ptr - gen_opc_buf); + dc->pc - pc_start, tcg_cur_ctx->gen_opc_ptr - + tcg_cur_ctx->gen_opc_buf); } #endif #endif diff --git a/target-i386/translate.c b/target-i386/translate.c index b28bfb3..c4fdff9 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -7958,7 +7958,7 @@ static inline void gen_intermediate_code_internal(CPUX86State *env, cpu_ptr0 = tcg_temp_new_ptr(); cpu_ptr1 = tcg_temp_new_ptr(); - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; pc_ptr = pc_start; @@ -7980,7 +7980,7 @@ static inline void gen_intermediate_code_internal(CPUX86State *env, } } if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -8030,7 +8030,7 @@ static inline void gen_intermediate_code_internal(CPUX86State *env, *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; /* we don't forget to fill the last values */ if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; diff --git a/target-lm32/translate.c b/target-lm32/translate.c index 4a17ec1..6a70096 100644 --- a/target-lm32/translate.c +++ b/target-lm32/translate.c @@ -1018,7 +1018,7 @@ static void gen_intermediate_code_internal(CPULM32State *env, dc->env = env; dc->tb = tb; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; @@ -1047,7 +1047,7 @@ static void gen_intermediate_code_internal(CPULM32State *env, check_breakpoint(env, dc); if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) { @@ -1107,7 +1107,7 @@ static void gen_intermediate_code_internal(CPULM32State *env, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) { gen_opc_instr_start[lj++] = 0; @@ -1122,7 +1122,8 @@ static void gen_intermediate_code_internal(CPULM32State *env, qemu_log("\n"); log_target_disas(pc_start, dc->pc - pc_start, 0); qemu_log("\nisize=%d osize=%td\n", - dc->pc - pc_start, tcg_cur_ctx->gen_opc_ptr - gen_opc_buf); + dc->pc - pc_start, tcg_cur_ctx->gen_opc_ptr - + tcg_cur_ctx->gen_opc_buf); } #endif } diff --git a/target-m68k/translate.c b/target-m68k/translate.c index 9fa82d4..8d22391 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -2982,7 +2982,7 @@ gen_intermediate_code_internal(CPUM68KState *env, TranslationBlock *tb, dc->tb = tb; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; dc->env = env; dc->is_jmp = DISAS_NEXT; @@ -3015,7 +3015,7 @@ gen_intermediate_code_internal(CPUM68KState *env, TranslationBlock *tb, break; } if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -3075,7 +3075,7 @@ gen_intermediate_code_internal(CPUM68KState *env, TranslationBlock *tb, } #endif if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index aeffed0..b84cd3b 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -1741,7 +1741,7 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb, dc->tb = tb; org_flags = dc->synced_flags = dc->tb_flags = tb->flags; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->jmp = 0; @@ -1784,7 +1784,7 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb, check_breakpoint(env, dc); if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -1899,7 +1899,7 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; @@ -1916,7 +1916,8 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb, log_target_disas(pc_start, dc->pc - pc_start, 0); #endif qemu_log("\nisize=%d osize=%td\n", - dc->pc - pc_start, tcg_cur_ctx->gen_opc_ptr - gen_opc_buf); + dc->pc - pc_start, tcg_cur_ctx->gen_opc_ptr - + tcg_cur_ctx->gen_opc_buf); } #endif #endif diff --git a/target-mips/translate.c b/target-mips/translate.c index 10690b0..1fea036 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -12809,7 +12809,7 @@ gen_intermediate_code_internal (CPUMIPSState *env, TranslationBlock *tb, qemu_log("search pc %d\n", search_pc); pc_start = tb->pc; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; ctx.pc = pc_start; ctx.saved_pc = -1; ctx.singlestep_enabled = env->singlestep_enabled; @@ -12845,7 +12845,7 @@ gen_intermediate_code_internal (CPUMIPSState *env, TranslationBlock *tb, } if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -12928,7 +12928,7 @@ done_generating: gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c index 1c4017a..3394cb0 100644 --- a/target-openrisc/translate.c +++ b/target-openrisc/translate.c @@ -1675,7 +1675,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, pc_start = tb->pc; dc->tb = tb; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->ppc = pc_start; dc->pc = pc_start; @@ -1703,7 +1703,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, do { check_breakpoint(cpu, dc); if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (k < j) { k++; while (k < j) { @@ -1784,7 +1784,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; k++; while (k <= j) { gen_opc_instr_start[k++] = 0; @@ -1799,7 +1799,8 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, qemu_log("\n"); log_target_disas(pc_start, dc->pc - pc_start, 0); qemu_log("\nisize=%d osize=%td\n", - dc->pc - pc_start, tcg_cur_ctx->gen_opc_ptr - gen_opc_buf); + dc->pc - pc_start, tcg_cur_ctx->gen_opc_ptr - + tcg_cur_ctx->gen_opc_buf); } #endif } diff --git a/target-ppc/translate.c b/target-ppc/translate.c index f9cfea5..08aafd3 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -9617,7 +9617,7 @@ static inline void gen_intermediate_code_internal(CPUPPCState *env, int max_insns; pc_start = tb->pc; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; ctx.nip = pc_start; ctx.tb = tb; ctx.exception = POWERPC_EXCP_NONE; @@ -9668,7 +9668,7 @@ static inline void gen_intermediate_code_internal(CPUPPCState *env, } } if (unlikely(search_pc)) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -9770,7 +9770,7 @@ static inline void gen_intermediate_code_internal(CPUPPCState *env, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (unlikely(search_pc)) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; diff --git a/target-s390x/translate.c b/target-s390x/translate.c index c5f6af2..87b6eb8 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -5134,7 +5134,7 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env, dc.tb = tb; dc.cc_op = CC_OP_DYNAMIC; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; @@ -5156,7 +5156,7 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env, } } if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) { @@ -5209,7 +5209,7 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) { gen_opc_instr_start[lj++] = 0; diff --git a/target-sh4/translate.c b/target-sh4/translate.c index 4d89b3d..ab2fa8d 100644 --- a/target-sh4/translate.c +++ b/target-sh4/translate.c @@ -1967,7 +1967,7 @@ gen_intermediate_code_internal(CPUSH4State * env, TranslationBlock * tb, int max_insns; pc_start = tb->pc; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; ctx.pc = pc_start; ctx.flags = (uint32_t)tb->flags; ctx.bstate = BS_NONE; @@ -1999,7 +1999,7 @@ gen_intermediate_code_internal(CPUSH4State * env, TranslationBlock * tb, } } if (search_pc) { - i = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + i = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (ii < i) { ii++; while (ii < i) @@ -2058,7 +2058,7 @@ gen_intermediate_code_internal(CPUSH4State * env, TranslationBlock * tb, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (search_pc) { - i = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + i = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; ii++; while (ii <= i) gen_opc_instr_start[ii++] = 0; diff --git a/target-sparc/translate.c b/target-sparc/translate.c index daa4c5d..62669bd 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -5257,7 +5257,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, dc->fpu_enabled = tb_fpu_enabled(tb->flags); dc->address_mask_32bit = tb_am_enabled(tb->flags); dc->singlestep = (env->singlestep_enabled || singlestep); - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; @@ -5279,7 +5279,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, } if (spc) { qemu_log("Search PC...\n"); - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) @@ -5336,7 +5336,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, gen_icount_end(tb, num_insns); *tcg_cur_ctx->gen_opc_ptr = INDEX_op_end; if (spc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) gen_opc_instr_start[lj++] = 0; diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c index 3575c7e..c8cd686 100644 --- a/target-unicore32/translate.c +++ b/target-unicore32/translate.c @@ -1956,7 +1956,7 @@ static inline void gen_intermediate_code_internal(CPUUniCore32State *env, dc->tb = tb; - gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; dc->is_jmp = DISAS_NEXT; dc->pc = pc_start; @@ -1999,7 +1999,7 @@ static inline void gen_intermediate_code_internal(CPUUniCore32State *env, } } if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) { @@ -2114,7 +2114,7 @@ done_generating: } #endif if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; lj++; while (lj <= j) { gen_opc_instr_start[lj++] = 0; diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index e14f1a2..38c6e6e 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -2849,7 +2849,7 @@ static void gen_intermediate_code_internal( DisasContext dc; int insn_count = 0; int j, lj = -1; - uint16_t *gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; + uint16_t *gen_opc_end = tcg_cur_ctx->gen_opc_buf + OPC_MAX_SIZE; int max_insns = tb->cflags & CF_COUNT_MASK; uint32_t pc_start = tb->pc; uint32_t next_page_start = @@ -2893,7 +2893,7 @@ static void gen_intermediate_code_internal( check_breakpoint(env, &dc); if (search_pc) { - j = tcg_cur_ctx->gen_opc_ptr - gen_opc_buf; + j = tcg_cur_ctx->gen_opc_ptr - tcg_cur_ctx->gen_opc_buf; if (lj < j) { lj++; while (lj < j) { diff --git a/tcg/optimize.c b/tcg/optimize.c index a06c8eb..fffa682 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -484,10 +484,10 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, nb_globals = s->nb_globals; memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); - nb_ops = tcg_opc_ptr - gen_opc_buf; + nb_ops = tcg_opc_ptr - s->gen_opc_buf; gen_args = args; for (op_index = 0; op_index < nb_ops; op_index++) { - op = gen_opc_buf[op_index]; + op = s->gen_opc_buf[op_index]; def = &tcg_op_defs[op]; /* Do copy propagation */ if (op == INDEX_op_call) { @@ -569,7 +569,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(rotr): if (temps[args[1]].state == TCG_TEMP_CONST && temps[args[1]].val == 0) { - gen_opc_buf[op_index] = op_to_movi(op); + s->gen_opc_buf[op_index] = op_to_movi(op); tcg_opt_gen_movi(gen_args, args[0], 0); args += 3; gen_args += 2; @@ -598,9 +598,9 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, if (temps[args[2]].state == TCG_TEMP_CONST && temps[args[2]].val == 0) { if (temps_are_copies(args[0], args[1])) { - gen_opc_buf[op_index] = INDEX_op_nop; + s->gen_opc_buf[op_index] = INDEX_op_nop; } else { - gen_opc_buf[op_index] = op_to_mov(op); + s->gen_opc_buf[op_index] = op_to_mov(op); tcg_opt_gen_mov(s, gen_args, args[0], args[1]); gen_args += 2; } @@ -618,7 +618,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(mul): if ((temps[args[2]].state == TCG_TEMP_CONST && temps[args[2]].val == 0)) { - gen_opc_buf[op_index] = op_to_movi(op); + s->gen_opc_buf[op_index] = op_to_movi(op); tcg_opt_gen_movi(gen_args, args[0], 0); args += 3; gen_args += 2; @@ -635,9 +635,9 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(and): if (temps_are_copies(args[1], args[2])) { if (temps_are_copies(args[0], args[1])) { - gen_opc_buf[op_index] = INDEX_op_nop; + s->gen_opc_buf[op_index] = INDEX_op_nop; } else { - gen_opc_buf[op_index] = op_to_mov(op); + s->gen_opc_buf[op_index] = op_to_mov(op); tcg_opt_gen_mov(s, gen_args, args[0], args[1]); gen_args += 2; } @@ -654,7 +654,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(sub): CASE_OP_32_64(xor): if (temps_are_copies(args[1], args[2])) { - gen_opc_buf[op_index] = op_to_movi(op); + s->gen_opc_buf[op_index] = op_to_movi(op); tcg_opt_gen_movi(gen_args, args[0], 0); gen_args += 2; args += 3; @@ -672,7 +672,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(mov): if (temps_are_copies(args[0], args[1])) { args += 2; - gen_opc_buf[op_index] = INDEX_op_nop; + s->gen_opc_buf[op_index] = INDEX_op_nop; break; } if (temps[args[1]].state != TCG_TEMP_CONST) { @@ -684,7 +684,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, /* Source argument is constant. Rewrite the operation and let movi case handle it. */ op = op_to_movi(op); - gen_opc_buf[op_index] = op; + s->gen_opc_buf[op_index] = op; args[1] = temps[args[1]].val; /* fallthrough */ CASE_OP_32_64(movi): @@ -702,7 +702,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, case INDEX_op_ext32s_i64: case INDEX_op_ext32u_i64: if (temps[args[1]].state == TCG_TEMP_CONST) { - gen_opc_buf[op_index] = op_to_movi(op); + s->gen_opc_buf[op_index] = op_to_movi(op); tmp = do_constant_folding(op, temps[args[1]].val, 0); tcg_opt_gen_movi(gen_args, args[0], tmp); gen_args += 2; @@ -729,7 +729,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(nor): if (temps[args[1]].state == TCG_TEMP_CONST && temps[args[2]].state == TCG_TEMP_CONST) { - gen_opc_buf[op_index] = op_to_movi(op); + s->gen_opc_buf[op_index] = op_to_movi(op); tmp = do_constant_folding(op, temps[args[1]].val, temps[args[2]].val); tcg_opt_gen_movi(gen_args, args[0], tmp); @@ -742,7 +742,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(deposit): if (temps[args[1]].state == TCG_TEMP_CONST && temps[args[2]].state == TCG_TEMP_CONST) { - gen_opc_buf[op_index] = op_to_movi(op); + s->gen_opc_buf[op_index] = op_to_movi(op); tmp = ((1ull << args[4]) - 1); tmp = (temps[args[1]].val & ~(tmp << args[3])) | ((temps[args[2]].val & tmp) << args[3]); @@ -756,7 +756,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, CASE_OP_32_64(setcond): tmp = do_constant_folding_cond(op, args[1], args[2], args[3]); if (tmp != 2) { - gen_opc_buf[op_index] = op_to_movi(op); + s->gen_opc_buf[op_index] = op_to_movi(op); tcg_opt_gen_movi(gen_args, args[0], tmp); gen_args += 2; args += 4; @@ -769,11 +769,11 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, if (tmp != 2) { if (tmp) { memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); - gen_opc_buf[op_index] = INDEX_op_br; + s->gen_opc_buf[op_index] = INDEX_op_br; gen_args[0] = args[3]; gen_args += 1; } else { - gen_opc_buf[op_index] = INDEX_op_nop; + s->gen_opc_buf[op_index] = INDEX_op_nop; } args += 4; break; @@ -784,13 +784,13 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, tmp = do_constant_folding_cond(op, args[1], args[2], args[5]); if (tmp != 2) { if (temps_are_copies(args[0], args[4-tmp])) { - gen_opc_buf[op_index] = INDEX_op_nop; + s->gen_opc_buf[op_index] = INDEX_op_nop; } else if (temps[args[4-tmp]].state == TCG_TEMP_CONST) { - gen_opc_buf[op_index] = op_to_movi(op); + s->gen_opc_buf[op_index] = op_to_movi(op); tcg_opt_gen_movi(gen_args, args[0], temps[args[4-tmp]].val); gen_args += 2; } else { - gen_opc_buf[op_index] = op_to_mov(op); + s->gen_opc_buf[op_index] = op_to_mov(op); tcg_opt_gen_mov(s, gen_args, args[0], args[4-tmp]); gen_args += 2; } @@ -820,12 +820,12 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, } /* We emit the extra nop when we emit the add2/sub2. */ - assert(gen_opc_buf[op_index + 1] == INDEX_op_nop); + assert(s->gen_opc_buf[op_index + 1] == INDEX_op_nop); rl = args[0]; rh = args[1]; - gen_opc_buf[op_index] = INDEX_op_movi_i32; - gen_opc_buf[++op_index] = INDEX_op_movi_i32; + s->gen_opc_buf[op_index] = INDEX_op_movi_i32; + s->gen_opc_buf[++op_index] = INDEX_op_movi_i32; tcg_opt_gen_movi(&gen_args[0], rl, (uint32_t)a); tcg_opt_gen_movi(&gen_args[2], rh, (uint32_t)(a >> 32)); gen_args += 4; @@ -843,12 +843,12 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, TCGArg rl, rh; /* We emit the extra nop when we emit the mulu2. */ - assert(gen_opc_buf[op_index + 1] == INDEX_op_nop); + assert(s->gen_opc_buf[op_index + 1] == INDEX_op_nop); rl = args[0]; rh = args[1]; - gen_opc_buf[op_index] = INDEX_op_movi_i32; - gen_opc_buf[++op_index] = INDEX_op_movi_i32; + s->gen_opc_buf[op_index] = INDEX_op_movi_i32; + s->gen_opc_buf[++op_index] = INDEX_op_movi_i32; tcg_opt_gen_movi(&gen_args[0], rl, (uint32_t)r); tcg_opt_gen_movi(&gen_args[2], rh, (uint32_t)(r >> 32)); gen_args += 4; @@ -862,11 +862,11 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, if (tmp != 2) { if (tmp) { memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); - gen_opc_buf[op_index] = INDEX_op_br; + s->gen_opc_buf[op_index] = INDEX_op_br; gen_args[0] = args[5]; gen_args += 1; } else { - gen_opc_buf[op_index] = INDEX_op_nop; + s->gen_opc_buf[op_index] = INDEX_op_nop; } } else if ((args[4] == TCG_COND_LT || args[4] == TCG_COND_GE) && temps[args[2]].state == TCG_TEMP_CONST @@ -876,7 +876,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info)); - gen_opc_buf[op_index] = INDEX_op_brcond_i32; + s->gen_opc_buf[op_index] = INDEX_op_brcond_i32; gen_args[0] = args[1]; gen_args[1] = args[3]; gen_args[2] = args[4]; @@ -891,7 +891,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, case INDEX_op_setcond2_i32: tmp = do_constant_folding_cond2(&args[1], &args[3], args[5]); if (tmp != 2) { - gen_opc_buf[op_index] = INDEX_op_movi_i32; + s->gen_opc_buf[op_index] = INDEX_op_movi_i32; tcg_opt_gen_movi(gen_args, args[0], tmp); gen_args += 2; } else if ((args[5] == TCG_COND_LT || args[5] == TCG_COND_GE) @@ -901,7 +901,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr, && temps[args[4]].val == 0) { /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ - gen_opc_buf[op_index] = INDEX_op_setcond_i32; + s->gen_opc_buf[op_index] = INDEX_op_setcond_i32; gen_args[0] = args[0]; gen_args[1] = args[2]; gen_args[2] = args[4]; diff --git a/tcg/tcg.c b/tcg/tcg.c index 2c8669b..c4e663b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -297,7 +297,7 @@ void tcg_func_start(TCGContext *s) s->goto_tb_issue_mask = 0; #endif - s->gen_opc_ptr = gen_opc_buf; + s->gen_opc_ptr = s->gen_opc_buf; s->gen_opparam_ptr = gen_opparam_buf; } @@ -884,7 +884,7 @@ void tcg_dump_ops(TCGContext *s) char buf[128]; first_insn = 1; - opc_ptr = gen_opc_buf; + opc_ptr = s->gen_opc_buf; args = gen_opparam_buf; while (opc_ptr < s->gen_opc_ptr) { c = *opc_ptr++; @@ -1222,7 +1222,7 @@ static void tcg_liveness_analysis(TCGContext *s) s->gen_opc_ptr++; /* skip end */ - nb_ops = s->gen_opc_ptr - gen_opc_buf; + nb_ops = s->gen_opc_ptr - s->gen_opc_buf; s->op_dead_args = tcg_malloc(nb_ops * sizeof(uint16_t)); @@ -1232,7 +1232,7 @@ static void tcg_liveness_analysis(TCGContext *s) args = s->gen_opparam_ptr; op_index = nb_ops - 1; while (op_index >= 0) { - op = gen_opc_buf[op_index]; + op = s->gen_opc_buf[op_index]; def = &tcg_op_defs[op]; switch(op) { case INDEX_op_call: @@ -1254,7 +1254,7 @@ static void tcg_liveness_analysis(TCGContext *s) if (!dead_temps[arg]) goto do_not_remove_call; } - tcg_set_nop(s, gen_opc_buf + op_index, + tcg_set_nop(s, s->gen_opc_buf + op_index, args - 1, nb_args); } else { do_not_remove_call: @@ -1323,11 +1323,11 @@ static void tcg_liveness_analysis(TCGContext *s) } else { op = INDEX_op_sub_i32; } - gen_opc_buf[op_index] = op; + s->gen_opc_buf[op_index] = op; args[1] = args[2]; args[2] = args[4]; - assert(gen_opc_buf[op_index + 1] == INDEX_op_nop); - tcg_set_nop(s, gen_opc_buf + op_index + 1, args + 3, 3); + assert(s->gen_opc_buf[op_index + 1] == INDEX_op_nop); + tcg_set_nop(s, s->gen_opc_buf + op_index + 1, args + 3, 3); /* Fall through and mark the single-word operation live. */ nb_iargs = 2; nb_oargs = 1; @@ -1343,11 +1343,11 @@ static void tcg_liveness_analysis(TCGContext *s) if (dead_temps[args[0]]) { goto do_remove; } - gen_opc_buf[op_index] = op = INDEX_op_mul_i32; + s->gen_opc_buf[op_index] = op = INDEX_op_mul_i32; args[1] = args[2]; args[2] = args[3]; - assert(gen_opc_buf[op_index + 1] == INDEX_op_nop); - tcg_set_nop(s, gen_opc_buf + op_index + 1, args + 3, 1); + assert(s->gen_opc_buf[op_index + 1] == INDEX_op_nop); + tcg_set_nop(s, s->gen_opc_buf + op_index + 1, args + 3, 1); /* Fall through and mark the single-word operation live. */ nb_oargs = 1; } @@ -1369,7 +1369,7 @@ static void tcg_liveness_analysis(TCGContext *s) goto do_not_remove; } do_remove: - tcg_set_nop(s, gen_opc_buf + op_index, args, def->nb_args); + tcg_set_nop(s, s->gen_opc_buf + op_index, args, def->nb_args); #ifdef CONFIG_PROFILER s->del_op_count++; #endif @@ -1417,7 +1417,7 @@ static void tcg_liveness_analysis(TCGContext *s) static void tcg_liveness_analysis(TCGContext *s) { int nb_ops; - nb_ops = s->gen_opc_ptr - gen_opc_buf; + nb_ops = s->gen_opc_ptr - s->gen_opc_buf; s->op_dead_args = tcg_malloc(nb_ops * sizeof(uint16_t)); memset(s->op_dead_args, 0, nb_ops * sizeof(uint16_t)); @@ -2135,7 +2135,7 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf, op_index = 0; for(;;) { - opc = gen_opc_buf[op_index]; + opc = s->gen_opc_buf[op_index]; #ifdef CONFIG_PROFILER tcg_table_op_count[opc]++; #endif @@ -2219,7 +2219,7 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf) #ifdef CONFIG_PROFILER { int n; - n = (s->gen_opc_ptr - gen_opc_buf); + n = (s->gen_opc_ptr - s->gen_opc_buf); s->op_count += n; if (n > s->op_count_max) s->op_count_max = n;