From patchwork Tue Apr 11 01:04:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 672314 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp537850wrx; Mon, 10 Apr 2023 18:14:09 -0700 (PDT) X-Google-Smtp-Source: AKy350ZmiwpkbY3Lc6+6AOVMNUiEeycN4/WC+bFlCArIltZfi3z5FYMfLBKEOccWi/KkOlgi5dqY X-Received: by 2002:a05:622a:180d:b0:3e1:9a13:66b2 with SMTP id t13-20020a05622a180d00b003e19a1366b2mr14059433qtc.24.1681175649262; Mon, 10 Apr 2023 18:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681175649; cv=none; d=google.com; s=arc-20160816; b=JiVFHOuaolNESMyjtc+yTkvbLGiVC4a3q+bWQuo5nf88Sm+mZHf0dlfvvXbt4w0uIv Fn2S7BTIn2/ZyEk3pQjqxm2Hcw/66s/azcRJb7p2P6ISb+5PCkPquhH96kKsnagM+6fA MGc0scYNJcmbmUPVklELQQa4Yy5NsX5mMy8SaYBzPZdt71GlxAo42o+auVAX9fc8RjEz g1EMaEDKHFCoyfC1OZYKj4ZfRXml9loxi6AKO9c8CyNUKPpe5LMZGCgFx8tUQp4L18g9 8b0zd3WRvr7sLOFw26yluW2AYkHPoTa0d5cTN9UeyLlD/AWDs/NK2nbUSkujOwPDYAv8 uolg== 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=CKis80chZUaL+QCeBY/st3bpNxzPB2hybijcnSgD+kY=; b=OGV5fy0Buj9rvUnyHskDopgNfS7mwXBN76OYuUIV/J4Y86ZcJUtoUjNx5a8+i4wlxa Htzh+Gm4D0GmJGoLBrAVxTC3apQTC2RJ4YC7bWOhZlNqCVNAQsFKIkNU6V2+6au2+KEA /9sZqXoJ0Szvaws2lmBQQiBcVPyUR14jNlwsg5oCz7N/VgRBwEMs6LjNU1WpjAXkzUXY duSiWEhRUPlEuGKKcL1uSNhEwu40w+ZASmcu+CvBBj70uYruAEHtQl82coFBoa1d49us 8i/JdGdfij7PTQmTED98CbZ4C5dCr+ZsisRWBO0V8zHKhRwcvSucP1WoZygXsBWy/QNz 29PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SMkr67+2; 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=fail (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 t1-20020ac85881000000b003b9b44758eesi8210299qta.730.2023.04.10.18.14.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Apr 2023 18:14: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=fail header.i=@linaro.org header.s=google header.b=SMkr67+2; 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=fail (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 1pm2T5-0005wK-5O; Mon, 10 Apr 2023 21:06:43 -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 1pm2Ss-0005QB-M9 for qemu-devel@nongnu.org; Mon, 10 Apr 2023 21:06:30 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pm2So-0000r1-Db for qemu-devel@nongnu.org; Mon, 10 Apr 2023 21:06:30 -0400 Received: by mail-pl1-x636.google.com with SMTP id e13so5953847plc.12 for ; Mon, 10 Apr 2023 18:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681175185; 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=CKis80chZUaL+QCeBY/st3bpNxzPB2hybijcnSgD+kY=; b=SMkr67+2j4j9auD4OV8bJ1VCiaww0bcrZscbQiljSaJdr9BHdhMvhh/m+eEJbjuMCI VVkoH/Ouoae6183aGrViXqtCKfb1bjWqZMHqRoDnYCQG9PDTNCzCxU4/DxHUlPX47Wwr rKBZ6rkY06tcF3P42Pt5XSc/VBMZzVG1irx4bZQxJJa/XNQm/kYXc25WKoLA0F0mvsS9 i7ksDvOWEMLfCg5rv3Ad/3Bwqrxpr4yzXXNt20Wm1Xxtx4EtznMSLJGRmUa/Ct+hR5XG jVm7o90UibRTGyYqeh+uyKHU0BjWCysywkiXm89zPvzlRx7aCplaBhyx1d37jp4s4XXV npMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681175185; 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=CKis80chZUaL+QCeBY/st3bpNxzPB2hybijcnSgD+kY=; b=2QmAecmb/jZkRDHSjUt4LK0F5UFkoSPHhvi6wdo3LJu/8kRCN2+mAYMwxPtDLnnB6V nLGLcG2ktkLQQd0V9awNuIBafYdtt8rv5TcYd6Ci1oFz+5DctEN5Yv/ZHXoF/axTmwMD y1PJtqgpS1IU7XX4BsL3oKs4Fq9rj2DIglhIy6NqCQYXQEXKAOoZSLgBaTvhEdG8ulqj PoMFL0nhNIzIXwJgzWb3hnaW1aofvXgpYfz9fh6hsc2dpQvFaDlg65+7r1YVUut0jIIc rzHutITItNQw8EvTi+jHQ4nP8Z0Gj40DwH5IG11kJ/A4mglApHzdIHYy5LH6lsvXBEPl WlJA== X-Gm-Message-State: AAQBX9emHF01URtwYB7/iKtpjwAqKsmwgLIrLLfdK9WKV8aLWPfBYA2z lvBFjGMsxrHrtDQeCrbMhOd1gGclDNqqKYev4GT/3g== X-Received: by 2002:a17:90b:1e09:b0:246:da2a:49be with SMTP id pg9-20020a17090b1e0900b00246da2a49bemr1374536pjb.20.1681175184820; Mon, 10 Apr 2023 18:06:24 -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 s10-20020a65690a000000b0051b0e564963sm1320291pgq.49.2023.04.10.18.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 18:06:24 -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 24/54] tcg/loongarch64: Rationalize args to tcg_out_qemu_{ld, st} Date: Mon, 10 Apr 2023 18:04:42 -0700 Message-Id: <20230411010512.5375-25-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::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 Interpret the variable argument placement in the caller. Mark the argument registers const, because they must be passed to add_qemu_ldst_label unmodified. Shift some code around slightly to share more between softmmu and user-only. Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 102 +++++++++++++------------------ 1 file changed, 44 insertions(+), 58 deletions(-) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 0940788c6f..0daefa18fc 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -1049,39 +1049,32 @@ static void tcg_out_qemu_ld_indexed(TCGContext *s, TCGReg rd, TCGReg rj, } } -static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, TCGType type) +static void tcg_out_qemu_ld(TCGContext *s, const TCGReg data_reg, + const TCGReg addr_reg, const MemOpIdx oi, + TCGType data_type) { - TCGReg addr_regl; - TCGReg data_regl; - MemOpIdx oi; - MemOp opc; -#if defined(CONFIG_SOFTMMU) + MemOp opc = get_memop(oi); + TCGReg base, index; + +#ifdef CONFIG_SOFTMMU tcg_insn_unit *label_ptr[1]; -#else - unsigned a_bits; -#endif - TCGReg base; - data_regl = *args++; - addr_regl = *args++; - oi = *args++; - opc = get_memop(oi); - -#if defined(CONFIG_SOFTMMU) - tcg_out_tlb_load(s, addr_regl, oi, label_ptr, 1); - base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); - tcg_out_qemu_ld_indexed(s, data_regl, base, TCG_REG_TMP2, opc, type); - add_qemu_ldst_label(s, 1, oi, type, - data_regl, addr_regl, - s->code_ptr, label_ptr); + tcg_out_tlb_load(s, addr_reg, oi, label_ptr, 1); + index = TCG_REG_TMP2; #else - a_bits = get_alignment_bits(opc); + unsigned a_bits = get_alignment_bits(opc); if (a_bits) { - tcg_out_test_alignment(s, true, addr_regl, a_bits); + tcg_out_test_alignment(s, true, addr_reg, a_bits); } - base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); - TCGReg guest_base_reg = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; - tcg_out_qemu_ld_indexed(s, data_regl, base, guest_base_reg, opc, type); + index = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; +#endif + + base = tcg_out_zext_addr_if_32_bit(s, addr_reg, TCG_REG_TMP0); + tcg_out_qemu_ld_indexed(s, data_reg, base, index, opc, data_type); + +#ifdef CONFIG_SOFTMMU + add_qemu_ldst_label(s, true, oi, data_type, data_reg, addr_reg, + s->code_ptr, label_ptr); #endif } @@ -1109,39 +1102,32 @@ static void tcg_out_qemu_st_indexed(TCGContext *s, TCGReg data, } } -static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, TCGType type) +static void tcg_out_qemu_st(TCGContext *s, const TCGReg data_reg, + const TCGReg addr_reg, const MemOpIdx oi, + TCGType data_type) { - TCGReg addr_regl; - TCGReg data_regl; - MemOpIdx oi; - MemOp opc; -#if defined(CONFIG_SOFTMMU) + MemOp opc = get_memop(oi); + TCGReg base, index; + +#ifdef CONFIG_SOFTMMU tcg_insn_unit *label_ptr[1]; -#else - unsigned a_bits; -#endif - TCGReg base; - data_regl = *args++; - addr_regl = *args++; - oi = *args++; - opc = get_memop(oi); - -#if defined(CONFIG_SOFTMMU) - tcg_out_tlb_load(s, addr_regl, oi, label_ptr, 0); - base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); - tcg_out_qemu_st_indexed(s, data_regl, base, TCG_REG_TMP2, opc); - add_qemu_ldst_label(s, 0, oi, type, - data_regl, addr_regl, - s->code_ptr, label_ptr); + tcg_out_tlb_load(s, addr_reg, oi, label_ptr, 0); + index = TCG_REG_TMP2; #else - a_bits = get_alignment_bits(opc); + unsigned a_bits = get_alignment_bits(opc); if (a_bits) { - tcg_out_test_alignment(s, false, addr_regl, a_bits); + tcg_out_test_alignment(s, false, addr_reg, a_bits); } - base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); - TCGReg guest_base_reg = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; - tcg_out_qemu_st_indexed(s, data_regl, base, guest_base_reg, opc); + index = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; +#endif + + base = tcg_out_zext_addr_if_32_bit(s, addr_reg, TCG_REG_TMP0); + tcg_out_qemu_st_indexed(s, data_reg, base, index, opc); + +#ifdef CONFIG_SOFTMMU + add_qemu_ldst_label(s, false, oi, data_type, data_reg, addr_reg, + s->code_ptr, label_ptr); #endif } @@ -1564,16 +1550,16 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_qemu_ld_i32: - tcg_out_qemu_ld(s, args, TCG_TYPE_I32); + tcg_out_qemu_ld(s, a0, a1, a2, TCG_TYPE_I32); break; case INDEX_op_qemu_ld_i64: - tcg_out_qemu_ld(s, args, TCG_TYPE_I64); + tcg_out_qemu_ld(s, a0, a1, a2, TCG_TYPE_I64); break; case INDEX_op_qemu_st_i32: - tcg_out_qemu_st(s, args, TCG_TYPE_I32); + tcg_out_qemu_st(s, a0, a1, a2, TCG_TYPE_I32); break; case INDEX_op_qemu_st_i64: - tcg_out_qemu_st(s, args, TCG_TYPE_I64); + tcg_out_qemu_st(s, a0, a1, a2, TCG_TYPE_I64); break; case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */