From patchwork Mon Oct 23 18:12:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737296 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp1665920wrl; Mon, 23 Oct 2023 11:18:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOylgrH/90JY8Hed+HK1Dgk5FLwG3BM9Q2DBlr2rj5aAnjUBLWL5yopyvMTmycbDX60m71 X-Received: by 2002:a05:6214:20ad:b0:66d:2852:6f17 with SMTP id 13-20020a05621420ad00b0066d28526f17mr10510048qvd.14.1698085117083; Mon, 23 Oct 2023 11:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698085117; cv=none; d=google.com; s=arc-20160816; b=WsEb25+HuuLpjK3KhZzeJJYjcnx2erVldR8a+LHv3mIIfeNsXO82BfJZqynncsma2U EMOJQRAXzsasv/lJYUZ6RSmhEw5DKkA3+j5fMNWsgB7VoGmVw137Kc0Lb8ie7vW1NeHF Nf9rsqbbln4ZqFrGee23EdiIxFqorC0UiKfXInh5J7OIQL6udNbwOoird9VJWuYGhKHL 4y+jsMvEwNdrw67VY5jt95tor36pCjW8WPHYGLl2UVE04bV40hwZ0u6SbF2eJOh2KqcJ m9FXFMy9BZm/CXAZvLR7qlZtpcnYAvfFMWPJ4EuPnuip9J+BB7d4qVw74jqnPtNNGEbn Nijw== 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=IcT+t2NWvvAgl7ag7U9fcr97JnnF4drB4JEVTRDmT40=; fh=o1FzCaEAYG4VwCHNWCaZIuDmCIpwE3zCfwcgLY4wMqw=; b=Vzo0v+iaLDSJVcLs0d44rsqn6sWCRaz0XyusnOUtWmuTVOvo+ebcmSVxFasWuIM7lT 96LTmvLdJYKmICUjYcCZjc8NFOj4wUCuk0jIu8egkTl24d/tctH6UV9R4jO1lq1/NJi8 Jn1a/GHpxBXu5wYBRVgUe7OVUQZBfxO45uVTh6qk1boORgbRqA2MHf5HlhjFUpMB6CdO 5LKuG1PPCxoNjx8d0S4b1DlNovTccaM2f9CS7lWo/uu87a+MgjOGJEr2TIYFV5qJCFJr voZLY4fO39GKspN/Jg8ye5jCLsZZKzhBjenfH4k9ofSx/ejj0AF+bYXilvI7pgqT04xB ZP/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mQkW5tIj; 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 el17-20020ad459d1000000b0066d045aa0ffsi5858168qvb.543.2023.10.23.11.18.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2023 11:18:37 -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=mQkW5tIj; 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 1quzQw-0005WD-A3; Mon, 23 Oct 2023 14:13:46 -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 1quzQu-0005VA-Gn for qemu-devel@nongnu.org; Mon, 23 Oct 2023 14:13:44 -0400 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quzQp-00085c-M9 for qemu-devel@nongnu.org; Mon, 23 Oct 2023 14:13:44 -0400 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5849fc56c62so740927eaf.3 for ; Mon, 23 Oct 2023 11:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698084818; x=1698689618; darn=nongnu.org; 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=IcT+t2NWvvAgl7ag7U9fcr97JnnF4drB4JEVTRDmT40=; b=mQkW5tIj3yWQgjTi6C0WcCpCINt/dwAoqOEYlN4ID+EapZBwBhZMFty8iekGzZyory tCV66mSb2nmFBgLg1sdZe9hb1Jn5OEizVlP/wfibCvEE4GaWYOonTkUoQfbHz3j/VSi9 fVZGGJbzzMyFTgfDCyM6TIYVEbWMD1jf9zGjmf6CDViEyVlO1koEJxM3yeOwkhZY0GHH 7xJ/KbC/ghfkT3s0mwIqi8ciSKU4YUerhQr7lzc9lFKLJH0gsXtCKRnEpS+Ox4s9RPar rY2N/j6p2s0tSLM9SKLYUggCgVleJqOkdKykYltVDPF20sDoxkpJMdyaYvXbSnYicG2M +g/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698084818; x=1698689618; 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=IcT+t2NWvvAgl7ag7U9fcr97JnnF4drB4JEVTRDmT40=; b=wXpAHVSnj3p/GGsGGgAUEHqRMdhEPLiBDlnB6YZ7GSkIzPVCl0P8cT36epqStCv6xA 8x7q4TCe7CsUiGCIw1ZGo4BdF1QCaQVzblHmoCmhX0ZGjYtLWlHkXwLanX41pgZhJO9c ZRroJJC0xrwpIZDd5fMTqwHRHHRsYfHeB5Q/Y8H98TdlX7cMlVBgwuPuZiLRlCHqVaXb IRNEnMDAS4fSf8GFp9u9A8DosMG/1ya/7PqhL6t2nhFJ+htdpMjlltWYdiwbACYupiHG CW2XNIs1mC6fa5+5CNfXmlbsdCyr3zGnsAZ4TZhCNyVtN2WAVjE+jnoirDwBAhS54nbk XYtg== X-Gm-Message-State: AOJu0YyV7lD9Ikj2EgZYUuh1eBGrlN8ULaNOtSiioS4z2nSF5QuHLb/s on8gVhCdbFaPSghUVtOdu0VxzbjvuPlkJqYrVN8= X-Received: by 2002:a05:6358:810c:b0:168:d6cd:7b2e with SMTP id p12-20020a056358810c00b00168d6cd7b2emr5661037rwk.29.1698084817955; Mon, 23 Oct 2023 11:13:37 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id v10-20020a65568a000000b005b83bc255fbsm5205137pgs.71.2023.10.23.11.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 11:13:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Jordan Niethe Subject: [PULL v3 08/38] tcg/ppc: Use PADDI in tcg_out_movi Date: Mon, 23 Oct 2023 11:12:59 -0700 Message-Id: <20231023181329.171490-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231023181329.171490-1-richard.henderson@linaro.org> References: <20231023181329.171490-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2b; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2b.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 PADDI can load 34-bit immediates and 34-bit pc-relative addresses. Reviewed-by: Jordan Niethe Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 6337b1e8be..f4235383c6 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -719,6 +719,38 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, return true; } +/* Ensure that the prefixed instruction does not cross a 64-byte boundary. */ +static bool tcg_out_need_prefix_align(TCGContext *s) +{ + return ((uintptr_t)s->code_ptr & 0x3f) == 0x3c; +} + +static void tcg_out_prefix_align(TCGContext *s) +{ + if (tcg_out_need_prefix_align(s)) { + tcg_out32(s, NOP); + } +} + +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 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) +{ + tcg_insn_unit p, i; + + p = OPCD(1) | (2 << 24) | (r << 20) | ((imm >> 16) & 0x3ffff); + i = opc | TAI(rt, ra, imm); + + tcg_out_prefix_align(s); + tcg_out32(s, p); + tcg_out32(s, i); +} + static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, TCGReg base, tcg_target_long offset); @@ -1017,6 +1049,25 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, return; } + /* + * Load values up to 34 bits, and pc-relative addresses, + * with one prefixed insn. + */ + if (have_isa_3_10) { + if (arg == sextract64(arg, 0, 34)) { + /* pli ret,value = paddi ret,0,value,0 */ + tcg_out_mls_d(s, ADDI, ret, 0, arg, 0); + return; + } + + tmp = tcg_pcrel_diff_for_prefix(s, (void *)arg); + if (tmp == sextract64(tmp, 0, 34)) { + /* pla ret,value = paddi ret,0,value,1 */ + tcg_out_mls_d(s, ADDI, ret, 0, tmp, 1); + return; + } + } + /* Load 32-bit immediates with two insns. Note that we've already eliminated bare ADDIS, so we know both insns are required. */ if (TCG_TARGET_REG_BITS == 32 || arg == (int32_t)arg) {