From patchwork Sat Oct 21 05:31:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 736665 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp634625wrl; Fri, 20 Oct 2023 22:46:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFF5BnY865M7VsgbCJ30TnU2QkY33GD7TwvN2XKWR9JhC1+AA+2uGh8NdHLFTgdIxV1QeIw X-Received: by 2002:a05:620a:1108:b0:76e:fea2:cc79 with SMTP id o8-20020a05620a110800b0076efea2cc79mr3410354qkk.67.1697867166017; Fri, 20 Oct 2023 22:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697867166; cv=none; d=google.com; s=arc-20160816; b=bvwr6OakgeV37FOkBsqYoG4cMUFj1Yi/vy1/aX/1ZrvZInBbODNu7JWg/XIIVorhyk zXkHbLM8uNfgIMG+epwW+eK6zmk72PwKpQpH62y8JUUEtZW+Jo40NSFuHHqybQQRa95H 41oO2f0I0X3fuoA0JH3MNxCoAEPmtniOV8+H/D7Sm9LFYxc9aAbArrwCJL06N20+pzAp EsSU7X3qe3L2HMpXMaB2IFtF66VKn8ENtdmjw81WQWOmygAOLkTpocDeOR7DofYrC+Na cLMQnD3zdqjM+MvU1VpN4Ugmn/buXDPvcEbot/9MCYUMS4TsW5+4uTpYrhcQ0FTfNlOH wk2A== 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=oYhZ5h6y1sX5qhFTzMtfi7bhQk1LvgzZSBf+UyyWnvk=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=tNv33dv/Dl/GW9M2VCfo6mM4KgMJ1taLmXLcNcpSvLTCjxusb8xwXmz52KpzxLM022 IkVjCap0l1fRPNhbWpt++buvf7UJqdqKDT6AXryFqIXtpBH3HF2tRv6XlIdV+WGhSwPf R2C8HBW+3qJRlNNho5nwDVTp7A6etgm1IJy5RkbeYegXuqJM6iHbsxfJCliC2jQFLwtW sRiF82KeYLDWwVcCGnyAzbe3Rk4zzkPEpxeXOS6RqQMK2f/sNMzeZmHdr8zS8zkrDoVi Q5ZI/C0ME+qhS1fZCaTf+V8sGHAgncouyQ1gDvncvZCHZnoVS9hpQAn2WYKa4kazOVek SS3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mlxruulg; 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 qr21-20020a05620a391500b00778b0f5d4c0si1434176qkn.566.2023.10.20.22.46.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2023 22:46:06 -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=mlxruulg; 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 1qu4eZ-0003Km-CW; Sat, 21 Oct 2023 01:36:03 -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 1qu4eH-0002WR-Rf for qemu-devel@nongnu.org; Sat, 21 Oct 2023 01:35:48 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qu4eF-00016e-V4 for qemu-devel@nongnu.org; Sat, 21 Oct 2023 01:35:45 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso1122175a12.3 for ; Fri, 20 Oct 2023 22:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697866542; x=1698471342; darn=nongnu.org; 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=oYhZ5h6y1sX5qhFTzMtfi7bhQk1LvgzZSBf+UyyWnvk=; b=mlxruulgCnui90T3m6Dhg5B4CxWarsraBq+RLPa6k1zUhWEKmawLP6RSRum8qVw0dL wdWSunkoQ5HRE77Hp742Vdp4ISCTSkrQ+VapVYe7XFfCQewEq35NADZgveSdSb81NDf9 EWxOSMeSmOQ8ZtRC9gNyp9b3ZaSJoQ1OlkUbruTnT3eqKfObEWDg/LNnhSsKZ4PzjiLC nmv7XbIYg5RMgCFuTJKZZ5lieH96ijisRbBNv0EFNnjrNlGEKVyCZbmSzomwxquRG+na vEh2GEzkSeFKwCpWP5RHrGrSuiUfVD4RKTw/Ip8BBqf582VoFr0B2jcJXR2eT1VQyvWU otRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697866542; x=1698471342; 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=oYhZ5h6y1sX5qhFTzMtfi7bhQk1LvgzZSBf+UyyWnvk=; b=hBMkXxVlmlmsnEzRFbhxhJfWhh2gDdqZ72UwnByLzgoDkxPlT9O0ne0lhpvbHka+rb IAatWEHvubdokCVWYIWtfBjfprTI8BAzovsJiduVlyLBxoJ+8aiR9gvv+65ke4EO/GiI h5l43Z49k4rIH5yqhxwqbGeL06HfZsMBaj9NHF5BmB4GjcCedmYVSbuewcNYh0KiI0ne mjwTKtgyyA4Vf1X5VD5/9TI8QK4sPNhKli+Wub0ELvMmIISeg0LOkXzl+f2cbMm6C4hG 3P9CUROw1lCP1FBFsutUhmckg+JqLgh5ww3Y8sqYe6AqrUZrjgBIxeqGqogi2Su5mTe9 ORSw== X-Gm-Message-State: AOJu0YwSsO9zqJQyjlyziIFOe5vlf5w6lVvQgX2KGMmEq3IRdoWZFJig Iq+wG76izqcP+1QhCCJAShKPQBfKSxCxxLz3O+0= X-Received: by 2002:a05:6a20:7d9d:b0:161:2607:d815 with SMTP id v29-20020a056a207d9d00b001612607d815mr5020360pzj.24.1697866542413; Fri, 20 Oct 2023 22:35:42 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h1-20020a62b401000000b00690d255b5a1sm2427978pfn.217.2023.10.20.22.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 22:35:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 51/90] target/sparc: Move SWAP, SWAPA to decodetree Date: Fri, 20 Oct 2023 22:31:19 -0700 Message-Id: <20231021053158.278135-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231021053158.278135-1-richard.henderson@linaro.org> References: <20231021053158.278135-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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 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 Remove gen_swap_asi. Rename gen_swap_asi0 to gen_swap_asi. Merge gen_swap into gen_swap_asi. Signed-off-by: Richard Henderson --- target/sparc/insns.decode | 4 +++ target/sparc/translate.c | 58 +++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index 818ac33f2f..f3d02a3564 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -288,6 +288,10 @@ LDSTUB 11 ..... 001101 ..... . ............. @r_r_ri_na LDSTUB 11 ..... 011101 ..... . ............. @r_r_r_asi # LDSTUBA LDSTUB 11 ..... 011101 ..... . ............. @r_r_i_asi # LDSTUBA +SWAP 11 ..... 001111 ..... . ............. @r_r_ri_na +SWAP 11 ..... 011111 ..... . ............. @r_r_r_asi # SWAPA +SWAP 11 ..... 011111 ..... . ............. @r_r_i_asi # SWAPA + NCP 10 ----- 110110 ----- --------- ----- # v8 CPop1 NCP 10 ----- 110111 ----- --------- ----- # v8 CPop2 diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 70d0ed3db3..2dd50a38f2 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -1884,13 +1884,6 @@ static void gen_ne_fop_QD(DisasContext *dc, int rd, int rs, gen_update_fprs_dirty(dc, QFPREG(rd)); } -static void gen_swap(DisasContext *dc, TCGv dst, TCGv src, - TCGv addr, int mmu_idx, MemOp memop) -{ - gen_address_mask(dc, addr); - tcg_gen_atomic_xchg_tl(dst, addr, src, mmu_idx, memop | MO_ALIGN); -} - /* asi moves */ typedef enum { GET_ASI_HELPER, @@ -2243,14 +2236,15 @@ static void gen_st_asi(DisasContext *dc, DisasASI *da, TCGv src, TCGv addr) } } -static void gen_swap_asi0(DisasContext *dc, DisasASI *da, - TCGv dst, TCGv src, TCGv addr) +static void gen_swap_asi(DisasContext *dc, DisasASI *da, + TCGv dst, TCGv src, TCGv addr) { switch (da->type) { case GET_ASI_EXCP: break; case GET_ASI_DIRECT: - gen_swap(dc, dst, src, addr, da->mem_idx, da->memop); + tcg_gen_atomic_xchg_tl(dst, addr, src, + da->mem_idx, da->memop | MO_ALIGN); break; default: /* ??? Should be DAE_invalid_asi. */ @@ -2259,15 +2253,6 @@ static void gen_swap_asi0(DisasContext *dc, DisasASI *da, } } -static void __attribute__((unused)) -gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src, TCGv addr, int insn) -{ - DisasASI da = get_asi(dc, insn, MO_TEUL); - - gen_address_mask(dc, addr); - gen_swap_asi0(dc, &da, dst, src, addr); -} - static void gen_cas_asi0(DisasContext *dc, DisasASI *da, TCGv oldv, TCGv newv, TCGv cmpv, TCGv addr) { @@ -4725,6 +4710,24 @@ static bool trans_LDSTUB(DisasContext *dc, arg_r_r_ri_asi *a) return advance_pc(dc); } +static bool trans_SWAP(DisasContext *dc, arg_r_r_ri_asi *a) +{ + TCGv addr, dst, src; + DisasASI da; + + addr = gen_ldst_addr(dc, a->rs1, a->imm, a->rs2_or_imm); + if (addr == NULL) { + return false; + } + da = resolve_asi(dc, a->asi, MO_TEUL); + + dst = gen_dest_gpr(dc, a->rd); + src = gen_load_gpr(dc, a->rd); + gen_swap_asi(dc, &da, dst, src, addr); + gen_store_gpr(dc, a->rd, dst); + return advance_pc(dc); +} + #define CHECK_IU_FEATURE(dc, FEATURE) \ if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \ goto illegal_insn; @@ -4736,7 +4739,7 @@ static bool trans_LDSTUB(DisasContext *dc, arg_r_r_ri_asi *a) static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) { unsigned int opc, rs1, rs2, rd; - TCGv cpu_src1; + TCGv cpu_src1 __attribute__((unused)); TCGv cpu_src2 __attribute__((unused)); TCGv_i32 cpu_src1_32, cpu_src2_32, cpu_dst_32; TCGv_i64 cpu_src1_64, cpu_src2_64, cpu_dst_64; @@ -5554,6 +5557,7 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) case 0x9: /* ldsb, load signed byte */ case 0xa: /* ldsh, load signed halfword */ case 0xd: /* ldstub */ + case 0x0f: /* swap */ case 0x10: /* lda, V9 lduwa, load word alternate */ case 0x11: /* lduba, load unsigned byte alternate */ case 0x12: /* lduha, load unsigned halfword alternate */ @@ -5561,25 +5565,13 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) case 0x19: /* ldsba, load signed byte alternate */ case 0x1a: /* ldsha, load signed halfword alternate */ case 0x1d: /* ldstuba */ + case 0x1f: /* swapa */ g_assert_not_reached(); /* in decodetree */ case 0x08: /* V9 ldsw */ case 0x0b: /* V9 ldx */ case 0x18: /* V9 ldswa */ case 0x1b: /* V9 ldxa */ goto illegal_insn; /* in decodetree */ - case 0x0f: - /* swap, swap register with memory. Also atomically */ - cpu_src1 = gen_load_gpr(dc, rd); - gen_swap(dc, cpu_val, cpu_src1, cpu_addr, - dc->mem_idx, MO_TEUL); - break; -#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) - case 0x1f: /* swapa, swap reg with alt. memory. Also - atomically */ - cpu_src1 = gen_load_gpr(dc, rd); - gen_swap_asi(dc, cpu_val, cpu_src1, cpu_addr, insn); - break; -#endif #ifdef TARGET_SPARC64 case 0x2d: /* V9 prefetch, no effect */ goto skip_move;