From patchwork Tue Apr 11 01:05:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 672327 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp539112wrx; Mon, 10 Apr 2023 18:17:58 -0700 (PDT) X-Google-Smtp-Source: AKy350ar+j9QyCVDDvJcfnMsmcEmbLhJ/VwwmRdKJ3OBkf7t+LqATL7xduj9bqo7W2uKxQjroRxd X-Received: by 2002:a05:6214:d86:b0:5e8:f222:7fda with SMTP id e6-20020a0562140d8600b005e8f2227fdamr20430765qve.40.1681175877863; Mon, 10 Apr 2023 18:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681175877; cv=none; d=google.com; s=arc-20160816; b=yjYfiHKuykWacG0XtFAPQsFA/wKBq4w1m2YAzLGfHYnE13kwgT08U7bW56+4BxkBgV a9Odf5cTQeAdyGPY1+ebcwFQUwZn7neVot1n+kyR6vcO09+VqsCup2PEh2Qfx9wd1EHQ n5iqD37dk2PaSkYKbfaBruvf0lEA6hFeZjm4P1D/yMdFGwOsdxt0PgFouUgjew6XchEV dgbKKv6XSgptZXb3gciqdfCoKgEbxhQc35nDHqA3Ha5DBMlEqCPY+iU/cSYxHr0UbUje EVJLqScR7fD0SRbJEhHLZqJttC5EWHNqEKGv7Bu9ucluush9/eqf4IBAeZ32jUqvJjSZ mJXg== 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=whk/sbAs9+BgxjsuU75DgmoVbPnFYtMBoe2U/lcKgTQ=; b=Fk4i0VWgmt3IJUtZmPxWw6WJb4g/nTh+L0wSurPncTmHHVyY5Y2D1CQVOdwy2RYZf6 85wZiFK00aMbZEOaWKoXvlE7Yi/Hr2WbQs75iuz/k6SDFXdZvkKnatQwHh0X+nrgHJvF 6CZy/eCjfdU3MeovH9Qe10/YB5TvTcItrrdeTGZ+Mo4EqOW1g85eiWmEUpq9TDNGOuSS nz5RgmKGhEaMOi/35NYKSAsVRryGjIfzAn5pGuBShY6z96e5kagdTyxJnK1FAQLPvQJP HZHs0dy7FZcClCLrO9D54NiRCfigUhzJRofgEXcGns2e5M7M4GQ1cLANih2I0+rnH8xH TXxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OR2xHDnp; 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 o11-20020ac85a4b000000b003e3921b0837si8375915qta.216.2023.04.10.18.17.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Apr 2023 18:17:57 -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=OR2xHDnp; 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 1pm2Wc-0004eU-7Q; Mon, 10 Apr 2023 21:10:22 -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 1pm2WR-0003ki-Cj for qemu-devel@nongnu.org; Mon, 10 Apr 2023 21:10:12 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pm2WO-0001uB-7B for qemu-devel@nongnu.org; Mon, 10 Apr 2023 21:10:11 -0400 Received: by mail-pj1-x102f.google.com with SMTP id c10-20020a17090abf0a00b0023d1bbd9f9eso9348215pjs.0 for ; Mon, 10 Apr 2023 18:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681175406; 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=whk/sbAs9+BgxjsuU75DgmoVbPnFYtMBoe2U/lcKgTQ=; b=OR2xHDnpp8bhheZrUJB2FxNDewxKz2u5/msylF1TuSGrGk5kWLRLzDb9p1RKMvZ3EP gtHBa+tZtM0w/ip1w9k10JtcgXlz4lXN8bhbHXEqXI3PC4s0cC/DK4vyJtq46Qj+LQFN T6gbPtsouKNDtSTXu0XSoPGIbGHoU3KnmsEmyuICaFstZF6anOO14RzlkTqjp7bOfasj 5sGhMwtPjgrKyXy4It8i84r/+Zd1/9v7gucnfYvyy0JwvtJt+IKbk1EgnMjOp4mbUy9X cXJhsFxhrUgqHxt8MtHIH0sVsKtCugaGGB2bC0iaO6L+JsJanq1LylsFQB4VrV8/yqTJ 5hyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681175406; 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=whk/sbAs9+BgxjsuU75DgmoVbPnFYtMBoe2U/lcKgTQ=; b=0pkNYLj7UxSXT4zAefUBhph4eHQypaSgotzmU6ciJgILmuU15Mglk4v8d7DqLbf8/8 Fg7jUYelnegbfmAF5Ki+m5OECMd3owAeKJWg+LsddymnJXLpUow03gAhOQlN5JKuMfXZ kg6n4vY/8Jc98Gjk9VOP+M4wpKt6HYusIku0wbGrYjofp2JZdrCzHs41uR4bNIEX1F/l HnzJ+MqumC778N1QOhFYp4Aqg5H2Xs2wIwZdjfPcWjJan4ZLqEZUg372IsQFiTqsrNEG GbZWe4PvKTQVpxTWuZerQ1wQCMBl3mJifd3q7f6DC+Zr4VK5bHoy9yhg4crNVw2vG8hQ vS9g== X-Gm-Message-State: AAQBX9eeEJSCWR1NJnyrJz3V+teY2BUcLAKyLB0Bj59Z0i2kLp7NfQLL X/xPjrxvDHv/em3ZgsQS2OkjxTJzWSf8Z/XMPr2cmg== X-Received: by 2002:a17:903:124a:b0:1a1:d624:2fe2 with SMTP id u10-20020a170903124a00b001a1d6242fe2mr16822239plh.17.1681175405708; Mon, 10 Apr 2023 18:10:05 -0700 (PDT) Received: from stoup.WiFi.IPv4InfoBelow (h146.238.133.40.static.ip.windstream.net. [40.133.238.146]) by smtp.gmail.com with ESMTPSA id p12-20020a1709028a8c00b001a63deeb5e2sm2652130plo.92.2023.04.10.18.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 18:10:05 -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 Subject: [PATCH v2 42/54] tcg/ppc: Convert tcg_out_qemu_{ld,st}_slow_path Date: Mon, 10 Apr 2023 18:05:00 -0700 Message-Id: <20230411010512.5375-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411010512.5375-1-richard.henderson@linaro.org> References: <20230411010512.5375-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.google.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 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, SUSPICIOUS_RECIPS=2.51 autolearn=no 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. Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza --- 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 90093a6509..1b60166d2f 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -2137,44 +2137,38 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, label->label_ptr[0] = lptr; } +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; @@ -2182,43 +2176,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);