From patchwork Fri Aug 4 21:33:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 710242 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:d30:b0:129:c516:61db with SMTP id gp48csp219901rwb; Fri, 4 Aug 2023 14:35:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdPhWANv+P/lYEgwE/3b34A8R798BV62ZtGeJsNaRBIRA0mvmvwUr5CmzAC3x3z26OJihc X-Received: by 2002:a1f:3dc1:0:b0:486:4b9b:8f39 with SMTP id k184-20020a1f3dc1000000b004864b9b8f39mr1958922vka.11.1691184940592; Fri, 04 Aug 2023 14:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691184940; cv=none; d=google.com; s=arc-20160816; b=vaDp/W/8YHpxlfQ4JLHxHjKwsAOxoovq7PJFtSreJmrjH+dkQ+qnuoMBIfXFrE5DJ+ Rxhw8MHhLDQLJGljqyXSfeJFtWstTsqTOkJllrcy3hvT+s8SFxoYK4Hx8uYW9Npfp7CO P0259LsfOw4JNRN3D4C3OAqv9mvg38vwaF5LK2+H7e6SPy27czdlAvkWyuN/owvWapRC dUe2OIzO7TvYVy41ZMD6U2/BPlK+NHiKZhnuMYKqpyP5G2G94yKgBxX+AiRUQCKVDJ7V nLRj1swnt0aTQoo8nCy9sy3RVEzlILHeiq19+fqe+p7fLXGau2GtxYA0q83bFYonf3ME 8P9Q== 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=XSfXUkEbJi6XSSeczzkehSgMMZNGjw0txB1UvXtXqsU=; fh=oDpcRIg3pzWA7lEsXr2+AuYCXCfAwFhPMEhHe0xWPuA=; b=qirRf166HaGNzn19dYp3Yl8s5lmk/4mltHeFF4jWqObBRZMc7j3JFEHAmcaxBg5Rc4 EvuTWwenV0hHcFu/c+8Aqh3ilU4ucbJtEn9vJnmCBvnBymEyNXIAq1F5sImPh2DacjWr UHaqf/9kEpk1yds6GVw3k3SdMHahvndTfKaIL8aUjNAi3UVAVqsSfxy8Ye6LWn2FQbWT pJ2uMJHk0vSsAEsru6fHDOZwT43BLQ2pfZKYgWr8Y5aU5VIApnT1Hrt1uqaLoEAo9stC QCVV6eFqdxb8cXx+idcG3MCDnqBYmaTQ648zcN5x0/BF3r6Q6ljHVRJgtj0bI1fGoK/e d9zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e46yjR1Q; 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 z9-20020a05622a060900b0040354fda86csi1826696qta.370.2023.08.04.14.35.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Aug 2023 14:35:40 -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=e46yjR1Q; 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 1qS2Qz-0006Dt-67; Fri, 04 Aug 2023 17:34:09 -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 1qS2Qw-00068y-6y for qemu-devel@nongnu.org; Fri, 04 Aug 2023 17:34:06 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qS2Qs-0001tQ-6T for qemu-devel@nongnu.org; Fri, 04 Aug 2023 17:34:05 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bbf0f36ce4so18515105ad.0 for ; Fri, 04 Aug 2023 14:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691184840; x=1691789640; 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=XSfXUkEbJi6XSSeczzkehSgMMZNGjw0txB1UvXtXqsU=; b=e46yjR1QGQgC3aQQU5JqDJhotcAD2xGjqiPOQeo/qbXypkWLdO9quaFZFY1vzzA65T pqAA5ibS/c+iMvCw3FPZLvPZ4XxOUXNYYhgBMbX+gJi7D3CRbzCLnQVOQu/VcLn1JC8V 7UiuzUtub0Zh4cKNufAQMmdZTtcuxWiTuFcXQRphj7xnkeXWd3WW8jny5cKbeMvcATCn L+fQDw+/v0584qdGPYaKXtOIu8TbUa4AcoKquiKhGAsH7OFtK7u7PI3PBlDX5QN2Euwn yx5Mj+hwplUKSNUg7ymK21AFT785c1I8jc0Pb/+SF6xkz7Aq9+b4fZoCSwmYIQ/jz/v8 TEcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691184840; x=1691789640; 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=XSfXUkEbJi6XSSeczzkehSgMMZNGjw0txB1UvXtXqsU=; b=HByoDvHLtx5TJhTIiABb5wct5QVEHO3/n1LBTJSeHO7RiWid9qLCTyxQTPS35TVZf4 I56K/MQpcNnBeOQgaGczDvVIpAfiTeE6mo+bZxFmkBDgI2evT+XYIhJUxQt2uw8+pKel xAx9NGdndOYmwJTZUg626imLzaE8WgeLmfS9L9iYuDk7XX6Fssyxo0xoWhAnxdUmm1W/ ZdUwcptpzdITjbRfataejdiV4BcdCv8ulpb45nMaCz3Xffg53XEyBKMq+3xtgsVdrXzh uB7i1I2/x/VXdyOZPjjAqNplotydZ2W62KzSEiotVSZlP9KOT6PxNxfcEe0WYN7hLc7/ 7IzA== X-Gm-Message-State: AOJu0YyY6ZafKlaGs21tZsrAbCYE/mhlewTH4PXs+UlhZCBlFE/DpcHk uKEmnplezOsVLxCbiavEFlclhgKAcMlIS8J0H2Q= X-Received: by 2002:a17:902:6a85:b0:1bb:7a73:6b59 with SMTP id n5-20020a1709026a8500b001bb7a736b59mr2433016plk.32.1691184840155; Fri, 04 Aug 2023 14:34:00 -0700 (PDT) Received: from stoup.. ([2602:47:d490:6901:1eed:f77f:f320:8b14]) by smtp.gmail.com with ESMTPSA id t6-20020a170902e84600b001ae0152d280sm2188662plg.193.2023.08.04.14.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 14:33:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: jniethe5@gmail.com, qemu-ppc@nongnu.org, bgray@linux.ibm.com Subject: [PATCH 4/7] tcg/ppc: Use PLD in tcg_out_movi for constant pool Date: Fri, 4 Aug 2023 14:33:52 -0700 Message-Id: <20230804213355.294443-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804213355.294443-1-richard.henderson@linaro.org> References: <20230804213355.294443-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 The prefixed instruction has a pc-relative form to use here. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index d41c499b7d..a9e48a51c8 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -101,6 +101,10 @@ #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull +#ifndef R_PPC64_PCREL34 +#define R_PPC64_PCREL34 132 +#endif + #define have_isel (cpuinfo & CPUINFO_ISEL) #ifndef CONFIG_SOFTMMU @@ -260,6 +264,19 @@ static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) return false; } +static bool reloc_pc34(tcg_insn_unit *src_rw, const tcg_insn_unit *target) +{ + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp = tcg_ptr_byte_diff(target, src_rx); + + if (disp == sextract64(disp, 0, 34)) { + src_rw[0] = (src_rw[0] & ~0x3ffff) | ((disp >> 16) & 0x3ffff); + src_rw[1] = (src_rw[1] & ~0xffff) | (disp & 0xffff); + return true; + } + return false; +} + /* test if a constant matches the constraint */ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) { @@ -684,6 +701,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, return reloc_pc14(code_ptr, target); case R_PPC_REL24: return reloc_pc24(code_ptr, target); + case R_PPC64_PCREL34: + return reloc_pc34(code_ptr, target); case R_PPC_ADDR16: /* * We are (slightly) abusing this relocation type. In particular, @@ -1107,6 +1126,11 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, } /* Use the constant pool, if possible. */ + if (have_isa_3_10) { + tcg_out_8ls_d(s, PLD, ret, 0, 0, 1); + new_pool_label(s, arg, R_PPC64_PCREL34, s->code_ptr - 2, 0); + return; + } if (!in_prologue && USE_REG_TB) { new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, tcg_tbrel_diff(s, NULL));