From nobody Wed Nov 5 18:19:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496681830794859.7034024071987; Mon, 5 Jun 2017 09:57:10 -0700 (PDT) Received: from localhost ([::1]:34374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHvJT-0007ll-57 for importer@patchew.org; Mon, 05 Jun 2017 12:57:07 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =20 #if TCG_TARGET_REG_BITS =3D=3D 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, TCGOpco= de opc, =20 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 =3D=3D 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, TCGOpco= de opc, } s->tb_jmp_reset_offset[a0] =3D 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, TCGOpcod= e opc, =20 static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) { + static const TCGTargetOpDef r =3D { .args_ct_str =3D { "r" } }; static const TCGTargetOpDef ri_r =3D { .args_ct_str =3D { "ri", "r" } = }; static const TCGTargetOpDef re_r =3D { .args_ct_str =3D { "re", "r" } = }; static const TCGTargetOpDef qi_r =3D { .args_ct_str =3D { "qi", "r" } = }; @@ -2299,6 +2309,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpc= ode op) =3D { .args_ct_str =3D { "L", "L", "L", "L" } }; =20 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 =20 + /* + * 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 =3D s->code_ptr; + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); + /* TB epilogue */ tb_ret_addr =3D s->code_ptr; =20 --=20 2.9.4