From patchwork Fri May 11 04:23:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135491 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp392230lji; Thu, 10 May 2018 21:26:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpaTBBw8kIQ9DAWAzY/C0UfoSyfK9M+aG7Yi3T1u6GAfCqXsNAxGGMtXiX4q97BviU4VS1c X-Received: by 2002:a37:58c6:: with SMTP id m189-v6mr3647545qkb.144.1526012790547; Thu, 10 May 2018 21:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526012790; cv=none; d=google.com; s=arc-20160816; b=gZy5S7/UEZF0Tl8yXDbvuNzRtBYraLxzGrPvWa28nFm7IasGQEadQPsB/7WuVgmv0B vwhCBP6haA0msA9eXGWmt4q7aKPk4IoHwecfxWK/qcG3Da7N7UURUxJbNs9quTpcaGmt 03w4L4LhC5hGQ1kOJneJQhdGUmP8rZ+wvPDfr+SWrJ6kogcD9w30IVO9zYfthD3mH2N8 L2PSa/7+YSI47xpJENjaDlkCe4MzQvpW8l6xhj064rxZs1O0MGWfSJ+kcrlj1MeVqBvm 9xPtTbXkig0vENdiyleZ4X6yaGciGSz6Ar3aKp7irBGMd/Nvs/6xaH/HoGu/l8U/m/RZ uO0Q== 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=BiBMArvzBSclTtl+JJFYqnT65X4b0tbCIMNHU7EnCa8=; b=BbZZreBfS2RS9VU8gxmLGgbWd4n3snaEE9twQijzEWDogxc5U2jF2tSpFArtdSpZAX anVxEEQQYSeOWqPmE9YIICmrGS1ItRcEWrDuGCKICWR8Bw6N+Eq0Rg4SKAh/T0v8/ykI u8XdzdUwaI7GjcuMCEkPkoFilxRzNfHr6Cz1DHUA/EQyxFLbjIYavfhzLvynQd+5dnIY JKbb/9c73rLJ4TYaT+s+R3FtinJ78puBIwpcP7tmDrpnAVHq7kfVa+iL2iWTaXoyBo5M oSnX9Gc+eqsrPEDJA++kBlqpITjWjoyosdXOt3EOX4OiLY8FdWOoHNlAS5bXEW1/G+yi v8YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=M5DF0Em2; 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 c52-v6si2416108qtc.267.2018.05.10.21.26.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 10 May 2018 21:26:30 -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=M5DF0Em2; 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]:36682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGzdV-0004rb-SQ for patch@linaro.org; Fri, 11 May 2018 00:26:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGzae-0000X0-Uk for qemu-devel@nongnu.org; Fri, 11 May 2018 00:23:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGzad-00085k-KQ for qemu-devel@nongnu.org; Fri, 11 May 2018 00:23:32 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:46426) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGzad-00085U-DX for qemu-devel@nongnu.org; Fri, 11 May 2018 00:23:31 -0400 Received: by mail-pg0-x244.google.com with SMTP id z4-v6so1881375pgu.13 for ; Thu, 10 May 2018 21:23:31 -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=BiBMArvzBSclTtl+JJFYqnT65X4b0tbCIMNHU7EnCa8=; b=M5DF0Em2xu3YYMGb42MM8hiufWUF2WvtEYJ5rs7Y9U6Zu/XyeuA350+wqu/VIzGa6G jpfFil66dHxZFO4P5QhBPho8WiI/nlsIKMUxIPF+TV2KOIrX2VsdlFRsWf+G82cvJm8p zF/VKhUT6W60C95PAir2U4+7ZiTrRHuRh7XK8= 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=BiBMArvzBSclTtl+JJFYqnT65X4b0tbCIMNHU7EnCa8=; b=tLNCC8t1mcgSX2vD+802CNP2nATPhgHXeHTJGr+q+a7ang0jq7dzWh1wkCp/oERfZn CNSOvgBgLIU+W8GkyGmTWLsh6gTrS1g33eRC0Xl2AFBlTrRAdkttB3f0Mm5iktPkjmIn 0LGYJBqNf7eOIxi+M2Jx9Zr3SWOrpxDY8ZkCNoK/hq5vxBIsCu8x/ReBB2gI+uZt/AA2 EhASZI/2fh/a9Lob/gBjEZ2D2tEIcw7YAfrMstfLInt/9e8EQLHXzEqxOAsdg5Li2P5n 4lkbKud4ngS0bvDOw3oqFopgvchvTjzoHLj6T1EPFSrJYnV1FgTILBReOsjvp37JYGVs IbCw== X-Gm-Message-State: ALKqPwe8nz55lO9RUqbSadqd6yVRwNmxbmDgthTNbbQr3kSzKjiMzZ+0 dwhhM4bjj2xS5K2Pq81ONMRwdWl4vsI= X-Received: by 2002:a65:4acd:: with SMTP id c13-v6mr3274487pgu.32.1526012610059; Thu, 10 May 2018 21:23:30 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id r76-v6sm4509462pfl.1.2018.05.10.21.23.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 May 2018 21:23:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 10 May 2018 21:23:13 -0700 Message-Id: <20180511042324.5070-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511042324.5070-1-richard.henderson@linaro.org> References: <20180511042324.5070-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:c05::244 Subject: [Qemu-devel] [PULL 02/13] target/openrisc: Start conversion to decodetree.py 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: peter.maydell@linaro.org, Stafford Horne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Begin with the 0x08 major opcode, the system instructions. Acked-by: Stafford Horne Signed-off-by: Richard Henderson --- target/openrisc/translate.c | 79 +++++++++++++++++------------------ target/openrisc/Makefile.objs | 9 ++++ target/openrisc/insns.decode | 28 +++++++++++++ 3 files changed, 76 insertions(+), 40 deletions(-) create mode 100644 target/openrisc/insns.decode -- 2.17.0 diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 6876317971..40b21a5db1 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -31,6 +31,7 @@ #include "exec/helper-proto.h" #include "exec/helper-gen.h" +#include "exec/gen-icount.h" #include "trace-tcg.h" #include "exec/log.h" @@ -53,6 +54,9 @@ typedef struct DisasContext { bool singlestep_enabled; } DisasContext; +/* Include the auto-generated decoder. */ +#include "decode.inc.c" + static TCGv cpu_sr; static TCGv cpu_R[32]; static TCGv cpu_R0; @@ -67,7 +71,6 @@ static TCGv cpu_lock_value; static TCGv_i32 fpcsr; static TCGv_i64 cpu_mac; /* MACHI:MACLO */ static TCGv_i32 cpu_dflag; -#include "exec/gen-icount.h" void openrisc_translate_init(void) { @@ -1243,45 +1246,40 @@ static void dec_compi(DisasContext *dc, uint32_t insn) } } -static void dec_sys(DisasContext *dc, uint32_t insn) +static bool trans_l_sys(DisasContext *dc, arg_l_sys *a, uint32_t insn) { - uint32_t op0; - uint32_t K16; + LOG_DIS("l.sys %d\n", a->k); + tcg_gen_movi_tl(cpu_pc, dc->pc); + gen_exception(dc, EXCP_SYSCALL); + dc->is_jmp = DISAS_UPDATE; + return true; +} - op0 = extract32(insn, 16, 10); - K16 = extract32(insn, 0, 16); +static bool trans_l_trap(DisasContext *dc, arg_l_trap *a, uint32_t insn) +{ + LOG_DIS("l.trap %d\n", a->k); + tcg_gen_movi_tl(cpu_pc, dc->pc); + gen_exception(dc, EXCP_TRAP); + return true; +} - switch (op0) { - case 0x000: /* l.sys */ - LOG_DIS("l.sys %d\n", K16); - tcg_gen_movi_tl(cpu_pc, dc->pc); - gen_exception(dc, EXCP_SYSCALL); - dc->is_jmp = DISAS_UPDATE; - break; +static bool trans_l_msync(DisasContext *dc, arg_l_msync *a, uint32_t insn) +{ + LOG_DIS("l.msync\n"); + tcg_gen_mb(TCG_MO_ALL); + return true; +} - case 0x100: /* l.trap */ - LOG_DIS("l.trap %d\n", K16); - tcg_gen_movi_tl(cpu_pc, dc->pc); - gen_exception(dc, EXCP_TRAP); - break; +static bool trans_l_psync(DisasContext *dc, arg_l_psync *a, uint32_t insn) +{ + LOG_DIS("l.psync\n"); + return true; +} - case 0x300: /* l.csync */ - LOG_DIS("l.csync\n"); - break; - - case 0x200: /* l.msync */ - LOG_DIS("l.msync\n"); - tcg_gen_mb(TCG_MO_ALL); - break; - - case 0x270: /* l.psync */ - LOG_DIS("l.psync\n"); - break; - - default: - gen_illegal_exception(dc); - break; - } +static bool trans_l_csync(DisasContext *dc, arg_l_csync *a, uint32_t insn) +{ + LOG_DIS("l.csync\n"); + return true; } static void dec_float(DisasContext *dc, uint32_t insn) @@ -1509,17 +1507,18 @@ static void disas_openrisc_insn(DisasContext *dc, OpenRISCCPU *cpu) uint32_t op0; uint32_t insn; insn = cpu_ldl_code(&cpu->env, dc->pc); - op0 = extract32(insn, 26, 6); + /* Transition to the auto-generated decoder. */ + if (decode(dc, insn)) { + return; + } + + op0 = extract32(insn, 26, 6); switch (op0) { case 0x06: dec_M(dc, insn); break; - case 0x08: - dec_sys(dc, insn); - break; - case 0x2e: dec_logic(dc, insn); break; diff --git a/target/openrisc/Makefile.objs b/target/openrisc/Makefile.objs index 918b1c6e9c..1b98a911ea 100644 --- a/target/openrisc/Makefile.objs +++ b/target/openrisc/Makefile.objs @@ -3,3 +3,12 @@ obj-y += cpu.o exception.o interrupt.o mmu.o translate.o obj-y += exception_helper.o fpu_helper.o \ interrupt_helper.o mmu_helper.o sys_helper.o obj-y += gdbstub.o + +DECODETREE = $(SRC_PATH)/scripts/decodetree.py + +target/openrisc/decode.inc.c: \ + $(SRC_PATH)/target/openrisc/insns.decode $(DECODETREE) + $(call quiet-command,\ + $(PYTHON) $(DECODETREE) -o $@ $<, "GEN", $(TARGET_DIR)$@) + +target/openrisc/translate.o: target/openrisc/decode.inc.c diff --git a/target/openrisc/insns.decode b/target/openrisc/insns.decode new file mode 100644 index 0000000000..47d31afc5b --- /dev/null +++ b/target/openrisc/insns.decode @@ -0,0 +1,28 @@ +# +# OpenRISC instruction decode definitions. +# +# Copyright (c) 2018 Richard Henderson +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see . +# + +#### +# System Instructions +#### + +l_sys 001000 0000000000 k:16 +l_trap 001000 0100000000 k:16 +l_msync 001000 1000000000 00000000 00000000 +l_psync 001000 1010000000 00000000 00000000 +l_csync 001000 1100000000 00000000 00000000