From patchwork Tue Jun 6 09:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 689699 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp2539997wru; Tue, 6 Jun 2023 02:49:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4L+JLEUfQGzOOGbwduGvQ488JS2leT7k8Dmk/EvY0FHJQGqRBERjhdVjQyZA368/c27Vh/ X-Received: by 2002:ac8:7f91:0:b0:3f3:8bce:f1fd with SMTP id z17-20020ac87f91000000b003f38bcef1fdmr1176146qtj.57.1686044981261; Tue, 06 Jun 2023 02:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686044981; cv=none; d=google.com; s=arc-20160816; b=eRF7UIYWvIHNgkhK/J1LmptRjHzahggztaad/RZX/uFrVBUFbjG6G+xeVY6tEztAOI RoqYV+PJdfkDZQsRiYoZxiK2HQQgXq0szMeu2GDF1pXfoWW9PMLFRXnzqO7oJVWTm10v RqrcXqvdmr+CQXmWzAIPTI47P/WePj6/TPWsk9/KHGbu81QEsCmQxSJr/hS3h0HGtUib sqWtFOX4l344iCLMmVJvda2N6ZhRPv3yuB8wHvaHhH+TPffIGaBd875vd3uxF1mgwwDj 7wpddPe0Lxz6iwRMQf3Y2Jd4xjHX0JFOxTsGbtz99feEuBFK2x/tzGG6o2FOUBmUoTkg 29DQ== 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:to:from :dkim-signature; bh=DSMHqJBYQ/ZZe59fxFXssDmNBSSzK/3Oo7RgKV289TI=; b=SuR0Q7YBFXVbzfnXF3rVz2Ny3TiOHRPGSAQgmhfqxxnoWMNk/NiXs8EI1+Jy2PupiI 8fh1SYhTTSvzwdp+AegtXqA7v8jDzO+eNTJLMl+QISS8ByUPolhJKInRptgDXIdG6bDg UxfPA8PWY74kJQ9xY+Yuacm4PBPZSw7PC+LUPAEzWuj0Y3XtZqVGBFewJy3cIBvhG2cJ osPa1KOX5rdOCTbv30k7m1bXyCfcHzx7/AW9+UF8iISkRaMIB9X8EnXVUHslha+yJI4v OMaHwsNdsIgNoqJFtk8PSqnP2V6yugl6elpk4fJgsDmob/VWWsiQ1mk6zap3pj9SzuMF tTLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YI+IRAhD; 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 j10-20020a05622a038a00b003f39543cea9si1507785qtx.560.2023.06.06.02.49.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Jun 2023 02:49:41 -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=YI+IRAhD; 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 1q6TIr-0007lk-H1; Tue, 06 Jun 2023 05:48:37 -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 1q6TIp-0007ja-Ja for qemu-devel@nongnu.org; Tue, 06 Jun 2023 05:48:36 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6TIk-0004oN-S5 for qemu-devel@nongnu.org; Tue, 06 Jun 2023 05:48:35 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f739ec88b2so20106115e9.1 for ; Tue, 06 Jun 2023 02:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686044909; x=1688636909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DSMHqJBYQ/ZZe59fxFXssDmNBSSzK/3Oo7RgKV289TI=; b=YI+IRAhDulh1kJrkxp1T1G3dAweTD8IXhSyWi3fATJMFRGafJEkFrS2imCkpT54la1 hmN+qdI7zaGt1diiH0cHIbjynGDjlqVBWEZxkqmOn2h/aej0hucSkIRjTweo97xq8FwH z3YF4oRp3kZcSbDWghYueJ1uTYf170xHzYC/H93HL49OrPUJF3MDmyvRvPhZtvbAhU/R 5nmjf597q2x3XKz7Pob0WcieGsab06EqnBwjhqCYFEyh5kGM8MG6zIUiue8i6XRgpU/L /DjSzXlveAIaBBVSg9IK780Wulcuf2PitKuoOYvQmo+gFyFXt7itzcUHsOsCc02yldSt FiLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686044909; x=1688636909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DSMHqJBYQ/ZZe59fxFXssDmNBSSzK/3Oo7RgKV289TI=; b=g0nh22hfXfpN10MjjdyDQoCUUVvJDxP6tcu4xlsfsLgrqkn1xJJsgGUMRRZb9dawIo m7EDvjzEA80qXpXNWHSq/JmSM51hr1lIrleYcIc2dLIXybJGWEqqys9+eguQLOYe8t8F FsnilFMPQNHgxoQT9PpGyTNceStCFb0wlvpvBquhJ2lU7WjpZnYjhqcNsb+9TkaFlFlS DCRIhM//iHkJLjYBZ86Psa5vgPHlRZxZ3WpQH43Ums/qmgH/80yYa2DNU5QDMLkVy7do Ebju9vuY/z0M1gj0vmiblB2zI6V0LjyXpgVWcuW+RIt9RnQRU9akhaqY4O7nNKYIfKJF CFHw== X-Gm-Message-State: AC+VfDyoBvj2XV/WmZSxAC6S7ORKQAVGTGBM6u2sGzypHV8CXFBysfbN rbgHQ57I6HhcP2azOyEfp78K7d6bS2bvW6O8qRk= X-Received: by 2002:a05:600c:ace:b0:3f7:e6d8:457b with SMTP id c14-20020a05600c0ace00b003f7e6d8457bmr1518190wmr.19.1686044909555; Tue, 06 Jun 2023 02:48:29 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v10-20020a5d4b0a000000b0030789698eebsm12134017wrq.89.2023.06.06.02.48.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 02:48:29 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 28/42] target/arm: Load/store integer pair with one tcg operation Date: Tue, 6 Jun 2023 10:48:00 +0100 Message-Id: <20230606094814.3581397-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230606094814.3581397-1-peter.maydell@linaro.org> References: <20230606094814.3581397-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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 From: Richard Henderson This is required for LSE2, where the pair must be treated atomically if it does not cross a 16-byte boundary. But it simplifies the code to do this always. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230530191438.411344-10-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 70 ++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 15 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 729947b11a4..88183f9dca1 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2942,26 +2942,66 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn) } else { TCGv_i64 tcg_rt = cpu_reg(s, rt); TCGv_i64 tcg_rt2 = cpu_reg(s, rt2); + MemOp mop = size + 1; + + /* + * With LSE2, non-sign-extending pairs are treated atomically if + * aligned, and if unaligned one of the pair will be completely + * within a 16-byte block and that element will be atomic. + * Otherwise each element is separately atomic. + * In all cases, issue one operation with the correct atomicity. + * + * This treats sign-extending loads like zero-extending loads, + * since that reuses the most code below. + */ + if (s->align_mem) { + mop |= (size == 2 ? MO_ALIGN_4 : MO_ALIGN_8); + } + mop = finalize_memop_pair(s, mop); if (is_load) { - TCGv_i64 tmp = tcg_temp_new_i64(); + if (size == 2) { + int o2 = s->be_data == MO_LE ? 32 : 0; + int o1 = o2 ^ 32; - /* Do not modify tcg_rt before recognizing any exception - * from the second load. - */ - do_gpr_ld(s, tmp, clean_addr, size + is_signed * MO_SIGN, - false, false, 0, false, false); - tcg_gen_addi_i64(clean_addr, clean_addr, 1 << size); - do_gpr_ld(s, tcg_rt2, clean_addr, size + is_signed * MO_SIGN, - false, false, 0, false, false); + tcg_gen_qemu_ld_i64(tcg_rt, clean_addr, get_mem_index(s), mop); + if (is_signed) { + tcg_gen_sextract_i64(tcg_rt2, tcg_rt, o2, 32); + tcg_gen_sextract_i64(tcg_rt, tcg_rt, o1, 32); + } else { + tcg_gen_extract_i64(tcg_rt2, tcg_rt, o2, 32); + tcg_gen_extract_i64(tcg_rt, tcg_rt, o1, 32); + } + } else { + TCGv_i128 tmp = tcg_temp_new_i128(); - tcg_gen_mov_i64(tcg_rt, tmp); + tcg_gen_qemu_ld_i128(tmp, clean_addr, get_mem_index(s), mop); + if (s->be_data == MO_LE) { + tcg_gen_extr_i128_i64(tcg_rt, tcg_rt2, tmp); + } else { + tcg_gen_extr_i128_i64(tcg_rt2, tcg_rt, tmp); + } + } } else { - do_gpr_st(s, tcg_rt, clean_addr, size, - false, 0, false, false); - tcg_gen_addi_i64(clean_addr, clean_addr, 1 << size); - do_gpr_st(s, tcg_rt2, clean_addr, size, - false, 0, false, false); + if (size == 2) { + TCGv_i64 tmp = tcg_temp_new_i64(); + + if (s->be_data == MO_LE) { + tcg_gen_concat32_i64(tmp, tcg_rt, tcg_rt2); + } else { + tcg_gen_concat32_i64(tmp, tcg_rt2, tcg_rt); + } + tcg_gen_qemu_st_i64(tmp, clean_addr, get_mem_index(s), mop); + } else { + TCGv_i128 tmp = tcg_temp_new_i128(); + + if (s->be_data == MO_LE) { + tcg_gen_concat_i64_i128(tmp, tcg_rt, tcg_rt2); + } else { + tcg_gen_concat_i64_i128(tmp, tcg_rt2, tcg_rt); + } + tcg_gen_qemu_st_i128(tmp, clean_addr, get_mem_index(s), mop); + } } }