From patchwork Mon Oct 23 18:12:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737299 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp1665985wrl; Mon, 23 Oct 2023 11:18:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEPg6QC/FefFqUGHEgBE4AlmPvVK6ayslYEvsQswxeI4K0WXubhd4FAEJ7WNQPc1rZaNs/ X-Received: by 2002:a05:620a:219b:b0:767:1d7e:ec40 with SMTP id g27-20020a05620a219b00b007671d7eec40mr9917574qka.1.1698085125579; Mon, 23 Oct 2023 11:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698085125; cv=none; d=google.com; s=arc-20160816; b=zViriqjmwoGIh4+EW59qZnYs5/BwD/n+fGN/sOyGP67N4HyHe2GDMMzFhqEAXF7o/F VYOogAOoNR0/bh/34Mpz4kBFtGe0xz4SuEg6nLKXaD3RGA2CgvvjZV6x8mAw4GXiF7ff 5ikGi7VHRGgJl/oPbzy7e4578Sq/IFLKuxfkZY4f64hvk6wcVE22TLcPUBI9XpXaOJSA 2X3765GWmRp86pjb1d81GtYoCGpX6aHBZ5rhyV/eW/SS22mjXzn3wvzNfTnqcKA30e6H NUpLWB9mB7+MrUrVLElc+9kp3WJpeeqGYtU65h6MaVY+TjqE96Z3gL5tZWPmIvtdTiVQ d46g== 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:to:from :dkim-signature; bh=3KCQIgln5kN/33Jyz8B+r1A500q3A4Jm4TEcmcp8vS8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=bfEPROwPknMm0Zm10o07B7yy9fZRdxL4lPObCyJ5noK7t5gkM7C+mxbYUvfjYhSL9V BDZpCLRBTkBTtRq0+QIqynTmPh+U5okvlkjJzBGT4TU2IM3rRInrrs14Akk4CsgpklQb YvAD0WdBFxngl1A2E74fgDcsJC0djRhttXfRN7JOWTLGFVPqwPYx8ps3rg1MH4KolSOR 2b36ONQKpP8sGJGJfNVcslPfmloCAh3JJFm222qJ5DgCugLpsi6FnJYKLEyr3TgF9PcA +o3ffS5t6lcD3HANekIghMl3fLcKN6RXRMkRUn5AASX7IcIl6A9F6sOQL0hgfKGjqvVy h0pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z6xUgsqy; 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 p9-20020a05620a22a900b0076f39f669desi5949167qkh.51.2023.10.23.11.18.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2023 11:18:45 -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=Z6xUgsqy; 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 1quzQu-0005VV-Ua; Mon, 23 Oct 2023 14:13:44 -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 1quzQr-0005Tw-Dn for qemu-devel@nongnu.org; Mon, 23 Oct 2023 14:13:41 -0400 Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quzQl-000857-45 for qemu-devel@nongnu.org; Mon, 23 Oct 2023 14:13:41 -0400 Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-5845213c583so1032466eaf.0 for ; Mon, 23 Oct 2023 11:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698084814; x=1698689614; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3KCQIgln5kN/33Jyz8B+r1A500q3A4Jm4TEcmcp8vS8=; b=Z6xUgsqyg/YSo2mtmN81hn4f9jkjDkOnnYjxjptmIfVKsNGs+J6lZVTgXgSteB0rGo 5YpWTttqgfykuIXrj98RvMHRjm+0DlucedArR99+nY1zaQ00pj6I6qyBwERifTiuZkxb y0U1VFcU9tpNLE28Gm8f/r32Q08FTAD4sY931w+KHVPJBhKSsyGN9Q5cA8/DWQmVtt6V tmIeGnztE0S/wGnwJuH6wjgBEhIEafR5EM6Swf4WmMhPDm62bHVNuYWxRrBT0e+/ocQV 33Uk/7LHTJWQBgDXfPq5ofdDkUl2GPqssdqXR6HZMgVWdGz++11BcalvGwAPJPDIPa+g 9NeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698084814; x=1698689614; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3KCQIgln5kN/33Jyz8B+r1A500q3A4Jm4TEcmcp8vS8=; b=g/OSI5vtrJTHjFrVV/36ODJ9k8G0bWB+rFgae7+vWKP2BR5rdMLr9QK6Z2DEuXMKPC S5B9Js7Mef0DVsTCVQsrnZ/tGqX826WRW/6hF7wCuXuebVweR1IW8giQ4ZFHYOKjzyJc 2JHHawJoaHopgUrOv3aRmTnbia2RvCsolT4U0IRUA6PjaRo28ufMyrZXf3xWXeUd1c4Y jMA7SVKIbidyuU3OxDouEhIVrjO+s25hmeoFMZboW/P/G8uY9W3Uh6qLsnDJ4QV5Rtvg pliVUTgTK5RAtNVQejMVRnoRxMWueDEGadWbEZYoEBsioxIbeNhsVgJbMMQm8l2cixY3 V5ZQ== X-Gm-Message-State: AOJu0YwvwdMp2+u0PFseVNaWK5LBbF9OdnIUcihAhi1jmoA/zhttI916 YhPQf3CXoXMFLImkEqSHrtiP53DpELxmpkO4PYc= X-Received: by 2002:a05:6359:4289:b0:168:d0d4:d8e6 with SMTP id kp9-20020a056359428900b00168d0d4d8e6mr7666134rwb.16.1698084813892; Mon, 23 Oct 2023 11:13:33 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id v10-20020a65568a000000b005b83bc255fbsm5205137pgs.71.2023.10.23.11.13.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 11:13:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL v3 03/38] tcg/ppc: Reinterpret tb-relative to TB+4 Date: Mon, 23 Oct 2023 11:12:54 -0700 Message-Id: <20231023181329.171490-4-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::c34; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc34.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 It saves one insn to load the address of TB+4 instead of TB. Adjust all of the indexing to match. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 9197cfd6c6..aafbf2db4e 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -215,6 +215,12 @@ static const int tcg_target_callee_save_regs[] = { TCG_REG_R31 }; +/* For PPC, we use TB+4 instead of TB as the base. */ +static inline ptrdiff_t ppc_tbrel_diff(TCGContext *s, const void *target) +{ + return tcg_tbrel_diff(s, target) - 4; +} + static inline bool in_range_b(tcg_target_long target) { return target == sextract64(target, 0, 26); @@ -991,7 +997,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, } /* Load addresses within the TB with one insn. */ - tb_diff = tcg_tbrel_diff(s, (void *)arg); + tb_diff = ppc_tbrel_diff(s, (void *)arg); if (!in_prologue && USE_REG_TB && tb_diff == (int16_t)tb_diff) { tcg_out32(s, ADDI | TAI(ret, TCG_REG_TB, tb_diff)); return; @@ -1044,7 +1050,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, /* Use the constant pool, if possible. */ if (!in_prologue && USE_REG_TB) { new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, - tcg_tbrel_diff(s, NULL)); + ppc_tbrel_diff(s, NULL)); tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); return; } @@ -1104,7 +1110,7 @@ static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece, */ if (USE_REG_TB) { rel = R_PPC_ADDR16; - add = tcg_tbrel_diff(s, NULL); + add = ppc_tbrel_diff(s, NULL); } else { rel = R_PPC_ADDR32; add = 0; @@ -2531,7 +2537,6 @@ static void tcg_out_tb_start(TCGContext *s) /* bcl 20,31,$+4 (preferred form for getting nia) */ tcg_out32(s, BC | BO_ALWAYS | BI(7, CR_SO) | 0x4 | LK); tcg_out32(s, MFSPR | RT(TCG_REG_TB) | LR); - tcg_out32(s, ADDI | TAI(TCG_REG_TB, TCG_REG_TB, -4)); } } @@ -2551,7 +2556,7 @@ static void tcg_out_goto_tb(TCGContext *s, int which) /* When branch is out of range, fall through to indirect. */ if (USE_REG_TB) { - ptrdiff_t offset = tcg_tbrel_diff(s, (void *)ptr); + ptrdiff_t offset = ppc_tbrel_diff(s, (void *)ptr); tcg_out_mem_long(s, LD, LDX, TCG_REG_TMP1, TCG_REG_TB, offset); } else { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP1, ptr - (int16_t)ptr);