From patchwork Fri May 27 16:47:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 576521 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:8607:0:0:0:0 with SMTP id bb7csp816101mab; Fri, 27 May 2022 10:04:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIpik5NVb0QeMadEYYiqiHoDBbzCEzfT50xVESPWDn4LkXR5exIVBXBQB2ZPEr4k11W85C X-Received: by 2002:a37:9284:0:b0:6a3:55a3:81dd with SMTP id u126-20020a379284000000b006a355a381ddmr24276167qkd.316.1653671071637; Fri, 27 May 2022 10:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653671071; cv=none; d=google.com; s=arc-20160816; b=aqKp4Hy34jgeh2MN6Fe1qTGidtq4/AFQQcNs5NaWS6T/QrNvUKJPfO5bHVrXV0Z2u5 r/qk1X5rqHgr3UpRl9wFFuXVNHRurM3ekYzw1yiBHMOpmvcciU4BusMhE5dTh6ZsxtIc 5iCDdd3da5eRPT5uaMpDglz/2Fwe6LOFTMLIJ280K28s7STICcui5B/1/faoi8Y3WYYw atAuhmIOzNw3j+NqLznTakQ8IF9iSMySkjGndFHY1nG76QF9rfrNz9UslUvYNiSymzT0 GiUybtfxcrHYHRhzAWzb9xBPfFWZg9KHWT/Mmf3nDQ0QrH6sKXv/c6Y5F6Grhd94hJS/ 8/tQ== 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=cwESKCbeUqq8Fp51gCXlnu+zvieKC7JYRpWNMfnKmBPkkyOKuiA5ZJYRj+PZPsZFdo Q6PGQ3YC9sLjJTOJXPMPVgVwIkEmWIt8I5KUt/i+M/EL5i4CRCE0J1nN3WIroW48M4Wt 8HQ0/j5BJPZ/hw8YrU4CVpvuHV7MQDqHm6mLWd1PgGW8+l4UK4iu1DPVuliu5n4c5YSC Gr4yl7Qq7eKkx7I7kE9JdedphOvs6yG+aI4j7CcZ+cdeSmnc6QMtmBUSyaudKBrEGwhH joNqpuvDBUL16uNntooFOrZwCJODxr5nUyjG/lvhOm+h9mlR1h8F/5yRZejDjLYOsYRn Fjxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=szRP+MhW; 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 c25-20020a05620a269900b0069f9cd21cecsi3690739qkp.179.2022.05.27.10.04.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 May 2022 10:04: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=szRP+MhW; 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]:41948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nudO3-00071H-35 for patch@linaro.org; Fri, 27 May 2022 13:04:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nud8S-0001jl-RO for qemu-devel@nongnu.org; Fri, 27 May 2022 12:48:24 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:33426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nud8F-0005Nn-NL for qemu-devel@nongnu.org; Fri, 27 May 2022 12:48:24 -0400 Received: by mail-pf1-x42e.google.com with SMTP id 202so4823457pfu.0 for ; Fri, 27 May 2022 09:48:11 -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=szRP+MhWzymXnTC155Br3Y/VKDlUnUGfKKg5AvTeWtg8qXq9++gPhAM4mEA3IhVZMZ wDnVj39vXVRltmJ2mbsWTm4QhDAo2VejmmmlnoHLZ7P96N5MgV8Cskc7g5t0eSQq5RrK 2zw8DKs43l1ua2NS2Kz9KlGfsgH/H1wXuR0GUrtTRuUjORs3CJadCY7JR/7mHo6SEDdZ EwY9B3pBeBZ5wNds0HMcBFYPMJ82VdbWkWIBiOdcecSo5TkXWdqynUfbLSm36vCl+Ta2 TRS+HpPCw1XfCW2C3IeGYfysegaAzGScRfrkMUzi55PdzwXN4Sf7Ada0ZE7Rzp4ac/2b P4Ww== 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=XkaQ8ON4y9LLNy33hiLtSe9zqdW4vY9/I5p3Od5zz0hGNS0JmVI6eP5i6oov4wKocW NIZCGyY8Ala4VqOYtu8cvQp3L0eLm/G1UVW0UPOeQBTmxytZlCWG83gI6rggsWsQCUCU xWoBWp8r+kl5+ELQyUeFi88TW20lYNJN4Z2v5QLzQUO33mCH15b/UVd2drechq01Raa/ +D3IvoY8sxL5BJxPyq1Dq9axcE/WrKYHyWOJs5huDl5Zc+tCojfi14V8aQeoO++9khIQ JpD93wqc0WIqLLisDzDDjM2+n5VUgR+m7Y9g6QsgGCPl0IIhSfdpwf+jmPfDW9XLfexC Ox9Q== X-Gm-Message-State: AOAM532ilrHnEsfFBwtghGkmafMj0/3zL0oaLAnoEGv+sQ8apKCONFQz 3mNydDJHk24djaCvoyNrE36Xq4Wx2FBXpg== X-Received: by 2002:a63:a1e:0:b0:3db:6616:9f45 with SMTP id 30-20020a630a1e000000b003db66169f45mr37918068pgk.69.1653670090395; Fri, 27 May 2022 09:48:10 -0700 (PDT) Received: from stoup.. (174-21-71-225.tukw.qwest.net. [174.21.71.225]) by smtp.gmail.com with ESMTPSA id j11-20020aa7928b000000b0050dc7628133sm3861420pfa.13.2022.05.27.09.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 May 2022 09:48:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v5 02/17] target/m68k: Switch over exception type in m68k_interrupt_all Date: Fri, 27 May 2022 09:47:52 -0700 Message-Id: <20220527164807.135038-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220527164807.135038-1-richard.henderson@linaro.org> References: <20220527164807.135038-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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, 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;