From patchwork Tue Aug 22 07:13:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 715694 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp118966wrp; Tue, 22 Aug 2023 00:15:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHP+4JBNxD/wODKhE0SSg9G9e80Xri6LIP8T3J0cNKKTVtK2lYugwAxhfqZq6h/tTFGXH6 X-Received: by 2002:a05:620a:371c:b0:767:64cc:21c1 with SMTP id de28-20020a05620a371c00b0076764cc21c1mr9731541qkb.16.1692688546606; Tue, 22 Aug 2023 00:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692688546; cv=none; d=google.com; s=arc-20160816; b=tI3tPHPcI2WtqUrsv2xX2h74hj18I+z4q7oguwdWM5Fc17jlleIKuDYffkIcNsqRkU YO2DrEFEJJ0d1dJOImF2oxXsN2uZ2sYoZMVkWI7ly58BlCFbjmRGnUA8SWt/5bFP5iHh J5bPFnRP2Im7YwbQiIDW295Vnor38CpoPaiF7G+Dmi/DSt+AL2K28xpdNdUGmdMHTYts b5qblpB2sy9Cdu+cnxjYHRIcV34MMoaUjdFgmPnECII7FprfzyHAFEzPUX2NKj8vvyVs zZiJG1H4ZEuyMHYeZbecFZYhxPSHS9ZNTXfg8HrdcudHxO/lXqsHsSFMefk2DH0USQ3G PySg== 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=ac7pv2kpb0ajeFGbtJ3onoCTyP2ZNqDH1hhRLbCbPbE=; fh=iI1r750v8r6y4onCPOGlc5pA/zLiNuJX+n5Trfvo6Hc=; b=VAJrDnhhvoxAq+cmtkjyuTWFu6s5hTaSuxdiCBANwCYwI6V56LntVW0uLK3TyxCLeO WCNzhxQZRW/teJgzAjTeNyYomI5aVpwkmKSlrbWD1rCqmlsgszz2Oi92TdQPwT5C3Ws5 ZKBVTm2nQbSW7o9pEwL8hZaGSYuPoOCsWM8uprzRt3qR2gRqAJPr4FYGTmlvAGBG9zjM IU4JPYUNxSNPqqcT8r8uyKAnLthSmif8Ohg6BseVEvWTJ7HYhUUS/MTG5PAsYabW6HlO kAMwmHvdZKPSemEO/LFKlEVwQ6xIO8XpWxfCvaNw507BNetaSO0Qo/8Y4ySsEoW+aW1z TV1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t7hWtp1X; 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 u4-20020a05620a430400b0076770e82424si5806015qko.18.2023.08.22.00.15.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Aug 2023 00:15:46 -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=t7hWtp1X; 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 1qYLbQ-0001GK-9W; Tue, 22 Aug 2023 03:15:00 -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 1qYLbO-0001Dg-6Z for qemu-devel@nongnu.org; Tue, 22 Aug 2023 03:14:58 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYLbL-0002wi-QE for qemu-devel@nongnu.org; Tue, 22 Aug 2023 03:14:57 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fef34c33d6so13457755e9.3 for ; Tue, 22 Aug 2023 00:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692688494; x=1693293294; 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=ac7pv2kpb0ajeFGbtJ3onoCTyP2ZNqDH1hhRLbCbPbE=; b=t7hWtp1XXtA92hEauBLXvL4NRLQtopFBPefeCNXAmepOE4/nZ4nHlSipRrBuhQ/3cu jkySjBR3gOweCCw+oxLQhuWQy8JB6szAmII9I91+DseISbmTquTFPA4GItcQo7z+r/Of ib2ndPoDlN87CvpavmvBVIHRqBw0n8HVPFATt/0qBdTFJJkTgKsonyCU+fffTmcemKVy yBPeflCb2GNKEtnVKuzsh60L6zORQK9CE54KdVh5vLyWsVssd2wLx7veNaeQL2/C/V7D qf5c2meGSllAzJFrV/BtlhS3j0dpzSEv2svztPmaz7dv3d3ZbadLnBphNhtEeNcDEjOs vc3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692688494; x=1693293294; 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=ac7pv2kpb0ajeFGbtJ3onoCTyP2ZNqDH1hhRLbCbPbE=; b=PPLUAS6ova86Aww9rHmNA8wLZeDrMKwgs4E8+8PB9Me1nsgdMBBY9hTvYwECiwtoGe nrBSwkW3UejMn0MkHf3TG/mUnuAvFUjpAyNhFqUkUkhbXlrmFVmIJDVEY08UVtkoFuCX wwOWUaHn7LqDlG1bcuPqAVDsFNxj0zDhvlpAXeVnj+Nz70yU4QtmVcxQZGvRs88bZ3aG Z54asr1Y/8jsjGntXFqYzqrV5mWesrGjSFMzV4cns0sEuACdfA0S1SlBoHabYHaUlQtb jGzOaywGjicA/tnJUYFqOmLL6mwPFn2WjSEGe7WURaSayOjgYk7oocdx8Hz++1eeHniV 7xBA== X-Gm-Message-State: AOJu0YxMa360lKgPG0dBjCmyevwLXmivsGuU+jjjeEgEbZzj4zAUCN/m wVOxCUT6VC4acx7QlJLfaTZa0YpS9AONzGHgw/UZrA== X-Received: by 2002:a05:600c:210b:b0:3fe:ef5b:bb6 with SMTP id u11-20020a05600c210b00b003feef5b0bb6mr4233930wml.35.1692688492733; Tue, 22 Aug 2023 00:14:52 -0700 (PDT) Received: from localhost.localdomain ([37.19.214.4]) by smtp.gmail.com with ESMTPSA id a19-20020a05600c225300b003fee83ae4a3sm9452540wmm.9.2023.08.22.00.14.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Aug 2023 00:14:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Song Gao Cc: Xiaojuan Yang , Huacai Chen , Jiajie Chen , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH RESEND v5 07/19] target/loongarch: Extract make_address_pc() helper Date: Tue, 22 Aug 2023 09:13:53 +0200 Message-ID: <20230822071405.35386-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230822071405.35386-1-philmd@linaro.org> References: <20230822071405.35386-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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 From: Jiajie Chen Signed-off-by: Jiajie Chen Reviewed-by: Richard Henderson Signed-off-by: Song Gao Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20230822032724.1353391-7-gaosong@loongson.cn> [PMD: Extract helper from bigger patch] Signed-off-by: Philippe Mathieu-Daudé --- target/loongarch/translate.c | 5 +++++ target/loongarch/insn_trans/trans_arith.c.inc | 2 +- target/loongarch/insn_trans/trans_branch.c.inc | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/target/loongarch/translate.c b/target/loongarch/translate.c index acc54d7587..8b26555a27 100644 --- a/target/loongarch/translate.c +++ b/target/loongarch/translate.c @@ -226,6 +226,11 @@ static TCGv make_address_i(DisasContext *ctx, TCGv base, target_long ofs) return make_address_x(ctx, base, addend); } +static uint64_t make_address_pc(DisasContext *ctx, uint64_t addr) +{ + return addr; +} + #include "decode-insns.c.inc" #include "insn_trans/trans_arith.c.inc" #include "insn_trans/trans_shift.c.inc" diff --git a/target/loongarch/insn_trans/trans_arith.c.inc b/target/loongarch/insn_trans/trans_arith.c.inc index 43d6cf261d..2aea4e41d5 100644 --- a/target/loongarch/insn_trans/trans_arith.c.inc +++ b/target/loongarch/insn_trans/trans_arith.c.inc @@ -72,7 +72,7 @@ static bool gen_pc(DisasContext *ctx, arg_r_i *a, target_ulong (*func)(target_ulong, int)) { TCGv dest = gpr_dst(ctx, a->rd, EXT_NONE); - target_ulong addr = func(ctx->base.pc_next, a->imm); + target_ulong addr = make_address_pc(ctx, func(ctx->base.pc_next, a->imm)); tcg_gen_movi_tl(dest, addr); gen_set_gpr(a->rd, dest, EXT_NONE); diff --git a/target/loongarch/insn_trans/trans_branch.c.inc b/target/loongarch/insn_trans/trans_branch.c.inc index 3ad34bcc05..2e35572cea 100644 --- a/target/loongarch/insn_trans/trans_branch.c.inc +++ b/target/loongarch/insn_trans/trans_branch.c.inc @@ -12,7 +12,7 @@ static bool trans_b(DisasContext *ctx, arg_b *a) static bool trans_bl(DisasContext *ctx, arg_bl *a) { - tcg_gen_movi_tl(cpu_gpr[1], ctx->base.pc_next + 4); + tcg_gen_movi_tl(cpu_gpr[1], make_address_pc(ctx, ctx->base.pc_next + 4)); gen_goto_tb(ctx, 0, ctx->base.pc_next + a->offs); ctx->base.is_jmp = DISAS_NORETURN; return true; @@ -25,7 +25,7 @@ static bool trans_jirl(DisasContext *ctx, arg_jirl *a) TCGv addr = make_address_i(ctx, src1, a->imm); tcg_gen_mov_tl(cpu_pc, addr); - tcg_gen_movi_tl(dest, ctx->base.pc_next + 4); + tcg_gen_movi_tl(dest, make_address_pc(ctx, ctx->base.pc_next + 4)); gen_set_gpr(a->rd, dest, EXT_NONE); tcg_gen_lookup_and_goto_ptr(); ctx->base.is_jmp = DISAS_NORETURN;