From patchwork Tue Apr 26 18:18:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 566123 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp3876614map; Tue, 26 Apr 2022 12:23:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7W54ahr18d9aDg/S5HNpNHNELLbgikZg8fcX9xduwLOJp1VHikC5IpnJXMwiEc4qh6S/W X-Received: by 2002:a05:6902:1508:b0:644:c907:cc05 with SMTP id q8-20020a056902150800b00644c907cc05mr21824113ybu.31.1651001011625; Tue, 26 Apr 2022 12:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651001011; cv=none; d=google.com; s=arc-20160816; b=Gu/qA3tEckSwcvxjbBKIwr1guGtp9dl3365RvrxDAzshsgntOgnDHRAwtsRMyeZnx4 osP5N0KmkpnuJQuWUENkEJyfeK5T4NRGK4wVLEJ/VvGF+IuB7tjfd+qTrIO5WZJpi2/s Wkz+/oEnij7rzm0T9CUM6If3FGEKK0oBo1+CsS7DoWbECyt9LB3gXfxPQAhvXwChz4H/ g5JDEztzG4KpZJkyksJsLlSo1mCPJNIhW8sMZ4WguecMV79dzV8PxBf58RZ4kk/0/AYs LpOXlVciozBVmx7qtpvA6rFZjA7s6AD6FgMM12epya9GCXQyKxgwEW3Gy8N50BL6FWi9 Sf/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=FydhLHa4yRdKoi+QMZFm3ACoytrW9DGPCspIkMaQe9I=; b=Y7JnEaDvR/oAbPE5CVLTOQbYTeKZhOcS5nmoMGBUlkKud/5BCGIdJmf9d7FFPPOEM5 M86yan8JBWGc6J6hvV+oo1T+Iq2LWWnS2EdBKitMcQjlxSBooj/8/YAVcHYbH0zD4W8Z j1vFDS+Jian9ZmdgpL2U89wiGloIpjt4G6D/FEWHhT9HsgO5aB6teXMywwayGS/rCXmo UJ+t6H8Vlrk35C7ZhtGBKQdT8YNKHtBQPF4dap49va5XCFNiJdp65MHlIBsLVscoTSdn 8ep8VOrOdeUpkl3IjJic19J2/nljew0fJWZHy/5dxqItSRp0fRFjKeDqLj1EpAasuug9 5OLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UEanv7da; 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 123-20020a251581000000b006488672fba3si4138566ybv.310.2022.04.26.12.23.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Apr 2022 12:23:31 -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=UEanv7da; 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]:56026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njQmZ-0007xG-4k for patch@linaro.org; Tue, 26 Apr 2022 15:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njPpz-0001rc-6i for qemu-devel@nongnu.org; Tue, 26 Apr 2022 14:23:01 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:46850) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njPpx-0005Rs-JQ for qemu-devel@nongnu.org; Tue, 26 Apr 2022 14:22:58 -0400 Received: by mail-pj1-x1032.google.com with SMTP id u6-20020a17090a1f0600b001d86bd69427so3268659pja.5 for ; Tue, 26 Apr 2022 11:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FydhLHa4yRdKoi+QMZFm3ACoytrW9DGPCspIkMaQe9I=; b=UEanv7dasubxQge87dL0Fakxp502DYRAjTJIHVkkH9kNJa+VF3FmkUSi9SnkRzf5SL Sg5kqdvtVEdRg4yev1LuBuqS3E9wEFnpPGWJNKLf+IHKjB6WQd7hudR5SDq2qKZ6SJhh 7gKfCb6gkWPV2yo7RGLL+WdQHAPlYy31an9gDrlaRziyqYbU1KMDYTyk9I9ZRPrlL7Dd AEIfydJrKUZ5pc0rQjGuw5w/Ig2RQawaJ+R3ZUkAa/dC4sBauOWZyw6JH56nYG/IB7rZ vaIlPxJ20Dy0QesoRHe8dBW1gPmOlmXI5a8Jvtvt6fMzK95j+gMi1uoWnnPnVq4+31Cc DXDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FydhLHa4yRdKoi+QMZFm3ACoytrW9DGPCspIkMaQe9I=; b=VFBZ9zfxZf/mE1HUG3PqYP0i2ZwJ4GMvXYOJcc+g1vMig/paOmqt5bdWDLq0dIZ1nZ /+sjlabDpHoOasqJ38l9TLT5AVJA2PRh2Roi+a/RF1fHy9EYdWOn2iHYZRwyN1EX1nEP 7Znw9mEfvassDFJlKtCD7K0j1lMvaPvDyieeF+FVN5smKcDSaFqGElos+GRFf/Oa81mS xsI05ND0EufbVQ0Y7YX/mnfbJhNZwFJUDIgeYRxnVdgUWtyt73fmiO1lARa4JZHOKE2S o92+AmMgH/NeDx4Ux3UKTGv1h/TuC8onwssHLPxCa1GsvtJZT5SNeoSeJ/Top7NlEp71 +7kA== X-Gm-Message-State: AOAM5330Hypn41K5nBLjkH2G13bpiqeCi79BSJgRkHfHa/H4VCQDnKRQ 95XojJVamTJNICCEdQ73sS/KWrDz3I2qRA== X-Received: by 2002:a17:902:6ac7:b0:150:24d6:b2ee with SMTP id i7-20020a1709026ac700b0015024d6b2eemr24976450plt.168.1650997376254; Tue, 26 Apr 2022 11:22:56 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id k187-20020a636fc4000000b003983a01b896sm13585053pgc.90.2022.04.26.11.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 11:22:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 52/68] target/nios2: Create gen_jumpr Date: Tue, 26 Apr 2022 11:18:51 -0700 Message-Id: <20220426181907.103691-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220426181907.103691-1-richard.henderson@linaro.org> References: <20220426181907.103691-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split out a function to perform an indirect branch. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20220421151735.31996-49-richard.henderson@linaro.org> --- target/nios2/translate.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index e2742a8556..8616813365 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -36,7 +36,6 @@ #include "semihosting/semihost.h" /* is_jmp field values */ -#define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ #define DISAS_UPDATE DISAS_TARGET_1 /* cpu state was modified dynamically */ #define INSTRUCTION_FLG(func, flags) { (func), (flags) } @@ -195,6 +194,16 @@ static void gen_goto_tb(DisasContext *dc, int n, uint32_t dest) } } +static void gen_jumpr(DisasContext *dc, int regno, bool is_call) +{ + tcg_gen_mov_tl(cpu_pc, load_gpr(dc, regno)); + if (is_call) { + tcg_gen_movi_tl(dest_gpr(dc, R_RA), dc->base.pc_next); + } + tcg_gen_exit_tb(NULL, 0); + dc->base.is_jmp = DISAS_NORETURN; +} + static void gen_excp(DisasContext *dc, uint32_t code, uint32_t flags) { t_gen_helper_raise_exception(dc, flags); @@ -437,8 +446,7 @@ static void eret(DisasContext *dc, uint32_t code, uint32_t flags) /* PC <- ra */ static void ret(DisasContext *dc, uint32_t code, uint32_t flags) { - tcg_gen_mov_tl(cpu_pc, load_gpr(dc, R_RA)); - dc->base.is_jmp = DISAS_JUMP; + gen_jumpr(dc, R_RA, false); } /* @@ -468,8 +476,7 @@ static void jmp(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - tcg_gen_mov_tl(cpu_pc, load_gpr(dc, instr.a)); - dc->base.is_jmp = DISAS_JUMP; + gen_jumpr(dc, instr.a, false); } /* rC <- PC + 4 */ @@ -488,10 +495,7 @@ static void callr(DisasContext *dc, uint32_t code, uint32_t flags) { R_TYPE(instr, code); - tcg_gen_mov_tl(cpu_pc, load_gpr(dc, instr.a)); - tcg_gen_movi_tl(dest_gpr(dc, R_RA), dc->base.pc_next); - - dc->base.is_jmp = DISAS_JUMP; + gen_jumpr(dc, instr.a, true); } /* rC <- ctlN */ @@ -909,11 +913,6 @@ static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) tcg_gen_exit_tb(NULL, 0); break; - case DISAS_JUMP: - /* The jump will already have updated the PC register */ - tcg_gen_exit_tb(NULL, 0); - break; - case DISAS_NORETURN: /* nothing more to generate */ break;