From patchwork Tue Feb 27 23:26:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 129872 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp376190lja; Tue, 27 Feb 2018 15:26:37 -0800 (PST) X-Google-Smtp-Source: AG47ELs33gU6CmkkTTE6znMMM78a8vpyYZsW0/V9uatxqZoxqEnSCzqpRCi3ItlGam30O/F7oIAZ X-Received: by 2002:a25:4946:: with SMTP id w67-v6mr11112396yba.178.1519773997212; Tue, 27 Feb 2018 15:26:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519773997; cv=none; d=google.com; s=arc-20160816; b=mIhTP0Qcw/kK47y3XxFMgI0SSOWYVQ75hO9bNzE+nUsehpZrX8nCMNJT0SoiDxWLYf xsgE8IypMLabr8dG0ri5K3gNIqnrs+vcRgPvxUd6DsuRTV4Ush47ryAdjyrM7lxbFhL0 7A1uSE7F7R5xod3GPqUSSkTTStvRGNdLCxOWLS/FefzVONxzEKKUf1OTibJm2pER+HHI XEW7hvFmhWlNEfYsNRD0lrgQMZajWts9n4Aw2f6Fn8ihNUcUsy+wcnpIY7qnkFA3haS9 WWND6UcKN8619IyRVEVASqE9moUgafBZzcRXFrlji1tZepwZ3nt9YR/tpB68MpUFs65u DKjQ== 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:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=t4S8hXXojsgeimGUR2ZbYe3j+CW2I+6abRgSF3z2TVg=; b=Ptzi45zwE7b4T1mPWhdjT2Tx73a9nJLHb224g7dm06XdoCenOnT00xirJMCfbQ/+81 pFD3RY5pFZtIyuHXNl75MJSuxm+DPaOkf3Zvk81favyrvVw1dwIvRmYxdYcV9eHpkq8F 8gtwZwg4zNB7DfD8VBM/4K7goKE5yKPm5j6Y2Bql8PS0YcrE82IEt+tD1gyrviGLyIDo 7lcRj/VKGU5OocdmD+bUcqX7pmuCp6iOs2iq2mFOZTOdHKp80i1uLZrdAnUyr/nclIIs XFYAsCoQQkSIQVKleLucSwIAOYu+t6A+pSG7uN29xLarDqbxnY3FGJPnbAbLvehRSCg3 LhuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ilndoJuM; 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 u3-v6si50746yba.343.2018.02.27.15.26.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 15:26:37 -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=ilndoJuM; 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]:40664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqodo-0006Rt-Lw for patch@linaro.org; Tue, 27 Feb 2018 18:26:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqodd-0006Rf-I8 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 18:26:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqoda-0003P9-ED for qemu-devel@nongnu.org; Tue, 27 Feb 2018 18:26:25 -0500 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:43408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqoda-0003Ne-66 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 18:26:22 -0500 Received: by mail-pl0-x241.google.com with SMTP id f23-v6so341773plr.10 for ; Tue, 27 Feb 2018 15:26: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; bh=t4S8hXXojsgeimGUR2ZbYe3j+CW2I+6abRgSF3z2TVg=; b=ilndoJuMwCV8WJpgmucUFd5uZ+B3x591Zi1dQiEAZJJEp863x+jl0OrUo+PzaTFRm2 tzZWBtd3wGLMXE8SrR0OSV/GsgUQUynr8V6f0vLS5bZWvFTrn2mAAJc85pKmRW27pKx6 cNVBpZm4tH1WC7iTeEuhMSXz+Xp5V71ov1Rxk= 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; bh=t4S8hXXojsgeimGUR2ZbYe3j+CW2I+6abRgSF3z2TVg=; b=F6Z+JQH9NJVlE9YDWlyONPIAcz52qNbQoSU1+to2N83yJWMurMGZkFqr1DRZ5mOFVi r+u+32lgN2ctvAHP3P3R1wge4xcKG4zzZWSYNALCd3dG610u5WRd6O75aJPr8Qubf1Se CmTzL5ywxZSj+POODhsV34yOdekgXva1UU4vDGsp2LMNHtT/WIiQDsFaf4Pux5AX6B8j v8Y1o3p+WUhFw/v8T1rCQtUibkZIKrzxHrV22uFmk6mgV6FmZpHvf++Nf3Gvs05qslZp x4V2xV/77Cs7/p/RZiIY2zP4BqXeIGybHWhziTYJfRRVZfD/gELbg1E+NjkmydOKL5Ut p6XA== X-Gm-Message-State: APf1xPCdq4nmSrVUlx27qUOYh3M7B20RxpaUq3hdS5/xUsysq14xxoX/ EAfvF6X5xq7CQicGDzh/XnxhjJBL6XM= X-Received: by 2002:a17:902:d891:: with SMTP id b17-v6mr15476152plz.241.1519773980650; Tue, 27 Feb 2018 15:26:20 -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 v8sm321061pff.38.2018.02.27.15.26.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Feb 2018 15:26:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Feb 2018 15:26:18 -0800 Message-Id: <20180227232618.2908-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 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: peter.maydell@linaro.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 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