From patchwork Mon Jul 24 20:26:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9860369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 58C7660349 for ; Mon, 24 Jul 2017 20:29:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C42328554 for ; Mon, 24 Jul 2017 20:29:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41511285C1; Mon, 24 Jul 2017 20:29:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2416A285AE for ; Mon, 24 Jul 2017 20:29:51 +0000 (UTC) Received: from localhost ([::1]:56822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZjyv-00031e-S2 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 24 Jul 2017 16:29:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZjxX-0002zE-FB for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZjxW-0000pC-1X for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:07 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:38316) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZjxV-0000oh-Sj for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:05 -0400 Received: by mail-qk0-x243.google.com with SMTP id t2so10964748qkc.5 for ; Mon, 24 Jul 2017 13:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=efgR13kthOdwAvcx24PHxicwvxCBHfeTUqtdgtNZyOw=; b=bWjhEW+APeLjUqswXIX1/c2ybVIR+Nn4/y42aciA7UYjeHW9n4Ik44n4sz1B+o7vfc AoF/EoSUTfP4fztO6b+ffrl7RYJhWZyoKh99sddVLZnLmPQfNXInIMCiIPgeJK2ZyiNt PMmeaLlSdz6U7LHOHdOgcCnGfTzTUwD9UjNiK3+bTTL+5rUP0LfZ87lMBb3XZiotjiBm Z4Ia5arzU92wTPCoBlHYQHanhpQO+z85Bd5A2sYuiKXGz1dwpdYACTEgNvd7tbhL4hqd O5HWYd4iygr6ZWdZza3adRKnVS9txiAjFoUkcfFqpxDE+IR04wFiFhoSG9bNIimWaNS9 Sn5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=efgR13kthOdwAvcx24PHxicwvxCBHfeTUqtdgtNZyOw=; b=sCn8OyXQV0g6jv9P9QBovSb2EuRkc686l+JnWZw7wnsUvkNS7cDa9bEouSveMhfYDH miNSrBVsA8Vqs/jMnR9o9AuhcHcRQYWCltYBRHMYiG8gg0UkFpXhaveCtWSloaag8uLZ cdOEOYiTCDdK4+DQhTfTY3EjIetexldQhJcLXB77Cis2AIxVT3mjHHLKh8ScH55PLK5y syAbDU+YJL8LbZhUbNZFPAIbWWlc7mQamch3L27IE5/Mlt+1deG61ifnb4RX0T26UTR6 1cb22VQEBxWDCWD2ECfRS8Q3qX4DPGm/AFla4pTOraUu095msP3ulvWqk/4LEMJr2/Bm Cnhg== X-Gm-Message-State: AIVw112/CkPfyRfQiFEK5XoYhoh539MQLvd1+a4G5DnDVyXDJQKG1IEv ZSrieNrNz4PP9mbFdAM= X-Received: by 10.55.66.132 with SMTP id p126mr20232264qka.143.1500928084871; Mon, 24 Jul 2017 13:28:04 -0700 (PDT) Received: from bigtime.com ([71.217.194.233]) by smtp.gmail.com with ESMTPSA id p52sm9196808qtc.74.2017.07.24.13.28.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2017 13:28:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 24 Jul 2017 13:26:59 -0700 Message-Id: <20170724202728.25960-4-rth@twiddle.net> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170724202728.25960-1-rth@twiddle.net> References: <20170724202728.25960-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::243 Subject: [Qemu-devel] [PATCH v15 03/32] target/arm: Use DISAS_NORETURN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fold DISAS_EXC and DISAS_TB_JUMP into DISAS_NORETURN. In both cases all following code is dead. In the first case because we have exited the TB via exception; in the second case because we have exited the TB via goto_tb and its associated machinery. Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/arm/translate.h | 8 ++------ target/arm/translate-a64.c | 37 ++++++++++++++++++++----------------- target/arm/translate.c | 14 ++++++++------ 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/target/arm/translate.h b/target/arm/translate.h index 2fe144baa9..90f64d9716 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -124,12 +124,8 @@ static void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) * defer them until after the conditional execution state has been updated. * WFI also needs special handling when single-stepping. */ -#define DISAS_WFI 4 -#define DISAS_SWI 5 -/* For instructions which unconditionally cause an exception we can skip - * emitting unreachable code at the end of the TB in the A64 decoder - */ -#define DISAS_EXC 6 +#define DISAS_WFI 5 +#define DISAS_SWI 6 /* WFE */ #define DISAS_WFE 7 #define DISAS_HVC 8 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 883e9df0c2..789c66e634 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -304,7 +304,7 @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) { gen_a64_set_pc_im(s->pc - offset); gen_exception_internal(excp); - s->is_jmp = DISAS_EXC; + s->is_jmp = DISAS_NORETURN; } static void gen_exception_insn(DisasContext *s, int offset, int excp, @@ -312,7 +312,7 @@ static void gen_exception_insn(DisasContext *s, int offset, int excp, { gen_a64_set_pc_im(s->pc - offset); gen_exception(excp, syndrome, target_el); - s->is_jmp = DISAS_EXC; + s->is_jmp = DISAS_NORETURN; } static void gen_ss_advance(DisasContext *s) @@ -340,7 +340,7 @@ static void gen_step_complete_exception(DisasContext *s) gen_ss_advance(s); gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex), default_exception_el(s)); - s->is_jmp = DISAS_EXC; + s->is_jmp = DISAS_NORETURN; } static inline bool use_goto_tb(DisasContext *s, int n, uint64_t dest) @@ -371,7 +371,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) tcg_gen_goto_tb(n); gen_a64_set_pc_im(dest); tcg_gen_exit_tb((intptr_t)tb + n); - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; } else { gen_a64_set_pc_im(dest); if (s->ss_active) { @@ -380,7 +380,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) gen_exception_internal(EXCP_DEBUG); } else { tcg_gen_lookup_and_goto_ptr(cpu_pc); - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; } } } @@ -11305,7 +11305,7 @@ void gen_intermediate_code_a64(CPUState *cs, TranslationBlock *tb) assert(num_insns == 1); gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), default_exception_el(dc)); - dc->is_jmp = DISAS_EXC; + dc->is_jmp = DISAS_NORETURN; break; } @@ -11332,21 +11332,25 @@ void gen_intermediate_code_a64(CPUState *cs, TranslationBlock *tb) gen_io_end(); } - if (unlikely(cs->singlestep_enabled || dc->ss_active) - && dc->is_jmp != DISAS_EXC) { + if (unlikely(cs->singlestep_enabled || dc->ss_active)) { /* Note that this means single stepping WFI doesn't halt the CPU. * For conditional branch insns this is harmless unreachable code as * gen_goto_tb() has already handled emitting the debug exception * (and thus a tb-jump is not possible when singlestepping). */ - assert(dc->is_jmp != DISAS_TB_JUMP); - if (dc->is_jmp != DISAS_JUMP) { + switch (dc->is_jmp) { + default: gen_a64_set_pc_im(dc->pc); - } - if (cs->singlestep_enabled) { - gen_exception_internal(EXCP_DEBUG); - } else { - gen_step_complete_exception(dc); + /* fall through */ + case DISAS_JUMP: + if (cs->singlestep_enabled) { + gen_exception_internal(EXCP_DEBUG); + } else { + gen_step_complete_exception(dc); + } + break; + case DISAS_NORETURN: + break; } } else { switch (dc->is_jmp) { @@ -11356,8 +11360,7 @@ void gen_intermediate_code_a64(CPUState *cs, TranslationBlock *tb) case DISAS_JUMP: tcg_gen_lookup_and_goto_ptr(cpu_pc); break; - case DISAS_TB_JUMP: - case DISAS_EXC: + case DISAS_NORETURN: case DISAS_SWI: break; case DISAS_WFE: diff --git a/target/arm/translate.c b/target/arm/translate.c index d1a5f56998..699e810157 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -297,7 +297,7 @@ static void gen_step_complete_exception(DisasContext *s) gen_ss_advance(s); gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex), default_exception_el(s)); - s->is_jmp = DISAS_EXC; + s->is_jmp = DISAS_NORETURN; } static void gen_singlestep_exception(DisasContext *s) @@ -1184,7 +1184,7 @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) gen_set_condexec(s); gen_set_pc_im(s, s->pc - offset); gen_exception_internal(excp); - s->is_jmp = DISAS_EXC; + s->is_jmp = DISAS_NORETURN; } static void gen_exception_insn(DisasContext *s, int offset, int excp, @@ -1193,7 +1193,7 @@ static void gen_exception_insn(DisasContext *s, int offset, int excp, gen_set_condexec(s); gen_set_pc_im(s, s->pc - offset); gen_exception(excp, syn, target_el); - s->is_jmp = DISAS_EXC; + s->is_jmp = DISAS_NORETURN; } /* Force a TB lookup after an instruction that changes the CPU state. */ @@ -11944,7 +11944,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) /* We always get here via a jump, so know we are not in a conditional execution block. */ gen_exception_internal(EXCP_KERNEL_TRAP); - dc->is_jmp = DISAS_EXC; + dc->is_jmp = DISAS_NORETURN; break; } #endif @@ -12089,6 +12089,9 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) default: /* FIXME: Single stepping a WFI insn will not halt the CPU. */ gen_singlestep_exception(dc); + break; + case DISAS_NORETURN: + break; } } else { /* While branches must always occur at the end of an IT block, @@ -12113,8 +12116,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) /* indicate that the hash table must be used to find the next TB */ tcg_gen_exit_tb(0); break; - case DISAS_TB_JUMP: - case DISAS_EXC: + case DISAS_NORETURN: /* nothing more to generate */ break; case DISAS_WFI: