From patchwork Thu Jun 2 05:57:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9149117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 17F0060467 for ; Thu, 2 Jun 2016 05:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F18C32654B for ; Thu, 2 Jun 2016 05:58:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E646426B39; Thu, 2 Jun 2016 05:58:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 291042654B for ; Thu, 2 Jun 2016 05:58:35 +0000 (UTC) Received: from localhost ([::1]:45334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8LeM-0004M7-7h for patchwork-qemu-devel@patchwork.kernel.org; Thu, 02 Jun 2016 01:58:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Ldp-0004KB-0z for qemu-devel@nongnu.org; Thu, 02 Jun 2016 01:58:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8Ldm-00036X-T1 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 01:57:59 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:33528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Ldm-00036T-Nb for qemu-devel@nongnu.org; Thu, 02 Jun 2016 01:57:58 -0400 Received: by mail-qk0-x242.google.com with SMTP id q184so4325908qkf.0 for ; Wed, 01 Jun 2016 22:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=6u7DokbpMVQNrIby/7pXC/bTrKas2jsp5+Gzw121YtE=; b=tOUKvquSQCjgTjShl2bhXRcgjf8+3ufk/PBxbxls0dZqWSCQpzhq7J7N96X7aCpBrd lTeG02TzsJFw6lq65FORtmcZlIatVC/AG4TBOz87Wy677TcxT6/8x6nASuJN6TXRnwWv vG6npJ+e6IJkNdG0K4wBcc9QM2HruATqdpLaobdq4auE7cAaxIpM76j6xOuBoBfa/LSo 3a4yGu5bj4tle2Ehdi0i041cK+Dkiey+HgFzwoZK+SL5r0lw4wnk+xWr5EF6ofzHA2yg crOi2zy0ozzCoTGwcVv2SDMrHcUD1V+CiMkjBAD+k7TGKSE2PORgGVEAsp0/TCkVfV0j 8aBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=6u7DokbpMVQNrIby/7pXC/bTrKas2jsp5+Gzw121YtE=; b=mem2g8MUQeuYeiC0M3pjUN846ax0wjRNVql1jy8CLCYGHgLN7F1krWL7Bna6lCQpz4 /7aZmOE4RlW/VXTWGnVw7czn3qwQU2Os+dT+amdOENnLeIRf1FTQKRpcC9Fi8AaGLHb+ r/Xwvagtk/E8RPTYlmY8JrFRHZHB1X83WJt5W7bq1VAuzmytzYSrVOL7KgGn1kCMsKDA NJ3sDiScmYvU50dHOYIQdLQmKCnwSYieRQOTFfZsmQv3FvjSykXEneTMW4Do5vwmO4Xb 3LdxbIumhTucoy+hW7R2kAm5Uy3SC6NX54AHtWG0DTBwxYaq3iqspUlTwXE2i7X+H2Wa jTbA== X-Gm-Message-State: ALyK8tIk622uyLJiyc6t4ZoSp0iO/zUDkgxkxD+3cdjxgGkWrRhNgQIWzVXNHSffZSOuig== X-Received: by 10.55.82.195 with SMTP id g186mr42870954qkb.47.1464847078199; Wed, 01 Jun 2016 22:57:58 -0700 (PDT) Received: from anchor.com (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id b10sm11631835qta.3.2016.06.01.22.57.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jun 2016 22:57:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 1 Jun 2016 22:57:02 -0700 Message-Id: <1464847040-22536-7-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464847040-22536-1-git-send-email-rth@twiddle.net> References: <1464847040-22536-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH v3 06/24] target-sparc: Store %asi in TB flags 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: mark.cave-ayland@ilande.co.uk, atar4qemu@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Knowing the value of %asi at translation time means that we can handle the common settings without a function call. The steady state appears to be %asi == ASI_P, so that sparcv9 code can use offset forms of lda/sta. The %asi register gets pushed and popped on entry to certain functions, but it rarely takes on values other than ASI_P or ASI_AIUP. Therefore we're unlikely to be expanding the set of TBs created. Signed-off-by: Richard Henderson --- target-sparc/cpu.h | 2 ++ target-sparc/translate.c | 29 ++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 31ea65b..653517b 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -723,6 +723,7 @@ trap_state* cpu_tsptr(CPUSPARCState* env); #define TB_FLAG_MMU_MASK 7 #define TB_FLAG_FPU_ENABLED (1 << 4) #define TB_FLAG_AM_ENABLED (1 << 5) +#define TB_FLAG_ASI_SHIFT 24 static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) @@ -740,6 +741,7 @@ static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, target_ulong *pc, && (env->fprs & FPRS_FEF)) { flags |= TB_FLAG_FPU_ENABLED; } + flags |= env->asi << TB_FLAG_ASI_SHIFT; #else if ((env->def->features & CPU_FEATURE_FLOAT) && env->psref) { flags |= TB_FLAG_FPU_ENABLED; diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 7d5d2fe..cea839c 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -53,7 +53,7 @@ static TCGv cpu_tbr; #endif static TCGv cpu_cond; #ifdef TARGET_SPARC64 -static TCGv_i32 cpu_xcc, cpu_asi, cpu_fprs; +static TCGv_i32 cpu_xcc, cpu_fprs; static TCGv cpu_gsr; static TCGv cpu_tick_cmpr, cpu_stick_cmpr, cpu_hstick_cmpr; static TCGv cpu_hintp, cpu_htba, cpu_hver, cpu_ssr, cpu_ver; @@ -81,6 +81,9 @@ typedef struct DisasContext { TCGv ttl[5]; int n_t32; int n_ttl; +#ifdef TARGET_SPARC64 + int asi; +#endif } DisasContext; typedef struct { @@ -1975,19 +1978,19 @@ static inline void gen_ne_fop_QD(DisasContext *dc, int rd, int rs, #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) static TCGv_i32 gen_get_asi(DisasContext *dc, int insn) { - TCGv_i32 r_asi = tcg_temp_new_i32(); + int asi; if (IS_IMM) { #ifdef TARGET_SPARC64 - tcg_gen_mov_i32(r_asi, cpu_asi); + asi = dc->asi; #else gen_exception(dc, TT_ILL_INSN); - tcg_gen_movi_i32(r_asi, 0); + asi = 0; #endif } else { - tcg_gen_movi_i32(r_asi, GET_FIELD(insn, 19, 26)); + asi = GET_FIELD(insn, 19, 26); } - return r_asi; + return tcg_const_i32(asi); } static void gen_ld_asi(DisasContext *dc, TCGv dst, TCGv addr, @@ -2688,7 +2691,7 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) gen_store_gpr(dc, rd, cpu_dst); break; case 0x3: /* V9 rdasi */ - tcg_gen_ext_i32_tl(cpu_dst, cpu_asi); + tcg_gen_movi_tl(cpu_dst, dc->asi); gen_store_gpr(dc, rd, cpu_dst); break; case 0x4: /* V9 rdtick */ @@ -3614,7 +3617,13 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) case 0x3: /* V9 wrasi */ tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2); tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0xff); - tcg_gen_trunc_tl_i32(cpu_asi, cpu_tmp0); + tcg_gen_st32_tl(cpu_tmp0, cpu_env, + offsetof(CPUSPARCState, asi)); + /* End TB to notice changed ASI. */ + save_state(dc); + gen_op_next_insn(); + tcg_gen_exit_tb(0); + dc->is_br = 1; break; case 0x6: /* V9 wrfprs */ tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2); @@ -5192,6 +5201,9 @@ void gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb) dc->fpu_enabled = tb_fpu_enabled(tb->flags); dc->address_mask_32bit = tb_am_enabled(tb->flags); dc->singlestep = (cs->singlestep_enabled || singlestep); +#ifdef TARGET_SPARC64 + dc->asi = (tb->flags >> TB_FLAG_ASI_SHIFT) & 0xff; +#endif num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; @@ -5300,7 +5312,6 @@ void gen_intermediate_code_init(CPUSPARCState *env) static const struct { TCGv_i32 *ptr; int off; const char *name; } r32[] = { #ifdef TARGET_SPARC64 { &cpu_xcc, offsetof(CPUSPARCState, xcc), "xcc" }, - { &cpu_asi, offsetof(CPUSPARCState, asi), "asi" }, { &cpu_fprs, offsetof(CPUSPARCState, fprs), "fprs" }, #else { &cpu_wim, offsetof(CPUSPARCState, wim), "wim" },