From nobody Wed Feb 11 04:36:28 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.zohomail.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 15048246415041022.0177901318519; Thu, 7 Sep 2017 15:50:41 -0700 (PDT) Received: from localhost ([::1]:42552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq5dA-0002V9-Dj for importer@patchew.org; Thu, 07 Sep 2017 18:50:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq5U6-00038Q-EK for qemu-devel@nongnu.org; Thu, 07 Sep 2017 18:41:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq5U1-0008Fv-Ea for qemu-devel@nongnu.org; Thu, 07 Sep 2017 18:41:18 -0400 Received: from mail-pg0-x229.google.com ([2607:f8b0:400e:c05::229]:34449) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dq5U1-0008FE-8L for qemu-devel@nongnu.org; Thu, 07 Sep 2017 18:41:13 -0400 Received: by mail-pg0-x229.google.com with SMTP id q68so1823968pgq.1 for ; Thu, 07 Sep 2017 15:41:13 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-108-236.tukw.qwest.net. [97.126.108.236]) by smtp.gmail.com with ESMTPSA id h19sm770678pfh.142.2017.09.07.15.41.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 15:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GyID29fvgFconnX4hc2+M1A5fpECok1c1ASb0Yls7AI=; b=c+eSWtgplQVb6y3VMQpZFHgivuI4nvnIPHf5QqNy3vA7mu4nxgpHE0pl4m2OBXOgkV qwDDgCiNKlugaHpyKbo0u3ckP7r7wRnIo3aIfLWctzJuqfhjC2WmTwQNiVHgeqh2Ea9l j3eVaBXjbtbg8J64tpXxzDtdMx5MeXsqVl1KI= 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; bh=GyID29fvgFconnX4hc2+M1A5fpECok1c1ASb0Yls7AI=; b=oc2b/Yt/xkohOl/yDyT24fozPYzC9cLfyj8pT+EYf4iyet5sKq6l8KoyN1aUr8qqwq F0M7+peShrWKC9MnK5jpP4pBjaTlFTnhRJgdnVVJU3RrUGE7kHhcKaFc8ViAFEh7eRl0 VCauHU/7FKIwBLV+tdgN0GS8q3FZjFqIWqjGIIKfOngQm/uo06h/jyNelZbQ3vhucJ85 W13YsRuP+e2451wrsIwKcxyeT7yDZfylrOLFMzowT6RyEvue0Fy3sanh8UZtqiQiXose xlOEhuv8uLbpUmTP00tn/Kf2mxicZstXvqBY91xbRXYrSvoWxiK/yT0MnSIJ2xd60B2n 6/Ag== X-Gm-Message-State: AHPjjUjiUG/BHyj5hF/AU2F7J0DSQC41w/RMw2fU1wYIhboliG+5rGfC zPX3i0htCo9UIZBjjCHEjA== X-Google-Smtp-Source: ADKCNb5RiOrZUxD6zNRfOR586hfFn8TuLhutQEKM4FlS1Zfl3w91fJT3WtNB9laBGV5BIOs39QXpYA== X-Received: by 10.99.171.73 with SMTP id k9mr962353pgp.196.1504824071887; Thu, 07 Sep 2017 15:41:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 15:40:40 -0700 Message-Id: <20170907224051.21518-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170907224051.21518-1-richard.henderson@linaro.org> References: <20170907224051.21518-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::229 Subject: [Qemu-devel] [PULL 12/23] tcg/aarch64: Use constant pool 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, Richard Henderson 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" From: Richard Henderson Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 1 + tcg/aarch64/tcg-target.inc.c | 62 +++++++++++++++++++++++-----------------= ---- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 1bdbd7058b..c2525066ab 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -125,5 +125,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t); #ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS #endif +#define TCG_TARGET_NEED_POOL_LABELS =20 #endif /* AARCH64_TCG_TARGET_H */ diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index c7c751bafc..c2f3812214 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -10,6 +10,7 @@ * See the COPYING file in the top-level directory for details. */ =20 +#include "tcg-pool.inc.c" #include "qemu/bitops.h" =20 /* We're going to re-use TCGType in setting of the SF bit, which controls @@ -587,9 +588,11 @@ static void tcg_out_logicali(TCGContext *s, AArch64Ins= n insn, TCGType ext, static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, tcg_target_long value) { - int i, wantinv, shift; tcg_target_long svalue =3D value; tcg_target_long ivalue =3D ~value; + tcg_target_long t0, t1, t2; + int s0, s1; + AArch64Insn opc; =20 /* For 32-bit values, discard potential garbage in value. For 64-bit values within [2**31, 2**32-1], we can create smaller sequences by @@ -638,38 +641,29 @@ static void tcg_out_movi(TCGContext *s, TCGType type,= TCGReg rd, } } =20 - /* Would it take fewer insns to begin with MOVN? For the value and its - inverse, count the number of 16-bit lanes that are 0. */ - for (i =3D wantinv =3D 0; i < 64; i +=3D 16) { - tcg_target_long mask =3D 0xffffull << i; - wantinv -=3D ((value & mask) =3D=3D 0); - wantinv +=3D ((ivalue & mask) =3D=3D 0); - } - - if (wantinv <=3D 0) { - /* Find the lowest lane that is not 0x0000. */ - shift =3D ctz64(value) & (63 & -16); - tcg_out_insn(s, 3405, MOVZ, type, rd, value >> shift, shift); - /* Clear out the lane that we just set. */ - value &=3D ~(0xffffUL << shift); - /* Iterate until all non-zero lanes have been processed. */ - while (value) { - shift =3D ctz64(value) & (63 & -16); - tcg_out_insn(s, 3405, MOVK, type, rd, value >> shift, shift); - value &=3D ~(0xffffUL << shift); - } + /* Would it take fewer insns to begin with MOVN? */ + if (ctpop64(value) >=3D 32) { + t0 =3D ivalue; + opc =3D I3405_MOVN; } else { - /* Like above, but with the inverted value and MOVN to start. */ - shift =3D ctz64(ivalue) & (63 & -16); - tcg_out_insn(s, 3405, MOVN, type, rd, ivalue >> shift, shift); - ivalue &=3D ~(0xffffUL << shift); - while (ivalue) { - shift =3D ctz64(ivalue) & (63 & -16); - /* Provide MOVK with the non-inverted value. */ - tcg_out_insn(s, 3405, MOVK, type, rd, ~(ivalue >> shift), shif= t); - ivalue &=3D ~(0xffffUL << shift); + t0 =3D value; + opc =3D I3405_MOVZ; + } + s0 =3D ctz64(t0) & (63 & -16); + t1 =3D t0 & ~(0xffffUL << s0); + s1 =3D ctz64(t1) & (63 & -16); + t2 =3D t1 & ~(0xffffUL << s1); + if (t2 =3D=3D 0) { + tcg_out_insn_3405(s, opc, type, rd, t0 >> s0, s0); + if (t1 !=3D 0) { + tcg_out_insn(s, 3405, MOVK, type, rd, value >> s1, s1); } + return; } + + /* For more than 2 insns, dump it into the constant pool. */ + new_pool_label(s, value, R_AARCH64_CONDBR19, s->code_ptr, 0); + tcg_out_insn(s, 3305, LDR, 0, rd); } =20 /* Define something more legible for general use. */ @@ -2030,6 +2024,14 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_insn(s, 3207, RET, TCG_REG_LR); } =20 +static void tcg_out_nop_fill(tcg_insn_unit *p, int count) +{ + int i; + for (i =3D 0; i < count; ++i) { + p[i] =3D NOP; + } +} + typedef struct { DebugFrameHeader h; uint8_t fde_def_cfa[4]; --=20 2.13.5