From patchwork Sun May 27 14:13:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137017 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1788752lji; Sun, 27 May 2018 07:20:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJVaEsgP3veDRUZgSwCtBK+dhFMO0rEsoF44bsRx4ms46kdQaZwYdYI0Xc+acSc2Uq16jwz X-Received: by 2002:a37:9dd4:: with SMTP id g203-v6mr4263857qke.197.1527430846740; Sun, 27 May 2018 07:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527430846; cv=none; d=google.com; s=arc-20160816; b=hOqpTiKpvHxTprR9QYhfVz36OwV2dKmz5ifC2+3gxZ/vCqCekwnLG42q/0FBvScyIl urN+Kf+DEDkpXb4MM+FZ4qt1TVusvXGf67R6JMEHTfNywuM4lOsnc6EFBsL6vitzuRoc XEEQ9t59FV/X26W8NznljqvzRgckNrYkSOZs1nmkTJvb2UbpVlm8MrO977aO7Yr6Vqmm CfH1X9OAbOO3M+gRjuaWQVKTyn2UTOH9hk1Qhcr67uI0hwhMyClTtA2mqgvIWj4lcNUm y7hbQIMzy/rAiYOa9RDv43RLUavnanACnd+Nww92a3J3LTEtD7VJePmtzaYXyZEKsnrD ATfw== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Qhm86MLlNHiOqum7WU9JuSQ80vU+puuKZ6sHQm5Pl70=; b=QeODQurwg7Y0iy4/OdKJbpJ/e7D9rjj9yO1fWKAV3AHos1O5xVYoIKDEOw87H1KKYx XspCt0PdX1rTn9+mHeVsjfsmM7DPs4FphI9RJG2eNwy1vZwdzSGSUqDZ0UA5vo7VIImi NWQdYayVMi4/qtJBkK+Dgh4EDwQajML6B/ZBgP8VkCXzaKbNZPYcoXyz21zW6T9u+LMe 9FuDghaR5pqLmrP9kSCDWsoJoyYUKxAF0rqZkRMuBAw4Gi2RtSBVtCbf24l+Yf2ouO3o znuo2m3idrAURoLATdsUZUtEp0ajAuPyJAy7itDD6D/44N9S7zBjNmjJM73xXFZS+8O0 phfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LyH6Qtr1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w5-v6si5897740qvj.75.2018.05.27.07.20.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 27 May 2018 07:20:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LyH6Qtr1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:52231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMwXO-00059N-5C for patch@linaro.org; Sun, 27 May 2018 10:20:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMwQU-0008QE-8f for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fMwQT-0004Nr-AA for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:38 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:34533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fMwQT-0004Nk-4I for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:37 -0400 Received: by mail-pl0-x243.google.com with SMTP id ay10-v6so5747298plb.1 for ; Sun, 27 May 2018 07:13:37 -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; bh=Qhm86MLlNHiOqum7WU9JuSQ80vU+puuKZ6sHQm5Pl70=; b=LyH6Qtr1togFq4axeU1sCfZyJ6ouBmKzEprU2cFpwz96nrbdd+yFiGd+fTdy/mpB5a Sky3eBdPlHI4rKwVX3TitTl3u8o2m+AnjE29nXIx6zJX3my9MhuqUDGDWPfyRUro75+Z S7kYBN9tFQPbc6SvlAB8BePmghH04pFdK9sTk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Qhm86MLlNHiOqum7WU9JuSQ80vU+puuKZ6sHQm5Pl70=; b=FKNv8W0iUNQK9FR9M2QGiVbBUqUE8M4xCjO7CZW0W+erq6G/PjXh7BudN03uIDUsx+ F4JbAgBeAAJ23+DafYZla4v650f6F9T6T30igR8GKbOXsBdgSHFSRzyefN/ozNAzVaYN ziU1AociqHpwm/0N4BXVBQ++JRGVLtsPnFnJOUPPjPiRnxNvsIDQhs1K5LYcqCEWy1lX XIMaFDTa8O/WKw/3h6YAahDmUYye680rXfj9DJ1HRzuyfoPtKZx6KZ71quMpTdLWdNrY hu9BmfA45XhXdpouVes548Chc1L1tJlLrYY/xQTyL0+3ciFCCaD2rIOfhehpCvGP7X8S D8Xg== X-Gm-Message-State: ALKqPwe/Dm/H+WmeUTQTW0lSAdJ5Ni+jsmyVhNa6axXZwoA3UTwoXIKC tdYYZzJMHn0+mWQ+oYyqITmNP/+RTUA= X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr9806485pla.88.1527430415938; Sun, 27 May 2018 07:13:35 -0700 (PDT) Received: from cloudburst.twiddle.net (50-233-235-3-static.hfc.comcastbusiness.net. [50.233.235.3]) by smtp.gmail.com with ESMTPSA id b89-v6sm66680075pfd.85.2018.05.27.07.13.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 27 May 2018 07:13:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 27 May 2018 09:13:09 -0500 Message-Id: <20180527141324.11937-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180527141324.11937-1-richard.henderson@linaro.org> References: <20180527141324.11937-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH 05/20] target/openrisc: Split out is_user 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: Stafford Horne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows us to limit the amount of ifdefs and isolate the test for usermode. Signed-off-by: Richard Henderson --- target/openrisc/translate.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) -- 2.17.0 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stafford Horne diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index a8afb9a562..61e6deef69 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -54,6 +54,15 @@ typedef struct DisasContext { target_ulong jmp_pc_imm; } DisasContext; +static inline bool is_user(DisasContext *dc) +{ +#ifdef CONFIG_USER_ONLY + return true; +#else + return dc->mem_idx == MMU_USER_IDX; +#endif +} + /* Include the auto-generated decoder. */ #include "decode.inc.c" @@ -914,17 +923,13 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a, uint32_t insn) LOG_DIS("l.mfspr r%d, r%d, %d\n", a->d, a->a, a->k); check_r0_write(a->d); -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti = tcg_const_i32(a->k); gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], ti); tcg_temp_free_i32(ti); } -#endif return true; } @@ -932,17 +937,13 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) { LOG_DIS("l.mtspr r%d, r%d, %d\n", a->a, a->b, a->k); -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { TCGv_i32 ti = tcg_const_i32(a->k); gen_helper_mtspr(cpu_env, cpu_R[a->a], cpu_R[a->b], ti); tcg_temp_free_i32(ti); } -#endif return true; } @@ -1204,16 +1205,12 @@ static bool trans_l_rfe(DisasContext *dc, arg_l_rfe *a, uint32_t insn) { LOG_DIS("l.rfe\n"); -#ifdef CONFIG_USER_ONLY - gen_illegal_exception(dc); -#else - if (dc->mem_idx == MMU_USER_IDX) { + if (is_user(dc)) { gen_illegal_exception(dc); } else { gen_helper_rfe(cpu_env); dc->base.is_jmp = DISAS_EXIT; } -#endif return true; }