From patchwork Mon Jun 5 16:52:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9766897 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 A55FE6034B for ; Mon, 5 Jun 2017 16:56:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 962F127E5A for ; Mon, 5 Jun 2017 16:56:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B16827F8F; Mon, 5 Jun 2017 16:56:40 +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 F139F27E5A for ; Mon, 5 Jun 2017 16:56:39 +0000 (UTC) Received: from localhost ([::1]:34369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHvJ1-0006dx-2d for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Jun 2017 12:56:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHvFH-0004CC-1u for qemu-devel@nongnu.org; Mon, 05 Jun 2017 12:52:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHvFF-0003f6-MA for qemu-devel@nongnu.org; Mon, 05 Jun 2017 12:52:46 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:34320) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dHvFF-0003e7-HZ for qemu-devel@nongnu.org; Mon, 05 Jun 2017 12:52:45 -0400 Received: by mail-qt0-x242.google.com with SMTP id o21so13465089qtb.1 for ; Mon, 05 Jun 2017 09:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=boxfsC7ARA0+SRhHiBno4csgRRpSxyfGIe88V5j6QfY=; b=lDf+mnEOjEVycYC/0BfEgC369awzUukbpbRyaGu6GAN2wURZLE75squ/TliNG5PCT3 ZrOpdIPZ2EtGR2Qx7NQ74RHiCroNycJEnoGzcx7WMiV4eDu1LmQnaHyApR3N4Z74Wclt K4IKNNiCjkdxG9LXwGBy9ArAOBdvi5rKI4/B/fGjXZAlHQ4nMcF8du5NtLAK77YaUt7a gUUMgWRNdmLfPbngvgEFZivr9JRQWWjs+RSbUNVLMCuN77uV2A0H1wAbbkSjieZEfEaz GvjRMOkpGJ2BWTX393cicjpyQNdXjHt2i1/1p8MtAKHjuJEWjztsWxiciW5trm8GX9Xa lRiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=boxfsC7ARA0+SRhHiBno4csgRRpSxyfGIe88V5j6QfY=; b=NDo7a9vKV3y2eKUcj4vYlU9/EsOaG2Q2xHQtZIgxm81EGtHxxvpHc6e3ae7nEAGEk3 t8FMdoWlPUNmV9MPbV4J/gNwKwN220JnQ1A+KmLo2DU1XmuOKTVcnMKw7zdHD7v/mL4M Iv/QGONi7q0n2jPFUiesbLPfrCDoy4XjFF26GvvlnVWtYXsLBfb8+HvAUDM+lV0QL+5W aJ7geaWauR2y39wdmNr3hhCj1vgX+CBE5tqwPJXEbxJ6UYdKZfkn/ZLHsTR2cr0NP/gH bZ+3XtYouohSU7TfF/hWZoE55wXFOgxVt4wyPW9DLZLw5V9X3wCp5WuWspKBgO5C5b2g ojyQ== X-Gm-Message-State: AODbwcAuZlttnEFw7KpjxzLR+HYxxEnlX+MYVds5qArXwtWoAlFmgL8T CtWzjs+xa4YqnHDZ2Ic= X-Received: by 10.55.6.18 with SMTP id 18mr22817650qkg.179.1496681564786; Mon, 05 Jun 2017 09:52:44 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2602:47:d954:1500:5e51:4fff:fe40:9c64]) by smtp.gmail.com with ESMTPSA id c6sm1637044qtb.56.2017.06.05.09.52.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Jun 2017 09:52:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 5 Jun 2017 09:52:12 -0700 Message-Id: <20170605165233.4135-6-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170605165233.4135-1-rth@twiddle.net> References: <20170605165233.4135-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PULL 05/26] tcg/i386: implement goto_ptr 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, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Emilio G. Cota" Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Message-Id: <1493263764-18657-6-git-send-email-cota@braap.org> [rth: Reuse goto_ptr epilogue for exit_tb 0.] Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.inc.c | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 59d9835..73a15f7 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -107,7 +107,7 @@ extern bool have_popcnt; #define TCG_TARGET_HAS_muls2_i32 1 #define TCG_TARGET_HAS_muluh_i32 0 #define TCG_TARGET_HAS_mulsh_i32 0 -#define TCG_TARGET_HAS_goto_ptr 0 +#define TCG_TARGET_HAS_goto_ptr 1 #if TCG_TARGET_REG_BITS == 64 #define TCG_TARGET_HAS_extrl_i64_i32 0 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 5918008..01e3b4e 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -1882,8 +1882,13 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, switch (opc) { case INDEX_op_exit_tb: - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_EAX, a0); - tcg_out_jmp(s, tb_ret_addr); + /* Reuse the zeroing that exists for goto_ptr. */ + if (a0 == 0) { + tcg_out_jmp(s, s->code_gen_epilogue); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_EAX, a0); + tcg_out_jmp(s, tb_ret_addr); + } break; case INDEX_op_goto_tb: if (s->tb_jmp_insn_offset) { @@ -1906,6 +1911,10 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, } s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s); break; + case INDEX_op_goto_ptr: + /* jmp to the given host address (could be epilogue) */ + tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, a0); + break; case INDEX_op_br: tcg_out_jxx(s, JCC_JMP, arg_label(a0), 0); break; @@ -2277,6 +2286,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) { + static const TCGTargetOpDef r = { .args_ct_str = { "r" } }; static const TCGTargetOpDef ri_r = { .args_ct_str = { "ri", "r" } }; static const TCGTargetOpDef re_r = { .args_ct_str = { "re", "r" } }; static const TCGTargetOpDef qi_r = { .args_ct_str = { "qi", "r" } }; @@ -2299,6 +2309,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) = { .args_ct_str = { "L", "L", "L", "L" } }; switch (op) { + case INDEX_op_goto_ptr: + return &r; + case INDEX_op_ld8u_i32: case INDEX_op_ld8u_i64: case INDEX_op_ld8s_i32: @@ -2567,6 +2580,13 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, tcg_target_call_iarg_regs[1]); #endif + /* + * Return path for goto_ptr. Set return value to 0, a-la exit_tb, + * and fall through to the rest of the epilogue. + */ + s->code_gen_epilogue = s->code_ptr; + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); + /* TB epilogue */ tb_ret_addr = s->code_ptr;