From nobody Tue Feb 10 04:12:55 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 1501826066819783.2377626604307; Thu, 3 Aug 2017 22:54:26 -0700 (PDT) Received: from localhost ([::1]:36695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddVZ3-000405-2J for importer@patchew.org; Fri, 04 Aug 2017 01:54:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddVPe-0003yO-Al for qemu-devel@nongnu.org; Fri, 04 Aug 2017 01:44:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddVPc-0003Pl-RX for qemu-devel@nongnu.org; Fri, 04 Aug 2017 01:44:42 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:34288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ddVPc-0003O9-Lv for qemu-devel@nongnu.org; Fri, 04 Aug 2017 01:44:40 -0400 Received: by mail-pg0-x244.google.com with SMTP id y192so836729pgd.1 for ; Thu, 03 Aug 2017 22:44:40 -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 o14sm1061063pfi.158.2017.08.03.22.44.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Aug 2017 22:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=vLeKdneB1QC0NshN929RWsqX3Q88g5E4JPnA7bVKopk=; b=GICkTc3fpxraf5jl2rnvnaseWW8JdVvVX2tWuC6/nQ3no7YwWVZtZGRdgTnmDQ6ahE 5FtSfeciCcFRm6JSBdIn4QqAx3K8CL7EgRbawo43Uhxke1u6rJSzo7BwzXDpQH663zLH vSvfnxSCfVNYe3HIzejHa3BLwJ0A2NWA9WhfuOpnnEcsdPAWLdGe8JEEqjAvmYV0CzcQ yIKO4bi+Eb0gHko7enGjnSNdb5wYcB1a646UrLVJLhA/e9nRXqb5Hu6iJ1527mqBngcC AgjpSzHc69ZRAgcH0t8QqA9Ot0lucodATw+GTaSX8726qL+QcXk8rbFZQAtYlKBjL/Dm pWDQ== 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:subject:date:message-id :in-reply-to:references; bh=vLeKdneB1QC0NshN929RWsqX3Q88g5E4JPnA7bVKopk=; b=gEVyY926shueVxUtQYDh5d+GqDwjK0P5B9JT5TIr9B8kUFbRN8K1djc8eJCSNuYXxg OYJ+tD6mQkH8m+rk32GmLkrDXxJicZjglNzRzb1yAZWyMALAmxqxpKd9F5HKBeX7U1xh BWCnlBIcXPM23o1NQlVQAB+kmvqSkemhuCSTYm/nAc7GJWv013bfH/cjKWntkfQ7ohAC uG8OrpRmN4jooP3M7y6KCGR7JxTfRPdrKgL6nGk0Ab3myDd/si/fA5XzwQYLKQsQf5Jd EX71RV0EDFZmpkzZmxwfxD0wVc3xUodNKM+CsG0+Edf44ENI50M3N45BA2DAo50YWWOX X3ew== X-Gm-Message-State: AIVw113RV6gjFRPFLsLWxhCdEVd1gcvAV5VoXPULSKb2uYib3TaEhBsI cXnNlmyukuoXfUFes0M= X-Received: by 10.98.217.210 with SMTP id b79mr1193397pfl.297.1501825479375; Thu, 03 Aug 2017 22:44:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 3 Aug 2017 22:44:15 -0700 Message-Id: <20170804054426.10590-13-rth@twiddle.net> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170804054426.10590-1-rth@twiddle.net> References: <20170804054426.10590-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH for-2.11 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: , 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/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 484cf6236c..e86c2684fb 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -123,5 +123,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.3