From patchwork Wed Jan 18 01:11:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 643668 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1489758pvb; Tue, 17 Jan 2023 17:12:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXvm7mKd5+WZkz8XhTco4vFgK1gXwT2hr7kFNnzd3u1+5O8X4GJZ6VGAsK5lrTt6P2wNVPcv X-Received: by 2002:a05:622a:5d9a:b0:3b4:d5ce:9f1f with SMTP id fu26-20020a05622a5d9a00b003b4d5ce9f1fmr6656171qtb.45.1674004365038; Tue, 17 Jan 2023 17:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674004365; cv=none; d=google.com; s=arc-20160816; b=wduNPN8HQaalgHjIao8LcLPtErHMrXjAcaCpBeF9+BecItRGT3PSihze2dUufRrnlo C0qIiTNeTxBEWdzijGakW7bB+vSJsPgYF0LLmJghJrcDn+sJ/FuymWhqJ8+osmFc325g ZRaHTvRIz2J0OPao18jjdyAhkZ0HyJ5jVyg//vOXPdPSsprl9b51d2dzrAvH5mzej4Yi TxLMzvKMFdaVNO15+CX0Q7RxkrpQTa76HEo4U2jE09xWl2FHjW9XPy5RdhAebpfb9w5E 1GShpWYpPf87toemVUmCcAECh8+PEZPKpE41pkSG1vLsoRNt5VpiT2zbtqBypx5MKAC1 cPlw== 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=vX/i9PddUxPpu4wKsNIpRjvexpTXXwf910s7846V1ss=; b=lShYMLQhn3sIWKZmk+maOmUjDGuJNWm7u6yGZp+HFYVOkRczXEOqt62egdo1fz0TQ/ aOR/b/HhAiNyuTs5PzAQfcSAV/9Gn/6iZpr4XX2e2YscVQswOk64/56CFLZazncHK3G0 fUbS3OvPDLnMg2k84wivvZApa4ufbqJMg1L2y8iT6ByT40UPK90J08UguBo64IdlvQIq +WDeln6Gio18ilkB1t9JE5gto0lhuCWuNYmmJ6ic7rgHg1bJu1vsmMQ3Ve09af0gXMp8 Zd45ameE9CmiWlYnum7ahHSyh6YyO7sgQ+8mxzy6prizBOU7tySOgeig590PZi6O3rOh dHSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s3UPhLDx; 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 d12-20020ac847cc000000b003b4155467b2si6745423qtr.232.2023.01.17.17.12.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jan 2023 17:12:45 -0800 (PST) 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=s3UPhLDx; 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 1pHwzG-00020W-TU; Tue, 17 Jan 2023 20:11:34 -0500 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 1pHwzF-0001zS-Dw for qemu-devel@nongnu.org; Tue, 17 Jan 2023 20:11:33 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHwzD-0002EI-Pm for qemu-devel@nongnu.org; Tue, 17 Jan 2023 20:11:33 -0500 Received: by mail-pj1-x102c.google.com with SMTP id a14-20020a17090a70ce00b00229a2f73c56so708566pjm.3 for ; Tue, 17 Jan 2023 17:11:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=vX/i9PddUxPpu4wKsNIpRjvexpTXXwf910s7846V1ss=; b=s3UPhLDxxfSmawKS23EyN6J7QF1stx430KGbnjPhvJn8vqi0SkDH3UPJfsQ1dTuei/ ssP5O34Kl8C+2ReW7a+DEai5ra5MFlOadnfm1edNwvRb0p6TEDblc9b9YhlFa+DgI6lH uEenrbqAsowGcXJhaMgprMdCEUssJ3lUJWMdCoU2BayBa7nh1QTAsgUxznpjGJtzZcUG 50ssdK0xiOyDwzPU74XlSRMSC2bFPFS7R+fWbgm2ZUz/416ozrH2+5MMIC/DZiCOnsdT nQdkc+HVg/gzp9Dk07Tge9/BtLI+AZdTZE40KlpuFN8F7ECeswSVoPwEOGu/RiwHB/NY M6lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vX/i9PddUxPpu4wKsNIpRjvexpTXXwf910s7846V1ss=; b=LCs8on5aEIy6vxu9dNanojTyB3qXfbBhJGU6Bk8hysczVuClLdX4p+4xz/NtDsX5v2 NmR5KT0oNFppkPS33FUuAF43fWRLfOWKlcqHsz4jYVsb1jkhE4XbGdwTH12/0lyT+D3B YLPBZUK/4qaSGOS9zkF0YhNIKK8m/Cs0IrPJCKgUFVr64iExlt/rz3E4nErhpkZ6sK4q ZTMcss75rji3Yq2S0p9jjS+DS9oM6bquKLT2oAOEDb0OCxl39xHPdlY8Jc4q1J1w9Wyb B34LEVBW7CvhNZC8gHCAPXfk3CfciZtoa5sstc8097KKulbRZIN1IIbZGtWECSx+pvP3 BbjQ== X-Gm-Message-State: AFqh2kpx5csVDt/j3WOiPgY0Ij+RZjJJgkniKRcVMDTBbHM5DqOjOMKp 3O1GolvCvZrAQVsuVZ2pHN+dBYp8eHD2XOTj X-Received: by 2002:a17:902:bf03:b0:194:9847:9cd4 with SMTP id bi3-20020a170902bf0300b0019498479cd4mr5092959plb.60.1674004290009; Tue, 17 Jan 2023 17:11:30 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b0017ec1b1bf9fsm21660259plp.217.2023.01.17.17.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 17:11:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: git@xen0n.name Subject: [PATCH v2 02/10] target/loongarch: Disassemble jirl properly Date: Tue, 17 Jan 2023 15:11:15 -1000 Message-Id: <20230118011123.392823-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118011123.392823-1-richard.henderson@linaro.org> References: <20230118011123.392823-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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 While jirl shares the same instruction format as bne etc, it is not assembled the same. In particular, rd is printed first not second and the immediate is not pc-relative. Decode into the arg_rr_i structure, which prints correctly. This changes the "offs" member to "imm", to update translate. Signed-off-by: Richard Henderson Reviewed-by: WANG Xuerui --- target/loongarch/disas.c | 2 +- target/loongarch/insn_trans/trans_branch.c.inc | 2 +- target/loongarch/insns.decode | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/target/loongarch/disas.c b/target/loongarch/disas.c index 858dfcc53a..7cffd853ec 100644 --- a/target/loongarch/disas.c +++ b/target/loongarch/disas.c @@ -628,7 +628,7 @@ INSN(beqz, r_offs) INSN(bnez, r_offs) INSN(bceqz, c_offs) INSN(bcnez, c_offs) -INSN(jirl, rr_offs) +INSN(jirl, rr_i) INSN(b, offs) INSN(bl, offs) INSN(beq, rr_offs) diff --git a/target/loongarch/insn_trans/trans_branch.c.inc b/target/loongarch/insn_trans/trans_branch.c.inc index 65dbdff41e..a860f7e733 100644 --- a/target/loongarch/insn_trans/trans_branch.c.inc +++ b/target/loongarch/insn_trans/trans_branch.c.inc @@ -23,7 +23,7 @@ static bool trans_jirl(DisasContext *ctx, arg_jirl *a) TCGv dest = gpr_dst(ctx, a->rd, EXT_NONE); TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE); - tcg_gen_addi_tl(cpu_pc, src1, a->offs); + tcg_gen_addi_tl(cpu_pc, src1, a->imm); tcg_gen_movi_tl(dest, ctx->base.pc_next + 4); gen_set_gpr(a->rd, dest, EXT_NONE); tcg_gen_lookup_and_goto_ptr(); diff --git a/target/loongarch/insns.decode b/target/loongarch/insns.decode index 3fdc6e148c..de7b8f0f3c 100644 --- a/target/loongarch/insns.decode +++ b/target/loongarch/insns.decode @@ -67,6 +67,7 @@ @rr_ui12 .... ...... imm:12 rj:5 rd:5 &rr_i @rr_i14s2 .... .... .............. rj:5 rd:5 &rr_i imm=%i14s2 @rr_i16 .... .. imm:s16 rj:5 rd:5 &rr_i +@rr_i16s2 .... .. ................ rj:5 rd:5 &rr_i imm=%offs16 @hint_r_i12 .... ...... imm:s12 rj:5 hint:5 &hint_r_i @rrr_sa2p1 .... ........ ... .. rk:5 rj:5 rd:5 &rrr_sa sa=%sa2p1 @rrr_sa2 .... ........ ... sa:2 rk:5 rj:5 rd:5 &rrr_sa @@ -444,7 +445,7 @@ beqz 0100 00 ................ ..... ..... @r_offs21 bnez 0100 01 ................ ..... ..... @r_offs21 bceqz 0100 10 ................ 00 ... ..... @c_offs21 bcnez 0100 10 ................ 01 ... ..... @c_offs21 -jirl 0100 11 ................ ..... ..... @rr_offs16 +jirl 0100 11 ................ ..... ..... @rr_i16s2 b 0101 00 .......................... @offs26 bl 0101 01 .......................... @offs26 beq 0101 10 ................ ..... ..... @rr_offs16