From nobody Mon Feb 9 11:32:58 2026 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; 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 1493187971423215.31212062299858; Tue, 25 Apr 2017 23:26:11 -0700 (PDT) Received: from localhost ([::1]:52885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3GOu-0002Qr-QT for importer@patchew.org; Wed, 26 Apr 2017 02:26:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3GMT-0000dv-IL for qemu-devel@nongnu.org; Wed, 26 Apr 2017 02:23:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3GMS-0000PJ-GX for qemu-devel@nongnu.org; Wed, 26 Apr 2017 02:23:37 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:44035) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3GMN-0000JZ-FO; Wed, 26 Apr 2017 02:23:31 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2D79821C9F; Wed, 26 Apr 2017 02:23:31 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 02:23:31 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id BD2A67E0A4; Wed, 26 Apr 2017 02:23:30 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=cqt 4P12yd8eMB0Cc/rCpxhrES6uXYFxJNF0pVOpZJPM=; b=pHisjKcvWn+t3OYLGmj c6HuyTC/nPIP59cQpLU/04MInudjWksAtccZNbk8hMm7H7Q3vIDz6nOxUHnGZHCr nV+c34/Gh/UIj1nBMUfqL8Rz6BWCi0cZ5C8qaWR26nitBjYnhiPd2rq4S0HWwkOO 64P7qjzWJmPFrSzpg59cUhdE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=cqt4P12yd8eMB0Cc/rCpxhrES6uXYFxJNF0pVOpZJ PM=; b=qFzFupocXj3GqAs2E1Wgm6EntaAJ3GzqCDaURgjiP29gYf37Uoos/n96/ +IQcstgt4mVxuMhjJ8xIL0z9QiTYf0x20++0UgvZpTMjQewoGbsb2l6DlCDJIYNJ Xmph1NyVX/jVYMEn1qe/gop5o1eVP82la0pFmaMs6Puq+UzrhOI4h8bN7fjGDJv5 Rl4BSRkkwQeuf2W82uLQiJQj0R3U+kmmajR82AMNjj3htuSJBRCzEZh8FN2jp1ZL d1c4gOn/5wi7tyTehYbd2EZ8SW9Dd97Gpvpvk20NiFvWxkfiXeIkefakfHYkayXk P7s4Uabzio08g8RQxMfk4aCByNomw== X-ME-Sender: X-Sasl-enc: Se0nGs1zfgbQMVqH2YMcbnkOWoRYLQKgCXwdP7MdiM1v 1493187810 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 02:23:16 -0400 Message-Id: <1493187803-4510-4-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493187803-4510-1-git-send-email-cota@braap.org> References: <1493187803-4510-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v3 03/10] tcg: export tcg_gen_lookup_and_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 , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of exporting goto_ptr directly to TCG frontends, export tcg_gen_lookup_and_goto_ptr(), which calls goto_ptr with the pointer returned by the lookup_tb_ptr() helper. This is the only use case we have for goto_ptr and lookup_tb_ptr, so having this function is very convenient. Furthermore, it trivially allows us to avoid calling the lookup helper if goto_ptr is not implemented by the backend. Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- tcg/README | 8 ++++++++ tcg/tcg-op.c | 13 +++++++++++++ tcg/tcg-op.h | 11 +++++++++++ 3 files changed, 32 insertions(+) diff --git a/tcg/README b/tcg/README index a9858c2..bf49e82 100644 --- a/tcg/README +++ b/tcg/README @@ -477,6 +477,14 @@ current TB was linked to this TB. Otherwise execute th= e next instructions. Only indices 0 and 1 are valid and tcg_gen_goto_tb may be is= sued at most once with each slot index per TB. =20 +* lookup_and_goto_ptr tb_addr + +Look up a TB address ('tb_addr') and jump to it if valid. If not valid, +jump to the TCG epilogue to go back to the exec loop. + +This operation is optional. If the TCG backend does not implement the +goto_ptr opcode, emitting this op is equivalent to emitting exit_tb(0). + * qemu_ld_i32/i64 t0, t1, flags, memidx * qemu_st_i32/i64 t0, t1, flags, memidx =20 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 95a39b7..8ff1eaf 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2587,6 +2587,19 @@ void tcg_gen_goto_tb(unsigned idx) tcg_gen_op1i(INDEX_op_goto_tb, idx); } =20 +void tcg_gen_lookup_and_goto_ptr(TCGv addr) +{ + if (TCG_TARGET_HAS_goto_ptr) { + TCGv_ptr ptr =3D tcg_temp_new_ptr(); + + gen_helper_lookup_tb_ptr(ptr, tcg_ctx.tcg_env, addr); + tcg_gen_op1i(INDEX_op_goto_ptr, GET_TCGV_PTR(ptr)); + tcg_temp_free_ptr(ptr); + } else { + tcg_gen_exit_tb(0); + } +} + static inline TCGMemOp tcg_canonicalize_memop(TCGMemOp op, bool is64, bool= st) { /* Trigger the asserts within as early as possible. */ diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index c68e300..5d3278f 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -796,6 +796,17 @@ static inline void tcg_gen_exit_tb(uintptr_t val) */ void tcg_gen_goto_tb(unsigned idx); =20 +/** + * tcg_gen_lookup_and_goto_ptr() - look up a TB and jump to it if valid + * @addr: Guest address of the target TB + * + * If the TB is not valid, jump to the epilogue. + * + * This operation is optional. If the TCG backend does not implement goto_= ptr, + * this op is equivalent to calling tcg_gen_exit_tb() with 0 as the argume= nt. + */ +void tcg_gen_lookup_and_goto_ptr(TCGv addr); + #if TARGET_LONG_BITS =3D=3D 32 #define tcg_temp_new() tcg_temp_new_i32() #define tcg_global_reg_new tcg_global_reg_new_i32 --=20 2.7.4