From patchwork Tue Aug 15 19:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 713796 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1968132wrp; Tue, 15 Aug 2023 12:58:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOuXOs3DQpP+3EXUXucA5ka+kYcFp+pgUtIPB/6t3v1jDG/y7h+SX/Ls9MXAfzuCIOtXGJ X-Received: by 2002:a05:6102:2e6:b0:443:8b27:6dac with SMTP id j6-20020a05610202e600b004438b276dacmr13708416vsj.9.1692129528628; Tue, 15 Aug 2023 12:58:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692129528; cv=none; d=google.com; s=arc-20160816; b=X6T8lhrEGpizgDjj7qhiKX3ua3uKXnTcA4REtiKaAErrpM5gjsoKGkLZVZxj9AruGr C0nNrwDme29iXvEisUrnXomaGd8zN81tRqVdQ+Xoc/Lh6+MxG2J36AMv/CIVMJHH2MFH BYjzSVzEnyOHoeSLRsjeLWdQTdTNoJxNhz6h8Nz932WxUGsLwl0h7JOU5BZ34IuBZnkb qHbOBxEAN0IlsBe1QIAVqQwd4zfcfITTIQhhGt7UWuUjWKpoS9m4BeyFodIzRjVvT9zR anqaBz0L8U7GH8QWnwwZMl41h6OVid7LQFu7Nc2hSZYjs/TPu1qIMGPcpVHp1ymVty1j uXmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NqBKPmbTeyzbaEOoqwFakyRjcnv8k/gpOjB7jfp4teM=; fh=1LlI9qg4dDC6jzYzk4mr2RaPQDh8MKMNLXu5CCRW41Q=; b=fG2a1INHJiLPciWIaYO605hl3SLmO5XkPG21zDk3wkaG2+MnTx6RcbbjeLAr/Yzymk JZ9BtPh9q7toobWW1UsuLRUNgvZwslIChdNT49G7YOiE2bT1Ughd06zixd7kMhPUUKsI ai/d9Fd+Oec+Kiu7Fth6hbF9KGvckUFi03P3lZwyJwbHMylWGKa7cQIrFn/515DNGLAX oc39BCYVZFEE9XJ5fcQV7QHII6ySEqrHkxjmdFddMBh2NfivKB3tGu0xR/hILZvgzZ8y Vxz+6JX7270XMc8bVLhDVAvbMmnsIJDBE8NZOfakJTlPPX99diIS/24ybSl8ax1SsOXo 7ueA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iph7fDMS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a25-20020a0cb359000000b0062596e0fb72si7581302qvf.121.2023.08.15.12.58.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Aug 2023 12:58:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iph7fDMS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qW0Aw-0005A8-LJ; Tue, 15 Aug 2023 15:57:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qW0Av-00059B-5e for qemu-devel@nongnu.org; Tue, 15 Aug 2023 15:57:57 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qW0As-00015Y-Hp for qemu-devel@nongnu.org; Tue, 15 Aug 2023 15:57:56 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6887059f121so586573b3a.3 for ; Tue, 15 Aug 2023 12:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692129473; x=1692734273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NqBKPmbTeyzbaEOoqwFakyRjcnv8k/gpOjB7jfp4teM=; b=Iph7fDMSyC3A81kverLqvoj0p1sM6GHXO+KQgSLyJzG5NGNdsTj/tIgS1vg2lycEaU VNC5jzIKPkpSuUonn+zIG1LC9rNVS3zwh082eCRRyBBZcetZ2JwLq1TFSW37acAoIL5G zJSzve5W70Gd8B1uqp80DEM4bNhO4AXCPHwoCOg0ZmUlZaZriXOE4uqw33T97Et0Isg7 7YsvhnP5YDi4Rln01YwzH0JJEgEeIRwrHZIG0gxSioK3Wl9BUpN+eELt13BRUuXu7e/W dssDLh0LaX4hvxIt3NI3xTPQ0D7Mq6ylECbQDkS11Q6MI+F+8yGmM2ILX1lHhSMFalK7 b6dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692129473; x=1692734273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NqBKPmbTeyzbaEOoqwFakyRjcnv8k/gpOjB7jfp4teM=; b=eAsSGICywoJLCVIsYw8HcpR3X4jsjOy2PPkdaBXdi+P7e8fE+rNC4disqiK0evgReR e3Myb3fg5oBKswAdL2VyRq8tUAGFipDHkTwolTnmvP5UUjBjs1gWDAo5e3Lgg3XyxeI4 AaO19JQJwiPKSWcgcCIQ2lROZsQ6jk8KFZLUwt2iJ9j7kN+8jfU6QsAKC6rfIHXHKkTL htugxcPwtIJe81QbhWY147y2C+o7hjGkwiOuBHybHbfQbtRcVjM2mRIHX+KLIT2pIUxF zyaAormSJ9YGudFDb2sZV1floy+huBrexdxlloCTQiaa9ArlJvv2knH0Us2iyxSWO0j5 +7Xg== X-Gm-Message-State: AOJu0YzUKv80bQnk89PnyOPFnDRyp6ditbBVmrso1qYwnhOHB7gnEBZa Orgzhep+F2OMGknnlu/rb/bvOfIkXevSGgxvFHM= X-Received: by 2002:a05:6a00:2e20:b0:686:be77:431c with SMTP id fc32-20020a056a002e2000b00686be77431cmr14303019pfb.13.1692129473034; Tue, 15 Aug 2023 12:57:53 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:8d06:f27b:d26c:91c1]) by smtp.gmail.com with ESMTPSA id n7-20020a62e507000000b00686b649cdd0sm9667699pff.86.2023.08.15.12.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:57:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, jniethe5@gmail.com Subject: [PATCH v3 10/14] tcg/ppc: Use prefixed instructions in tcg_out_mem_long Date: Tue, 15 Aug 2023 12:57:37 -0700 Message-Id: <20230815195741.8325-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230815195741.8325-1-richard.henderson@linaro.org> References: <20230815195741.8325-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When the offset is out of range of the non-prefixed insn, but fits the 34-bit immediate of the prefixed insn, use that. Reviewed-by: Jordan Niethe Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 40472f3d00..1aece2cbf7 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -329,6 +329,15 @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) #define STDX XO31(149) #define STQ XO62( 2) +#define PLWA OPCD( 41) +#define PLD OPCD( 57) +#define PLXSD OPCD( 42) +#define PLXV OPCD(25 * 2 + 1) /* force tx=1 */ + +#define PSTD OPCD( 61) +#define PSTXSD OPCD( 46) +#define PSTXV OPCD(27 * 2 + 1) /* force sx=1 */ + #define ADDIC OPCD( 12) #define ADDI OPCD( 14) #define ADDIS OPCD( 15) @@ -732,6 +741,20 @@ static ptrdiff_t tcg_pcrel_diff_for_prefix(TCGContext *s, const void *target) return tcg_pcrel_diff(s, target) - (tcg_out_need_prefix_align(s) ? 4 : 0); } +/* Output Type 00 Prefix - 8-Byte Load/Store Form (8LS:D) */ +static void tcg_out_8ls_d(TCGContext *s, tcg_insn_unit opc, unsigned rt, + unsigned ra, tcg_target_long imm, bool r) +{ + tcg_insn_unit p, i; + + p = OPCD(1) | (r << 20) | ((imm >> 16) & 0x3ffff); + i = opc | TAI(rt, ra, imm); + + tcg_out_prefix_align(s); + tcg_out32(s, p); + tcg_out32(s, i); +} + /* Output Type 10 Prefix - Modified Load/Store Form (MLS:D) */ static void tcg_out_mls_d(TCGContext *s, tcg_insn_unit opc, unsigned rt, unsigned ra, tcg_target_long imm, bool r) @@ -1413,6 +1436,49 @@ static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, break; } + /* For unaligned or large offsets, use the prefixed form. */ + if (have_isa_3_10 + && (offset != (int16_t)offset || (offset & align)) + && offset == sextract64(offset, 0, 34)) { + /* + * Note that the MLS:D insns retain their un-prefixed opcode, + * while the 8LS:D insns use a different opcode space. + */ + switch (opi) { + case LBZ: + case LHZ: + case LHA: + case LWZ: + case STB: + case STH: + case STW: + case ADDI: + tcg_out_mls_d(s, opi, rt, base, offset, 0); + return; + case LWA: + tcg_out_8ls_d(s, PLWA, rt, base, offset, 0); + return; + case LD: + tcg_out_8ls_d(s, PLD, rt, base, offset, 0); + return; + case STD: + tcg_out_8ls_d(s, PSTD, rt, base, offset, 0); + return; + case LXSD: + tcg_out_8ls_d(s, PLXSD, rt & 31, base, offset, 0); + return; + case STXSD: + tcg_out_8ls_d(s, PSTXSD, rt & 31, base, offset, 0); + return; + case LXV: + tcg_out_8ls_d(s, PLXV, rt & 31, base, offset, 0); + return; + case STXV: + tcg_out_8ls_d(s, PSTXV, rt & 31, base, offset, 0); + return; + } + } + /* For unaligned, or very large offsets, use the indexed form. */ if (offset & align || offset != (int32_t)offset || opi == 0) { if (rs == base) {