From patchwork Thu Feb 14 22:59:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10813973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5094613A4 for ; Thu, 14 Feb 2019 23:17:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D8642F3FE for ; Thu, 14 Feb 2019 23:17:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 320E82F40A; Thu, 14 Feb 2019 23:17:16 +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=-2.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 748542F3FE for ; Thu, 14 Feb 2019 23:17:14 +0000 (UTC) Received: from localhost ([127.0.0.1]:56526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guQFl-0007x4-Lo for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Feb 2019 18:17:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guQ8u-00034j-0w for qemu-devel@nongnu.org; Thu, 14 Feb 2019 18:10:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1guQ05-00055L-NW for qemu-devel@nongnu.org; Thu, 14 Feb 2019 18:01:03 -0500 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:33464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1guQ05-00052p-DM for qemu-devel@nongnu.org; Thu, 14 Feb 2019 18:01:01 -0500 Received: by mail-lf1-x136.google.com with SMTP id q12so5834625lfm.0 for ; Thu, 14 Feb 2019 15:00:59 -0800 (PST) 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; bh=8AYLej++XvBy1SibnXvhyZvu53iD0ixJlNMXGnRIq/Q=; b=rF0V2MmfKCBpNw6r3fellc3zDlc9qezOgHmL9mm3x0U4vNov292oV5EZ4zDO1NZWoi pIw1YfrhFzuWzUh0zSUYIQVveekBzJ8ug5EKTTXFTNJ1JKeXUX+qC6tvdrnDR/ueXrdp E2UAagvOdt6dMXZ4A1bGI6fJYBgF68rLZqxCk/SMmRGV9+/BdTh3arv1AurbrwtOMhvH 3kQvrs6vLh7k105W6Ux9w81lJwy4uTQU38Doy+BQaVQA+AalOa4bmHb5ysTuYKlMNian vAU7jn5zfOrZBeMp0+7TSGLr+PDv7a3B4o6T9ms4iR8JLUJvfmlELvz/BB79eD54gPF8 nexg== 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; bh=8AYLej++XvBy1SibnXvhyZvu53iD0ixJlNMXGnRIq/Q=; b=BZ2rfN/9GnY4ni2Gl/6dYBfXz5gZregZo+DKdAwZYX0rC/NNuLFpmPQ8p8Apb55kDA M9zJ2OooZM0OaYFfBp2UcNXj1qKutXDDkhPyyWxvWzpzYeteLHXw5arrLURRCrS0rFxr R2ATwIKa/MNM9bZ8DVtbQsrVi+104CqVck+ysCK6F3lmLjskOwROby9mw/5amkBqTmug 4U/RmY1F6tp7NbAh9S0dMQXqyIkrCNOtrjYBJAF15kaUIZRk/XFxp+OrYWQa7aui1ruu cS0ibusiwCqfSmwEacTa/gQ7jlns/IXV0vJJ3lQ0zWSNyNTb+eKlA3orJklcr/O4Y57K Kokg== X-Gm-Message-State: AHQUAuYXchNq+ghW78WwefmtYmyx5OsBNOUyDCChRqYfSHqSykRDcK5Q CANvQWWuFQhPztX4YHNGVwlGIsRyXlQ= X-Google-Smtp-Source: AHgI3IalB6G8i7lVNTA3bKLcJjZduIJxtR0schlH7+PWbX3ADY7gUcvRU9Dnv7P6h9skaJ9d8RAERA== X-Received: by 2002:ac2:51bc:: with SMTP id f28mr3992667lfk.123.1550185258038; Thu, 14 Feb 2019 15:00:58 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id h123sm172384lfh.26.2019.02.14.15.00.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 15:00:57 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Thu, 14 Feb 2019 14:59:55 -0800 Message-Id: <20190214230000.24894-9-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190214230000.24894-1-jcmvbkbc@gmail.com> References: <20190214230000.24894-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::136 Subject: [Qemu-devel] [PATCH 08/13] target/xtensa: only rotate window in the retw helper 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: Max Filippov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Move return address calculation and WINDOW_START adjustment out of the retw helper to simplify logic a bit and avoid using registers directly. Pass a0 as a parameter to the helper. Signed-off-by: Max Filippov --- target/xtensa/helper.h | 2 +- target/xtensa/translate.c | 9 +++++++-- target/xtensa/win_helper.c | 8 ++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/target/xtensa/helper.h b/target/xtensa/helper.h index b6529a8925f3..0b9ec670c86e 100644 --- a/target/xtensa/helper.h +++ b/target/xtensa/helper.h @@ -7,7 +7,7 @@ DEF_HELPER_1(sync_windowbase, void, env) DEF_HELPER_4(entry, void, env, i32, i32, i32) DEF_HELPER_2(test_ill_retw, void, env, i32) DEF_HELPER_2(test_underflow_retw, void, env, i32) -DEF_HELPER_2(retw, i32, env, i32) +DEF_HELPER_2(retw, void, env, i32) DEF_HELPER_3(window_check, noreturn, env, i32, i32) DEF_HELPER_1(restore_owb, void, env) DEF_HELPER_2(movsp, void, env, i32) diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 0213cef1b605..f991cc360889 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -2226,8 +2226,13 @@ static bool test_ill_retw(DisasContext *dc, const uint32_t arg[], static void translate_retw(DisasContext *dc, const uint32_t arg[], const uint32_t par[]) { - TCGv_i32 tmp = tcg_const_i32(dc->pc); - gen_helper_retw(tmp, cpu_env, tmp); + TCGv_i32 tmp = tcg_const_i32(1); + tcg_gen_shl_i32(tmp, tmp, cpu_SR[WINDOW_BASE]); + tcg_gen_andc_i32(cpu_SR[WINDOW_START], + cpu_SR[WINDOW_START], tmp); + tcg_gen_movi_i32(tmp, dc->pc); + tcg_gen_deposit_i32(tmp, tmp, cpu_R[0], 0, 30); + gen_helper_retw(cpu_env, cpu_R[0]); gen_jump(dc, tmp); tcg_temp_free(tmp); } diff --git a/target/xtensa/win_helper.c b/target/xtensa/win_helper.c index d7a4e2782186..f6f96a64c30e 100644 --- a/target/xtensa/win_helper.c +++ b/target/xtensa/win_helper.c @@ -184,15 +184,11 @@ void HELPER(test_underflow_retw)(CPUXtensaState *env, uint32_t pc) } } -uint32_t HELPER(retw)(CPUXtensaState *env, uint32_t pc) +void HELPER(retw)(CPUXtensaState *env, uint32_t a0) { - int n = (env->regs[0] >> 30) & 0x3; - uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env); - uint32_t ret_pc = (pc & 0xc0000000) | (env->regs[0] & 0x3fffffff); + int n = (a0 >> 30) & 0x3; xtensa_rotate_window(env, -n); - env->sregs[WINDOW_START] &= ~windowstart_bit(windowbase, env); - return ret_pc; } void xtensa_restore_owb(CPUXtensaState *env)