From patchwork Mon May 18 16:40:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186899 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3058711ilb; Mon, 18 May 2020 09:48:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqBZqa8z5aEoEVeBsiEY3grMSluwjo+InF9pUDT+Ym4C49LH9OVZXqSvjt8/R/3+vHYTEq X-Received: by 2002:a05:620a:759:: with SMTP id i25mr12538502qki.118.1589820515603; Mon, 18 May 2020 09:48:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589820515; cv=none; d=google.com; s=arc-20160816; b=xHYym1CejJ2yvzxPKQI9M+8/Gax81h9tY2xIOqTPYob93rvhb5VuSKDWakK9a0tfY4 +SyYROfMmVSgnoLo8Iyj7rTbcCRvEkbWe5OTdVkGW8WPIbTCxEF7EhaH2NDm4WNKZRZM jJGORW1kCkiFXnae4EgJoFaotONbixtscs2r0KXJgxImmvHTnIQpylHqPG949rYZ4R7c rmUTtRigpLqifsV9RfEPgtbZKogIAeWyOcBBu6cLS9D/Ue61wdfem6t1V8gs0Q3BJo9g FVEyX7fujtkCy1Ot2dAfaDRXM/tIpbRoNASuT4upKcq9cz4mOsZJZJx1Lga+DtPttFor 34ow== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=z/u2gGUYvwpC8sb/rqLeX8kHv104pan4Dnbe4hQpH4A=; b=h2w2NUT99sKKogeq093BA6az7K4EdIL6Op9zs45RMEsjiIeB0Dzt8IOdyIXh0uglZu 0o2Az7FNE9hyu+uqIwfI63NE60n+xKfK8/XgUN0H3rpJJ6s54mqjr7nuvn8nB8QmtXiz A3UHjmwc3vXHVUaQZOiD/FChYcn1Fg/UM6eNsLp5tJ75v+TflHplYU170cT+pY2lqKIJ dID/bP5VURL9ooiyCnhm48Ls/h2815G/fiP/tJrOlOW0UcwEj5PB8ADRSF33oX+iOIY/ Vpb3igQHkZYITkUe8P54Ldha95AVdqyAx6SD6qdswojcm9aFtxoVtZtMTcBUS3uiHx3I UlFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I14a1Wbn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f17si5837966qto.282.2020.05.18.09.48.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 09:48:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I14a1Wbn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaiwN-0004cq-3C for patch@linaro.org; Mon, 18 May 2020 12:48:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaip7-00027l-97 for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:05 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:42784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaip6-0005rH-A8 for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:04 -0400 Received: by mail-pl1-x642.google.com with SMTP id k19so4440130pll.9 for ; Mon, 18 May 2020 09:41:03 -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 :mime-version:content-transfer-encoding; bh=z/u2gGUYvwpC8sb/rqLeX8kHv104pan4Dnbe4hQpH4A=; b=I14a1WbnGlHu8xISviWfGDFF/LvZVLn6s7gKLC63sw8bpfRtHKks98Le1odBnra35W 7iqhjfY3cOk3Ew61Nu7s2hAOcpO11LEdQDOcqFpChJf3E4PGWEKtDZ6c8vr3Pg7kjkMk Hdzpstf6qYItl5QAlLnakEwcqtLW9KvJHjLVq8idfyy3jycUl/S1Jqyn0zZlJjTyzDZI nBr6ByKIWB17i+bKT0tJtP6xQpR9T/dOyD75lLDB+DoeF1+zHt5QyN8/Ty1GAWWZAFT8 zldko/x1v8bPXu2B/N/c/mGF5+4u0g10Lqc53RCNtlMJ2N+Ws/eXauzlaDZhs3SdRG1x TQvQ== 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:mime-version:content-transfer-encoding; bh=z/u2gGUYvwpC8sb/rqLeX8kHv104pan4Dnbe4hQpH4A=; b=XSrglVFTuH0msLayoOCXSRbRBkmSlUTy/3CF+IqpQNTdcm/BjEDlELiz/RDD9u3PS8 g69MnQPqTDDGHdGjyDEYa6q5R1Jkl3GOITQtqLKLBuKyMdLgI5JOby+SXBosIidhTsC5 QeYgC4KsjCuD5aZcWRGlclMbChNZZxQn73FhTsyT026WTBOYQAAnQPGCNoNT/SDj4xPK jYZ+lczYv7TNuOQ3kNxwDzpl0kfJD+hNy8Mu2lNfLOEaXl23ppSCi0ivwcLzRj8mTFtq 5L3S7PrUgiwfEWNiwmJQ4Xek7BEdGOzkCs1hjU7HbUYIrjLK+am1qVbU/ZMv0NgyHFnC qxJg== X-Gm-Message-State: AOAM532oPCqjdO09YEvrZyYiMdLhliUMih3e3V/VKSLzmumgolTAdL/T M0JgWF/6+kIZJptUF7RdCItgMkBiVWo= X-Received: by 2002:a17:902:502:: with SMTP id 2mr12036921plf.134.1589820062371; Mon, 18 May 2020 09:41:02 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id x132sm5790610pfd.214.2020.05.18.09.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 09:41:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 5/8] decodetree: Allow group covering the entire insn space Date: Mon, 18 May 2020 09:40:49 -0700 Message-Id: <20200518164052.18689-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200518164052.18689-1-richard.henderson@linaro.org> References: <20200518164052.18689-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x642.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" This is an edge case for sure, but the logic that disallowed this case was faulty. Further, a few fixes scattered about can allow this to work. Signed-off-by: Richard Henderson --- ...est1.decode => succ_pattern_group_nest2.decode} | 2 +- scripts/decodetree.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) rename tests/decode/{err_pattern_group_nest1.decode => succ_pattern_group_nest2.decode} (85%) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/tests/decode/err_pattern_group_nest1.decode b/tests/decode/succ_pattern_group_nest2.decode similarity index 85% rename from tests/decode/err_pattern_group_nest1.decode rename to tests/decode/succ_pattern_group_nest2.decode index 92e971c3c5..8d5ab4b2d3 100644 --- a/tests/decode/err_pattern_group_nest1.decode +++ b/tests/decode/succ_pattern_group_nest2.decode @@ -6,7 +6,7 @@ %sub3 16:8 %sub4 24:8 -# Groups with no overlap are supposed to fail +# Group with complete overlap of the two patterns { top 00000000 00000000 00000000 00000000 sub4 ........ ........ ........ ........ %sub1 %sub2 %sub3 %sub4 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index ea313bcdea..3307c74c30 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -124,6 +124,7 @@ def is_pow2(x): def ctz(x): """Return the number of times 2 factors into X.""" + assert x != 0 r = 0 while ((x >> r) & 1) == 0: r += 1 @@ -131,6 +132,8 @@ def ctz(x): def is_contiguous(bits): + if bits == 0: + return -1 shift = ctz(bits) if is_pow2((bits >> shift) + 1): return shift @@ -793,9 +796,8 @@ def build_incmulti_pattern(lineno, pats): error(lineno, 'width mismatch in patterns within braces') repeat = True - while repeat: - if fixedmask == 0: - error(lineno, 'no overlap in patterns within braces') + fixedbits = 0 + while repeat and fixedmask != 0: fixedbits = None for p in pats: thisbits = p.fixedbits & fixedmask @@ -978,6 +980,12 @@ def build_tree(pats, outerbits, outermask): innermask &= i.fixedmask if innermask == 0: + # Edge condition: One pattern covers the entire insnmask + if len(pats) == 1: + t = Tree(outermask, innermask) + t.subs.append((0, pats[0])) + return t + text = 'overlapping patterns:' for p in pats: text += '\n' + p.file + ':' + str(p.lineno) + ': ' + str(p)