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: 10501469 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 A5DFB6028F for ; Mon, 2 Jul 2018 14:01:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 924C928A86 for ; Mon, 2 Jul 2018 14:01:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8492228AB7; Mon, 2 Jul 2018 14:01:20 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 5CB5028A86 for ; Mon, 2 Jul 2018 14:01:19 +0000 (UTC) Received: from localhost ([::1]:32955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZzOI-0004kV-JK for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 Jul 2018 10:01:18 -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-Google-Smtp-Source: ADUXVKK9J/q7uif6LMt22ALdd/DqIpSY9acP8poj+xu8CvjoxnaScvkhN9+PWljUH8pMroX80iw/tA== 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; }