From patchwork Tue Jan 24 02:04:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 646010 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp2512112pvb; Mon, 23 Jan 2023 18:06:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXtfVCnf6IHOTOZ8eckDafpepfFLaXvfynKyAghIqQJjGO2agJD+IQp+6GExUep0q+cpYZAT X-Received: by 2002:a05:6214:5f87:b0:534:1cd3:1393 with SMTP id ls7-20020a0562145f8700b005341cd31393mr37726679qvb.12.1674525982783; Mon, 23 Jan 2023 18:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674525982; cv=none; d=google.com; s=arc-20160816; b=CoezG9VBO77v7amVor1AwI2BzFmgDM67oZVgW7PiBhIAfK882r8pK2cIPktz2WYDWT XSO0EBfBBcLmzLBo7bztDTeLrdluGrJEzMALgKKaYQmJVc02RDAkEK8lMxqpRRIouV4y CzOslZiNivDGCC0QTZIoyA0bfnvuIrOWcQa1slS4x8IMN7lyWPovMJagKPOwDfZEIMQI NWoCMpk7nJSzKDx8kJM/tnxhqcSZF2HTxFh+m2l1i1X36foP6Qcr0dqc9qtji3ygDX+M jyYALZ2K6219/J7v29wkBe7jVyZ3hASgxRheY6QR9BomBe1fRgl1cQvxsHtIzahkbCCL mtPg== 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=S4RKktMcPf3rE7CRNPQPl4hZIXa54SUO3jBV2MtYQsw=; b=wasLKgTLPBW2EN+I2IO5hvtmVIxP69GFvgBAyqrrry9U2D2/vPMzeJxxkyBpP6+rQ3 cbTMEvtNO2sOWO9SOJxLiQARh1KEiYKELHYV3OSvE7HrWXvSPOhM7ecl8Eq+b/gqLtjf WDf81aoRuAQZT1An6PSdajyBRa6cWeSzhJJwAJcrmFoaqMHdAT3LH/rp3sabaBpeFgVG W5ETXgqezFXQRj4soIHNxyYYpvByJGFFviUq98+wI6Vyp229KiHJn85yzqHLpzoj3F3U zy6Ci7x4O+vvst05/KUcP3WErJmn9vlr48A5sgPijnrKlN8L0Wju/m8HP7hE7UR7UpYU 5nzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f8sfINkT; 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 w10-20020a05620a128a00b007064b3da30esi613325qki.713.2023.01.23.18.06.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jan 2023 18:06:22 -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=f8sfINkT; 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 1pK8gi-0008QS-EB; Mon, 23 Jan 2023 21:05:28 -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 1pK8ge-0008PD-Cd for qemu-devel@nongnu.org; Mon, 23 Jan 2023 21:05:24 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pK8gc-0003oT-KD for qemu-devel@nongnu.org; Mon, 23 Jan 2023 21:05:24 -0500 Received: by mail-pl1-x62a.google.com with SMTP id a18so789953plm.2 for ; Mon, 23 Jan 2023 18:05:22 -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=S4RKktMcPf3rE7CRNPQPl4hZIXa54SUO3jBV2MtYQsw=; b=f8sfINkTADLVNu4YdzXrTS3VT1PnAjgEi7bG4VKoQvhyTPCI8vIzp8FhFxfTSEF6N8 jhfwiHS/1PMLMTO+IWWFQ+nVQOA6GS0qWyI+daApp86g8GgNFT+hKi7QIbbGXGKFAqzX xt4KK2/InoBU7L6GWOUF8O3BC/eTS6l+HNUFrMQpM0sEYlkgfCW0XvTgMBuljAWSudOT H3maPj4M230T488VKt24r8WhWV7zK6lVJ4NMDcgmcl741SmdTILpc2wYXV9ZKt3LOIRS fizynaKsDdNJLu0nQN7uDw3CMVg5QFP+cWUHozF+tX/cGhZjGD4sS/LYNbq4WltuE4V3 2T7w== 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=S4RKktMcPf3rE7CRNPQPl4hZIXa54SUO3jBV2MtYQsw=; b=gF4JqfElMUpDDJvBjqarMNlK6FUy8Ziz0NcE4TwAGnR1IcTzoxmfX1KEuEjFli2yZZ jK1lX0/Qrt2xztUAkjVmsToZkQ5GKW7Kzi1NKLDrJAxzeEx9NVdaLi2KlfYZ3p6u9y8y U0LShfhzcmpyoHDVeU2uLjPMm8kwKwu2vVxcvDNbh+LEX9MwdZVeaSkRSr4Tca8HSB8p /aLnmdlBZ+ifRCXKspYFGCF5cH7vf6NWo64dy6tlheKbBzQDIOtGoCozHnbvBGDzaDre YT54qM/M+TGqlIchSDIg8IzcvUot233tXBxuqxWEgLQ6qnHkgJCTqPuu/C6yfwW7C97R rO+g== X-Gm-Message-State: AFqh2krw9E/OuLUbzMc5AVT6SXYqXdPaw9ZVAAgtgbm2C6CWTZLwYV4I l10MEtFcC4x7DCtKYyVhf0tRsKP2iU7TfwKV X-Received: by 2002:a17:90a:2f89:b0:219:6619:848a with SMTP id t9-20020a17090a2f8900b002196619848amr28083402pjd.36.1674525921783; Mon, 23 Jan 2023 18:05:21 -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 fh3-20020a17090b034300b00228e56d375asm283936pjb.33.2023.01.23.18.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 18:05:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, WANG Xuerui Subject: [PULL v2 07/15] target/loongarch: Disassemble jirl properly Date: Mon, 23 Jan 2023 16:04:59 -1000 Message-Id: <20230124020507.3732200-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124020507.3732200-1-richard.henderson@linaro.org> References: <20230124020507.3732200-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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. Reviewed-by: WANG Xuerui Signed-off-by: Richard Henderson --- target/loongarch/insns.decode | 3 ++- target/loongarch/disas.c | 2 +- target/loongarch/insn_trans/trans_branch.c.inc | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) 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 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();