From patchwork Tue Aug 15 19:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 713807 Delivered-To: patch@linaro.org Received: by 2002:a5d:4012:0:b0:317:ecd7:513f with SMTP id n18csp1969146wrp; Tue, 15 Aug 2023 13:01:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOFD82P2d5jFwZB70ORKXxH25IQOnNKDMrA3z6y79hryj+jxTvdRQYRdBNxJfaI1frVDVu X-Received: by 2002:a0c:8e05:0:b0:647:29f3:4b54 with SMTP id v5-20020a0c8e05000000b0064729f34b54mr4944568qvb.30.1692129665316; Tue, 15 Aug 2023 13:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692129665; cv=none; d=google.com; s=arc-20160816; b=b/wTbeHjqhICMJdwyh5h3piJoHdAmk0yEPwxPieRoFcfdpp+DbtIifb1+5srvlpGSP u2+b+U583eQ7cicHRrUt0u/70GHuwtn0brvqM8v74dELX1gZXUxm9ayh24rT5aub6Mc2 MdOD9YnGiAgb8i0WMTf7Q6GiNQv+OWlgbOVJpmLYKSYbshtkqBil1D7M53ePbsFt4ayW 4tCJHZS6fhHkH+X36xZqovizD+W4CFdD0puBzYblHHXNY09nyEMCq5naR5Y5AqWi4X57 sn4G760hGRkwhYgu6S4JfyR1h8d9x/MGEDhO3cJAeuvQrhhYZK15+8EfWfIS3CQ1plJs Gu0Q== 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=pu9KEBeJ8el0D1W01E7RaWKVL1yngJNhhEobU208UWE=; fh=1LlI9qg4dDC6jzYzk4mr2RaPQDh8MKMNLXu5CCRW41Q=; b=TI+U4mOJ8p37SpkGNaXJ2/IJiQr8m6ZUWpDinXwMbaw+71nsvWoYtNqc2Oj4yOnkx4 QlN6ge1GmBJdr+byiZ/A4CkS7m0GyYBRNSM6KyZQ24CWZ71ptEB0zxLg4I+nc1EbjJW8 kMBFucZGh37cot6pPtRpGajf36O/5Mx+b8NvLyzlda9WhX3zs0Mt3kGeyXa4XnrzLuE2 cdPO3x+WtEPhV+HV9JSNEHO3GPM6mz8+5VBGyVZJo9beZnV39Njt6ISkb2itm5t4B5NG jAMoFCTY8a7hyP8grbB84Dfqwo1tLpAhE4CPee0XqEiHmAlX4hB9MKtJ/P1HC1E8Bvw0 Ou1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PQS7Veyx; 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 dl4-20020a05620a1d0400b007681285fdf3si7790668qkb.744.2023.08.15.13.01.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Aug 2023 13:01:05 -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=PQS7Veyx; 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 1qW0Ax-0005BK-KV; Tue, 15 Aug 2023 15:57:59 -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 1qW0Aw-00059x-6p for qemu-devel@nongnu.org; Tue, 15 Aug 2023 15:57:58 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qW0At-00015q-7V for qemu-devel@nongnu.org; Tue, 15 Aug 2023 15:57:57 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-686efa1804eso3931879b3a.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=1692129474; x=1692734274; 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=pu9KEBeJ8el0D1W01E7RaWKVL1yngJNhhEobU208UWE=; b=PQS7Veyxa8xlO69A62nAoJkL51SxfZU5sICvPXZE45pZxkmLCow05I2o/JDNcX0od7 dasyY7gRq3K2TMZILUiXTjF/BD13DdLtz7bEozaw0Z/SgWIEV9lNvKZPaTQY4sCq+GKA ybiHU6dgP9uVvAjfuNfuffZsijSMNm8Il3YH0EUN482mPajjOYom1EFiEBA5kFdnV2TM xiMGTpleBSOMUaw9C5yVIvu2iPttyooiMivIzkkNW3pyZoSCf+APUb8ovlSQ8/J7zb2x WV5GnvPy7nM9c0fPo4/BGge0Fo4UrxS66XJ8wPwyHhUJPbjX6+gcN6lFYdu2RbXhC9NL fodw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692129474; x=1692734274; 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=pu9KEBeJ8el0D1W01E7RaWKVL1yngJNhhEobU208UWE=; b=IlAzIehpVtTZzK+PGAJsGjsQbhbxDZWmyrTQ/YglDBkwwIi2FS5k4Z++rkb+38EROF TEnaOG5AlWjFynN+nFPTFmP7axnmvYzqL2Yom+gYrcy+7Lou2sgHY4Mjnk0vbUs/JUiW 4Qg7K3fa9hV2QX9GyqRQDrGOPY3fXYLV4kp9Qyq0NVdjeZ4W3X9HFOxBLB0I6wThKWWK GtGpiMDr+pTpQAjdtSGfR3SJcL1YcD9phnRV9dBzQ6N+qvAbCGGnDB83i5cGgiB0V2ES F9HkZSM/XV+Zw6+Q316s0QtTd1Nlh1YNZMP8gFlDbcQq2wt3euP94xmAZzUFvvoqZvnF ORBw== X-Gm-Message-State: AOJu0YzsceWLtKJarHbefzQhEUm9TBoS8EwRlfrF4xN5XehrS/Vve0fD lzATQgNdhUaeHSgM9SEE5xubQ4T1R254+3KRyF8= X-Received: by 2002:a05:6a00:2345:b0:687:14df:51a9 with SMTP id j5-20020a056a00234500b0068714df51a9mr13923290pfj.12.1692129473936; 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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:57:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, jniethe5@gmail.com Subject: [PATCH v3 11/14] tcg/ppc: Use PLD in tcg_out_movi for constant pool Date: Tue, 15 Aug 2023 12:57:38 -0700 Message-Id: <20230815195741.8325-12-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::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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 1aece2cbf7..670811b636 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 @@ -266,6 +270,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) { @@ -691,6 +708,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, @@ -1150,6 +1169,11 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); return; } + 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 (have_isa_3_00) { tcg_out_addpcis(s, TCG_REG_TMP2, 0); new_pool_label(s, arg, R_PPC_REL14, s->code_ptr, 0);