From patchwork Fri Oct 13 17:10:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 733246 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1580471wrv; Fri, 13 Oct 2023 10:11:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJ4NHrIyAyNzEKRYoDz5t9eDeVsPGYpQ+ymqC23oYNRK5Kuzd53+KXp731HnrknDQt3vGW X-Received: by 2002:a05:622a:130b:b0:419:a2c6:8207 with SMTP id v11-20020a05622a130b00b00419a2c68207mr34072192qtk.22.1697217077550; Fri, 13 Oct 2023 10:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697217077; cv=none; d=google.com; s=arc-20160816; b=XnlLGZpl6Z3kzhKNPqccHdz+9G/xqJcLJm0YbIP0qpZZrPbxq0NJJSsd1y0kXlKa5d B7gIux2rSxbh69xsLOmdB4rw1pGDB1732qi3jBmjZyedEiW48h4Fe6g8b2cEGaj04bKo E8+ag9YL2CDA6Sd1ldUz20HXGwSyPQoE6s8PfODbmsY197+/GzKzmFu0T3I0Up2cUWpP G8cyasWq6XZoDIrUA1xtONVlU0eIrXjyAduoxU2kVRf0iClo+oBLUb0RKxDMt4FdKYCP aE3JJegrm8DN/sqn7gzVwuh4yyzcHEZs8umCUmqjTAWIK167qr+jYSC2m4+F8qIOpda5 2jSg== 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=UhxwdZYHP7zKrVOsDzSwq52OyFUIKgoVzT4P2jPed6w=; b=zi7rMAPJi66g5GLliOALUbKbHIE/vQfUqRL9mYH/vOvlXB50C32IEvQ6H54p1/61Or NZXDWXE/Ru2JUcm4FcQhVxPuDGmr2MLkVcy0Hm94b8ozdyFsMBp6eTtxeZuhkLhnp5ck sjgmTAcX/Zifgc9YDSaQj47PiTKFwMevO0cPBSNYtJezB1Zs6+uya/2gd1h23sXsmW2I VHf6y9RXE6uXo8AZY+vn6F9o5tHH9Vo40Sk94BKGRn/+gvezIi6zvx0gtVzvJrpk/cb6 oxkbkP/BTh8R6WMZTeGr+Q+h7lq0Swup4LJY0FxxVkk/8UM2rsW4uxXBrfv+t20m9h2O IKHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=avUC1n5x; 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 f17-20020ac87f11000000b00410a08b3c74si1518212qtk.278.2023.10.13.10.11.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 10:11:17 -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=avUC1n5x; 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 1qrLgE-00014T-E4; Fri, 13 Oct 2023 13:10:30 -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 1qrLg9-00012v-8b for qemu-devel@nongnu.org; Fri, 13 Oct 2023 13:10:25 -0400 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrLg6-0005Z5-KP for qemu-devel@nongnu.org; Fri, 13 Oct 2023 13:10:25 -0400 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6c64c2c0f97so1450633a34.3 for ; Fri, 13 Oct 2023 10:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697217021; x=1697821821; 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=avUC1n5xIFxvVBI3cqnRTaM16sDJ1k/p0KQHvrm91rg1VZPKdJaVj4IlzAv7Ma4KT/ z7WRO4QKXKpJHsv5pS2FncDhnmuTR+aXkYzHDfNzs1/mmei91cRjn6nqsk2m2bJm/gAM lO7HYyTIytfyZV9bwWSzcOBPsVtZktaLIQgKmta/ibDxQieDviMNAOxiLvlJQJh5MIh8 9D/mvn/1bCeCjYcA6oLIDkn2PBRLcPIv0LWqYvoUjQtU1dTPvq9chWHsA4H1t53GTLFs PRIaqs0ihrTAvcn1XI0fBfBRk5VStRe9OzqQq1io6IDxFUHXt1BoF+g6MOB7Nx4dRlvE z4SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697217021; x=1697821821; 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=M4u8oAGLAtFAMUVlTV6LwBPEPRphmltNXggaza3Z+LcHiXfbhwVz63Q6YgL4oGT0nK 9hdNGToZZpya0Rln97ccwjJr3VNp4VSyfxOR9Hi/tA2syex3E87gT6rbHXwN8X86zXOF g6YElC6Hw+eZjJunES5efmxoX1swJyOFwvW1PVvH2nPmPotkqbI2fWksfjAMmQ6QrdHS +pixMLx7fN7qgRyMxlfghyk+uN0vpWw2fJK7ywempcirCvFsEJJE/rVuYcSjSLeRuLRE /v0RrqZsLKDhiWyClnA9Kgq+ZcjnHM3E3aLMtlUsGHIprcGYN3riFhfEF13Dnf+/VClM wNkg== X-Gm-Message-State: AOJu0Ywt7FiXpe7cX1aVmlNf60HkLyNAOMVe5LZntWKxKmzNK6MdRQQb RjkS5sGXGQi7+Mc9RuZFUnAziEFeGcQyBBuJP4k= X-Received: by 2002:a05:6830:1d81:b0:6bd:db8:db with SMTP id y1-20020a0568301d8100b006bd0db800dbmr27658077oti.32.1697217021555; Fri, 13 Oct 2023 10:10:21 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id n7-20020a62e507000000b00693411c6c3csm13687926pff.39.2023.10.13.10.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 10:10:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: jniethe5@gmail.com Subject: [PATCH v4 08/13] tcg/ppc: Use PADDI in tcg_out_movi Date: Fri, 13 Oct 2023 10:10:07 -0700 Message-Id: <20231013171012.122980-9-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::32a; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32a.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) {