From patchwork Sat May 4 15:39:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794624 Delivered-To: patch@linaro.org Received: by 2002:adf:a453:0:b0:34e:ceec:bfcd with SMTP id e19csp189934wra; Sat, 4 May 2024 08:40:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUf3nZprE4uq7Yyr7qw0g66TwjOM2b2zzYtTl0A69S78rD/kwk4RT+BfgvSvglho9LbbH/UnwIgxj7WVMBKArNd X-Google-Smtp-Source: AGHT+IHufRtQNtW6N07doDns7csUB+SEOSji9USxYlZKB4gUOiMF5oti+8QDsB3QVsp6m0TXBQTN X-Received: by 2002:a05:6214:501d:b0:6a0:8238:943 with SMTP id jo29-20020a056214501d00b006a082380943mr6217103qvb.65.1714837224884; Sat, 04 May 2024 08:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714837224; cv=none; d=google.com; s=arc-20160816; b=BMHMBpuxkSoUydlA5FBcKi9OzEB6XCemnNlzlh/xgqoNBHH7K9jJGWxyoGIs6sCcYC vhGNpu3JbToMoh19byGvpfwv9ciNHziL3MRVdR4zmT5+LIdofeMMbILLo8WPOGBI3VVZ iWjZEGksJg01vVbK0BlxX2gzchvqvp+Vic08N+NWGq2l9XHoBxfG31YDP7qEMGI51eam NKUFYUPdciO3VACLTzAVfrMT1D3mUgzfEq7i6b9iWOvYsA1IjemNipOr7bvol6x7PLzc 3roPgL69nPfza1gn8IWAwpSHgxAT1ebtbBcuCCuGbtArhv7+SqVjQVR+H1iyI6tjpJW9 WhIw== 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=/dNPNLs1khRCpqkW7qQSkGpf2gCcH5jGPYIjxIk0MdY=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=zgts/bdU25va+XU0S0Xn5Y2Vt3beA7TStmuc0EYHXhuyGK9kpfBozFBoRXrrtjuSJs ttgBlW/9hYRfpg71YZiqI1W6M4X12jjVjMYeU3pcZopGGjK1PLPWUUueQ9hWQ2cT9vMP 7p2z+KYHL88kh/FQnPp8HOWJT3LeKkex6OQqOXTZVWU4fmGC8AIbuJXQ+PDX7VbebWK5 +4NWpUiYzbdDPGXpc2RQZ36f7HexJOl5SjuwXe+BYKSI1EojtDvz8qqRzmvaAH1t2VBx H48Z4BaijQikK1wh3+esrH5wJKP8+dIWfodRipADYgaiS57mFi/wFrtqlQi1glMK2Bx8 ml9A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dtl7I85o; 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 p21-20020a05622a00d500b00439ff2a9b0asi4538880qtw.124.2024.05.04.08.40.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 May 2024 08: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=Dtl7I85o; 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 1s3HUC-00024q-0P; Sat, 04 May 2024 11:39:40 -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 1s3HUA-000249-Nk for qemu-devel@nongnu.org; Sat, 04 May 2024 11:39:38 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s3HU8-0006FI-Tz for qemu-devel@nongnu.org; Sat, 04 May 2024 11:39:38 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5e42b4bbfa4so319570a12.1 for ; Sat, 04 May 2024 08:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714837175; x=1715441975; 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=/dNPNLs1khRCpqkW7qQSkGpf2gCcH5jGPYIjxIk0MdY=; b=Dtl7I85o02IsilE/RAvQycghH3veu4YufVfJT+ozjzsmkH/RZdFCz6zTkMV4NZpeme ERsGso6XoTNf/G8GfWpv9nQtRLyT0TFVPtbjAg4pLlIo2spWKPaVPAh+X+6o/6gTokHB 5LZdtfDmH4/T+a9ipliyJUWHUBokQqbUF9zXDme1cxC3KUREFKJIjyFoSPadZM8HxNYK Sdl4OhlmbTYDx2p6HWzT9l5TPjNL4wLFHf98rToNMhFmEg637LnYYfRPbLq7iamD9o51 mAhP7c4B1E8IGH/YUEg5/1/sOpUZiZv4VbjtbEyD11ze3azYJyh/rhLGuQ2wMhDz4FZP CRDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714837175; x=1715441975; 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=/dNPNLs1khRCpqkW7qQSkGpf2gCcH5jGPYIjxIk0MdY=; b=itz0WwvV944T5SyWhQyvYwhJDaV717Q7hLNE+m+v9ZlsfVOcCrSrskbe3aqo+iUn3l UF7BKWyAGgqd/Ubow376QCX43yu2ye0S6dNqsvRptopMHNFJPE1vAhC+iehIhEVT5y/T WoocvN84hdUmitpG/o2EQUyrL1YTOIqB6eN43QUHTU4gHg841s8iQEtIwWTj9NsWQbBW eYvjJJu6uymk8VIuZeQnRQpVEuadD39dH4lWeORYPH46px8nhOnURj7X1RFCeM3HRynj OGORFRU8EGZnwmQwc37tYFBAzTs7Z7oLFHO7kip4MHJEaMhibIhnPmuqqSYwzkT/gELG ukPQ== X-Gm-Message-State: AOJu0Yw6ZGm0eX8kt9i7kM5yJG5ZnXX1QOyM2MJkyxtg11Y58WuRXfkY QwrcY/OMGv7Ins5nXSuJTh4SN9SEzo1xlfLFKG+NdL9JPP1IMQkKdPyI6bduxGUPCIe5Z/W39DV U X-Received: by 2002:a17:902:ea0e:b0:1e5:3d8a:75fd with SMTP id s14-20020a170902ea0e00b001e53d8a75fdmr6739272plg.69.1714837175579; Sat, 04 May 2024 08:39:35 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id n15-20020a170902e54f00b001e4d22f828fsm5197859plf.33.2024.05.04.08.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 08:39:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 8/9] target/alpha: Split out gen_pc_disp Date: Sat, 4 May 2024 08:39:25 -0700 Message-Id: <20240504153926.357845-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240504153926.357845-1-richard.henderson@linaro.org> References: <20240504153926.357845-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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 Prepare for pcrel by not modifying cpu_pc before use, in the case of JSR. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240503072014.24751-9-philmd@linaro.org> --- target/alpha/translate.c | 41 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index c1a55e5153..86402d96d5 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -252,6 +252,11 @@ static void st_flag_byte(TCGv val, unsigned shift) tcg_gen_st8_i64(val, tcg_env, get_flag_ofs(shift)); } +static void gen_pc_disp(DisasContext *ctx, TCGv dest, int32_t disp) +{ + tcg_gen_movi_i64(dest, ctx->base.pc_next + disp); +} + static void gen_excp_1(int exception, int error_code) { TCGv_i32 tmp1, tmp2; @@ -263,7 +268,7 @@ static void gen_excp_1(int exception, int error_code) static DisasJumpType gen_excp(DisasContext *ctx, int exception, int error_code) { - tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next); + gen_pc_disp(ctx, cpu_pc, 0); gen_excp_1(exception, error_code); return DISAS_NORETURN; } @@ -427,14 +432,12 @@ static DisasJumpType gen_store_conditional(DisasContext *ctx, int ra, int rb, static void gen_goto_tb(DisasContext *ctx, int idx, int32_t disp) { - uint64_t dest = ctx->base.pc_next + disp; - - if (translator_use_goto_tb(&ctx->base, dest)) { + if (translator_use_goto_tb(&ctx->base, ctx->base.pc_next + disp)) { tcg_gen_goto_tb(idx); - tcg_gen_movi_i64(cpu_pc, dest); + gen_pc_disp(ctx, cpu_pc, disp); tcg_gen_exit_tb(ctx->base.tb, idx); } else { - tcg_gen_movi_i64(cpu_pc, dest); + gen_pc_disp(ctx, cpu_pc, disp); tcg_gen_lookup_and_goto_ptr(); } } @@ -442,7 +445,7 @@ static void gen_goto_tb(DisasContext *ctx, int idx, int32_t disp) static DisasJumpType gen_bdirect(DisasContext *ctx, int ra, int32_t disp) { if (ra != 31) { - tcg_gen_movi_i64(ctx->ir[ra], ctx->base.pc_next); + gen_pc_disp(ctx, ctx->ir[ra], 0); } /* Notice branch-to-next; used to initialize RA with the PC. */ @@ -1091,7 +1094,7 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, int palcode) } /* Allow interrupts to be recognized right away. */ - tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next); + gen_pc_disp(ctx, cpu_pc, 0); return DISAS_PC_UPDATED_NOCHAIN; case 0x36: @@ -1138,19 +1141,17 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, int palcode) #else { TCGv tmp = tcg_temp_new(); - uint64_t exc_addr = ctx->base.pc_next; - uint64_t entry = ctx->palbr; + uint64_t entry; + gen_pc_disp(ctx, tmp, 0); if (ctx->tbflags & ENV_FLAG_PAL_MODE) { - exc_addr |= 1; + tcg_gen_ori_i64(tmp, tmp, 1); } else { - tcg_gen_movi_i64(tmp, 1); - st_flag_byte(tmp, ENV_FLAG_PAL_SHIFT); + st_flag_byte(tcg_constant_i64(1), ENV_FLAG_PAL_SHIFT); } - - tcg_gen_movi_i64(tmp, exc_addr); tcg_gen_st_i64(tmp, tcg_env, offsetof(CPUAlphaState, exc_addr)); + entry = ctx->palbr; entry += (palcode & 0x80 ? 0x2000 + (palcode - 0x80) * 64 : 0x1000 + palcode * 64); @@ -2344,9 +2345,13 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn) /* JMP, JSR, RET, JSR_COROUTINE. These only differ by the branch prediction stack action, which of course we don't implement. */ vb = load_gpr(ctx, rb); - tcg_gen_andi_i64(cpu_pc, vb, ~3); if (ra != 31) { - tcg_gen_movi_i64(ctx->ir[ra], ctx->base.pc_next); + tmp = tcg_temp_new(); + tcg_gen_andi_i64(tmp, vb, ~3); + gen_pc_disp(ctx, ctx->ir[ra], 0); + tcg_gen_mov_i64(cpu_pc, tmp); + } else { + tcg_gen_andi_i64(cpu_pc, vb, ~3); } ret = DISAS_PC_UPDATED; break; @@ -2908,7 +2913,7 @@ static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) gen_goto_tb(ctx, 0, 0); break; case DISAS_PC_STALE: - tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next); + gen_pc_disp(ctx, cpu_pc, 0); /* FALLTHRU */ case DISAS_PC_UPDATED: tcg_gen_lookup_and_goto_ptr();