From nobody Wed Nov 5 17:38:11 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 1496851360339290.46692387353653; Wed, 7 Jun 2017 09:02:40 -0700 (PDT) Received: from localhost ([::1]:44854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIdPo-0006FM-F5 for importer@patchew.org; Wed, 07 Jun 2017 12:02:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIdJU-0000i3-8s for qemu-devel@nongnu.org; Wed, 07 Jun 2017 11:56:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIdJT-0005dh-2Z for qemu-devel@nongnu.org; Wed, 07 Jun 2017 11:56:04 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:33167) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIdJS-0005dc-Qm for qemu-devel@nongnu.org; Wed, 07 Jun 2017 11:56:02 -0400 Received: by mail-qt0-x241.google.com with SMTP id w1so1993363qtg.0 for ; Wed, 07 Jun 2017 08:56:02 -0700 (PDT) Received: from bigtime.twiddle.net.com (184-217-116-168.pools.spcsdns.net. [184.217.116.168]) by smtp.gmail.com with ESMTPSA id i28sm1272525qta.52.2017.06.07.08.56.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 08:56:01 -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=Qn7zigQ4JePj4rS0z86bLZLfsreZec2whGKz5dT27XxqGYYo/3CR+2cAZ4pB3tTnAF xtctjv5jL3cQoqwJMR8FF5vop8fZ+7MCZYOt5R3BMhqwSJxssm8LPUExlkgKGMIrdUwU lW3hubOZodruXOB/uxTfliw5wpz43QCQbhSkOt3DiIbgmqSGg4xlBq9ER2jZSZGC7aC1 3vlN0WUIrEP/51DAlev9+i2BMFcCR79hOwLr8YhKIOXy7dqLxeWSwX+cQSNEaJbnrjnf lLpgN0HAJgBplgxOvNq5H117/78/eN6ZSbDXiY7/5f2mQaOCumANfb7ZztCi5ZU2whji UuJw== 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=ITCOfsNHQBv7UWuea9+s2EYaKeG0lhbR5cdU8p6rQVueDUVSz0nE0ppvtNNGZRn0cn kgC72E7qtBedDKqSs4n7GOBSGXkI3lj+tY9wuhcE90VQ3InU5eqmuVvKyznDhwvxaFWt duauTt4UBZ9Z9OTSMZM/lqNhT2MLH7yJGDhsVLc6che/ilyFNMp7jyniiqoGN1EDfP+n fqHROLslq56tuoyklR+9Lah/p2o6N9jKnKeyg6nhFuoEAz2ZlXaSvVrRKUdiTzeOpK29 XxjTSRNtO91nYlWwYsgWIcDUzujEtpzRbBtER30yVZtxlykcoFhzg5jAn2HZlTKhM+Fr 2Crw== X-Gm-Message-State: AODbwcBAmIpNiURvURRRpAHx8JplTsaHxyYCMlfLfTRw5O4dtXMIM8Tn WhAIg/7gGI7nsDW0YvY= X-Received: by 10.200.45.35 with SMTP id n32mr10540127qta.15.1496850961954; Wed, 07 Jun 2017 08:56:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 7 Jun 2017 08:55:35 -0700 Message-Id: <20170607155536.1193-7-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170607155536.1193-1-rth@twiddle.net> References: <20170607155536.1193-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::241 Subject: [Qemu-devel] [PATCH v4 6/7] target/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