From patchwork Wed Sep 6 16:05:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111829 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1148747qge; Wed, 6 Sep 2017 09:29:51 -0700 (PDT) X-Received: by 10.55.10.76 with SMTP id 73mr4007760qkk.205.1504715391262; Wed, 06 Sep 2017 09:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504715391; cv=none; d=google.com; s=arc-20160816; b=flWCoCDNiVJGWQ+BV7jSG1+PtE34NpmEbLPMxIU4PdLfBwWQvI8jLNnFPofWrwG6TJ mxUuwgtiOtc/vhrF9VlEkhSmOUYfdEdDFe6ee2d3SY7Z6nuyhohTd83gvgG/+yVlI4mS KtSK1ACYc2ebQxoIM1/heMwNm09Gss0DQP/LTVfqsQuRujwdDk0zcr6qf4q0Qakp3nQv CwxrJFVfCIAUjOBWOZWqpTFWhZYpDidv+x67ILHVkkZwMz52cP9oIdwDbTUu023LNbOb 9A61pT4ziMxykmHpW+VcyGzvMEDAYGrDaypeBIuN6+E95YjX6gpQtwLLhp641htxJ2kl UOwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Nw/N7XFADUQ4cz+yLiuI9eEsEgwzSGmakMAgbO2x7d4=; b=kY60O0+hc8FYJTI73z6EfQt2uuchrVJrZOnt9M9ixr/EUpzWbcFAlvnDVpqA30QOMN IyfxLi4QU+triJ6lebCk+cS6C3ytxG0QkczSwXvJGnKCbjkDxHHYVHPtxKi0tgwYS8xx f0PUXJ26hHWgkGsZJfDedwhmGd8q/l0dFtOfxu5fqabvu9vxlTYqNli6M5z5/h28Thnf NTcNZObGtwT6TRnhqbPciSUT4ONmEKCcd+NGHDNNff2vn13H+3iDAErF8GQjQngMN3jZ NTWFXCCiFuU74nMzliaWVPzfXHGE3PpAEJiMsW2my7E0zNXBW5F7AIBfYJIeXc0aGFzf m89g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dceGHqUz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w42si267939qtb.136.2017.09.06.09.29.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 09:29:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dceGHqUz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpdD2-00030r-KP for patch@linaro.org; Wed, 06 Sep 2017 12:29:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqi-0000Hn-AN for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpcqb-0002Kd-RD for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:44 -0400 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:37872) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpcqb-0002Js-J7 for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:37 -0400 Received: by mail-pg0-x230.google.com with SMTP id d8so15975225pgt.4 for ; Wed, 06 Sep 2017 09:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nw/N7XFADUQ4cz+yLiuI9eEsEgwzSGmakMAgbO2x7d4=; b=dceGHqUzBwaApPXbAl744O7m8yyVGmmEYfK2tf+rMUxxpPdcb+5FnsmFY8N7hXJJX0 q2+4w7GkJvcfn2xBNwsnKaMOm+bAxKxqwvei4fjVs6zzUiQIyDrBFNfqMP/VoHiqROYP LdWVKt72UMSWjF2+cdIrYGZ+MyrNs7V0Wp7/0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nw/N7XFADUQ4cz+yLiuI9eEsEgwzSGmakMAgbO2x7d4=; b=jOhEh2UTSXqwwPkn4cDsrCd8s8e0sZo1aVK+oKkGfoH62JeOMrdaPz4Yv2GDAHGn4/ UNqXGS+0NvXmy1E7GxVUrgUYvSQ5g/fnuiYcbqqiGiXzmRluKYf26wbEzQC3J7u7/BLa MP1alCVZZJUflhiGUiTWWKKWMcKTnIuYqjMhv0VdeErafdqdDKJ4d8o2pqQSJs4ic26B GBVNzzmcb7V+vubJCMqHglM6gv6bIFe2R1AJ9BcMC5wp9woPT2YovpPxoxERz4p+DCCQ 8UzmhE79YSUpJ8YA3yIq875cVoj2dG0XpMR0YquCPITFA8G/v4trUEVzDdpvfWg2viyG hkiQ== X-Gm-Message-State: AHPjjUjxFm4UXLH4VIvA29p6JTZjo5wBp9Z6xBJd3jlIjx4XWxwOKRcG TGeItPcQqt0aQTgtY8gLrQ== X-Google-Smtp-Source: ADKCNb7se6GWoPC7BcS+c3voJXIa2sBFTmWaMXWzc7SuBAu1Wpu8Lja+0imVEea56CsIm27O62xDFw== X-Received: by 10.84.240.129 with SMTP id z1mr8836159plk.219.1504713996419; Wed, 06 Sep 2017 09:06:36 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-108-236.tukw.qwest.net. [97.126.108.236]) by smtp.gmail.com with ESMTPSA id t65sm262863pfk.59.2017.09.06.09.06.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 09:06:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 09:05:56 -0700 Message-Id: <20170906160612.22769-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170906160612.22769-1-richard.henderson@linaro.org> References: <20170906160612.22769-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::230 Subject: [Qemu-devel] [PULL 16/32] target/arm: [tcg] Port to init_disas_context X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?utf-8?q?Llu=C3=ADs_Vilanova?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Lluís Vilanova Incrementally paves the way towards using the generic instruction translation loop. Signed-off-by: Lluís Vilanova Reviewed-by: Richard Henderson Reviewed-by: Alex Benneé Message-Id: <150002316201.22386.12115078843605656029.stgit@frigg.lan> [rth: Adjust for max_insns interface change.] Signed-off-by: Richard Henderson --- target/arm/translate.c | 88 ++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 38 deletions(-) -- 2.13.5 diff --git a/target/arm/translate.c b/target/arm/translate.c index 4db8978a93..a95c183cee 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -11824,32 +11824,12 @@ static bool insn_crosses_page(CPUARMState *env, DisasContext *s) return false; } -/* generate intermediate code for basic block 'tb'. */ -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) +static int arm_tr_init_disas_context(DisasContextBase *dcbase, + CPUState *cs, int max_insns) { + DisasContext *dc = container_of(dcbase, DisasContext, base); CPUARMState *env = cs->env_ptr; ARMCPU *cpu = arm_env_get_cpu(env); - DisasContext dc1, *dc = &dc1; - target_ulong next_page_start; - int max_insns; - bool end_of_page; - - /* generate intermediate code */ - - /* The A64 decoder has its own top level loop, because it doesn't need - * the A32/T32 complexity to do with conditional execution/IT blocks/etc. - */ - if (ARM_TBFLAG_AARCH64_STATE(tb->flags)) { - gen_intermediate_code_a64(&dc->base, cs, tb); - return; - } - - dc->base.tb = tb; - dc->base.pc_first = tb->pc; - dc->base.pc_next = dc->base.pc_first; - dc->base.is_jmp = DISAS_NEXT; - dc->base.num_insns = 0; - dc->base.singlestep_enabled = cs->singlestep_enabled; dc->pc = dc->base.pc_first; dc->condjmp = 0; @@ -11860,23 +11840,23 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) */ dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3); - dc->thumb = ARM_TBFLAG_THUMB(tb->flags); - dc->sctlr_b = ARM_TBFLAG_SCTLR_B(tb->flags); - dc->be_data = ARM_TBFLAG_BE_DATA(tb->flags) ? MO_BE : MO_LE; - dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(tb->flags) & 0xf) << 1; - dc->condexec_cond = ARM_TBFLAG_CONDEXEC(tb->flags) >> 4; - dc->mmu_idx = core_to_arm_mmu_idx(env, ARM_TBFLAG_MMUIDX(tb->flags)); + dc->thumb = ARM_TBFLAG_THUMB(dc->base.tb->flags); + dc->sctlr_b = ARM_TBFLAG_SCTLR_B(dc->base.tb->flags); + dc->be_data = ARM_TBFLAG_BE_DATA(dc->base.tb->flags) ? MO_BE : MO_LE; + dc->condexec_mask = (ARM_TBFLAG_CONDEXEC(dc->base.tb->flags) & 0xf) << 1; + dc->condexec_cond = ARM_TBFLAG_CONDEXEC(dc->base.tb->flags) >> 4; + dc->mmu_idx = core_to_arm_mmu_idx(env, ARM_TBFLAG_MMUIDX(dc->base.tb->flags)); dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); #if !defined(CONFIG_USER_ONLY) dc->user = (dc->current_el == 0); #endif - dc->ns = ARM_TBFLAG_NS(tb->flags); - dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(tb->flags); - dc->vfp_enabled = ARM_TBFLAG_VFPEN(tb->flags); - dc->vec_len = ARM_TBFLAG_VECLEN(tb->flags); - dc->vec_stride = ARM_TBFLAG_VECSTRIDE(tb->flags); - dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(tb->flags); - dc->v7m_handler_mode = ARM_TBFLAG_HANDLER(tb->flags); + dc->ns = ARM_TBFLAG_NS(dc->base.tb->flags); + dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(dc->base.tb->flags); + dc->vfp_enabled = ARM_TBFLAG_VFPEN(dc->base.tb->flags); + dc->vec_len = ARM_TBFLAG_VECLEN(dc->base.tb->flags); + dc->vec_stride = ARM_TBFLAG_VECSTRIDE(dc->base.tb->flags); + dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(dc->base.tb->flags); + dc->v7m_handler_mode = ARM_TBFLAG_HANDLER(dc->base.tb->flags); dc->cp_regs = cpu->cp_regs; dc->features = env->features; @@ -11895,11 +11875,12 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) * emit code to generate a software step exception * end the TB */ - dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags); - dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags); + dc->ss_active = ARM_TBFLAG_SS_ACTIVE(dc->base.tb->flags); + dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(dc->base.tb->flags); dc->is_ldex = false; dc->ss_same_el = false; /* Can't be true since EL_d must be AArch64 */ + cpu_F0s = tcg_temp_new_i32(); cpu_F1s = tcg_temp_new_i32(); cpu_F0d = tcg_temp_new_i64(); @@ -11908,6 +11889,36 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) cpu_V1 = cpu_F1d; /* FIXME: cpu_M0 can probably be the same as cpu_V0. */ cpu_M0 = tcg_temp_new_i64(); + + return max_insns; +} + +/* generate intermediate code for basic block 'tb'. */ +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) +{ + CPUARMState *env = cs->env_ptr; + DisasContext dc1, *dc = &dc1; + target_ulong next_page_start; + int max_insns; + bool end_of_page; + + /* generate intermediate code */ + + /* The A64 decoder has its own top level loop, because it doesn't need + * the A32/T32 complexity to do with conditional execution/IT blocks/etc. + */ + if (ARM_TBFLAG_AARCH64_STATE(tb->flags)) { + gen_intermediate_code_a64(&dc->base, cs, tb); + return; + } + + dc->base.tb = tb; + dc->base.pc_first = dc->base.tb->pc; + dc->base.pc_next = dc->base.pc_first; + dc->base.is_jmp = DISAS_NEXT; + dc->base.num_insns = 0; + dc->base.singlestep_enabled = cs->singlestep_enabled; + next_page_start = (dc->base.pc_first & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { @@ -11916,6 +11927,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) if (max_insns > TCG_MAX_INSNS) { max_insns = TCG_MAX_INSNS; } + max_insns = arm_tr_init_disas_context(&dc->base, cs, max_insns); gen_tb_start(tb);