From patchwork Fri May 5 21:24:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 679340 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp579695wrs; Fri, 5 May 2023 14:28:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NlRk1xeCmRdIwZNchoPKVxjzOSirZQ38e4ZTp4VZxm8guuF8cj6FZyaYslKlxX1uyC4je X-Received: by 2002:a05:622a:508:b0:3ee:be98:9fe1 with SMTP id l8-20020a05622a050800b003eebe989fe1mr4723940qtx.22.1683322090900; Fri, 05 May 2023 14:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683322090; cv=none; d=google.com; s=arc-20160816; b=UkskOFj8GorIHLo4ZHCSiY1osn2tFwFG8S/u1buhZJUIn3HGvoxtwjyalwdAedrLTj 93wg6/tk7vSquzZqFrcCIDIEJaPFeXTMZ4iVxhKicEpuARxZA+FTC4PEOg/gLu1LTFX5 EGvV2E/sXHpW4BNFpJaxxipKz2V4D6KKNeeYgN/iF32FTTBTTQMIeC47UvKpKImiRjc1 a59RGkjgPjXF7b/65cxOrFWDOWoPHLDTXdSFuFCdvqX2DJTO5hTbPYsIr448Tvebg5Vg 1XY6wdScCTCM3fNRZMEgwBR65hdQrklK8sl2z9LprAkaP35LyghkaaFZ2yDvqrpFZMet xaNg== 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=N3QoKqsv+R/CZvxHdMJxo06yfgQBTVK77OIFinD6LW0=; b=CPCb/TMOViK7Bm+wDO27TEaeO3QMPiRXCO7FL/7XI1vQ3bKZGaN37ButsPkrQcRZR1 2O/BceqSZocCwxqX91AtbQRFbdKnL1nrsbbxofSYbix4HoEVYamS0MdCiUkisa+N/do7 ffW9/z07+0dXEVRZgP4Y4ahgmPI6egaITagtcqJ78urfgTgkxkj1lyOEqfODK0mjimXW XCkoFdnQkgoXK4aZnc3p74PEcDWuzJ4+OkFjt/CIXZD4woCFhnm+X2VJowVK+yt13S3U u1GtnegNswsBDF8XWnNxsNH8ILM84M9ovkGKUy0c/wAHYIsiQUXG/ZSZ4HjQ+zQmo6o0 p0iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lCcnUi1P; 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 s15-20020a05620a030f00b0074a8a66d1d2si996937qkm.366.2023.05.05.14.28.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 May 2023 14:28:10 -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=lCcnUi1P; 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 1pv2vU-0000n8-3C; Fri, 05 May 2023 17:25:16 -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 1pv2vQ-0000jn-DB for qemu-devel@nongnu.org; Fri, 05 May 2023 17:25:12 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pv2vK-0004eP-Ki for qemu-devel@nongnu.org; Fri, 05 May 2023 17:25:12 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3023a56048bso2068746f8f.3 for ; Fri, 05 May 2023 14:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683321904; x=1685913904; 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=N3QoKqsv+R/CZvxHdMJxo06yfgQBTVK77OIFinD6LW0=; b=lCcnUi1PNBXtVTJG9bDLiZ+8llf4r1cNbKK/Y6LPEnovFCGoIW2aqmicEMk+peJ1ZL Wm9fijbi8Kd2Sd3kLi3K32Dbi+oSj9UbGheOHRkpHCQy5gm5hJVxvfrQWACgCK3wI52o FkR/jABsLj/g+YzblDLKZ3AEW40XzWpCzGnzLIlktpNKbq9YuparbFoLLwH3GedWv5U3 yCV0TBK34E8TK1YmmI0GgJ+QboUNkT/9zxC2iC9z+01krc5W+gtI1b/3wN6RgxnaehTa wpCVIeDtLfKnjRDSlkHs6PWcz7RtMSWwUVc5/C2Q0OP23mADVqs5yeCdARS9UPkLaRMv edgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683321904; x=1685913904; 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=N3QoKqsv+R/CZvxHdMJxo06yfgQBTVK77OIFinD6LW0=; b=cgamqStpaUJX936O8p/SagAnX8f2MaERHL/AYIop0FQas6eWN12q5ZdDANqQMxQgmN LtpxdIQMV11CKp7B594rC0LCc1HARgT6nfHNdW4Lm3fkoe8IhhIisEY751pD6GbhehoE G7XjFEo67ysWyxqKDSrrk9klVK08b41uiswACf92Co9HvQ1LBcV1Jmz8Hv/q/vaGKXkj bO9s3/3YtLeZogLgjuxVIQdGrmYr+XASnzLXi/XBxKkkfVpjMh/kJgQNUxdBbdPNpqbq rvCDIu7umFr0QC8WprLAH5B2Qhf6S7x8Xz5HEMR7Zab0MyThj9qS5//SEZkWx3yiFKbV kZeg== X-Gm-Message-State: AC+VfDw64WvvggopYYZBquyvHBjbSpjOiAhS2kFJjFg2/72Vpq+FBmuN xUu7cHrzAHPvMB5yPdrEtl1TmGnaQqO97V2xHJz+zQ== X-Received: by 2002:adf:e70c:0:b0:306:330e:bfe3 with SMTP id c12-20020adfe70c000000b00306330ebfe3mr2555508wrm.19.1683321904687; Fri, 05 May 2023 14:25:04 -0700 (PDT) Received: from stoup.. ([212.241.182.8]) by smtp.gmail.com with ESMTPSA id t14-20020a5d460e000000b003047ae72b14sm3426709wrq.82.2023.05.05.14.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 14:25:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 29/42] tcg/loongarch64: Introduce HostAddress Date: Fri, 5 May 2023 22:24:34 +0100 Message-Id: <20230505212447.374546-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230505212447.374546-1-richard.henderson@linaro.org> References: <20230505212447.374546-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42f.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 Collect the 2 parts of the host address into a struct. Reorg tcg_out_qemu_{ld,st}_direct to use it. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 55 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 2e3c67054b..6a87a5e5a3 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -1013,36 +1013,41 @@ static TCGReg tcg_out_zext_addr_if_32_bit(TCGContext *s, return addr; } -static void tcg_out_qemu_ld_indexed(TCGContext *s, TCGReg rd, TCGReg rj, - TCGReg rk, MemOp opc, TCGType type) +typedef struct { + TCGReg base; + TCGReg index; +} HostAddress; + +static void tcg_out_qemu_ld_indexed(TCGContext *s, MemOp opc, TCGType type, + TCGReg rd, HostAddress h) { /* Byte swapping is left to middle-end expansion. */ tcg_debug_assert((opc & MO_BSWAP) == 0); switch (opc & MO_SSIZE) { case MO_UB: - tcg_out_opc_ldx_bu(s, rd, rj, rk); + tcg_out_opc_ldx_bu(s, rd, h.base, h.index); break; case MO_SB: - tcg_out_opc_ldx_b(s, rd, rj, rk); + tcg_out_opc_ldx_b(s, rd, h.base, h.index); break; case MO_UW: - tcg_out_opc_ldx_hu(s, rd, rj, rk); + tcg_out_opc_ldx_hu(s, rd, h.base, h.index); break; case MO_SW: - tcg_out_opc_ldx_h(s, rd, rj, rk); + tcg_out_opc_ldx_h(s, rd, h.base, h.index); break; case MO_UL: if (type == TCG_TYPE_I64) { - tcg_out_opc_ldx_wu(s, rd, rj, rk); + tcg_out_opc_ldx_wu(s, rd, h.base, h.index); break; } /* fallthrough */ case MO_SL: - tcg_out_opc_ldx_w(s, rd, rj, rk); + tcg_out_opc_ldx_w(s, rd, h.base, h.index); break; case MO_UQ: - tcg_out_opc_ldx_d(s, rd, rj, rk); + tcg_out_opc_ldx_d(s, rd, h.base, h.index); break; default: g_assert_not_reached(); @@ -1053,23 +1058,23 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, MemOpIdx oi, TCGType data_type) { MemOp opc = get_memop(oi); - TCGReg base, index; + HostAddress h; #ifdef CONFIG_SOFTMMU tcg_insn_unit *label_ptr[1]; tcg_out_tlb_load(s, addr_reg, oi, label_ptr, 1); - index = TCG_REG_TMP2; + h.index = TCG_REG_TMP2; #else unsigned a_bits = get_alignment_bits(opc); if (a_bits) { tcg_out_test_alignment(s, true, addr_reg, a_bits); } - index = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; + h.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); + h.base = tcg_out_zext_addr_if_32_bit(s, addr_reg, TCG_REG_TMP0); + tcg_out_qemu_ld_indexed(s, opc, data_type, data_reg, h); #ifdef CONFIG_SOFTMMU add_qemu_ldst_label(s, true, oi, data_type, data_reg, addr_reg, @@ -1077,24 +1082,24 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, #endif } -static void tcg_out_qemu_st_indexed(TCGContext *s, TCGReg data, - TCGReg rj, TCGReg rk, MemOp opc) +static void tcg_out_qemu_st_indexed(TCGContext *s, MemOp opc, + TCGReg rd, HostAddress h) { /* Byte swapping is left to middle-end expansion. */ tcg_debug_assert((opc & MO_BSWAP) == 0); switch (opc & MO_SIZE) { case MO_8: - tcg_out_opc_stx_b(s, data, rj, rk); + tcg_out_opc_stx_b(s, rd, h.base, h.index); break; case MO_16: - tcg_out_opc_stx_h(s, data, rj, rk); + tcg_out_opc_stx_h(s, rd, h.base, h.index); break; case MO_32: - tcg_out_opc_stx_w(s, data, rj, rk); + tcg_out_opc_stx_w(s, rd, h.base, h.index); break; case MO_64: - tcg_out_opc_stx_d(s, data, rj, rk); + tcg_out_opc_stx_d(s, rd, h.base, h.index); break; default: g_assert_not_reached(); @@ -1105,23 +1110,23 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg, MemOpIdx oi, TCGType data_type) { MemOp opc = get_memop(oi); - TCGReg base, index; + HostAddress h; #ifdef CONFIG_SOFTMMU tcg_insn_unit *label_ptr[1]; tcg_out_tlb_load(s, addr_reg, oi, label_ptr, 0); - index = TCG_REG_TMP2; + h.index = TCG_REG_TMP2; #else unsigned a_bits = get_alignment_bits(opc); if (a_bits) { tcg_out_test_alignment(s, false, addr_reg, a_bits); } - index = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; + h.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); + h.base = tcg_out_zext_addr_if_32_bit(s, addr_reg, TCG_REG_TMP0); + tcg_out_qemu_st_indexed(s, opc, data_reg, h); #ifdef CONFIG_SOFTMMU add_qemu_ldst_label(s, false, oi, data_type, data_reg, addr_reg,