From nobody Fri Dec 19 20:11:14 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 1493753101391628.9985429191182; Tue, 2 May 2017 12:25:01 -0700 (PDT) Received: from localhost ([::1]:33282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5dPv-0003CS-Su for importer@patchew.org; Tue, 02 May 2017 15:25:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5dOE-0001fh-17 for qemu-devel@nongnu.org; Tue, 02 May 2017 15:23:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5dOD-0001Wx-29 for qemu-devel@nongnu.org; Tue, 02 May 2017 15:23:14 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:32957) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d5dOC-0001Wb-TR for qemu-devel@nongnu.org; Tue, 02 May 2017 15:23:12 -0400 Received: by mail-qk0-x244.google.com with SMTP id o85so22940158qkh.0 for ; Tue, 02 May 2017 12:23:12 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2602:47:d954:1500:5e51:4fff:fe40:9c64]) by smtp.gmail.com with ESMTPSA id d65sm10664657qkc.53.2017.05.02.12.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 May 2017 12:23:11 -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=/7RPKOrF4upE4pTU8vz1GzObama5Ca73v1djSLCpa2s=; b=LQ5qHjKsBOUi7BGBbynzNEst5lhoiTQkKCqXUGrsNOcU0ZYZA0juDSmIiFVFz1NWzy vl4PvqI/gcxb4FHilNKu/Mt+2kTLi7BB7+6vZRmnT1c7kOr7Xzsdp2QOn+w5LdKRizwG LHiAnXnE/Go36dLHCHfBYdmINwKFtAJU7Pzn53X4YrlaJnaBl6uYCjz+lWvHgFlp8r0s zN/ihuO4XGcIAcBUWU/U9nFre7/Pw9nwe+y/9iB0yTbPWubm5oNafPiLBTzQ/eo+iSaU ahfjBvQ2RTqBA50npV9oAOg7eThFEMNQnfRSrRQDNPGOXZTesMuKF0X5L/oIEtu4f7SB e54g== 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=/7RPKOrF4upE4pTU8vz1GzObama5Ca73v1djSLCpa2s=; b=Y4TXuj49wDyhfAt9HHqec95ztJ+odegsFFVgbTBGcTPTYJUZJeWvxjs2HxrulMoRiY IQmQY4tO+HMAYDRiJtDyfUlxUu1a1miht45OopNueYkwgapmp39b9Vo9C8HlCGUWXeFh 25aVaHfXUinmnYGu1sAMJaYMT2x8TIdq9mPuLVRP/raki6VcmQ4ioQgayLYfT4+gHitc vzZRGC6ZyL7sel51JebPo3JXqt9KbKpOZF9BpMyoVxxeMeCoKaggYQfq8eT7MJlwy9X0 M2K4Tb4fRHvozpL71ghJgAGPNDbhFUnDoeKpy1hVfhQTaNOQDzItmxVOjlYy4LzBh5KC fg4A== X-Gm-Message-State: AN3rC/6S0u8E5MsH4G8tSJCFxkR+y0A2h083G7wIO4ZBqhLwgkvJ6/GW AU4B5SdGTd0N6w== X-Received: by 10.233.239.65 with SMTP id d62mr12758327qkg.119.1493752992373; Tue, 02 May 2017 12:23:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 2 May 2017 12:22:40 -0700 Message-Id: <20170502192300.2124-6-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170502192300.2124-1-rth@twiddle.net> References: <20170502192300.2124-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [PATCH v6 05/25] 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: cota@braap.org 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.3