From patchwork Mon Apr 24 05:40:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 676519 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp1987111wrs; Sun, 23 Apr 2023 22:53:09 -0700 (PDT) X-Google-Smtp-Source: AKy350YE3niGROf7Fn2woJhJxgHU2XmphF6eCaHkW7zNQCEJAX5HYa4FvQqKo03LG6e0omvVExT0 X-Received: by 2002:a05:622a:24e:b0:3e6:40f9:cf6c with SMTP id c14-20020a05622a024e00b003e640f9cf6cmr17373220qtx.28.1682315589037; Sun, 23 Apr 2023 22:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682315589; cv=none; d=google.com; s=arc-20160816; b=otq6KSlAQMoEfmTjT3iOLjAGkCenY7PcKVGZhlfluhHgvAH3YjXE/j9liaQtEyON8v W2wsptsQn9G0+LfZTucnTQ7dPTLA3gPIbHgXfeEPrp73+gVh90mZvbmBORkn3zYNf23d ygHyhNMfFTvDtAyAHhTSl7M/qd1zcwmGqR3RmvQKgo/7u8hXemGiZkZ6wcP4uA/PMpFo EsJRaO9jyI/tgE0dYN/ykCmgDGAlJ3jxQE+qYsnYi7y6HOaXsvEJi0BdCO+H2skxVHJZ D/2sj7BiX2ejGhXFbvYwJ6h1pUtmc8ljv3om3lLL0XwKeKcr23hiZR8mnA/nW0rCJiHJ i5kg== 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=Yu6T1N8rjMDvjcqVloIbI64DCiKYMAX1Jvlpvr4G/Zc=; b=VglD9KqSpC0umt5obq2wrHiuIXe9iaHtH+UM2015k6yRL5nkcqxec+CEaGVwwiXQND uCziYAlvyp4DgteSsK7eY/pXLd1+GXrWrBkmis9Z+IIxx9Ru0u7sq0PBTMIU1Msal+8i VIMdnuFlCePQk/VGfgMyWzy9trPELf0x7ozQrAqsYmcPeGZjd6yqVh13LpsudhqPKax5 dwFPl0H46P2dZB79Bha3qllyXXKWv4wTSWtFdMyv2mxI2rocxrmU4TKn7q/AXMCn4T3O 0mTXKXvzOS2lXkAUZVSUKbIf5Dz0FISxI/qiHuWz8/hLsQvHG+VNYNAWmuhiTjz2V+vS p/jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=unEiPoC3; 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 g13-20020ac87d0d000000b003ee392fe23dsi6738770qtb.636.2023.04.23.22.53.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Apr 2023 22:53:09 -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=unEiPoC3; 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 1pqp05-0005jY-7O; Mon, 24 Apr 2023 01:44:33 -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 1pqoxw-00063w-2T for qemu-devel@nongnu.org; Mon, 24 Apr 2023 01:42:31 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqox8-0004UE-7s for qemu-devel@nongnu.org; Mon, 24 Apr 2023 01:42:19 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f1957e80a2so63436255e9.1 for ; Sun, 23 Apr 2023 22:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682314887; x=1684906887; 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=Yu6T1N8rjMDvjcqVloIbI64DCiKYMAX1Jvlpvr4G/Zc=; b=unEiPoC3DGCbNlUVzWehnKJGBznQaFcD5SYtJBHW/C5O5WsSnZBkXAaxZuol/U+9js duT/VeJRTp94ans53sImsHCleGJRj5+KaX1C0LphQlmH4CpD4ZLYYGFRKytnu1m/hnGF P+5sMSXcwKFaGe5slJARNPutPo395qq0ODpPAvZDTe9+DyaBtgRxMqe9FZdMhE9reX90 M7+R9UvjijDMR7yzztgko0I6WCpQL6cAv+36Ail22WVRc7bkQVMCyOjyQADLQQ3UD2vR hUIflzKiwjkUk/8khkrvPqsrUEcYW9Zr4C2w75bUK2tt8vah0Jqzlwtm9WzeY3CdY+Bk JmUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682314887; x=1684906887; 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=Yu6T1N8rjMDvjcqVloIbI64DCiKYMAX1Jvlpvr4G/Zc=; b=CzKtOzukftI7ua/jP6AdaqRFLcRg6vAijt7xF3lyJPSgUf6SUl6XoZuLm68upRupm2 3aKa+KvPmuxcC0AE6fveumKVYMDcFcJTAKIIhoTK1s6EfdAt5Rxk8JQctHiDP9lQFx86 CF7twiBqJxurdpW2gb79NK2nnik9q0oewhJ/2NiIaF0B5D7gn5oiSlD1DdWzHZ+mXWbC laScwaQZN9atkHaVA2tl58nvrrgYHPY1k/qDFC+WGQezTZ6JwltHOtNxB+gqfZxD78pK 5QIa6cj18fZNK6aSfIx6nQQYBhVmiOkbrAWj1ZDVhl7TyjDYuLPVHyF1Gn1KDIidB5s8 KwEQ== X-Gm-Message-State: AAQBX9fTY3vQHFCUdtTif8aHmCR0MjsC3l7wKbnxtKJ6CqQP3hzSCxlB ZJ7Lk3FiJQ9al7EZdlTVxttVX2fY6fGdeSuCt4g76Q== X-Received: by 2002:a5d:6a11:0:b0:2f6:661:c03c with SMTP id m17-20020a5d6a11000000b002f60661c03cmr9340020wru.28.1682314887384; Sun, 23 Apr 2023 22:41:27 -0700 (PDT) Received: from stoup.c.hoisthospitality.com (cust-west-loneq8-46-193-226-34.wb.wifirst.net. [46.193.226.34]) by smtp.gmail.com with ESMTPSA id j22-20020a5d6e56000000b002fbb285b01fsm9997852wrz.25.2023.04.23.22.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 22:41:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, git@xen0n.name, jiaxun.yang@flygoat.com, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 36/57] tcg: Introduce arg_slot_stk_ofs Date: Mon, 24 Apr 2023 06:40:44 +0100 Message-Id: <20230424054105.1579315-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424054105.1579315-1-richard.henderson@linaro.org> References: <20230424054105.1579315-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 Unify all computation of argument stack offset in one function. This requires that we adjust ref_slot to be in the same units, by adding max_reg_slots during init_call_layout. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index fa28db0188..057423c121 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -816,6 +816,15 @@ static inline bool arg_slot_reg_p(unsigned arg_slot) return arg_slot < nreg; } +static inline int arg_slot_stk_ofs(unsigned arg_slot) +{ + unsigned max = TCG_STATIC_CALL_ARGS_SIZE / sizeof(tcg_target_long); + unsigned stk_slot = arg_slot - ARRAY_SIZE(tcg_target_call_iarg_regs); + + tcg_debug_assert(stk_slot < max); + return TCG_TARGET_CALL_STACK_OFFSET + stk_slot * sizeof(tcg_target_long); +} + typedef struct TCGCumulativeArgs { int arg_idx; /* tcg_gen_callN args[] */ int info_in_idx; /* TCGHelperInfo in[] */ @@ -1055,6 +1064,7 @@ static void init_call_layout(TCGHelperInfo *info) } } assert(ref_base + cum.ref_slot <= max_stk_slots); + ref_base += max_reg_slots; if (ref_base != 0) { for (int i = cum.info_in_idx - 1; i >= 0; --i) { @@ -4826,7 +4836,7 @@ static void load_arg_reg(TCGContext *s, TCGReg reg, TCGTemp *ts, } } -static void load_arg_stk(TCGContext *s, int stk_slot, TCGTemp *ts, +static void load_arg_stk(TCGContext *s, unsigned arg_slot, TCGTemp *ts, TCGRegSet allocated_regs) { /* @@ -4836,8 +4846,7 @@ static void load_arg_stk(TCGContext *s, int stk_slot, TCGTemp *ts, */ temp_load(s, ts, tcg_target_available_regs[ts->type], allocated_regs, 0); tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, - TCG_TARGET_CALL_STACK_OFFSET + - stk_slot * sizeof(tcg_target_long)); + arg_slot_stk_ofs(arg_slot)); } static void load_arg_normal(TCGContext *s, const TCGCallArgumentLoc *l, @@ -4848,18 +4857,16 @@ static void load_arg_normal(TCGContext *s, const TCGCallArgumentLoc *l, load_arg_reg(s, reg, ts, *allocated_regs); tcg_regset_set_reg(*allocated_regs, reg); } else { - load_arg_stk(s, l->arg_slot - ARRAY_SIZE(tcg_target_call_iarg_regs), - ts, *allocated_regs); + load_arg_stk(s, l->arg_slot, ts, *allocated_regs); } } -static void load_arg_ref(TCGContext *s, int arg_slot, TCGReg ref_base, +static void load_arg_ref(TCGContext *s, unsigned arg_slot, TCGReg ref_base, intptr_t ref_off, TCGRegSet *allocated_regs) { TCGReg reg; - int stk_slot = arg_slot - ARRAY_SIZE(tcg_target_call_iarg_regs); - if (stk_slot < 0) { + if (arg_slot_reg_p(arg_slot)) { reg = tcg_target_call_iarg_regs[arg_slot]; tcg_reg_free(s, reg, *allocated_regs); tcg_out_addi_ptr(s, reg, ref_base, ref_off); @@ -4869,8 +4876,7 @@ static void load_arg_ref(TCGContext *s, int arg_slot, TCGReg ref_base, *allocated_regs, 0, false); tcg_out_addi_ptr(s, reg, ref_base, ref_off); tcg_out_st(s, TCG_TYPE_PTR, reg, TCG_REG_CALL_STACK, - TCG_TARGET_CALL_STACK_OFFSET - + stk_slot * sizeof(tcg_target_long)); + arg_slot_stk_ofs(arg_slot)); } } @@ -4900,8 +4906,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) case TCG_CALL_ARG_BY_REF: load_arg_stk(s, loc->ref_slot, ts, allocated_regs); load_arg_ref(s, loc->arg_slot, TCG_REG_CALL_STACK, - TCG_TARGET_CALL_STACK_OFFSET - + loc->ref_slot * sizeof(tcg_target_long), + arg_slot_stk_ofs(loc->ref_slot), &allocated_regs); break; case TCG_CALL_ARG_BY_REF_N: