From nobody Wed Nov 5 15:42:30 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 1497418136056226.76684575686772; Tue, 13 Jun 2017 22:28:56 -0700 (PDT) Received: from localhost ([::1]:46468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL0rO-00074p-NT for importer@patchew.org; Wed, 14 Jun 2017 01:28:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dL0m6-0001s0-N9 for qemu-devel@nongnu.org; Wed, 14 Jun 2017 01:23:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dL0m5-0007M2-S3 for qemu-devel@nongnu.org; Wed, 14 Jun 2017 01:23:26 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:35963) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dL0m5-0007Lu-O6 for qemu-devel@nongnu.org; Wed, 14 Jun 2017 01:23:25 -0400 Received: by mail-qt0-x244.google.com with SMTP id s33so39071479qtg.3 for ; Tue, 13 Jun 2017 22:23:25 -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 34sm10959480qtp.17.2017.06.13.22.23.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 22:23:24 -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=CR+HQBXWwwo3jOjl2EJ5uSCBnAkmH/RpZW4hX9VtpBc=; b=kwO1MbHibdijb16teI1ugH8Qsbs1pNxPv/Kdey4rgsekIiDrNilu+6kK9nzFMh0rj5 lEN4c/6qx/43Vqi3NaWuvALAifjCFXSv54ycvv38pAoUWMgNF9YXhbZ36BasrkxUUbLS HnLOI98wOcwLUTu5A4/tNbTULVjNLOWdVMf3WhSftmwlnarGs/P0H2XdJMx92lmBd+W5 JZFkqkumw02wQGTHHp1Enzo56STVUMv3P2LnSXRQouilRky7XUsiMtFVDbwabhEqzupj aFGwBJvU45nDeRsWLgDPSvheVGhAc33lN0cdRb14Rqm25HjUmvQmXqhskqcGQ5V8p+su AChQ== 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=CR+HQBXWwwo3jOjl2EJ5uSCBnAkmH/RpZW4hX9VtpBc=; b=YE/0XNkDzZslUUvgqdt07wxgAh4mxLzAEcA+Uwfpuo35AmxNewCZPboOJyEV8raugf pxQZrZdmDP6a5R9lZgRF07CM3roXOpJ4I6e8/ea4PqTtdmugkGuBYTIasHDfVPU4LU/Z j+bCHp9UP+DCx5U5D/ZfZpTrWqkscxNcg/iNY90IdQhtRh4XGuzEtHpgBTeMH0p7Yz50 6wU+IBS5DBaLFpVZU5bfkQ/bU269+tRdZ1eXiqU4yR2dhpiAjUp/mZdxTXbRbDWlt8q+ vUUIVuRACTJ4H2UnWyk3UcyCmPjcHKiPv2YXqPjC/2twg+rW/g4LFuehV6onMAYqWGEv no8w== X-Gm-Message-State: AKS2vOzVc6uBI+ioGxmB8Z5F7nV9YNxQ88gaE4LF3rrjJHH14ZXbx8Rd 0gtYbOiLwvRjozsMySY= X-Received: by 10.237.58.164 with SMTP id o33mr4549483qte.134.1497417805088; Tue, 13 Jun 2017 22:23:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 13 Jun 2017 22:23:08 -0700 Message-Id: <20170614052311.13785-8-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170614052311.13785-1-rth@twiddle.net> References: <20170614052311.13785-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::244 Subject: [Qemu-devel] [PULL 07/10] 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: peter.maydell@linaro.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 | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index fce382f..42370e5 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -418,23 +418,37 @@ 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 2.9.4