From nobody Mon Feb 9 09:34:50 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; 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 1493294844443333.42126109520586; Thu, 27 Apr 2017 05:07:24 -0700 (PDT) Received: from localhost ([::1]:60262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3iCe-0001B6-SB for importer@patchew.org; Thu, 27 Apr 2017 08:07:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3i5w-0003wp-Pq for qemu-devel@nongnu.org; Thu, 27 Apr 2017 08:00:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3i5v-0001SY-Oh for qemu-devel@nongnu.org; Thu, 27 Apr 2017 08:00:24 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:36485) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d3i5v-0001S5-I9 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 08:00:23 -0400 Received: by mail-wr0-x244.google.com with SMTP id v42so3520993wrc.3 for ; Thu, 27 Apr 2017 05:00:23 -0700 (PDT) Received: from bigtime.twiddle.net.com (251.red-80-29-7.adsl.static.ccgg.telefonica.net. [80.29.7.251]) by smtp.gmail.com with ESMTPSA id i199sm3056470wmf.33.2017.04.27.05.00.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Apr 2017 05:00:21 -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 :mime-version:content-transfer-encoding; bh=qqWlenhi9EeITH22lpF4gb12BwSiD8zOnLr7vHkHRt0=; b=mFPLEiTEPPade2u1LuKY76H77ovXa8nC9MtkdNYdmxbD9uZsU0UNxGh5H1Jsiszs52 g5qrIJP0By7jtwUoZI2FCocV6dLcOCfR7tYUbLkeuGYO/GvKgblCGmCK9SEsbn5TGu6h 2KPumhKZlywkVFMKFo1kI06aIXxCdZ8TW3Uf1BrYDMMNKZHF/oOnr+woLtPR2gm1RV1A Dx/U5+eI5Da6tsCs6Wj4pzn7YtJyIkB4dKCDVXnEcZEbQNLT/7PRYW5tmVfbQsYtkeRr YxmhXIzC9iAxSpAWr/i938g62AGgOQ3nOhkW8UQ2BsiVuQ+vk1LAXcL0mIrOprbZi/tm XM9w== 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:mime-version:content-transfer-encoding; bh=qqWlenhi9EeITH22lpF4gb12BwSiD8zOnLr7vHkHRt0=; b=GOl876uFM2xfTDWvtxSJird3uA88coWR1X74CO9i8zHEb2gX/OalV65/vwKZLcMgQq RE+yV4bnG0eNa6yDsu3ZrQmQzf+O/vZ+RZNAdEPW72Y6Bs7QSaLpMhbw1nBIShpp3NPX WKkyaxu2xfLKvlo6Ny6jxOTO13mdZNUy2D6SJ786b3ITs4OXGJU4f5mLN+wg45PLo4c2 iUJ/HtiPxCCIFgFioXCi8+aA2ffGSIsdyfsvK9QcJknLpxKZ+ehgEF48EHApa8+hxMm1 tvtRJ7nigZkfPU+TrvUey5IU08CJzHj9d4FLB9T8eZxm9M+M4+NaZVtkKxJLqnMQnLgL oXGg== X-Gm-Message-State: AN3rC/4SmStdfyw2cRd1Ln/GDd9GqBsGrSKILUceFI2zwE5CUTcqVHs5 0Lt3g05sBIlhUtSJYXg= X-Received: by 10.223.164.81 with SMTP id e17mr3191890wra.133.1493294422117; Thu, 27 Apr 2017 05:00:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 13:59:54 +0200 Message-Id: <20170427120006.20564-8-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170427120006.20564-1-rth@twiddle.net> References: <20170427120006.20564-1-rth@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH v5 07/19] 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: 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 From: "Emilio G. Cota" 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. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Message-Id: <1493263764-18657-5-git-send-email-cota@braap.org> Signed-off-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 6b1f415..660dac9 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.9.3