From patchwork Thu Mar 10 11:27:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 550128 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp939508mag; Thu, 10 Mar 2022 04:21:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSAs9uqoWZ+lcJiF5mKPvLdWJacjannxV0o9vHvs1HSq5HscE+SE6egRqt6CZ18DLGWQJC X-Received: by 2002:a25:8c10:0:b0:61d:b17e:703d with SMTP id k16-20020a258c10000000b0061db17e703dmr3526418ybl.154.1646914871720; Thu, 10 Mar 2022 04:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646914871; cv=none; d=google.com; s=arc-20160816; b=rvYQMzL3dThS8270L02YezF5Njiab4Y1lsJJK7MG1DzGmEzr4hPfvWIKhJgaPJgw2v pwb74XubMvbkWmuhm2gkeSTtE76dV75Ho7sZ8Vi8q9/TvDLRzqMa7jD6PzH/QGtm+ife 7JHuMxfimb+Y3vj+Ogdq5ezO66Vufk+N3FDplDn+R5MJM3qQEVlvtW5JOE05PLMkmodG ZOgPTFUU/0PkxzUFVqHCTkrC5P/f1xRbElkrWHAMg5jc6WtkIxCK7eJFr3sJoEOJ+1rr GEt1gPazgH9rTZ3KkGxmnaAGr9Arx3JI4DwaLKiNtnQfU2srhyLhCqQQJaOgV9B9YFKG S15w== 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=a0Y1+UOzMYE465JAg/1XZp8FHRvlzNh9RDhixInPs2c=; b=HakZ1em994d+7H2SizyleDzw2vznSfPZrtJGfiilfYqeUqh9vaopm7vQ9ZhHLuAYZX hHzhDYMbYupfZPFS2Eseq3aTGLSKtuMjIgDS6QJjKjUT1BDkqtdiUK1TrHCgJS85KtBo EjWxTfkHOs0/OBjLNuc5BWMP1tqCos94aLFymborHzK70bC8sYPt8c/57lFYwFn9cn1D dfkTv9cK/DxuTmmUIX3qjEOd/kw7shI27EgQU3b7wu1RpbTvF3ZcTebQObbbKZi/rv9A HxAIEVvc9jnLwV2Y/IjHT1MV4+sKYeo4XFBLLyuTQzX10Ur5EpAb5G8k8R463y2W38v1 0ZIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UxensK2T; 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=fail (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 f8-20020a251f08000000b0061e0b190dc7si2813541ybf.658.2022.03.10.04.21.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Mar 2022 04:21:11 -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=fail header.i=@linaro.org header.s=google header.b=UxensK2T; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHn5-00074R-6H for patch@linaro.org; Thu, 10 Mar 2022 07:21:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGxm-0006HQ-AU for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:10 -0500 Received: from [2607:f8b0:4864:20::531] (port=41818 helo=mail-pg1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSGxk-00081x-CC for qemu-devel@nongnu.org; Thu, 10 Mar 2022 06:28:09 -0500 Received: by mail-pg1-x531.google.com with SMTP id o26so4484750pgb.8 for ; Thu, 10 Mar 2022 03:28:07 -0800 (PST) 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=a0Y1+UOzMYE465JAg/1XZp8FHRvlzNh9RDhixInPs2c=; b=UxensK2TuV6aJUw6wTkkqlJOX4X1PpGUrf6kigLv44qOCxM2YeMsKdl4RG6dcmsFle 7lpRu9muFb1Qdh4bxAmsWJD45LlgSn1lRCckHuYXfbrBBlbNDfFLHwVGfcDADMuXn4vJ j1RDFZMXSk+9162990JnbnR6+FTqCh9Hv/YRmqYq3O0jZHJJULbqaoiOMHZJ53nXat5k F6UF5LrkOcxAK1FZBFpx5dS27XMBl/rBxgFTkZl3ZREhf5ocI5ved3veinggAn9UEnQA b0OyAHskLQsD2r7MgCxoNASr9WNK6nBty3344Xo4q/24RVryzdpvBBBR0Y43cVJhrsZp eRXw== 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=a0Y1+UOzMYE465JAg/1XZp8FHRvlzNh9RDhixInPs2c=; b=eW38fODZRL+gX1GU7wFTcCultpWuS/tmsz2RMEjdphjvBPF1Ki4Yv+pPD1o39y5qgQ ZuO2KaAzwEcaMwSWrXu/76WPSdKuVuvfTQ291cjywAc3qlftfEhJyQ7crFo+8n1pXZRr 2dwSRHNE4xmytdDVFZt05wqftrKfoCQHIYKxPpxfdNN3dzl8zOeJiQcvHE2bR9GHl2o4 nsng3FoU5W2R+OEure3QUUmCe+Vn/k8RCvNzDARswsE9s5ebyGMy+ttvvhkJC094gz8K gUepMZqicYlGG+V53QgCU8ULv3EGiUsz4TDGP1UicgRIn6c29/xGoV56xo2D5N8CLAGn FYcA== X-Gm-Message-State: AOAM532c9FZvXC7Iv8M4j8B1WSNoxwUPXztjeE2XE343hh4eond47xEA 2wJdYIVHNXYyDRS4yWT5qMokh/2rRlZ0og== X-Received: by 2002:a65:4845:0:b0:325:c147:146d with SMTP id i5-20020a654845000000b00325c147146dmr3769599pgs.140.1646911687159; Thu, 10 Mar 2022 03:28:07 -0800 (PST) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id js15-20020a17090b148f00b001bfc8614b93sm3114977pjb.1.2022.03.10.03.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 03:28:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 35/48] target/nios2: Create gen_jumpr Date: Thu, 10 Mar 2022 03:27:12 -0800 Message-Id: <20220310112725.570053-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220310112725.570053-1-richard.henderson@linaro.org> References: <20220310112725.570053-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::531 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: marex@denx.de, peter.maydell@linaro.org, amir.gonnen@neuroblade.ai Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split out a function to perform an indirect branch. Signed-off-by: Richard Henderson --- 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 d5f2e98de9..f61ba92052 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) } @@ -168,6 +167,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); @@ -387,8 +396,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); } /* @@ -418,8 +426,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 */ @@ -438,10 +445,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 */ @@ -838,11 +842,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;