From nobody Wed Nov 5 16:36:51 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 1496987466995668.859122605451; Thu, 8 Jun 2017 22:51:06 -0700 (PDT) Received: from localhost ([::1]:52798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCp7-0001oF-P3 for importer@patchew.org; Fri, 09 Jun 2017 01:51:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJCc0-0006D7-7M for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:37:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJCbz-0001eC-Hd for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:37:32 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:35364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dJCbz-0001e6-DH for qemu-devel@nongnu.org; Fri, 09 Jun 2017 01:37:31 -0400 Received: by mail-qt0-x242.google.com with SMTP id x58so13035554qtc.2 for ; Thu, 08 Jun 2017 22:37:31 -0700 (PDT) Received: from bigtime.twiddle.net.com (97-113-165-157.tukw.qwest.net. [97.113.165.157]) by smtp.gmail.com with ESMTPSA id q41sm61161qtc.8.2017.06.08.22.37.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 22:37:29 -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=lLjU86hOuYj5usrE9MTf7p6U4d883mbdUoUP9fm2UWU=; b=qE/KzdWtIyTIFyCarywfULrVdv3V6H890ocZ5ULLjigaSDsQ/WjOZ9twXNRq3ORmqo EQknOkLGE8gUxQ83nDuTydKtUF25NkCCLK5twAzd3v4D1fkcEO1bY4O+W0ZhjyCdrNKk 5r0NeTLwcKDilk9Zjbahh3JujwS1+j/c27lH52kr6amq6xqdTEBvJrcbzIjphsuDf44i WhxPPnrzjLKuokyRSIG/oi683G+t/isuhcqaxNGVHWWCNTt/j4Fu+K4AzfAUNkRrEt2T hbbofwmis2B+djER6YD+6rSTRrVsuIzSdtHyaxWGw/e4kZhMUNb6hEa+enE2ypHAr4qy 8KCw== 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=lLjU86hOuYj5usrE9MTf7p6U4d883mbdUoUP9fm2UWU=; b=H08Cqc47sl2cK0lmuFvppTVwzk8RCzVmm8xwqTZ0/KLHjt6YrrSiDzAk3zp++I6nMB bzX9MyEKaNcXM/2NZTNtNVIdA/FucznXSUo69Ic3MGrf0cnwmM2+E1SYiUKCw6fcJZkz HSRZ9xSWcBGEwaOLTSY2ieYWKro6IfCc92ATaIHMdCmgaz/hvCBzdF4sxHa1wj1RaR7k YKcUmWBt8OIYZcGzHwY9at/0800IbgsgpIf3YNCrIkIYTuumR4PUVOfPpeMlKTT2+W3h jXOfWgLt7OaqmzwGnY7GlYhs6erYNIu2TqZdVAtCSxBdk2in22Ke5ay4LiH9b5dVLoCA 0hug== X-Gm-Message-State: AODbwcCFVt/SRZ9wg4gI8Xu2BGrgJ1PRjBLE7nq8nyvLfsvmbbgsawn4 Yy6jn4dUiY4ja6gQ9H8= X-Received: by 10.237.52.163 with SMTP id x32mr36985346qtd.188.1496986650317; Thu, 08 Jun 2017 22:37:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 8 Jun 2017 22:37:18 -0700 Message-Id: <20170609053719.26251-7-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609053719.26251-1-rth@twiddle.net> References: <20170609053719.26251-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] [PATCH v5 6/7] tcg/arm: Try pc-relative addresses for movi 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" Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.inc.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index fce382f..18708b1 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -418,25 +418,39 @@ static inline void tcg_out_dat_imm(TCGContext *s, =20 static void tcg_out_movi32(TCGContext *s, int cond, int rd, uint32_t arg) { - int rot, opc, rn; - - /* For armv7, make sure not to use movw+movt when mov/mvn would do. - Speed things up by only checking when movt would be required. - Prior to armv7, have one go at fully rotated immediates before - doing the decomposition thing below. */ - if (!use_armv7_instructions || (arg & 0xffff0000)) { - rot =3D encode_imm(arg); + int rot, opc, rn, diff; + + /* Check a single MOV/MVN before anything else. */ + rot =3D encode_imm(arg); + if (rot >=3D 0) { + tcg_out_dat_imm(s, cond, ARITH_MOV, rd, 0, + rotl(arg, rot) | (rot << 7)); + return; + } + rot =3D encode_imm(~arg); + if (rot >=3D 0) { + tcg_out_dat_imm(s, cond, ARITH_MVN, rd, 0, + rotl(~arg, rot) | (rot << 7)); + return; + } + + /* Check for a pc-relative address. This will usually be the TB, + or within the TB, which is immediately before the code block. */ + diff =3D arg - ((intptr_t)s->code_ptr + 8); + if (diff >=3D 0) { + rot =3D encode_imm(diff); if (rot >=3D 0) { - tcg_out_dat_imm(s, cond, ARITH_MOV, rd, 0, - rotl(arg, rot) | (rot << 7)); + tcg_out_dat_imm(s, cond, ARITH_ADD, rd, TCG_REG_PC, + rotl(diff, rot) | (rot << 7)); return; - } - rot =3D encode_imm(~arg); + } + } else { + rot =3D encode_imm(-diff); if (rot >=3D 0) { - tcg_out_dat_imm(s, cond, ARITH_MVN, rd, 0, - rotl(~arg, rot) | (rot << 7)); + tcg_out_dat_imm(s, cond, ARITH_SUB, rd, TCG_REG_PC, + rotl(-diff, rot) | (rot << 7)); return; - } + } } =20 /* Use movw + movt. */ --=20 2.9.4