From patchwork Thu May 25 23:25: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: 685640 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp623418wrt; Thu, 25 May 2023 16:28:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QjorZJA8+e2wWVANopIDiH5AiDoVgxMh/xmsnBCkOPw6Hl1HCm/rbQl4aFXjCP4yUGH8X X-Received: by 2002:a05:620a:e8c:b0:75b:23a0:de87 with SMTP id w12-20020a05620a0e8c00b0075b23a0de87mr446626qkm.5.1685057324119; Thu, 25 May 2023 16:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685057324; cv=none; d=google.com; s=arc-20160816; b=GaPjGBBnMkhi+ghbkvpAid3zhq5M0aTuUysi/cgOIZVaKMfJWB6Vs6YuspM0CFNRxP xAI84rOvfdS1yZbEpxR6WRWsxn4mwaOBBbsUCsTRME1d9vldfSS0MlwsczC1AzzF0lMi HTh4qR6xO9oYSp9/OM0FsGzrcBHDG505EY4gBJKjF4Eh6fwW10l7tU8LSJDX7WhhjBcX fM/f4lNtFcXHrs5Rqd1NHvAc92Stv0aAnZftfEb2qt/9LYCZN8vdAX5V8UtXo+xA9/qH GqP2YKmqkftpIRuN3sJn4v/2fuZfHtQcK+SSz01JeCvJA2pLOykd4SYEmjpDW7/gib6K vnow== 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=reNglzojAm/2eSC7ZTJRnNXnyOyaPQoOTSyZDoXpgF4=; b=q2U25OPOMKc3zKVWp1X1sKyFFZ0vp+Z1Sbnq9/HepulB0ax25RTsgnAXXIy2CWEB/t lLonUH+E2+YrFzd5KxIds18pH2hdra7pPKqmdwsg7/bw02kPGyYBPjjhr8sBolEaDGtU 97P6x1JoC4Z8utxQhX+0H4tS7bS78zj4wIlBeRAmnojfDzPOiWFe1vTv7Eaxu5F4pC3j vy0T5H9olZWyDVLGo/T/CVIFd0bKGXVSi8v4xQ2WqwKCOSJid1LT67/e0Cf3vT91SS33 nT0lx+JWnN2jgcugyZqe8bbmKB9aPgbRE3rCPvhQFk/MPJvWcwh+Sh3N4per07F466GM OJOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ttAFYgjU; 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 x10-20020a05620a12aa00b0075c9cb484edsi922752qki.628.2023.05.25.16.28.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 May 2023 16:28:44 -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=ttAFYgjU; 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 1q2KLY-0005qI-Vj; Thu, 25 May 2023 19:26:17 -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 1q2KLR-0005me-JP for qemu-devel@nongnu.org; Thu, 25 May 2023 19:26:12 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2KLO-0005lS-7z for qemu-devel@nongnu.org; Thu, 25 May 2023 19:26:09 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-51b33c72686so72345a12.1 for ; Thu, 25 May 2023 16:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685057163; x=1687649163; 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=reNglzojAm/2eSC7ZTJRnNXnyOyaPQoOTSyZDoXpgF4=; b=ttAFYgjUID5bqCY5HC/r3gQuI2aI9gNe+jagFjsluF337n7Lf025YSJ641UTid+hDq n6/IHd4juVDXp7WaoZR3Jov4xLHTDmKc86LHJoyhpht2wY7opNAiHeta9TDyBoclnLNX ueelr0BKoY8DHmyarT2HP7zYAypka3JN0rLCjfl5Q+JaoUkpybcNWxDEYjRNlhJ96aST UREOucQlIuTC49VvzkGm7N23bxtt3jkSrLaWM2PoRBj+IQxP6QwnY0cYCuB43G9T81MT brPPmXsF2YTRhWvKah0dao4f1cmovQjWFcVp5xjnnhFWauiJ9DKbU7h+jNRx6CYBz1GG CDqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685057163; x=1687649163; 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=reNglzojAm/2eSC7ZTJRnNXnyOyaPQoOTSyZDoXpgF4=; b=M1mR1KcxgzMcQkssXDSRvCncizUZlkI9z/hzD6JmDJVjS67MYs5s0idisWDTPvoRbG XSfETYvU+kJEeVN4zsA7x9DMm9CqDzXwOMAVggU1cUMh/sOc5b1VcBNF+IYK3VMR482n xpTPGd060qkHlxGieyu/nFzvhvkfWAyO8NsqysnQc/TX544btramGpJF3UTv/R6qIHZ/ qhsLX1twBt3zEsGjobVdR44DDVvMox2ITPosV9/f8cXONsFzUWbPBhhg85NmRWaoyRiy nfM8xJnXTkOROY0q7p4Tl0g9ACMbEcpcsk/rtjOIOTlbVjMI5wW+12iLWnbturKI0yxz LbAw== X-Gm-Message-State: AC+VfDwbuYWGoK6BH1Y38np2y3qWoesbdH9bmg8C5xQlEwDhCbNDGCZB lCijcYARQlXaWjeQnX17ghAZ9KE0KoNAnQmhdKE= X-Received: by 2002:a17:902:d2c9:b0:1a9:90bc:c3c6 with SMTP id n9-20020a170902d2c900b001a990bcc3c6mr464591plc.16.1685057162943; Thu, 25 May 2023 16:26:02 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:7ac5:31cc:3997:3a16]) by smtp.gmail.com with ESMTPSA id s15-20020a170902ea0f00b0019e60c645b1sm1885036plg.305.2023.05.25.16.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 16:26:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 04/20] target/arm: Use tcg_gen_qemu_ld_i128 for LDXP Date: Thu, 25 May 2023 16:25:42 -0700 Message-Id: <20230525232558.1758967-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525232558.1758967-1-richard.henderson@linaro.org> References: <20230525232558.1758967-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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 While we don't require 16-byte atomicity here, using a single larger load simplifies the code, and makes it a closer match to STXP. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/tcg/translate-a64.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 967400ed68..0e720f2612 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -2398,14 +2398,14 @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2, TCGv_i64 addr, int size, bool is_pair) { int idx = get_mem_index(s); - MemOp memop = s->be_data; + MemOp memop; g_assert(size <= 3); if (is_pair) { g_assert(size >= 2); if (size == 2) { /* The pair must be single-copy atomic for the doubleword. */ - memop |= MO_64 | MO_ALIGN; + memop = finalize_memop(s, MO_64 | MO_ALIGN); tcg_gen_qemu_ld_i64(cpu_exclusive_val, addr, idx, memop); if (s->be_data == MO_LE) { tcg_gen_extract_i64(cpu_reg(s, rt), cpu_exclusive_val, 0, 32); @@ -2415,21 +2415,30 @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2, tcg_gen_extract_i64(cpu_reg(s, rt2), cpu_exclusive_val, 0, 32); } } else { - /* The pair must be single-copy atomic for *each* doubleword, not - the entire quadword, however it must be quadword aligned. */ - memop |= MO_64; - tcg_gen_qemu_ld_i64(cpu_exclusive_val, addr, idx, - memop | MO_ALIGN_16); + /* + * The pair must be single-copy atomic for *each* doubleword, not + * the entire quadword, however it must be quadword aligned. + * Expose the complete load to tcg, for ease of tlb lookup, + * but indicate that only 8-byte atomicity is required. + */ + TCGv_i128 t16 = tcg_temp_new_i128(); - TCGv_i64 addr2 = tcg_temp_new_i64(); - tcg_gen_addi_i64(addr2, addr, 8); - tcg_gen_qemu_ld_i64(cpu_exclusive_high, addr2, idx, memop); + memop = finalize_memop_atom(s, MO_128 | MO_ALIGN_16, + MO_ATOM_IFALIGN_PAIR); + tcg_gen_qemu_ld_i128(t16, addr, idx, memop); + if (s->be_data == MO_LE) { + tcg_gen_extr_i128_i64(cpu_exclusive_val, + cpu_exclusive_high, t16); + } else { + tcg_gen_extr_i128_i64(cpu_exclusive_high, + cpu_exclusive_val, t16); + } tcg_gen_mov_i64(cpu_reg(s, rt), cpu_exclusive_val); tcg_gen_mov_i64(cpu_reg(s, rt2), cpu_exclusive_high); } } else { - memop |= size | MO_ALIGN; + memop = finalize_memop(s, size | MO_ALIGN); tcg_gen_qemu_ld_i64(cpu_exclusive_val, addr, idx, memop); tcg_gen_mov_i64(cpu_reg(s, rt), cpu_exclusive_val); }