From patchwork Mon Jul 2 13:57:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 140754 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4035296ljj; Mon, 2 Jul 2018 07:02:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcRYxXsnei8rtK+q8fjgWucFa+jHGbw1o7j9i8Fp86WF6gnX99QFHOcy64Y19W7gE47gcoC X-Received: by 2002:ac8:2b23:: with SMTP id 32-v6mr13182196qtu.119.1530540173354; Mon, 02 Jul 2018 07:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530540173; cv=none; d=google.com; s=arc-20160816; b=Tb7sglNEmZxJrnl+28ytgxXE3H2/k7aLluQ3HKSljgXu7CKMejnHuaNuYTweAyb6VA Xij3XPBNUl5b/b1iR2UtUobKsYYLLQtqnmU3wdc+ZSIxzY1EQqWHVZJtb4jH4jgYWScn g2JPgPzFJLFFvGLMWwLNe/6abhXWtw+eMYOeHOqkiIOGDSkHy8dLV7DtsdN3zWZCEP6v 0MjQbs0Ypf6Ee/XQANHZSL7Jzc2m86r/oG3JnWxWI72RbAcP0TtBJD5FMTroP43PL6vH TXnt4Y+9vABNjW1W+d1Ru5Sg4gT029IwK+2FzEkKR2BhlZ2tHmyiWYwmVFWecSQpkchL 1uLQ== 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=BpXhKplcmVzaEgYPHqOAQOcTQDA7dzSkA3kbaZ3R+rw=; b=sypXHrhyeSaj8IJO4WrmyqOwLiagp0EVhUZnixJxJ0vycOT7nK/mv3NbkRWzL1aUJF h2sTEMvLbHo091+70A5ivLGhdsO9bwPLjfK5Csx8MRMMZYOn1hcD2QTMfkr0aMNJg1Wb zQwMZhbZWWSvBdxsw7l0/5XFEdhQef513w1rOpKcnIPBoHnAqxxNjSzkpRTbSx88TDZ/ 4FuBX4DEcCgSfFMqVnlhpyXVBxcmcl7s1cGkCqgdwD8R0vv+Q0cH604wCsBNroffEQTI sdklI8Zf6gHOmo5nbRClT+qUTgQ31p8clM9vUhytEVANy0C6PgRqIAQiARAfK3GfbHIS TB2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HWVkhi+g; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i58-v6si2935501qvi.285.2018.07.02.07.02.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 07:02:53 -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=@gmail.com header.s=20161025 header.b=HWVkhi+g; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:32955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZzPo-0004kV-Ix for patch@linaro.org; Mon, 02 Jul 2018 10:02:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZzLj-0002PO-FI for qemu-devel@nongnu.org; Mon, 02 Jul 2018 09:58:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZzLi-00087s-JE for qemu-devel@nongnu.org; Mon, 02 Jul 2018 09:58:39 -0400 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]:34258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZzLi-00087U-Ci for qemu-devel@nongnu.org; Mon, 02 Jul 2018 09:58:38 -0400 Received: by mail-pg0-x235.google.com with SMTP id y5-v6so917339pgv.1 for ; Mon, 02 Jul 2018 06:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BpXhKplcmVzaEgYPHqOAQOcTQDA7dzSkA3kbaZ3R+rw=; b=HWVkhi+gjzjSvhCXGmXJFkJm+KcQNENSN5bBy+uxpefgghCzcd1U429cgSsYicH3nh FcPVUsBL7U/C0t4ysxuTw+Geg4Y3XcmBjrTJKe70A9YlQpCOJmA3WBwS3mxwSxvwpatG 1yiRehuFP0J98bkzNYOCeSzLl02vMs9TLQtdsMxw/mU7ZD9dA4JsWNa5uezmVqUF6nBN f659WHFGguNUOY5GA0xHmOL8Dg3vaOqUHdQ6vzjKVzdmj/+XDkL56qAFRt1lMg9zb9t3 xCojKw5PWV04FcMM7zD5dmR/xtMDWVc+FuaZ61TiBxDOdF9QNYMZfXUP9l9PSaigYShU j7OA== 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=BpXhKplcmVzaEgYPHqOAQOcTQDA7dzSkA3kbaZ3R+rw=; b=QVxWszVP1CZcr+R28+p4VhAu2XCm9uC2NtdZiFZvHQZ/z09CGIrtV2MdMQVBYjvVDV CQrfVSAlpQX9ZNo2s78SYo6qjPdyV1TjycWQ3cYSNwXtQiF5F8Zb+90QDrN3CnV5n5pM F6Cs0IYJUwsi6dJ0dq0FlA8r83YkMOkam+u5noYe519luLcGsY/gopJdjuN2XscEiDau /lDQc1X6mB3tlplHe4dSNL73GvfOmZcYC9F5Wx1642ywYvVOzCtrfGiKQ4R103dCrXhY KlHYQ2tm+a68Gr/jMiGXC0+LpvOSbRCI3v/yQ3Gs4MVF5Y0pbfggtycjkPrtGCRCY/RJ 5s6A== X-Gm-Message-State: APt69E2dkoTEqi4Qg/yqQzAHh+Sv9byVT9U2UaTzeTGU3UG1Oqzoe5w+ Dz/xjGw06Fibidd/IHr/Frc= X-Received: by 2002:a65:4b0f:: with SMTP id r15-v6mr22245134pgq.103.1530539917411; Mon, 02 Jul 2018 06:58:37 -0700 (PDT) Received: from localhost (g90.124-44-6.ppp.wakwak.ne.jp. [124.44.6.90]) by smtp.gmail.com with ESMTPSA id h12-v6sm24012701pfi.114.2018.07.02.06.58.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 06:58:36 -0700 (PDT) From: Stafford Horne To: Peter Maydell Date: Mon, 2 Jul 2018 22:57:51 +0900 Message-Id: <20180702135806.7087-11-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180702135806.7087-1-shorne@gmail.com> References: <20180702135806.7087-1-shorne@gmail.com> 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::235 Subject: [Qemu-devel] [PULL 10/25] target/openrisc: Form the spr index from tcg 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: Stafford Horne , Richard Henderson , QEMU Development Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Rather than pass base+offset to the helper, pass the full index. In most cases the base is r0 and optimization yields a constant. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Stafford Horne --- target/openrisc/helper.h | 4 ++-- target/openrisc/sys_helper.c | 9 +++------ target/openrisc/translate.c | 16 +++++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) -- 2.17.0 diff --git a/target/openrisc/helper.h b/target/openrisc/helper.h index e37dabc77a..9db9bf3963 100644 --- a/target/openrisc/helper.h +++ b/target/openrisc/helper.h @@ -56,5 +56,5 @@ FOP_CMP(le) DEF_HELPER_FLAGS_1(rfe, 0, void, env) /* sys */ -DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) -DEF_HELPER_FLAGS_4(mfspr, TCG_CALL_NO_WG, tl, env, tl, tl, tl) +DEF_HELPER_FLAGS_3(mtspr, 0, void, env, tl, tl) +DEF_HELPER_FLAGS_3(mfspr, TCG_CALL_NO_WG, tl, env, tl, tl) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 2f337363ec..2c959f63f4 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -27,13 +27,11 @@ #define TO_SPR(group, number) (((group) << 11) + (number)) -void HELPER(mtspr)(CPUOpenRISCState *env, - target_ulong ra, target_ulong rb, target_ulong offset) +void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) { #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); - int spr = (ra | offset); int idx; switch (spr) { @@ -202,13 +200,12 @@ void HELPER(mtspr)(CPUOpenRISCState *env, #endif } -target_ulong HELPER(mfspr)(CPUOpenRISCState *env, - target_ulong rd, target_ulong ra, uint32_t offset) +target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, + target_ulong spr) { #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); - int spr = (ra | offset); int idx; switch (spr) { diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 59605aacca..64b5e84630 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -865,9 +865,10 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a, uint32_t insn) if (is_user(dc)) { gen_illegal_exception(dc); } else { - TCGv_i32 ti = tcg_const_i32(a->k); - gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], ti); - tcg_temp_free_i32(ti); + TCGv spr = tcg_temp_new(); + tcg_gen_ori_tl(spr, cpu_R[a->a], a->k); + gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], spr); + tcg_temp_free(spr); } return true; } @@ -877,7 +878,7 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) if (is_user(dc)) { gen_illegal_exception(dc); } else { - TCGv_i32 ti; + TCGv spr; /* For SR, we will need to exit the TB to recognize the new * exception state. For NPC, in theory this counts as a branch @@ -892,9 +893,10 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) } dc->base.is_jmp = DISAS_EXIT; - ti = tcg_const_i32(a->k); - gen_helper_mtspr(cpu_env, cpu_R[a->a], cpu_R[a->b], ti); - tcg_temp_free_i32(ti); + spr = tcg_temp_new(); + tcg_gen_ori_tl(spr, cpu_R[a->a], a->k); + gen_helper_mtspr(cpu_env, spr, cpu_R[a->b]); + tcg_temp_free(spr); } return true; }