From patchwork Thu May 11 08:04:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 680880 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp3268136wrs; Thu, 11 May 2023 01:14:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58x/XctI0cW2MkexqErBJuXRGvzHPxvaZ4OgjOxjLZSLbqjemMT8aqL1YGmlQ/hUQQX7K7 X-Received: by 2002:ac8:7f50:0:b0:3f2:2ac7:cda7 with SMTP id g16-20020ac87f50000000b003f22ac7cda7mr31960563qtk.10.1683792844662; Thu, 11 May 2023 01:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683792844; cv=none; d=google.com; s=arc-20160816; b=PcfzfAUDIpICNDrfgUtgk7tVbt9ze0uOyauC0aFefObd3zdeNgoHoVMrjEXfIwCAyG z6iqqtHuCgliXmcHbu/BBXE7BFGeF0XI0koMuM3RuZ5jtetS9epSPwpkZqLNVerntjVM hO7/3mE5w0hKZug0xXRj+scUqk+Lbnt/MPKjC0D4QQvPCUFS0ZoQslZ3lo60J1ZxehW4 8+NvWcWf8/W8U6AOYaNKEAGmeGlCMrdeK100dDoNtMiuZntoOVvpucw0+xNa60C8Vn+8 K9liOLh7tfPu3dteLkRm64CInEmtp3xdksw6muNk+C1GwsQmvx/+20cCe/37JQYqr8qw BrpQ== 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=4MyRgw/PtcZChVqlCdO0y70qQ7cwt0IlfzjPvvDgR9k=; b=qH/wrEr1pspyXB2kNrF7toWW8+J0Ex8Y/iLYulLQ7vk/9iik7qe4vJU3O7T+otjNk6 jIa1mJ20ytCkXtbGyGXVZrhEi1f3fyMQLYCW3+RUbYBaj3v4Hod3Vdza72Ruh1Cn/fPD ftPwlhKPehJqmurw/AyHfhBYlAa39dWasVOeFTG2OgZUTDnJgp45JsAT60TZofv4czf7 emJtGh5ovCFc4HpIaXKmd3N3faJQqsK44Esc8P+7UXKLYgs8gw7wbzyvl3H59dFTxRjl 08jCQ0u67FgmaOsLp9h3NU6nIoxqK60r3HDWxx/K1OtpK/QXnomdhLW/SiL7B+SPap6g 4KFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YdC/nHrI"; 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 f10-20020ac859ca000000b003f4e7d8d1e7si473810qtf.659.2023.05.11.01.14.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 May 2023 01:14:04 -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="YdC/nHrI"; 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 1px1Io-0006jX-Iz; Thu, 11 May 2023 04:05: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 1px1Ie-0006RC-QV for qemu-devel@nongnu.org; Thu, 11 May 2023 04:05:24 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1px1IV-0000wT-5U for qemu-devel@nongnu.org; Thu, 11 May 2023 04:05:20 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-50bc4b88998so14604437a12.3 for ; Thu, 11 May 2023 01:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683792309; x=1686384309; 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=4MyRgw/PtcZChVqlCdO0y70qQ7cwt0IlfzjPvvDgR9k=; b=YdC/nHrInwaBfiwsyuCCO+ZmhAk5cOKOpSlkmbBgEGemBIrgS9OqW04LHKqgACkh2Y DxlY4QwrwzujSROi3DQ+sgWAKqqvZ3g3u0w/ImtOiROlP14tm81rU3qx98cwEOXxDeGi KRpPAJlg4Uh9sUBSOOEACFlDs+xAwJSyRegaCx2i4HRycAxGWfzGHgANskHSEQamV9m6 Uv+hSYJJVhUoraxwDDSPHkEZwbV7tFxA5q28pZPvMTfKKarJzHcGBJm6o+3SyDgJ68wj yi3jfF6HOxwsuH1E5+cn+DQojdpMr1CfOX7lp0hOtXB3sclqNtjAHFokXBnBDAZwPDIz CTtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683792309; x=1686384309; 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=4MyRgw/PtcZChVqlCdO0y70qQ7cwt0IlfzjPvvDgR9k=; b=U7CX6Qhig8F2MjqQim1Dv8x8aVTV4H1PWb27jZyYSpgs0YY0vSiduiwDKPC8m/u69T UyIzfz+aNeLn5XiljLCxEsHADyWzOb6esbzZxh5D4fk8uNWgOG/gRPgmuiLkG13KOGKu ygmQ5+neYTRBLqFCl2ZaUAlbChkOGtytK8QafHBq6xAMyr/JioSrWd8UZrWq1dew7rKu xVBk8FUueRvkfgtWg1LzCeCN1HUQCvcOSRGbqq5uceWhpOpM0REGb3Uq6fht3toaiW8I tyJaO3FWrmr2yGVvRHSZHxNTCslr9b3aIfKCWXKIwripnMcwuK8yS/929jAfGZNtkvfg zCbw== X-Gm-Message-State: AC+VfDxmcA+HfIWFZy5UkpzPFzWAhF4Ux/ek5Xyvo1z4LE8VX/vgJHmZ p8r2CPxB+/hbOw0+yEhjw3GcGIM0mBiE5a9Hp4oSbA== X-Received: by 2002:aa7:c546:0:b0:50b:d4e8:3173 with SMTP id s6-20020aa7c546000000b0050bd4e83173mr16616614edr.8.1683792309340; Thu, 11 May 2023 01:05:09 -0700 (PDT) Received: from stoup.. ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i12-20020aa7c70c000000b0050bd7267a5csm2662095edq.58.2023.05.11.01.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 01:05:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Daniel Henrique Barboza Subject: [PULL 27/53] tcg/ppc: Convert tcg_out_qemu_{ld,st}_slow_path Date: Thu, 11 May 2023 09:04:24 +0100 Message-Id: <20230511080450.860923-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230511080450.860923-1-richard.henderson@linaro.org> References: <20230511080450.860923-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-ed1-x534.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=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 Use tcg_out_ld_helper_args, tcg_out_ld_helper_ret, and tcg_out_st_helper_args. Reviewed-by: Alex Bennée Reviewed-by: Daniel Henrique Barboza Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 88 ++++++++++++---------------------------- 1 file changed, 26 insertions(+), 62 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 0469e299a0..4c479fdece 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2003,44 +2003,38 @@ static void * const qemu_st_helpers[(MO_SIZE | MO_BSWAP) + 1] = { [MO_BEUQ] = helper_be_stq_mmu, }; +static TCGReg ldst_ra_gen(TCGContext *s, const TCGLabelQemuLdst *l, int arg) +{ + if (arg < 0) { + arg = TCG_REG_TMP1; + } + tcg_out32(s, MFSPR | RT(arg) | LR); + return arg; +} + +/* + * For the purposes of ppc32 sorting 4 input registers into 4 argument + * registers, there is an outside chance we would require 3 temps. + * Because of constraints, no inputs are in r3, and env will not be + * placed into r3 until after the sorting is done, and is thus free. + */ +static const TCGLdstHelperParam ldst_helper_param = { + .ra_gen = ldst_ra_gen, + .ntmp = 3, + .tmp = { TCG_REG_TMP1, TCG_REG_R0, TCG_REG_R3 } +}; + static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { - MemOpIdx oi = lb->oi; - MemOp opc = get_memop(oi); - TCGReg hi, lo, arg = TCG_REG_R3; + MemOp opc = get_memop(lb->oi); if (!reloc_pc14(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } - tcg_out_mov(s, TCG_TYPE_PTR, arg++, TCG_AREG0); - - lo = lb->addrlo_reg; - hi = lb->addrhi_reg; - if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - arg |= (TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN); - tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); - tcg_out_mov(s, TCG_TYPE_I32, arg++, lo); - } else { - /* If the address needed to be zero-extended, we'll have already - placed it in R4. The only remaining case is 64-bit guest. */ - tcg_out_mov(s, TCG_TYPE_TL, arg++, lo); - } - - tcg_out_movi(s, TCG_TYPE_I32, arg++, oi); - tcg_out32(s, MFSPR | RT(arg) | LR); - + tcg_out_ld_helper_args(s, lb, &ldst_helper_param); tcg_out_call_int(s, LK, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]); - - lo = lb->datalo_reg; - hi = lb->datahi_reg; - if (TCG_TARGET_REG_BITS == 32 && (opc & MO_SIZE) == MO_64) { - tcg_out_mov(s, TCG_TYPE_I32, lo, TCG_REG_R4); - tcg_out_mov(s, TCG_TYPE_I32, hi, TCG_REG_R3); - } else { - tcg_out_movext(s, lb->type, lo, - TCG_TYPE_REG, opc & MO_SSIZE, TCG_REG_R3); - } + tcg_out_ld_helper_ret(s, lb, false, &ldst_helper_param); tcg_out_b(s, 0, lb->raddr); return true; @@ -2048,43 +2042,13 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { - MemOpIdx oi = lb->oi; - MemOp opc = get_memop(oi); - MemOp s_bits = opc & MO_SIZE; - TCGReg hi, lo, arg = TCG_REG_R3; + MemOp opc = get_memop(lb->oi); if (!reloc_pc14(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } - tcg_out_mov(s, TCG_TYPE_PTR, arg++, TCG_AREG0); - - lo = lb->addrlo_reg; - hi = lb->addrhi_reg; - if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - arg |= (TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN); - tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); - tcg_out_mov(s, TCG_TYPE_I32, arg++, lo); - } else { - /* If the address needed to be zero-extended, we'll have already - placed it in R4. The only remaining case is 64-bit guest. */ - tcg_out_mov(s, TCG_TYPE_TL, arg++, lo); - } - - lo = lb->datalo_reg; - hi = lb->datahi_reg; - if (TCG_TARGET_REG_BITS == 32 && s_bits == MO_64) { - arg |= (TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN); - tcg_out_mov(s, TCG_TYPE_I32, arg++, hi); - tcg_out_mov(s, TCG_TYPE_I32, arg++, lo); - } else { - tcg_out_movext(s, s_bits == MO_64 ? TCG_TYPE_I64 : TCG_TYPE_I32, - arg++, lb->type, s_bits, lo); - } - - tcg_out_movi(s, TCG_TYPE_I32, arg++, oi); - tcg_out32(s, MFSPR | RT(arg) | LR); - + tcg_out_st_helper_args(s, lb, &ldst_helper_param); tcg_out_call_int(s, LK, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); tcg_out_b(s, 0, lb->raddr);