From patchwork Thu Jun 2 01:33:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 578078 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp104679max; Wed, 1 Jun 2022 18:37:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmHAis0NlszmGygxrLsYOoxNhyQjIZ6ewhrBQM2VQSDEdhg88WVnS4Xyn84TCWDlJGsZCA X-Received: by 2002:ac8:6ed0:0:b0:2f9:4564:97b5 with SMTP id f16-20020ac86ed0000000b002f9456497b5mr1982858qtv.669.1654133872414; Wed, 01 Jun 2022 18:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654133872; cv=none; d=google.com; s=arc-20160816; b=yEcOTPnQ92vdfXSTw0RdGs1lKpG6rNaZDRTnzmlZIVx6ApG9CIf8ScVfnC2QySq4rG 0GRpzqjgPapUVOYrt/cltoNf6F/fEVSkN3Zzs6gIEMfGW30Ta7tZf4wPj0xU2LeCTS7d yHCX5jMcni9DeDjYEQI+hY8bsLPq0lytNonrw2SsecffZgI8Q9RMSbFKKNaCvcp8lxhK nPey1urYFFKd3mKNdTAKvKuYTXKgTJqsQXvtD1xUt+6+8eUeCU/Hs1ua47EeZxbPXlJD Nxkni6yV6s5Q8CskrNVV7HXpBpN5klcwxrNZqwqjJeoEXR1/ahbDU0ejGBgvnSPlFhZF IM7g== 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=hV+IA21ry8VojR25e1IAEE42j7p287jopA93G1Fi9U8=; b=Oe6TBic5WQjMtGSDJMorMnnbMuy/fuYPz4zWDb0114ll/Ra6Hhr/fqQQToUmgqywuu wYqETjBEnifVskFVF8hdoquKPzgad0BwfMgNuJdoPnNp7lToW5K+fqPntTVX4Z+YWPhJ wfMWIfQKTtjxuQbWy2sSTgbHFr6FD0ViYAfqAt0vwctP2/4xFo9cIzRdbZiwGF03dJcJ usMak/VkZU+I68gX30ybB/DCOIzPQjKFvrLD2njog3VS3NEKBv2Kw72GpjFbRYmwpj9F IhhzsBiQHWBppQiTZpyM7mqQlhZsHQgWgCw/2gzjgkkptLufj6eBQscrKBKC0D1bEI5Y ZQnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ovgoZ/5L"; 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 w13-20020ac857cd000000b002fcc2c38fd9si1826263qta.693.2022.06.01.18.37.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Jun 2022 18:37:52 -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="ovgoZ/5L"; 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]:51798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nwZma-0004Ks-0Z for patch@linaro.org; Wed, 01 Jun 2022 21:37:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwZj1-0002Md-Q8 for qemu-devel@nongnu.org; Wed, 01 Jun 2022 21:34:12 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:33374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwZiw-0005EC-V1 for qemu-devel@nongnu.org; Wed, 01 Jun 2022 21:34:09 -0400 Received: by mail-pj1-x1030.google.com with SMTP id hv24-20020a17090ae41800b001e33eebdb5dso4312244pjb.0 for ; Wed, 01 Jun 2022 18:34:06 -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=hV+IA21ry8VojR25e1IAEE42j7p287jopA93G1Fi9U8=; b=ovgoZ/5Lrp0mnppAWS/xEp2q/zvJtCwmTkPtX4YwiLu6Ppv4zkVd4tV+ZMzGElwXEN 1mX8b/mrmHT/wujWhq+pyfBgAlOXC48N55fuDvj9zSFrh5bYH5VHraEQ8Vh1Ocl6GW2o QJsinlGnmUKGnd6q31sNM9WoroV4/S6gG+2kSNsEHleaWS5IXs2NQ3NOYl4pg17JzUJo As/7KZk1hH0kHmZhxHW1KHq/ZXcD3Hm1hl1DssOcwopg9aeuLexGn6Nhoh5dSTyIV8cs tsTVgWlsU9n/fKgmOSEDWxv7W1t2ynDAdMj/+IBDRURbr3aLZwGItja3bOdZroZ98kMc uH6A== 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=hV+IA21ry8VojR25e1IAEE42j7p287jopA93G1Fi9U8=; b=wUzclgO7nNXyEcmcw/OG1da8t/l08fdlUQii5BDsW1T08/2ExGpAkvuKx1wKi1+hvM NFWg0P0mLDRFWunD1iDXjXG4hWx+dwA7i2Yp0jq9Gj9x9jkv42baH3jjAafIH6fT7afS HpcZQlsRc5VDvErXMFez/ZGtp949uQTwV6uZam0fGzY+Rv1IjDgNAkzkT9mhISfi66H+ l3W5JjIn6hHm0Vq5H2DqQ/JUYL5Zh1NCcgbtKFS8+620DxiPfjdEyV6JpS+2W1SX/wNH D/1T+JgZPyJ9L4yaeuwx3ahz05ME/Sl96PirhHrhT8lGbL05NTw+N+VsgtrQcr0XoQYg qbWw== X-Gm-Message-State: AOAM532E6aEVaCZKA1Co3rSUXv4y0DQ7SmCbLJmhE2mxvd8KsVR2jZaZ PI5Uat+7zNgP5ITZiVYlKXAYiSPeYt6/NA== X-Received: by 2002:a17:902:ce8a:b0:161:af5e:a7b9 with SMTP id f10-20020a170902ce8a00b00161af5ea7b9mr2219577plg.167.1654133645361; Wed, 01 Jun 2022 18:34:05 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:1eca:8ee3:9269:e00c]) by smtp.gmail.com with ESMTPSA id l191-20020a6391c8000000b003fc5b1db26fsm1962875pge.52.2022.06.01.18.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 18:34:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v6 02/17] target/m68k: Switch over exception type in m68k_interrupt_all Date: Wed, 1 Jun 2022 18:33:46 -0700 Message-Id: <20220602013401.303699-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220602013401.303699-1-richard.henderson@linaro.org> References: <20220602013401.303699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Replace an if ladder with a switch for clarity. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/m68k/op_helper.c | 49 +++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index d30f988ae0..2b94a6ec84 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -333,7 +333,8 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw) sp &= ~1; } - if (cs->exception_index == EXCP_ACCESS) { + switch (cs->exception_index) { + case EXCP_ACCESS: if (env->mmu.fault) { cpu_abort(cs, "DOUBLE MMU FAULT\n"); } @@ -391,29 +392,39 @@ static void m68k_interrupt_all(CPUM68KState *env, int is_hw) "ssw: %08x ea: %08x sfc: %d dfc: %d\n", env->mmu.ssw, env->mmu.ar, env->sfc, env->dfc); } - } else if (cs->exception_index == EXCP_ADDRESS) { + break; + + case EXCP_ADDRESS: do_stack_frame(env, &sp, 2, oldsr, 0, retaddr); - } else if (cs->exception_index == EXCP_ILLEGAL || - cs->exception_index == EXCP_DIV0 || - cs->exception_index == EXCP_CHK || - cs->exception_index == EXCP_TRAPCC || - cs->exception_index == EXCP_TRACE) { + break; + + case EXCP_ILLEGAL: + case EXCP_DIV0: + case EXCP_CHK: + case EXCP_TRAPCC: + case EXCP_TRACE: /* FIXME: addr is not only env->pc */ do_stack_frame(env, &sp, 2, oldsr, env->pc, retaddr); - } else if (is_hw && oldsr & SR_M && - cs->exception_index >= EXCP_SPURIOUS && - cs->exception_index <= EXCP_INT_LEVEL_7) { - do_stack_frame(env, &sp, 0, oldsr, 0, retaddr); - oldsr = sr; - env->aregs[7] = sp; - cpu_m68k_set_sr(env, sr &= ~SR_M); - sp = env->aregs[7]; - if (!m68k_feature(env, M68K_FEATURE_UNALIGNED_DATA)) { - sp &= ~1; + break; + + case EXCP_SPURIOUS ... EXCP_INT_LEVEL_7: + if (is_hw && oldsr & SR_M) { + do_stack_frame(env, &sp, 0, oldsr, 0, retaddr); + oldsr = sr; + env->aregs[7] = sp; + cpu_m68k_set_sr(env, sr &= ~SR_M); + sp = env->aregs[7]; + if (!m68k_feature(env, M68K_FEATURE_UNALIGNED_DATA)) { + sp &= ~1; + } + do_stack_frame(env, &sp, 1, oldsr, 0, retaddr); + break; } - do_stack_frame(env, &sp, 1, oldsr, 0, retaddr); - } else { + /* fall through */ + + default: do_stack_frame(env, &sp, 0, oldsr, 0, retaddr); + break; } env->aregs[7] = sp;