From patchwork Sat Oct 21 05:31:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 736631 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp633545wrl; Fri, 20 Oct 2023 22:40:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/uzWUXRO76bhnE5LSDjew+f8YL+qq7Pm6rLf35OSGNLWW7+3M88SDZlIscG63oCDjIVUp X-Received: by 2002:a05:6214:2629:b0:658:708c:4d56 with SMTP id gv9-20020a056214262900b00658708c4d56mr5873638qvb.17.1697866824030; Fri, 20 Oct 2023 22:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697866824; cv=none; d=google.com; s=arc-20160816; b=ePVADlEvXOcQSGctaatieMXLpyeeFYQYeCZ5LcQQlVhVC3T+Nc0Wa+CX/sVuat5AWe ddYs9qyjGHd95y+s7gJ09kHPqjFMVnpl8gcm0LfnVLRikjCbLyGNRd+g0+WOCOEXzVVx qhkrGxbM79jCn1FVu0ZYQMJ9qA33sMLNl/3/HDM0GsIvEjSBWetTbm0KF2brvYnQVNm4 1dPpSYK5BIbAjeCJC9AsJNF40GWbX5QGwq1UmcWVIwnpj8G9mfOomTYSVjA5v87Syary aOuGvMSHMCTjuJqdEBIPMnOGhiSOqu8VBuLT+x0G+P0Jh+Z7giYdhvl7gERiGIfZ2OHz KmPw== 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=5oloSKqPa4uKUpAROBAkURcXE2SWvCw2Bc9j/aFyVWY=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=biLL1a5egETsczB7ylFaEQ/Kcn3eRC5wDn5J4kTW4Pjaa2TYyv6l2QH/GPA3/PZ5Wj KnWRxVL8X4BvNKV/KmX60xpeDyX42LNeLgO7uRCP8F3WJy6Yj5ZVX3ZSmc+jLcWkQzV2 HVn3xSJ0Lg5XrMvNQVvAIJC/l98K/MjiZjYQJdEsCEpZXzgXbpVIZDRNEZbexH2l8uT/ yMBEXBDFw2A1kJ+Y4wNLWZcJrjYCgcjwCidqqpTwIIjEaWLdhJlPZXUam0v84Ph+SnHw a8L5Z/Pfu8ptFM101w+uVxauS8cWfl8TJUOFTyOcvb78eyUo20UQcYrA0RJV3o5RlOgs 0C9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ONec+FU2; 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 s6-20020ad45246000000b00658963f9a37si2547586qvq.270.2023.10.20.22.40.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2023 22:40:24 -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=ONec+FU2; 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 1qu4eF-0002UM-JT; Sat, 21 Oct 2023 01:35: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 1qu4eA-0002Ac-O4 for qemu-devel@nongnu.org; Sat, 21 Oct 2023 01:35:39 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qu4e7-00014j-II for qemu-devel@nongnu.org; Sat, 21 Oct 2023 01:35:37 -0400 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b3e13fc1f7so1103950b6e.0 for ; Fri, 20 Oct 2023 22:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697866534; x=1698471334; 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=5oloSKqPa4uKUpAROBAkURcXE2SWvCw2Bc9j/aFyVWY=; b=ONec+FU2SST0ob7+s0Ow4WH9xAXTpqZAggIzhCS1FfjrSxd9r4t4ioNcZCKHXPaNMP Vy5uhdFyhNBPgVUxjyTQ/kB8btRBeizNgkw/dKohDVqavnJjPWbJNaFbCA3zMVAv4QY6 TsJxFlEJiI7/cdRyF/EMi2cF+NN3ucr6wF+eCJku/OCKgx4gj8VWuM9aqZhGG1INwxFz SHrFMS+NjwGr+yUp3UcIoj2t4JhsLua9U3SZcANCiamaACYXW1XlS4p1v8bWY8XEmyax rUP0kPHU99vLh9vlV5GRw6QZjAIr+yjFHrCEncY//x+ulD4dr1UpLM9Oajhn++AHUZmL M7KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697866534; x=1698471334; 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=5oloSKqPa4uKUpAROBAkURcXE2SWvCw2Bc9j/aFyVWY=; b=oTFpblgjd3DG6uBKwT6jfqhRw4SrygbDb2GIsg7S5Ar12idi/KXsaHFdQfUQixKsYH kVyq2wW7ACjWYlcOkIOFuKO4VWJT486jsh765diigNRhpqFpHXEf8K/Jzyfr2IlPPO7P Xa65JPlIvEedEnx1a4eiMnHHQPTF4jbB+ES9Nh0K9p9MzxnojcMFiSx4AmBkhv14um8l XYosfVtNZxE9tePyrc/tKcmBByJgKGci6nTHuHjcVjrMHnNKS4Dyxpod08+ncK/l+C3R Y22V7lnzjNn4nPE61rbiQTA9YUY6HdhkXcvs0Am2EBhDuQMcV6QY5yEIKjZy3Pb6tqvl 16ng== X-Gm-Message-State: AOJu0YzdnCrAMwzkxM9O4A3bzwyF2XSW5ThM8Rm4I9s7R8cpn1UsHMPj VHHK+Jy5lamQvNnrJ3qROG7RUzZgrFdzPytQveU= X-Received: by 2002:aca:2410:0:b0:3ad:ffa4:e003 with SMTP id n16-20020aca2410000000b003adffa4e003mr3604087oic.33.1697866533730; Fri, 20 Oct 2023 22:35:33 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h1-20020a62b401000000b00690d255b5a1sm2427978pfn.217.2023.10.20.22.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 22:35:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 41/90] target/sparc: Move JMPL, RETT, RETURN to decodetree Date: Fri, 20 Oct 2023 22:31:09 -0700 Message-Id: <20231021053158.278135-42-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::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.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 Signed-off-by: Richard Henderson --- target/sparc/insns.decode | 7 +++ target/sparc/translate.c | 126 ++++++++++++++++++++++++-------------- 2 files changed, 88 insertions(+), 45 deletions(-) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index 1303df92a7..c2bf5f78e3 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -28,6 +28,7 @@ CALL 01 i:s30 &r_r_ri rd rs1 rs2_or_imm imm:bool @n_r_ri .. ..... ...... rs1:5 imm:1 rs2_or_imm:s13 &r_r_ri rd=0 +@r_r_ri .. rd:5 ...... rs1:5 imm:1 rs2_or_imm:s13 &r_r_ri &r_r_ri_cc rd rs1 rs2_or_imm imm:bool cc:bool @r_r_ri_cc .. rd:5 . cc:1 .... rs1:5 imm:1 rs2_or_imm:s13 &r_r_ri_cc @@ -217,6 +218,12 @@ MOVcc 10 rd:5 101100 1 cond:4 imm:1 cc:1 0 rs2_or_imm:s11 MOVfcc 10 rd:5 101100 0 cond:4 imm:1 cc:2 rs2_or_imm:s11 MOVR 10 rd:5 101111 rs1:5 imm:1 cond:3 rs2_or_imm:s10 +JMPL 10 ..... 111000 ..... . ............. @r_r_ri +{ + RETT 10 00000 111001 ..... . ............. @n_r_ri + RETURN 10 00000 111001 ..... . ............. @n_r_ri +} + NCP 10 ----- 110110 ----- --------- ----- # v8 CPop1 NCP 10 ----- 110111 ----- --------- ----- # v8 CPop2 diff --git a/target/sparc/translate.c b/target/sparc/translate.c index edd9211572..51c267f019 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -40,6 +40,7 @@ #define gen_helper_rdpsr(D, E) qemu_build_not_reached() #define gen_helper_wrpsr(E, S) qemu_build_not_reached() #define gen_helper_power_down(E) g_assert_not_reached() +#define gen_helper_rett(E) qemu_build_not_reached() #else #define gen_helper_rdccr(D, E) qemu_build_not_reached() #define gen_helper_rdcwp(D, E) qemu_build_not_reached() @@ -4480,6 +4481,85 @@ static bool trans_MOVR(DisasContext *dc, arg_MOVR *a) return do_mov_cond(dc, &cmp, a->rd, src2); } +static bool do_add_special(DisasContext *dc, arg_r_r_ri *a, + bool (*func)(DisasContext *dc, int rd, TCGv src)) +{ + TCGv src1, sum; + + /* For simplicity, we under-decoded the rs2 form. */ + if (!a->imm && a->rs2_or_imm & ~0x1f) { + return false; + } + + /* + * Always load the sum into a new temporary. + * This is required to capture the value across a window change, + * e.g. SAVE and RESTORE, and may be optimized away otherwise. + */ + sum = tcg_temp_new(); + src1 = gen_load_gpr(dc, a->rs1); + if (a->imm || a->rs2_or_imm == 0) { + tcg_gen_addi_tl(sum, src1, a->rs2_or_imm); + } else { + tcg_gen_add_tl(sum, src1, cpu_regs[a->rs2_or_imm]); + } + return func(dc, a->rd, sum); +} + +static bool do_jmpl(DisasContext *dc, int rd, TCGv src) +{ + /* + * Preserve pc across advance, so that we can delay + * the writeback to rd until after src is consumed. + */ + target_ulong cur_pc = dc->pc; + + gen_check_align(dc, src, 3); + + gen_mov_pc_npc(dc); + tcg_gen_mov_tl(cpu_npc, src); + gen_address_mask(dc, cpu_npc); + gen_store_gpr(dc, rd, tcg_constant_tl(cur_pc)); + + dc->npc = DYNAMIC_PC_LOOKUP; + return true; +} + +TRANS(JMPL, ALL, do_add_special, a, do_jmpl) + +static bool do_rett(DisasContext *dc, int rd, TCGv src) +{ + if (!supervisor(dc)) { + return raise_priv(dc); + } + + gen_check_align(dc, src, 3); + + gen_mov_pc_npc(dc); + tcg_gen_mov_tl(cpu_npc, src); + gen_helper_rett(tcg_env); + + dc->npc = DYNAMIC_PC; + return true; +} + +TRANS(RETT, 32, do_add_special, a, do_rett) + +static bool do_return(DisasContext *dc, int rd, TCGv src) +{ + gen_check_align(dc, src, 3); + + gen_mov_pc_npc(dc); + tcg_gen_mov_tl(cpu_npc, src); + gen_address_mask(dc, cpu_npc); + + gen_helper_restore(tcg_env); + dc->npc = DYNAMIC_PC_LOOKUP; + return true; +} + +TRANS(RETURN, 64, do_add_special, a, do_return) + #define CHECK_IU_FEATURE(dc, FEATURE) \ if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \ goto illegal_insn; @@ -5277,30 +5357,6 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) } else if (xop == 0x37) { /* V8 CPop2, V9 impdep2 */ goto illegal_insn; /* in decodetree */ -#ifdef TARGET_SPARC64 - } else if (xop == 0x39) { /* V9 return */ - save_state(dc); - cpu_src1 = get_src1(dc, insn); - cpu_tmp0 = tcg_temp_new(); - if (IS_IMM) { /* immediate */ - simm = GET_FIELDs(insn, 19, 31); - tcg_gen_addi_tl(cpu_tmp0, cpu_src1, simm); - } else { /* register */ - rs2 = GET_FIELD(insn, 27, 31); - if (rs2) { - cpu_src2 = gen_load_gpr(dc, rs2); - tcg_gen_add_tl(cpu_tmp0, cpu_src1, cpu_src2); - } else { - tcg_gen_mov_tl(cpu_tmp0, cpu_src1); - } - } - gen_check_align(dc, cpu_tmp0, 3); - gen_helper_restore(tcg_env); - gen_mov_pc_npc(dc); - tcg_gen_mov_tl(cpu_npc, cpu_tmp0); - dc->npc = DYNAMIC_PC_LOOKUP; - goto jmp_insn; -#endif } else { cpu_src1 = get_src1(dc, insn); cpu_tmp0 = tcg_temp_new(); @@ -5318,28 +5374,8 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) } switch (xop) { case 0x38: /* jmpl */ - { - gen_check_align(dc, cpu_tmp0, 3); - gen_store_gpr(dc, rd, tcg_constant_tl(dc->pc)); - gen_mov_pc_npc(dc); - gen_address_mask(dc, cpu_tmp0); - tcg_gen_mov_tl(cpu_npc, cpu_tmp0); - dc->npc = DYNAMIC_PC_LOOKUP; - } - goto jmp_insn; -#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64) case 0x39: /* rett, V9 return */ - { - if (!supervisor(dc)) - goto priv_insn; - gen_check_align(dc, cpu_tmp0, 3); - gen_mov_pc_npc(dc); - tcg_gen_mov_tl(cpu_npc, cpu_tmp0); - dc->npc = DYNAMIC_PC; - gen_helper_rett(tcg_env); - } - goto jmp_insn; -#endif + g_assert_not_reached(); /* in decode tree */ case 0x3b: /* flush */ /* nop */ break;