From patchwork Fri Oct 13 17:10:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 733245 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1580399wrv; Fri, 13 Oct 2023 10:11:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwr+md7NlUacjkjQZNXWBfW3dVeZTT4N/qqtYIGvABtEMJjcwWXlEl0A3+fmvUARbc1oka X-Received: by 2002:a9d:6a05:0:b0:6c4:fc45:8681 with SMTP id g5-20020a9d6a05000000b006c4fc458681mr28632929otn.25.1697217068497; Fri, 13 Oct 2023 10:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697217068; cv=none; d=google.com; s=arc-20160816; b=azpidPvYbmAjNGKafEagoKcj2SOlEscEbu8PkYliwGtcd8Sr4FCcGR+pdAAhdOIwwm t+DCQcDR14qh1R6tnKGJbEC6ptbvNBpim0m/zolJ5Uppey4blbyM90CmYXt5wcJD9GWz qP07BnWg3nZLYHxfB+iaXHVBerv9rAp6GstYiAVcnxnHSSgM8prxfUAlqbuzGkeR+I2Q EGrxfJLSTeZTmdDYNxScKGPiPen8h9Rgo7E/eesNhDW/qtK3EAk4qBG/Z7/AhfuVInjd GBNRiC0zfTZXzt5mrUR57AXR3DFLvOZqkP3NRp1Vi0hpAGeGBQWSgGnWpsjzqWN1PCXX PWGg== 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=4gXGK6fIVAMAIDlPSRafHxXOFGChnJBeeF+QM2JUpio=; fh=UhxwdZYHP7zKrVOsDzSwq52OyFUIKgoVzT4P2jPed6w=; b=GU4zTZOglnSrPean+DbklEHFBrt08OWlWw6wfnyv9Nd6AVYn19kCX/EjZfirXfYfmn Y0JAMl/DnjAl2UAK6JEPEARWqoGzsFpWQlf5Wxcxs8UWsFQmAAzBuP0pjpiLdubsgBa1 XnwV7vcXV/uOO9QR29K/hVUyDNtS/L5gytQ2c22Nf+HpJKDp6raLeK+ytOYpDsp3O2X8 cPh7rFX73IPFZODzmNYJa7GPnx5O6aycUY+MPc6znhMZnFaK8szTdkqYPKjdJtGylAC4 COifWMPLyu+MToggWmSjH10ZvAEUnvrP+R22Isc3oTSFgFQ3bxzXDnhlh/kk73qgXZnU PYdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IzYvn2T8; 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 c19-20020ac87dd3000000b00417f817da78si1591225qte.565.2023.10.13.10.11.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 10:11:08 -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=IzYvn2T8; 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 1qrLgV-0001Ro-Se; Fri, 13 Oct 2023 13:10:47 -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 1qrLgC-00013Z-7t for qemu-devel@nongnu.org; Fri, 13 Oct 2023 13:10:29 -0400 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrLg8-0005Zw-IN for qemu-devel@nongnu.org; Fri, 13 Oct 2023 13:10:27 -0400 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-57b5ef5b947so1425740eaf.0 for ; Fri, 13 Oct 2023 10:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697217023; x=1697821823; 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=4gXGK6fIVAMAIDlPSRafHxXOFGChnJBeeF+QM2JUpio=; b=IzYvn2T8OuS3mczGb7W2maZalHlQwg/D3g5MItOQ3So0xqsLG/rz5IdS8A3iQc0tLR mcmKqhKT9BRQaVfPpA0xia7UVgNdtWLzMJTi47+tqzb5vCFIaUxulyX9rkZJgSTLqoLQ q8ff4YUB0MdoF6TW1TO+H88ZETfGzXnIg7/Hh/mqMjkX9wOQkbbENBgNYaKPl8C/J+DI pMBSLXbbeETf3SlghKlIh9Xr8Ggmu92ovOVbY8iOs1K+4943TEOy1XRfj1Vx5X0KDHrl BlI2eZ1GpXspWEymcG/lHzIRkB7rIxcI5RhVKbqAGvR1wzp05mlOqbfIV1W1HnVYhfXZ 0DNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697217023; x=1697821823; 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=4gXGK6fIVAMAIDlPSRafHxXOFGChnJBeeF+QM2JUpio=; b=fN7mW21Ul4g9/3Bzv5/RjvNF69npknPkTCIUELZXzX9m/a0LPQeschIC0lVSm2ss9T jSNUaQVRK+r0Dmslsnzv/UbBh9Z/DXexZdb4EPeiQiHT67LVoNGyzkrZhQaJaTlvrc+F IFxpcvwAsMt+bSYCYEEU7S0OAQARbg/q35l5NBtMH1BOZUrlqEINIvoxSxvqjSYlG56s IfBGIpUQTRzp5wyT/zoVdJzqkn6W1WHj7xC9vZbyMDCsFdxhikJnipopocFzyxXPFM1I gLwLSUPJRPTnaqa6GXpIFrMYg93czttm52gx8Q/yiZBUlQPTUn1Q5+qEoOEh8II71uD+ 8SFQ== X-Gm-Message-State: AOJu0YzqRW/aughOLDMH99yS8b9ChyphTTU18/dDygeO+JED8FIOi+4E ZB2U04gsyHl/t05g7TKIZiZ/LRms4Eo93GFdwmw= X-Received: by 2002:a05:6358:917:b0:14a:e358:f436 with SMTP id r23-20020a056358091700b0014ae358f436mr34972246rwi.1.1697217023263; Fri, 13 Oct 2023 10:10:23 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id n7-20020a62e507000000b00693411c6c3csm13687926pff.39.2023.10.13.10.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 10:10:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: jniethe5@gmail.com Subject: [PATCH v4 10/13] tcg/ppc: Use PLD in tcg_out_movi for constant pool Date: Fri, 13 Oct 2023 10:10:09 -0700 Message-Id: <20231013171012.122980-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013171012.122980-1-richard.henderson@linaro.org> References: <20231013171012.122980-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2f; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2f.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 34df9144cc..79e82d2f94 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, int vece) { @@ -696,6 +713,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, @@ -1155,6 +1174,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);