From patchwork Fri Jun 30 00:40:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 9818205 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 0278A603F2 for ; Fri, 30 Jun 2017 00:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E365928511 for ; Fri, 30 Jun 2017 00:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D80D72851A; Fri, 30 Jun 2017 00:42:20 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 55FE828517 for ; Fri, 30 Jun 2017 00:42:19 +0000 (UTC) Received: from localhost ([::1]:41835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQk0o-0001gM-Jk for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Jun 2017 20:42:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQjzd-0001fI-PC for qemu-devel@nongnu.org; Thu, 29 Jun 2017 20:41:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQjzb-0006HU-Op for qemu-devel@nongnu.org; Thu, 29 Jun 2017 20:41:05 -0400 Received: from mail-yw0-x243.google.com ([2607:f8b0:4002:c05::243]:35314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dQjzb-0006HG-KL for qemu-devel@nongnu.org; Thu, 29 Jun 2017 20:41:03 -0400 Received: by mail-yw0-x243.google.com with SMTP id z21so5860675ywz.2 for ; Thu, 29 Jun 2017 17:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YlYU+r9CZ1WfbLrR+FNjtel3zIeloCgLnxvEOP/FaLk=; b=kiu3CNSSfjy/sMCnmGX6KC0/Pe6y/+TBe/UGky9ls5cWHXPSLTcibcKxDSyGhTXDKN 2u/BYMhpdHxznz70BQ38t8KZnZ2+h79sStRXL0kH4OKv7rxaRzH7Ddyr2uGUffh9fdMj L0EtxEL3mN+ole+RLt59DgMhjTbuPZDJiIn2kOGazfXniwRSUpDJh6d8k6Q1rQPcpVYx /ga+sdLvwMHAWDJdgWzr1WBj0qcG0Pd0ckt0TtC/CiGiwM4t9GmF3TIBRRHDHBK0x1O1 AXcGolaLWCRmIK0C3bq7BtJmMEyj2IVb2++I0M/JH+u2w5YVFxaZJ5J2Gl6dGlaEageX Rk/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YlYU+r9CZ1WfbLrR+FNjtel3zIeloCgLnxvEOP/FaLk=; b=dFBMkYJNXygy8j2aEcsh7hEZAGe5CZhYpRyhCL2xDZJjsX1SwG87hVY8geX9MkvkTs I5F+yM7ffu0cOuzy1V4w59OxY9J6BAzZX6HvtxTVHtMY74Cljhcn7y9hQpOHXIjZNHQK +EpVZDaLsHH9oBSzE+9nOI1sKDFu2WZXgz7KTeDUZs5WqhOCrjEKww3wJ5o/C06Ch3/Q kGsdBFSP/nq974uftpUcdb4UJ3dl2HXXLehuB3CrsqQxCEySj94VGKTNG5HpaPDq876i EEFNRQ/z/RMiKM+K1W519elfC6fUH+rxcyoXs2wJHr/7k/waeRrpL3h+dDRnIzanDAN7 7VGA== X-Gm-Message-State: AKS2vOzapFr0ZGBwQm2LhNsowthCXnq7y7bwX/JihMvqOYL8K68tITVb Ft+aVR+OlZ3Kqx8uTXI= X-Received: by 10.129.163.136 with SMTP id a130mr2694481ywh.266.1498783263082; Thu, 29 Jun 2017 17:41:03 -0700 (PDT) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id s29sm2914542ywa.45.2017.06.29.17.41.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 17:41:02 -0700 (PDT) From: Pranith Kumar To: alex.bennee@linaro.org Date: Thu, 29 Jun 2017 20:40:57 -0400 Message-Id: <20170630004059.25619-2-bobby.prani@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170630004059.25619-1-bobby.prani@gmail.com> References: <20170630004059.25619-1-bobby.prani@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c05::243 Subject: [Qemu-devel] [PATCH v3 1/3] tcg/aarch64: Introduce and use long branch to register 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: qemu-devel@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We can use a branch to register instruction for exit_tb for offsets greater than 128MB. CC: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Pranith Kumar --- tcg/aarch64/tcg-target.inc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 1fa3bccc89..8fce11ace7 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -819,6 +819,17 @@ static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) tcg_out_insn(s, 3206, B, offset); } +static inline void tcg_out_goto_long(TCGContext *s, tcg_insn_unit *target) +{ + ptrdiff_t offset = target - s->code_ptr; + if (offset == sextract64(offset, 0, 26)) { + tcg_out_insn(s, 3206, BL, offset); + } else { + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (intptr_t)target); + tcg_out_insn(s, 3207, BR, TCG_REG_TMP); + } +} + static inline void tcg_out_goto_noaddr(TCGContext *s) { /* We pay attention here to not modify the branch target by reading from @@ -1364,10 +1375,10 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_exit_tb: /* Reuse the zeroing that exists for goto_ptr. */ if (a0 == 0) { - tcg_out_goto(s, s->code_gen_epilogue); + tcg_out_goto_long(s, s->code_gen_epilogue); } else { tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_X0, a0); - tcg_out_goto(s, tb_ret_addr); + tcg_out_goto_long(s, tb_ret_addr); } break;