From patchwork Wed Feb 13 15:53:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 10810241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8474013A4 for ; Wed, 13 Feb 2019 15:59:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 720D02D430 for ; Wed, 13 Feb 2019 15:59:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65E962DABD; Wed, 13 Feb 2019 15:59:23 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E612D2D430 for ; Wed, 13 Feb 2019 15:59:22 +0000 (UTC) Received: from localhost ([127.0.0.1]:59102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtwwU-0004sY-4Y for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Feb 2019 10:59:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtwsU-00018Q-NM for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:55:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtwsR-0001U8-2b for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:55:12 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:43497) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtwsP-00012F-9T for qemu-devel@nongnu.org; Wed, 13 Feb 2019 10:55:10 -0500 Received: by mail-pg1-x532.google.com with SMTP id v28so1302307pgk.10 for ; Wed, 13 Feb 2019 07:54:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=subject:date:message-id:in-reply-to:references:cc:from:to; bh=UqruLD0D3gmwyXgIGQ4bTHq08y9NO+xuyJhuaPWdkSw=; b=AcGOYgNKfZ6M3/uWz04xJVW37qgiDkvMkPiwQqj9Wm1lBXGLsUF0WWuBr7M2G8rZsi KT/CvNylps4LQSc5/DI8ZqSxHnu9osvIB9YPPSUO9ZtpTbI1vGVeb5A3ZayfCeD2zAAx oY3JTmypjLB7FlxYQRr01HYZiDi5QNoFbKbg7Qxm6338qdpgnAqLT43hiv1aV0TbZ+Cg gzEUwZ1TTGNDgJ0iLsQ4Ij1EEXuFCgGL2OGOlwYVR3tQEsUAkJXVZwUBFI7HZ05Rt8HA R5iorGX3mh+4k6pIlTrm4dEKdCppKn/0OATXErh0OFDYhDDK8w94v4atFEqj7fn/z2Kz aSBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :cc:from:to; bh=UqruLD0D3gmwyXgIGQ4bTHq08y9NO+xuyJhuaPWdkSw=; b=ckzcdrz7p/+PldE1NKG5P2LWxbPJGTCAQwgnpjO0PVjrD1cZhOezJ4LBHTlT/afFEf Ob+GoN1zhI4Fu2oOXCVWjwf9elVrAiRM5+yrXDO+C7NK8B+Qu+qC3gH+scMFWaCA8Ab6 AkCxM1wDDTcarkqj12RxqMWa5p2Im+Vk0wanWfu66HdJeBAi/h4DYF0d9+bqLfsmSPLZ 07F3BfXOD8m9gXVW36laaW6ywS1zq2EoF4lSHTfxB1JsoEgr3XDqp7v6cAfUOFfZ/FBU BW5syzV1Ik5ckQx42g9GgQUJ/XEderGAUWu0uT/VfeOANn0Xjmq6HaVXKFgZrp/SRgXu HyNA== X-Gm-Message-State: AHQUAuYv7eWE+AFoZOYXrehxzii6+ABg0LhjBm9iknJdsQaXXk7hW1zz SLWJMtEC3n9FcQ0wVoIESvqVG/PqYeU= X-Google-Smtp-Source: AHgI3IYHxgRSz/Cj4xF37hLgjE9RTFijjQacKMPnweywz/KfvlgFTvN/8eK1hG+q1kaMtT5I6D1utg== X-Received: by 2002:a63:5d5f:: with SMTP id o31mr1064943pgm.414.1550073288213; Wed, 13 Feb 2019 07:54:48 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id i71sm40222644pfi.170.2019.02.13.07.54.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 07:54:47 -0800 (PST) Date: Wed, 13 Feb 2019 07:53:46 -0800 Message-Id: <20190213155414.22285-8-palmer@sifive.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190213155414.22285-1-palmer@sifive.com> References: <20190213155414.22285-1-palmer@sifive.com> From: Palmer Dabbelt To: qemu-riscv@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::532 Subject: [Qemu-devel] [PATCH v7 07/35] target/riscv: Convert RVXI fence insns to decodetree 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: Bastian Koppelmann , Peer Adelt , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Bastian Koppelmann Acked-by: Alistair Francis Reviewed-by: Richard Henderson Signed-off-by: Bastian Koppelmann Signed-off-by: Peer Adelt --- target/riscv/insn32.decode | 2 ++ target/riscv/insn_trans/trans_rvi.inc.c | 19 +++++++++++++++++++ target/riscv/translate.c | 12 ------------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 1f5bf1f6f97d..804b721ca51e 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -82,3 +82,5 @@ srl 0000000 ..... ..... 101 ..... 0110011 @r sra 0100000 ..... ..... 101 ..... 0110011 @r or 0000000 ..... ..... 110 ..... 0110011 @r and 0000000 ..... ..... 111 ..... 0110011 @r +fence ---- pred:4 succ:4 ----- 000 ----- 0001111 +fence_i ---- ---- ---- ----- 001 ----- 0001111 diff --git a/target/riscv/insn_trans/trans_rvi.inc.c b/target/riscv/insn_trans/trans_rvi.inc.c index 136fa54d0655..973d6371df85 100644 --- a/target/riscv/insn_trans/trans_rvi.inc.c +++ b/target/riscv/insn_trans/trans_rvi.inc.c @@ -318,3 +318,22 @@ static bool trans_sraw(DisasContext *ctx, arg_sraw *a) return true; } #endif + +static bool trans_fence(DisasContext *ctx, arg_fence *a) +{ + /* FENCE is a full memory barrier. */ + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); + return true; +} + +static bool trans_fence_i(DisasContext *ctx, arg_fence_i *a) +{ + /* + * FENCE_I is a no-op in QEMU, + * however we need to end the translation block + */ + tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn); + tcg_gen_exit_tb(NULL, 0); + ctx->base.is_jmp = DISAS_NORETURN; + return true; +} diff --git a/target/riscv/translate.c b/target/riscv/translate.c index bb02ef23e791..442e75fc40fb 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1951,18 +1951,6 @@ static void decode_RV32_64G(DisasContext *ctx) gen_fp_arith(ctx, MASK_OP_FP_ARITH(ctx->opcode), rd, rs1, rs2, GET_RM(ctx->opcode)); break; - case OPC_RISC_FENCE: - if (ctx->opcode & 0x1000) { - /* FENCE_I is a no-op in QEMU, - * however we need to end the translation block */ - tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn); - tcg_gen_exit_tb(NULL, 0); - ctx->base.is_jmp = DISAS_NORETURN; - } else { - /* FENCE is a full memory barrier. */ - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); - } - break; case OPC_RISC_SYSTEM: gen_system(ctx, MASK_OP_SYSTEM(ctx->opcode), rd, rs1, (ctx->opcode & 0xFFF00000) >> 20);