From patchwork Wed Feb 28 16:48:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 130018 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp1756397edc; Wed, 28 Feb 2018 08:53:08 -0800 (PST) X-Google-Smtp-Source: AG47ELui6Zy5Y6CgKXp6TScmkQuZ8eRsYBD6iUj4m73+x1oGYa1TBTYKV3EKuZF1wgqQWR2m7hzc X-Received: by 10.129.201.11 with SMTP id o11mr12632763ywi.2.1519836788321; Wed, 28 Feb 2018 08:53:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519836788; cv=none; d=google.com; s=arc-20160816; b=avFCZyEh2CptGVpN2/EHR980vZaRnGTHjcH0HYA7Mu0NvzCKKY8bIh5juVD6JVkSVW 5Z1dvBERwhMOcBzR4LKJEbaGp5tAxA2vblTisMjdsVH+tj28SO3vbhjbmYbB7ExpAf4o I60nw2OEXJqydQ0pSI2e2yyemQ5z3Ks2Fo3R3f2dwuG0l/SDfbAvF5Ta8gGR/ajNr77D Pif+ZFPGUnUD90v8aq+17GpXptQGOWuGgOBcgcAUfSiT1tW6XLTI1Hl4K05c7hjmV6wt 2zmlDGU0lTebI54J1mmAhKm/0Ij/8MixPhZJf0tOjYTkOo4EeLumuvwc+S+7x7Pd+RZM KfrQ== 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=t4S8hXXojsgeimGUR2ZbYe3j+CW2I+6abRgSF3z2TVg=; b=AHTom9XKKQEljX7zuZOd2VfO3u0M3eOQovHURqPm50MWef+bV6lM/R/MNYVOT8GeU5 rLCMMEZD8YmO7YUQk3kKJCnEYXwNRUjX2c+FirzgTYzAZOyNaNxKMHazkCh1tD26GvHf JCwMiyeNYzpG+x4TBYskYP0p36PeqcvsM0xM1BiNXpb6ZkozwvNyO7MojF3WvkIRuPvK AtE2GbSl2CoURxcEfKeSkFFcQYLmGKmkMI2X7h+GtL+RMACdswv8s9DgzRd4DonT0gCP aYgxqSN3zX+98+8OQwODfJqdfdD9IXXqJzAV5UKQYoUXnpAVieBKLQlt/m+dl9ZaSSfr vuwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jD4NC+J+; 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 64-v6si326646ybh.321.2018.02.28.08.53.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 28 Feb 2018 08:53:08 -0800 (PST) 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=jD4NC+J+; 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]:45526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er4yZ-00045S-Qf for patch@linaro.org; Wed, 28 Feb 2018 11:53:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er4u1-0000g3-Fr for qemu-devel@nongnu.org; Wed, 28 Feb 2018 11:48:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er4tz-00073p-1M for qemu-devel@nongnu.org; Wed, 28 Feb 2018 11:48:25 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:39019) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1er4ty-00072W-SM for qemu-devel@nongnu.org; Wed, 28 Feb 2018 11:48:22 -0500 Received: by mail-pg0-x244.google.com with SMTP id w16so253009pgv.6 for ; Wed, 28 Feb 2018 08:48:22 -0800 (PST) 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=t4S8hXXojsgeimGUR2ZbYe3j+CW2I+6abRgSF3z2TVg=; b=jD4NC+J+eOpWZm7LMIHD/YoYAcDLXmixPayy/90eO/Xi+q1VxqIsrUTFK3xvAV3B/6 13jxlCVFiUa1Cy9lkjFVhtOLSwc+JJ2jXpo6Mg/TV2jXiAhGdwCF24JjDyqxZrnmxJZl UMOva6AjzRnPBm+9UTM1Q+ZqoYFNQiQe41oRI= 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=t4S8hXXojsgeimGUR2ZbYe3j+CW2I+6abRgSF3z2TVg=; b=NyO1RABxqzmeXXdwFwGCU/NM+ejfzWzUlz6DUeHfG0IKrxi9A2uz9MKc78rRKQ2yu1 H+jgdo1SSx5PKg0wNvZLj7pKHkKHYp2X8eyn8vE6gpNni1M05kFbvpedYrtlptBRBEnk OchStr+rvB8O2OPmZCePUjPxvNirBRV2XpN7DHjNH0xWU8UQ6UWk/K69bw/knbHGgu9R oDMFdvi5qcd8pvlWHCaPzcYiwOXdxbROIR5hhe5RqLi4wn1VrIe6mL9T81lUkEVc0Yjv 6XB5exD/2dhcJeRFx7YmBJyjLcsarzcgKYZ59BvcYE+XDTA401s6FE1RPtDTvfM1jPS1 66Bg== X-Gm-Message-State: APf1xPCC9IHDssrB/Uuw5n74Rm7Z53abewjTfmF5Cv/wI6IejnWeyA6K Xf5PXzXMRIDVNdSx0hZR7M7ZemTtQxM= X-Received: by 10.99.37.7 with SMTP id l7mr14802382pgl.311.1519836501520; Wed, 28 Feb 2018 08:48:21 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-169-147.tukw.qwest.net. [97.113.169.147]) by smtp.gmail.com with ESMTPSA id p9sm4123698pgs.89.2018.02.28.08.48.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Feb 2018 08:48:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 08:48:14 -0800 Message-Id: <20180228164816.24110-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180228164816.24110-1-richard.henderson@linaro.org> References: <20180228164816.24110-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] [PATCH] decodetree: Propagate return value from translate subroutines 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: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Allow the translate subroutines to return false for invalid insns. At present we can of course invoke an invalid insn exception from within the translate subroutine, but in the short term this consolidates code. In the long term it would allow the decodetree language to support overlapping patterns for ISA extensions. Signed-off-by: Richard Henderson --- Since this makes an ABI change to the translate functions called by the decode function, let's make it now before there are any in-tree users. My SVE branch over-decodes in quite a lot of cases -- e.g. things like the 2-bit size field must be 1-3 for fp operands, and so size==0 is unallocated. Returning false for these cases allows the actual call to unallocated_encoding to be done in one place instead of hundreds. Longer term, I'm thinking of how to handle decode of overlapping ISA extensions. One could allow (specific) overlapping patterns and prioritize them in some way (e.g. first in file is first matched). My thought is that trans_insn_a would check a cpu feature bit and return false if not enabled. Then trans_insn_b would be given its chance to handle the insn. r~ --- scripts/decodetree.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.14.3 Reviewed-by: Peter Maydell diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 6a33f8f8dd..41301c84aa 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -461,7 +461,7 @@ class Pattern(General): global translate_prefix output('typedef ', self.base.base.struct_name(), ' arg_', self.name, ';\n') - output(translate_scope, 'void ', translate_prefix, '_', self.name, + output(translate_scope, 'bool ', translate_prefix, '_', self.name, '(DisasContext *ctx, arg_', self.name, ' *a, ', insntype, ' insn);\n') @@ -474,9 +474,8 @@ class Pattern(General): output(ind, self.base.extract_name(), '(&u.f_', arg, ', insn);\n') for n, f in self.fields.items(): output(ind, 'u.f_', arg, '.', n, ' = ', f.str_extract(), ';\n') - output(ind, translate_prefix, '_', self.name, + output(ind, 'return ', translate_prefix, '_', self.name, '(ctx, &u.f_', arg, ', insn);\n') - output(ind, 'return true;\n') # end Pattern