From patchwork Mon May 18 16:40:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186897 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3055774ilb; Mon, 18 May 2020 09:44:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy/g56IzcB7z02X2wR4fQ6+X8fnbLW+ukOe67twZa02D/zCLcc147HHsRv11i+fb7rWb2f X-Received: by 2002:ac8:4e16:: with SMTP id c22mr7654816qtw.281.1589820278459; Mon, 18 May 2020 09:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589820278; cv=none; d=google.com; s=arc-20160816; b=h2ZM6uEO5hz8ssbtmq5BzsyrIA9WC3wgfKn114IPEmVeJMdyQ9Rxoj1I15lUC8P4M6 w9X7wFDCLnk1eG2SeJqkEG17tWFnIN5xgfpCI/y6vD79BQp9u8EiGG4FhR57abn6WusR otge/B7GiDwdKkhSQXXVKkww7NrDnFNX68YSIn9Xc8nLlBLiAgydOr5ohHUz5MnuSaW4 bOPTeg78ASZlcLEdWfUTXSNxEKJei9RpAV7Wzjd82Mx1fZzGZ3MKPv9qdjgWI9gXJh7e Ys/Eur+ZRHBHiahdoOZWAoVmr5HTpn/3opDif9272M9gOwOQxt61ugGcQufbk3+fGdg/ Pvww== 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=uFTRRQZQW7zKIC58JAMoD76cKh/Xgd23HtxsN8e+2Qk=; b=Ag4lFAFIgNiawDhbDmcVHSjMYYji0SDZrarchQuklaYNeNuMx+y82WYduwVBWVwwtz zeJ4cbmjYN0eJ8J7uyvNA1NqqOIXlCSHr6xbS0e7WQrsfQcuO6Qf0+Q+CAK3aX9RHv7M GjFSwZLsf/dkpVTdmhIxS296TsrBzg46i7BF5WzCxnKyJ7ztv0F0FdmxlguZIa5abhr4 KSuU0hn57d9/d/0dMW2cRInB9PDUIv2gxAiYSDuCX1IClRiTe8CN9L61PkWaFEB6BXGr bWYApGGyoFoCxRmVxPB05TRqYMtYOSpT9AB3GCtkV+fp6DE7xVlPWO3gxrXtm9LecCZx IH/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BN6CrBuU; 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 h22si5874553qtn.53.2020.05.18.09.44.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 09:44:38 -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=BN6CrBuU; 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]:58182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaisY-0007cP-1d for patch@linaro.org; Mon, 18 May 2020 12:44:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaip0-0001wB-Lh for qemu-devel@nongnu.org; Mon, 18 May 2020 12:40:58 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:36861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaioz-0005pH-Kg for qemu-devel@nongnu.org; Mon, 18 May 2020 12:40:58 -0400 Received: by mail-pl1-x630.google.com with SMTP id f15so4451133plr.3 for ; Mon, 18 May 2020 09:40:57 -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=uFTRRQZQW7zKIC58JAMoD76cKh/Xgd23HtxsN8e+2Qk=; b=BN6CrBuU1DRAEwPUwW5flubL4z1nKZQ9L5ZB+miR0mfZ9zyNi3WpsQhKOhc7tl6jJ+ qZlIKK1Vwe1JLQJCtkvVCxAbqCMCm1VdVcV7vQemfaokSSJQEG60EUxIMJhxlmysVP/x E1KEaYXfYsFm9jQExDtslSPn6R12iI6Rm9iJk3CF2AUplAiqcheD8uuFROnOFvHrdeYt BsGlrBQ2rM4lwp0ayNXwmj52XvB3iqxj4eBkANgrBXWdI8n7ZvIdeLEyu2+++OtvzVkA ZIutUpJFGIpotVWYnitksSKQjZMhfOp+/OvHaC4hOSOLtuEBfVh4lZnU6DVlNbEFEIeC ETnw== 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=uFTRRQZQW7zKIC58JAMoD76cKh/Xgd23HtxsN8e+2Qk=; b=VXtrc8Fmqi0cZ1CP5Ew1EULcCBMqMetbrP6AHPDetUfQ6mTBOKdw4jCASmMYDfNVUb 5KwRL4AN8yhuY3h3LQspk6PimdHPcQn2OgUjhRC0D76QCuVXPz4vXlR3KkXE3ycMUql0 Yoez5gxVQKTEuAD74YVlmdAm2/QlR3Hl4/YBzA4lf6kAvo7syE2JM/Bk8T+nXFp1ED7e wkN2H2KnueAM+TsLUq1YBQq1ABQIpT8BmfJyIb+FfG/CQfqbM9lr1Juu1L4hOtr0hiNA r8cBeP1JzOQl0D6jscAzK51kdxn3o4u39YTUMgWpZoCrQ0MpX8phWV1fzB5/un9unwA1 Jizg== X-Gm-Message-State: AOAM532OMBxHXoVYTTKrNB5jSjWQmTKgeDi9T3hxYZf7ZtVzDfmvl/Vd rDsNH0PcIU4hdpB0ngTAmu/opCrbqhc= X-Received: by 2002:a17:90a:8c01:: with SMTP id a1mr255381pjo.127.1589820055721; Mon, 18 May 2020 09:40:55 -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.40.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 09:40:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/8] decodetree: Remove python 3.4 check Date: Mon, 18 May 2020 09:40:45 -0700 Message-Id: <20200518164052.18689-2-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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" We are now guaranteed python 3.5 or later. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 46ab917807..f9d204aa36 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -75,13 +75,6 @@ def output(*args): output_fd.write(a) -if sys.version_info >= (3, 4): - re_fullmatch = re.fullmatch -else: - def re_fullmatch(pat, str): - return re.match('^' + pat + '$', str) - - def output_autogen(): output('/* This file is autogenerated by scripts/decodetree.py. */\n\n') @@ -428,18 +421,18 @@ def parse_field(lineno, name, toks): width = 0 func = None for t in toks: - if re_fullmatch('!function=' + re_ident, t): + if re.fullmatch('!function=' + re_ident, t): if func: error(lineno, 'duplicate function') func = t.split('=') func = func[1] continue - if re_fullmatch('[0-9]+:s[0-9]+', t): + if re.fullmatch('[0-9]+:s[0-9]+', t): # Signed field extract subtoks = t.split(':s') sign = True - elif re_fullmatch('[0-9]+:[0-9]+', t): + elif re.fullmatch('[0-9]+:[0-9]+', t): # Unsigned field extract subtoks = t.split(':') sign = False @@ -488,11 +481,11 @@ def parse_arguments(lineno, name, toks): flds = [] extern = False for t in toks: - if re_fullmatch('!extern', t): + if re.fullmatch('!extern', t): extern = True anyextern = True continue - if not re_fullmatch(re_ident, t): + if not re.fullmatch(re_ident, t): error(lineno, 'invalid argument set token "{0}"'.format(t)) if t in flds: error(lineno, 'duplicate argument "{0}"'.format(t)) @@ -621,13 +614,13 @@ def parse_generic(lineno, is_format, name, toks): continue # 'Foo=%Bar' imports a field with a different name. - if re_fullmatch(re_ident + '=%' + re_ident, t): + if re.fullmatch(re_ident + '=%' + re_ident, t): (fname, iname) = t.split('=%') flds = add_field_byname(lineno, flds, fname, iname) continue # 'Foo=number' sets an argument field to a constant value - if re_fullmatch(re_ident + '=[+-]?[0-9]+', t): + if re.fullmatch(re_ident + '=[+-]?[0-9]+', t): (fname, value) = t.split('=') value = int(value) flds = add_field(lineno, flds, fname, ConstField(value)) @@ -635,7 +628,7 @@ def parse_generic(lineno, is_format, name, toks): # Pattern of 0s, 1s, dots and dashes indicate required zeros, # required ones, or dont-cares. - if re_fullmatch('[01.-]+', t): + if re.fullmatch('[01.-]+', t): shift = len(t) fms = t.replace('0', '1') fms = fms.replace('.', '0') @@ -652,7 +645,7 @@ def parse_generic(lineno, is_format, name, toks): fixedmask = (fixedmask << shift) | fms undefmask = (undefmask << shift) | ubm # Otherwise, fieldname:fieldwidth - elif re_fullmatch(re_ident + ':s?[0-9]+', t): + elif re.fullmatch(re_ident + ':s?[0-9]+', t): (fname, flen) = t.split(':') sign = False if flen[0] == 's': From patchwork Mon May 18 16:40:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186898 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3057486ilb; Mon, 18 May 2020 09:46:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7EbzBFQ2SULTBJJVWJbvjeDdOJHCZPU0LZOSIR1Nta9AgW4GtZtTw62VI35TtZ/xnVTEv X-Received: by 2002:a05:620a:14ac:: with SMTP id x12mr16073022qkj.262.1589820411002; Mon, 18 May 2020 09:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589820410; cv=none; d=google.com; s=arc-20160816; b=egBNY2OTzJEEkS3LHSptYM8v7kZOLwb6AY6OOKZTIGUh/DDUYFIzw+V3mD8AxpmX1u y6ayxQqG3BnHySCRwenqXlThl4RuIt5m+n3gQ9h1COYuUGeG/F1Ph7IHaKxikOZSzl/9 sXhqtCk65g55iV/XLPJv8yC4SIhbimH7Ws4a5A5CBllccSpjUWFpr/mDoSp1ChP7wR7z NFdNkdGyxY48vwB+btsvNtHttbX3AH3ROY0WSqqMaaj99cc8YWgMvZIXT6UxnlsR68C1 Ae+WkbkHYimFmarbvZzH/9gzZ2M/9vDu16RobKcCJig47/0mtr3fsJAH+u5x383ZyD9q beag== 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=23ujhSNHwAa6m2PV/44zvOLpUgf1M+P1yqoPvCdPMfY=; b=AJm7HaSLxlwZW72NEnpKlRiFijmla4PX5McQ+bCVqfAt7cJBwAknGDuzHx0xxetzPM ZBI/a0bhv+PJYKqmCCcXM8M8fX09bHiWVvU9QdG7udHeTLjwAXxyY64FnYy9m7Dwcyd2 VJ0VEkvwKf5gLeVNAMOb6c7WJCw5nIwAuvnUOEr9S0U/eFC80ZWP3/9wrApXcFVXBT4f h1pOLmyX17fICkqsQFujdTRHXFS9tXBqTRfdNIVG0qKFmrCTmxCiazOBjh1xgexNUvI+ //kBJ45m924/SA6L1BoijzjCSAeZhBIa28B3O0SgomEVZnEpiQHWF4GcVzEFW4k5yYXH +Khg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e9Cv00Aa; 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 v127si5802103qka.57.2020.05.18.09.46.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 09:46:50 -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=e9Cv00Aa; 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]:36384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaiuf-0002A9-5p for patch@linaro.org; Mon, 18 May 2020 12:46:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaip2-0001yt-Ak for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:00 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:50989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaip1-0005pj-73 for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:00 -0400 Received: by mail-pj1-x102e.google.com with SMTP id nu7so84693pjb.0 for ; Mon, 18 May 2020 09:40:58 -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=23ujhSNHwAa6m2PV/44zvOLpUgf1M+P1yqoPvCdPMfY=; b=e9Cv00AaKl1LCY9WqohCEiRKz1OrlndQHn+JPCOweENat+0toMfJxMg5CumlBmXvxd hUC5RLplZiB4EFPPexZIsv4hDojSJ4qlB9ftV6GfWwFoDRiUVhmvl+qdtm6AYXLYJjq7 KpVTeE1YzZ8qjM0/Bc2c65CcZivBPJjcjzD+WDBSdkpxuaAfgVo23oFfeGDixC/IE18i DZo9w+zKUrVx4LpWtv33/Cx2WwNTIEutYFiTV6lSJPYPTtjgDMa4K8BDXNpVIrZP6nOf kOHE/EEXo/shb/yBgMVWrnT3aDSbu89DDsRmjzF3oylNXcUs7Peb9SWesRKARk+YVr86 wIbQ== 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=23ujhSNHwAa6m2PV/44zvOLpUgf1M+P1yqoPvCdPMfY=; b=RnuL0hFz+PvkwrtkgHpSWlcL+bScrQeDTDylQr+ZlcfLPHO/NPRNRp7oBU6fh3D+eZ InO34UgW3mFZyCWjVMxDlhNdFD9Eve42M9pD5WMHm8PqplVkNDWaoD5BmR61V6J9A69e vbFs3otgcoxmkzAl1iCpaGbWH3ekXMGTeGdNY0aun1Gi6LP7nboOOTs6qdawOlvT6JEH NzNTQVECu7n+QfgpdyyvuxG0oeJCILRXPKA5+ZPcX1OnDSeKZ/G2z3pVlRBptc3UkSUV 0rx2O06GzwosMGi98M7fwpYc9bLSZYQXYhKZc/AmNKUVvXgHtlG2McNjpJTgLyBXoosJ oAXQ== X-Gm-Message-State: AOAM531cygHL5pooGbkgknDOPVushe1//3I1NirWmX9xb0GVEDWykFEM aVY9kpT6RB0BnZaY3fiD/dUBL9s2jcw= X-Received: by 2002:a17:902:6949:: with SMTP id k9mr17288565plt.47.1589820057328; Mon, 18 May 2020 09:40:57 -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.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 09:40:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/8] decodetree: Tidy error_with_file Date: Mon, 18 May 2020 09:40:46 -0700 Message-Id: <20200518164052.18689-3-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::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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" Use proper varargs to print the arguments. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/scripts/decodetree.py b/scripts/decodetree.py index f9d204aa36..b559db3086 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -51,23 +51,27 @@ def error_with_file(file, lineno, *args): global output_file global output_fd + prefix = '' + if file: + prefix += '{0}:'.format(file) if lineno: - r = '{0}:{1}: error:'.format(file, lineno) - elif input_file: - r = '{0}: error:'.format(file) - else: - r = 'error:' - for a in args: - r += ' ' + str(a) - r += '\n' - sys.stderr.write(r) + prefix += '{0}:'.format(lineno) + if prefix: + prefix += ' ' + print(prefix, end='error: ', file=sys.stderr) + print(*args, file=sys.stderr) + if output_file and output_fd: output_fd.close() os.remove(output_file) exit(1) +# end error_with_file + def error(lineno, *args): - error_with_file(input_file, lineno, args) + error_with_file(input_file, lineno, *args) +# end error + def output(*args): global output_fd From patchwork Mon May 18 16:40:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186895 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3054576ilb; Mon, 18 May 2020 09:43:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXLUWIDpyKANm4z58koI0/6Mz2rgWxHICbnpt6z+DNQBzNpygtLfYYvdHiTRhVOHOuQ1jS X-Received: by 2002:aed:3889:: with SMTP id k9mr17778185qte.347.1589820184552; Mon, 18 May 2020 09:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589820184; cv=none; d=google.com; s=arc-20160816; b=S4b9wt4in/o8A3WP5CJh5/FIc29jf12dBCyTLYDnGuZrQquRGyqHTu/zhpbvgvj9Bg MsY4fsVN9XojcgjagVYsm5S2Dqb9AZTOqPCcuGrO091zXyJjdnfGJ4TNltoR81tUksWv Ho8vpY7I0+pbjZc4lQXCCN3/A5hv/tSLxM/LcG66uJeK1IokZauNhkVv4+82EvNPy2zW XLLd8hm/xsAgfZijQLIrKbjB8YTVy0FlKBq2XVzIa1DxkgQ4soS7xSjAFFMdJmMzGhxd C8XB+WkqXRPwEjqQSIKGE1IsCzfNCqVZ2KPNGOdQD4CIE29ttmGe/k2SQm+vurLo1xJU necg== 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=mRcK8czV/oom/pkIx79cPTpR+Nhj4Hg+rOsk6vM94j4=; b=IQxdhMAhmqDreuwo02hDzOdvV/PVE2embIpgHSKKvzY3i02+EujCSJeHdsyVd659HU NCDrwtVQhozLfvCDOgu5CC4yX6EPr8EwdaAokpuXT4ECRITIkgrhAwTH/SsFxMce2Ksu blLtZXV3C+KykjEuT7L1hvEkPgma57B20qXkORitqwsyA3qw8LhNsiAUu/AdlH5vSLVc xveSdANu8DYMCi2AxMcOqSZLG/UaGZPJPZakyuIeR74HpB/ID0UW7xoLsrr9nGjyYco9 2QK+LWDblR98njjbgNEoKBKpc59Iv+Kl6P7e5B1NLbjE2nyrN+BDalqmaY4nUQ1hkK9t HKDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cNbsIj9e; 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 k1si6220970qkg.346.2020.05.18.09.43.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 09:43:04 -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=cNbsIj9e; 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]:51316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jair2-0004kH-3R for patch@linaro.org; Mon, 18 May 2020 12:43:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaip3-000212-CR for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:01 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:34692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaip2-0005pw-GJ for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:01 -0400 Received: by mail-pl1-x62b.google.com with SMTP id g11so4453983plp.1 for ; Mon, 18 May 2020 09:41:00 -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=mRcK8czV/oom/pkIx79cPTpR+Nhj4Hg+rOsk6vM94j4=; b=cNbsIj9eglGL5hwv9PKqKn/U1sEOD3nRLjBRyV0j8hserxzrN3sLVX3BM3R+jJRLX3 eVCpcWHep/pXovhC84H+1dLpsjkChFKlXNUuBLpqMzidhMXrXC24XX65QDSQqQkx4yE7 VJdPUkUjFR1AMzYVd1DJCBCU3+hhH1heQTZ443oFqQVNuZ57aHon2+nTIL3VVuYL+kI1 ETVQpuV/EgNFIbDzwM1V/30RV/53hlAQ1xH4Cl9csYFt/b+/K2jDXP1WRNmOLImkYur/ OT9oKQ3fiolNVgQ7iSB4+ODMBi2UVOYX5esqWjZmkgxEIBLAJld9QUqE5xCK+Zi3o8kn u2lA== 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=mRcK8czV/oom/pkIx79cPTpR+Nhj4Hg+rOsk6vM94j4=; b=rpRpBqtv5Y6JWPF6pvMeDfKz7VpHOhQ3FdKVcYFFQJtDnyJ9DMNd7r+vO1jd1hX/fx 92XRpEp07+083JpawjgkesFqrN1ahcBKe+DmFzfJgCvAxyHkKIvSI1GAOhAyDJ0purIY 6DmLB5Vkv9x1FKAcd7FCNsDbsXL5XXMNN6h5kbQeElgtPxrn4pNwrQNw1xSMPOJe1OTo 6yU/Zj31STWKW0Cj4HD+xSZHLPfSc7PBOZzLwZ1Ovh4s/PBu4eGJsaU1ZTYLVtd0/c8f ijxFMnjhR4dYhtziyihD6foWyiaQ0d3ueIi2VXABj1hQ+Y6pBqGKnMDsQaIHFBW4qu87 gQFw== X-Gm-Message-State: AOAM5319HVo2tIFgAb8sUsNSsv2P0ozTZZjc5R0WJ9p5+VxukyFjYWOG HeyZyvfHhMVnK/faCQG5MIQZOYx/c+c= X-Received: by 2002:a17:90a:a402:: with SMTP id y2mr291192pjp.24.1589820058605; Mon, 18 May 2020 09:40:58 -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.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 09:40:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/8] decodetree: Rename MultiPattern to IncMultiPattern Date: Mon, 18 May 2020 09:40:47 -0700 Message-Id: <20200518164052.18689-4-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::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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" Name the current node for "inclusive" multi-pattern, in preparation for adding a node for "exclusive" multi-pattern. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/scripts/decodetree.py b/scripts/decodetree.py index b559db3086..7af6b3056d 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -371,7 +371,7 @@ class Pattern(General): # end Pattern -class MultiPattern(General): +class IncMultiPattern(General): """Class representing an overlapping set of instruction patterns""" def __init__(self, lineno, pats, fixb, fixm, udfm, w): @@ -410,7 +410,7 @@ class MultiPattern(General): output(ind, '}\n') else: p.output_code(i, extracted, p.fixedbits, p.fixedmask) -#end MultiPattern +#end IncMultiPattern def parse_field(lineno, name, toks): @@ -751,8 +751,8 @@ def parse_generic(lineno, is_format, name, toks): .format(allbits ^ insnmask)) # end parse_general -def build_multi_pattern(lineno, pats): - """Validate the Patterns going into a MultiPattern.""" +def build_incmulti_pattern(lineno, pats): + """Validate the Patterns going into a IncMultiPattern.""" global patterns global insnmask @@ -792,9 +792,9 @@ def build_multi_pattern(lineno, pats): else: repeat = False - mp = MultiPattern(lineno, pats, fixedbits, fixedmask, undefmask, width) + mp = IncMultiPattern(lineno, pats, fixedbits, fixedmask, undefmask, width) patterns.append(mp) -# end build_multi_pattern +# end build_incmulti_pattern def parse_file(f): """Parse all of the patterns within a file""" @@ -860,7 +860,7 @@ def parse_file(f): error(start_lineno, 'indentation ', indent, ' != ', nesting) pats = patterns patterns = saved_pats.pop() - build_multi_pattern(lineno, pats) + build_incmulti_pattern(lineno, pats) toks = [] continue From patchwork Mon May 18 16:40:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186896 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3055731ilb; Mon, 18 May 2020 09:44:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj/bjhiNANpckMIcfxf8HRNvv8PyzJu/FZdLkit5B5qRQ8vhjCpf/D4SLIvZ0w7QEjtIAh X-Received: by 2002:a0c:ec49:: with SMTP id n9mr16981561qvq.143.1589820274562; Mon, 18 May 2020 09:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589820274; cv=none; d=google.com; s=arc-20160816; b=DRtkfbRbgmgfAsF9NZk21nKaBHd5o0+ExWkDe9oPdUGoXTlN2gw/v29zZn34sTqFMh D1pIcfx/Lb+1rbMDjtC8IjTLPlgivYlOtr8x/7/2SJ9YbWkVyevzv8tI2FfEJV+L+aF1 P36Rx+WrXsNup66qYCy4dtJQDqFOMCTzf6NgiE0wASEqdV39UKBntol5iOll06C09nr1 Kbbmtv9/RlkDuD7HQOEECtIfLVJxw1dcoetIIU5tG8FBlRgvoE7fRyHgO873JdJDGYkF YixmU6oLtGpW0YPzc8qoDi2oD7Phh6bEPm6hx0DmTl7Hw0wyEUOXbyhkUDPcmhwihh7Q WW/w== 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=DXF5hhG17BDEOETPzoe+bSK9+O1lQ05HYEEgNG7hh+w=; b=xJp+tPkroD6g8uPoLp/BJJc7HpfNloQ5+orxIo8Pk6+XaChwwIOXEQnPBikWvyfjPx TZh4VpVo9jhoHgdGhsTRZlbTKDu9Uy2W+XQhA41I3wGWHNjHBuZaKVoBfFoGJHpFO9Bj T9RZqYYej71MxSRR8vImi3WQTGEhNuOkz0zBhdA16HMoJR1QZu6YiaGTX4L7DfGPCgGO /yPGQcdaiMYNGNBMK3EQM5M3yOO/8PQNWCA3vRu7Fx93f75PI6LY8CSadImziaHxFRpq z4VzGd5hRP35qPP0k8WDOKDeBi8PPmFoI2DPM3OFV3CiorJDF4VwFi5xYIzSRH5cQmDg Q5fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FjihzZwM; 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 p10si5980759qkh.143.2020.05.18.09.44.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 09:44:34 -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=FjihzZwM; 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]:57892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaisU-0007VH-1j for patch@linaro.org; Mon, 18 May 2020 12:44:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaip5-00025C-LA for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:03 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:46135) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaip4-0005qu-ME for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:03 -0400 Received: by mail-pl1-x629.google.com with SMTP id b12so4430219plz.13 for ; Mon, 18 May 2020 09:41:02 -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=DXF5hhG17BDEOETPzoe+bSK9+O1lQ05HYEEgNG7hh+w=; b=FjihzZwM2wYtERi0Zws7yos2C7KGw20k78/MJFU1LrZ+TmbscZxA63HJVgPAJsmHFp F4FBLdZqtGUGycqOLe8S7ZaVCK6hpDvQZ+M+0q7u6KiRhn1z2XVGh2qRmPQoZ7Zp3zL6 DHScloroEExBlpVlx7ZUTHKQBMYe/lAE1MbsNks1Dw4epwKA1TfwDT1LPOqnjcstQFeg C7HqdDxicOgVUoNNtmlBj+GnH15B5bP1u+dIB6iqIoNf33MQL5iGWWNbwK2NzHd8x6i6 yMFc2hmZPaRISftqap7jE0VpMTxqls3hSKI8B0OxMZBd5dJnpmdU2LsuOAGTg3ga6SEg TkSg== 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=DXF5hhG17BDEOETPzoe+bSK9+O1lQ05HYEEgNG7hh+w=; b=XwW+f5EMJv/IIxd0fHYtyM2UswB3Bt5MIhU2FZjA+T+MwjxONN6Uc3JSQt75xBcqa1 iD3KzwPHXGMPj1FeL4pvvqqUEnJ7HpJGD7fDP4zEfqWpDELoKyRqMO9GHuwTnHNHtsj9 9kajFeNz0Za+WQE/kh+gMF5Ir+gpv4TQid0zgqnEeo+31MmYy0SCaXTTG1bJhDQ+7uAn RoCiAuvxGAnrvRk0op1B2X4E18epCozZS4ktmUR6sSq+rgBOGfOyPP+EN7oUSHmO2FSb G/+m2MobmYwEpu7RY0lN3ZhLQ2EMt4qtJyxZpkPA9eeI9lgebIZna7XiBm6uL4IGxQ5z +DSw== X-Gm-Message-State: AOAM530A0Pm8FSb/0z80ORsGhSdwaNc5+i3oQlDNkCpVbXwPBSl92MqT DXPEdNWZD0ojgmGPCQJg1zlvpf8W/5A= X-Received: by 2002:a17:90a:dd45:: with SMTP id u5mr302350pjv.156.1589820060313; Mon, 18 May 2020 09:41:00 -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.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 09:40:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/8] decodetree: Split out MultiPattern from IncMultiPattern Date: Mon, 18 May 2020 09:40:48 -0700 Message-Id: <20200518164052.18689-5-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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" Signed-off-by: Richard Henderson --- scripts/decodetree.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 7af6b3056d..ea313bcdea 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -371,7 +371,32 @@ class Pattern(General): # end Pattern -class IncMultiPattern(General): +class MultiPattern(General): + """Class representing a set of instruction patterns""" + + def __init__(self, lineno, pats): + self.file = input_file + self.lineno = lineno + self.pats = pats + self.base = None + self.fixedbits = 0 + self.fixedmask = 0 + self.undefmask = 0 + self.width = None + + def __str__(self): + r = 'group' + if self.fixedbits is not None: + r += ' ' + str_match_bits(self.fixedbits, self.fixedmask) + return r + + def output_decl(self): + for p in self.pats: + p.output_decl() +# end MultiPattern + + +class IncMultiPattern(MultiPattern): """Class representing an overlapping set of instruction patterns""" def __init__(self, lineno, pats, fixb, fixm, udfm, w): @@ -384,16 +409,6 @@ class IncMultiPattern(General): self.undefmask = udfm self.width = w - def __str__(self): - r = "{" - for p in self.pats: - r = r + ' ' + str(p) - return r + "}" - - def output_decl(self): - for p in self.pats: - p.output_decl() - def output_code(self, i, extracted, outerbits, outermask): global translate_prefix ind = str_indent(i) 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) From patchwork Mon May 18 16:40:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186901 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3061762ilb; Mon, 18 May 2020 09:52:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySUdRolDlbrTXqVgsfqfyzES4iSCAEMb0ijIwl8ixHLEdwpZq6ZREOnwY38+rMoPZHGC05 X-Received: by 2002:ac8:404b:: with SMTP id j11mr11369246qtl.351.1589820768868; Mon, 18 May 2020 09:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589820768; cv=none; d=google.com; s=arc-20160816; b=Um4hVsuKPf528TJwUlK7FAGgaDJnWbxq0BQ9SAdYrgTE5ejTteQ3zS5ksRaAJnTVmZ KN0Vaiw4IeLNJXO+IRvnr10mq0mpW7TAaBnCV3s75RD94Jh9/IQ4ngwPx144HHNeOZpf NNMIWKbTBltVvVJYuOmgTygG4PQAzF/V7+rpr5EuMnO/Ny+Lc9nJjaqg30eZlJkBzvw2 1o3M25w/2oYOJKcJeA2Bbe0ahSldwLVWbCcSGOHiVEjJxOm39znw2waDJqXxkRI11cTC 7wGHHcAdIc4KERq097s0ACcrd3I5DqbkBck5wT2BHPVLFEplx70/ZLyAAlfTcT/gi5Vk qpFA== 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=MPJKFuko3o4wPQ/LQBUVo3W7uSIJWuyYbNATR0QRJU4=; b=IAYi2FhZmC0exRJNGR232ZUi7hf9AFuU030a4eTwHcJfrGtfY9YVKwwrIzRUE1s50r 8jBCO/X0z8YSDC00LkiU83h+/JbViOyq2axcTs9rzD5kSMJtQbAe2dAzbyA2tnq7qZD2 VIdRyTZlzG1EgjDt2iM9c7DqE7W88d3kPrQ1+hi+3gX+F4oPWyWNrzgIE+fRIBqD+OD2 YDmt3mTLNFDAdWX+eY7pZajhMuCJj7x9SN3i/tfq6o5zlkKOugIkPk83GzPn6t+3WKmV G/LSeAbD/crocVlPvB2DqDExVG6SjlRmGFtnfqORmPLshNtcX3lL8hQDoP4r5ou3BLin 3dZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Rdr/B7ZI"; 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 p21si6123520qtf.143.2020.05.18.09.52.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 09:52:48 -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="Rdr/B7ZI"; 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]:57252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaj0S-0002Vr-CI for patch@linaro.org; Mon, 18 May 2020 12:52:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaipA-0002DA-6R for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:08 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:41386) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaip8-0005ry-AR for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:07 -0400 Received: by mail-pg1-x544.google.com with SMTP id r10so5085943pgv.8 for ; Mon, 18 May 2020 09:41:05 -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=MPJKFuko3o4wPQ/LQBUVo3W7uSIJWuyYbNATR0QRJU4=; b=Rdr/B7ZI/okB7UoaMC0ANOO8pcLb4y2+yJb4AZ8lHDtbc1vZ6Ydynhd1w0//6u3z78 tvQWjGkAl4i+4nLGwjgWmdOzLlb1jsRzVCNN25MaIasUxPETksYb+LDD9p78FlWTxI+t jnh4C6BSeulQVABfCyUvCfOEMk3wI0aI77udHiAv/OeS366KVUvYQcz88ecUDWjE3DMe C8lkZpx1UzfLZNRDjfl6B0YctF8rQy09zHS4iuwL0WDQ1Vzsm3UObH6XFlRjVmrTN8WG xh3uW/+DPSWUCAnOecFjmJssnA79cGFzrUFs1Znwqs04iCeXgN5oJfOAyGOOSdJFkaSS n8yg== 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=MPJKFuko3o4wPQ/LQBUVo3W7uSIJWuyYbNATR0QRJU4=; b=H8l3A60tTXPHXYaTT85iT5SdQONtut8iqyzuMtEI4hLxrjCP9Gu2nr7u2LDonSw0IA U9D7uKuB1kX1ZySzm3r6V6funDr21bB6W/jvf6UXoLPZX/lhGiaFtSLOtVcVl+LffxBo VEqrFXVVAyKJ2LcfLFycxo1G+uBlKuUrW6TPtPWxnmL3rkn6f1IijyNlQIAN0ar9UG57 5O36KcyBmx3i44NA5D2m+tOwCBDx3fHl+gGGj7iIlkfFQbH9Y9T76Bq51eKYSeyxfIlZ jSE6t+cPi27mI7SzNAcbKXj8vzefjxF2Inw4hgg991dVXMT4rbh6niHiGaHZ9UZjjDDC Y1+A== X-Gm-Message-State: AOAM530wiHry6pAeuSKHbuCU/pbTngK2gDrDQngn++buTgNaaC88EjAX YdxduRPpGjzjuF71tpfqnA8nLNw7B7g= X-Received: by 2002:aa7:939c:: with SMTP id t28mr17528853pfe.38.1589820063706; Mon, 18 May 2020 09:41:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 09:41:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 6/8] decodetree: Move semantic propagation into classes Date: Mon, 18 May 2020 09:40:50 -0700 Message-Id: <20200518164052.18689-7-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::544; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x544.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" Create ExcMultiPattern to hold an set of non-overlapping patterns. The body of build_tree, prop_format become member functions on this class. Add minimal member functions to Pattern and MultiPattern to allow recusion through the tree. Move the bulk of build_incmulti_pattern to prop_masks and prop_width in MultiPattern, since we will need this for both kinds of containers. Only perform prop_width for variablewidth. Remove global patterns variable, and pass down container object into parse_file from main. No functional change in all of this. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 464 +++++++++++++++++++++++------------------- 1 file changed, 253 insertions(+), 211 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 3307c74c30..0ba01e049c 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -31,7 +31,6 @@ variablewidth = False fields = {} arguments = {} formats = {} -patterns = [] allpatterns = [] anyextern = False @@ -371,16 +370,27 @@ class Pattern(General): output(ind, 'u.f_', arg, '.', n, ' = ', f.str_extract(), ';\n') output(ind, 'if (', translate_prefix, '_', self.name, '(ctx, &u.f_', arg, ')) return true;\n') + + # Normal patterns do not have children. + def build_tree(self): + return + def prop_masks(self): + return + def prop_format(self): + return + def prop_width(self): + return + # end Pattern class MultiPattern(General): """Class representing a set of instruction patterns""" - def __init__(self, lineno, pats): + def __init__(self, lineno): self.file = input_file self.lineno = lineno - self.pats = pats + self.pats = [] self.base = None self.fixedbits = 0 self.fixedmask = 0 @@ -396,22 +406,63 @@ class MultiPattern(General): def output_decl(self): for p in self.pats: p.output_decl() + + def prop_masks(self): + global insnmask + + fixedmask = insnmask + undefmask = insnmask + + # Collect fixedmask/undefmask for all of the children. + for p in self.pats: + p.prop_masks() + fixedmask &= p.fixedmask + undefmask &= p.undefmask + + # Widen fixedmask until all fixedbits match + repeat = True + fixedbits = 0 + while repeat and fixedmask != 0: + fixedbits = None + for p in self.pats: + thisbits = p.fixedbits & fixedmask + if fixedbits is None: + fixedbits = thisbits + elif fixedbits != thisbits: + fixedmask &= ~(fixedbits ^ thisbits) + break + else: + repeat = False + + self.fixedbits = fixedbits + self.fixedmask = fixedmask + self.undefmask = undefmask + + def build_tree(self): + for p in self.pats: + p.build_tree() + + def prop_format(self): + for p in self.pats: + p.build_tree() + + def prop_width(self): + width = None + for p in self.pats: + p.prop_width() + if width is None: + width = p.width + elif width != p.width: + error_with_file(self.file, self.lineno, + 'width mismatch in patterns within braces') + self.width = width + # end MultiPattern class IncMultiPattern(MultiPattern): """Class representing an overlapping set of instruction patterns""" - def __init__(self, lineno, pats, fixb, fixm, udfm, w): - self.file = input_file - self.lineno = lineno - self.pats = pats - self.base = None - self.fixedbits = fixb - self.fixedmask = fixm - self.undefmask = udfm - self.width = w - def output_code(self, i, extracted, outerbits, outermask): global translate_prefix ind = str_indent(i) @@ -431,6 +482,153 @@ class IncMultiPattern(MultiPattern): #end IncMultiPattern +class Tree: + """Class representing a node in a decode tree""" + + def __init__(self, fm, tm): + self.fixedmask = fm + self.thismask = tm + self.subs = [] + self.base = None + + def str1(self, i): + ind = str_indent(i) + r = '{0}{1:08x}'.format(ind, self.fixedmask) + if self.format: + r += ' ' + self.format.name + r += ' [\n' + for (b, s) in self.subs: + r += '{0} {1:08x}:\n'.format(ind, b) + r += s.str1(i + 4) + '\n' + r += ind + ']' + return r + + def __str__(self): + return self.str1(0) + + def output_code(self, i, extracted, outerbits, outermask): + ind = str_indent(i) + + # If we identified all nodes below have the same format, + # extract the fields now. + if not extracted and self.base: + output(ind, self.base.extract_name(), + '(ctx, &u.f_', self.base.base.name, ', insn);\n') + extracted = True + + # Attempt to aid the compiler in producing compact switch statements. + # If the bits in the mask are contiguous, extract them. + sh = is_contiguous(self.thismask) + if sh > 0: + # Propagate SH down into the local functions. + def str_switch(b, sh=sh): + return '(insn >> {0}) & 0x{1:x}'.format(sh, b >> sh) + + def str_case(b, sh=sh): + return '0x{0:x}'.format(b >> sh) + else: + def str_switch(b): + return 'insn & 0x{0:08x}'.format(b) + + def str_case(b): + return '0x{0:08x}'.format(b) + + output(ind, 'switch (', str_switch(self.thismask), ') {\n') + for b, s in sorted(self.subs): + assert (self.thismask & ~s.fixedmask) == 0 + innermask = outermask | self.thismask + innerbits = outerbits | b + output(ind, 'case ', str_case(b), ':\n') + output(ind, ' /* ', + str_match_bits(innerbits, innermask), ' */\n') + s.output_code(i + 4, extracted, innerbits, innermask) + output(ind, ' return false;\n') + output(ind, '}\n') +# end Tree + + +class ExcMultiPattern(MultiPattern): + """Class representing a non-overlapping set of instruction patterns""" + + def output_code(self, i, extracted, outerbits, outermask): + # Defer everything to our decomposed Tree node + self.tree.output_code(i, extracted, outerbits, outermask) + + @staticmethod + def __build_tree(pats, outerbits, outermask): + # Find the intersection of all remaining fixedmask. + innermask = ~outermask & insnmask + for i in pats: + 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) + error_with_file(pats[0].file, pats[0].lineno, text) + + fullmask = outermask | innermask + + # Sort each element of pats into the bin selected by the mask. + bins = {} + for i in pats: + fb = i.fixedbits & innermask + if fb in bins: + bins[fb].append(i) + else: + bins[fb] = [i] + + # We must recurse if any bin has more than one element or if + # the single element in the bin has not been fully matched. + t = Tree(fullmask, innermask) + + for b, l in bins.items(): + s = l[0] + if len(l) > 1 or s.fixedmask & ~fullmask != 0: + s = ExcMultiPattern.__build_tree(l, b | outerbits, fullmask) + t.subs.append((b, s)) + + return t + + def build_tree(self): + super().prop_format() + self.tree = self.__build_tree(self.pats, self.fixedbits, + self.fixedmask) + + @staticmethod + def __prop_format(tree): + """Propagate Format objects into the decode tree""" + + # Depth first search. + for (b, s) in tree.subs: + if isinstance(s, Tree): + ExcMultiPattern.__prop_format(s) + + # If all entries in SUBS have the same format, then + # propagate that into the tree. + f = None + for (b, s) in tree.subs: + if f is None: + f = s.base + if f is None: + return + if f is not s.base: + return + tree.base = f + + def prop_format(self): + super().prop_format() + self.__prop_format(self.tree) + +# end ExcMultiPattern + + def parse_field(lineno, name, toks): """Parse one instruction field from TOKS at LINENO""" global fields @@ -587,18 +785,19 @@ def infer_format(arg, fieldmask, flds, width): # end infer_format -def parse_generic(lineno, is_format, name, toks): +def parse_generic(lineno, parent_pat, name, toks): """Parse one instruction format from TOKS at LINENO""" global fields global arguments global formats - global patterns global allpatterns global re_ident global insnwidth global insnmask global variablewidth + is_format = parent_pat is None + fixedmask = 0 fixedbits = 0 undefmask = 0 @@ -749,7 +948,7 @@ def parse_generic(lineno, is_format, name, toks): error(lineno, 'field {0} not initialized'.format(f)) pat = Pattern(name, lineno, fmt, fixedbits, fixedmask, undefmask, fieldmask, flds, width) - patterns.append(pat) + parent_pat.pats.append(pat) allpatterns.append(pat) # Validate the masks that we have assembled. @@ -769,61 +968,16 @@ def parse_generic(lineno, is_format, name, toks): .format(allbits ^ insnmask)) # end parse_general -def build_incmulti_pattern(lineno, pats): - """Validate the Patterns going into a IncMultiPattern.""" - global patterns - global insnmask - if len(pats) < 2: - error(lineno, 'less than two patterns within braces') - - fixedmask = insnmask - undefmask = insnmask - - # Collect fixed/undefmask for all of the children. - # Move the defining lineno back to that of the first child. - for p in pats: - fixedmask &= p.fixedmask - undefmask &= p.undefmask - if p.lineno < lineno: - lineno = p.lineno - - width = None - for p in pats: - if width is None: - width = p.width - elif width != p.width: - error(lineno, 'width mismatch in patterns within braces') - - repeat = True - fixedbits = 0 - while repeat and fixedmask != 0: - fixedbits = None - for p in pats: - thisbits = p.fixedbits & fixedmask - if fixedbits is None: - fixedbits = thisbits - elif fixedbits != thisbits: - fixedmask &= ~(fixedbits ^ thisbits) - break - else: - repeat = False - - mp = IncMultiPattern(lineno, pats, fixedbits, fixedmask, undefmask, width) - patterns.append(mp) -# end build_incmulti_pattern - -def parse_file(f): +def parse_file(f, parent_pat): """Parse all of the patterns within a file""" - global patterns - # Read all of the lines of the file. Concatenate lines # ending in backslash; discard empty lines and comments. toks = [] lineno = 0 nesting = 0 - saved_pats = [] + nesting_pats = [] for line in f: lineno += 1 @@ -868,16 +1022,20 @@ def parse_file(f): # End nesting? if name == '}': - if nesting == 0: - error(start_lineno, 'mismatched close brace') if len(toks) != 0: error(start_lineno, 'extra tokens after close brace') + if len(parent_pat.pats) < 2: + error(lineno, 'less than two patterns within braces') + + try: + parent_pat = nesting_pats.pop() + except: + error(lineno, 'mismatched close brace') + nesting -= 2 if indent != nesting: - error(start_lineno, 'indentation ', indent, ' != ', nesting) - pats = patterns - patterns = saved_pats.pop() - build_incmulti_pattern(lineno, pats) + error(lineno, 'indentation ', indent, ' != ', nesting) + toks = [] continue @@ -889,8 +1047,12 @@ def parse_file(f): if name == '{': if len(toks) != 0: error(start_lineno, 'extra tokens after open brace') - saved_pats.append(patterns) - patterns = [] + + nested_pat = IncMultiPattern(start_lineno) + parent_pat.pats.append(nested_pat) + nesting_pats.append(parent_pat) + parent_pat = nested_pat + nesting += 2 toks = [] continue @@ -901,121 +1063,13 @@ def parse_file(f): elif name[0] == '&': parse_arguments(start_lineno, name[1:], toks) elif name[0] == '@': - parse_generic(start_lineno, True, name[1:], toks) + parse_generic(start_lineno, None, name[1:], toks) else: - parse_generic(start_lineno, False, name, toks) + parse_generic(start_lineno, parent_pat, name, toks) toks = [] # end parse_file -class Tree: - """Class representing a node in a decode tree""" - - def __init__(self, fm, tm): - self.fixedmask = fm - self.thismask = tm - self.subs = [] - self.base = None - - def str1(self, i): - ind = str_indent(i) - r = '{0}{1:08x}'.format(ind, self.fixedmask) - if self.format: - r += ' ' + self.format.name - r += ' [\n' - for (b, s) in self.subs: - r += '{0} {1:08x}:\n'.format(ind, b) - r += s.str1(i + 4) + '\n' - r += ind + ']' - return r - - def __str__(self): - return self.str1(0) - - def output_code(self, i, extracted, outerbits, outermask): - ind = str_indent(i) - - # If we identified all nodes below have the same format, - # extract the fields now. - if not extracted and self.base: - output(ind, self.base.extract_name(), - '(ctx, &u.f_', self.base.base.name, ', insn);\n') - extracted = True - - # Attempt to aid the compiler in producing compact switch statements. - # If the bits in the mask are contiguous, extract them. - sh = is_contiguous(self.thismask) - if sh > 0: - # Propagate SH down into the local functions. - def str_switch(b, sh=sh): - return '(insn >> {0}) & 0x{1:x}'.format(sh, b >> sh) - - def str_case(b, sh=sh): - return '0x{0:x}'.format(b >> sh) - else: - def str_switch(b): - return 'insn & 0x{0:08x}'.format(b) - - def str_case(b): - return '0x{0:08x}'.format(b) - - output(ind, 'switch (', str_switch(self.thismask), ') {\n') - for b, s in sorted(self.subs): - assert (self.thismask & ~s.fixedmask) == 0 - innermask = outermask | self.thismask - innerbits = outerbits | b - output(ind, 'case ', str_case(b), ':\n') - output(ind, ' /* ', - str_match_bits(innerbits, innermask), ' */\n') - s.output_code(i + 4, extracted, innerbits, innermask) - output(ind, ' return false;\n') - output(ind, '}\n') -# end Tree - - -def build_tree(pats, outerbits, outermask): - # Find the intersection of all remaining fixedmask. - innermask = ~outermask & insnmask - for i in pats: - 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) - error_with_file(pats[0].file, pats[0].lineno, text) - - fullmask = outermask | innermask - - # Sort each element of pats into the bin selected by the mask. - bins = {} - for i in pats: - fb = i.fixedbits & innermask - if fb in bins: - bins[fb].append(i) - else: - bins[fb] = [i] - - # We must recurse if any bin has more than one element or if - # the single element in the bin has not been fully matched. - t = Tree(fullmask, innermask) - - for b, l in bins.items(): - s = l[0] - if len(l) > 1 or s.fixedmask & ~fullmask != 0: - s = build_tree(l, b | outerbits, fullmask) - t.subs.append((b, s)) - - return t -# end build_tree - - class SizeTree: """Class representing a node in a size decode tree""" @@ -1157,28 +1211,6 @@ def build_size_tree(pats, width, outerbits, outermask): # end build_size_tree -def prop_format(tree): - """Propagate Format objects into the decode tree""" - - # Depth first search. - for (b, s) in tree.subs: - if isinstance(s, Tree): - prop_format(s) - - # If all entries in SUBS have the same format, then - # propagate that into the tree. - f = None - for (b, s) in tree.subs: - if f is None: - f = s.base - if f is None: - return - if f is not s.base: - return - tree.base = f -# end prop_format - - def prop_size(tree): """Propagate minimum widths up the decode size tree""" @@ -1199,7 +1231,6 @@ def prop_size(tree): def main(): global arguments global formats - global patterns global allpatterns global translate_scope global translate_prefix @@ -1246,18 +1277,29 @@ def main(): if len(args) < 1: error(0, 'missing input file') + + toppat = ExcMultiPattern(0) + for filename in args: input_file = filename f = open(filename, 'r') - parse_file(f) + parse_file(f, toppat) f.close() - if variablewidth: - stree = build_size_tree(patterns, 8, 0, 0) - prop_size(stree) + # We do not want to compute masks for toppat, because those masks + # are used as a starting point for build_tree. For toppat, we must + # insist that decode begins from naught. + for i in toppat.pats: + i.prop_masks() - dtree = build_tree(patterns, 0, 0) - prop_format(dtree) + toppat.build_tree() + toppat.prop_format() + + if variablewidth: + for i in toppat.pats: + i.prop_width() + stree = build_size_tree(toppat.pats, 8, 0, 0) + prop_size(stree) if output_file: output_fd = open(output_file, 'w') @@ -1316,7 +1358,7 @@ def main(): f = arguments[n] output(i4, i4, f.struct_name(), ' f_', f.name, ';\n') output(i4, '} u;\n\n') - dtree.output_code(4, False, 0, 0) + toppat.output_code(4, False, 0, 0) output(i4, 'return false;\n') output('}\n') From patchwork Mon May 18 16:40:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186900 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3060331ilb; Mon, 18 May 2020 09:50:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLYuAQddGi7VK8UN6pNE/Kkzl/GcpbHHP7ZdLXOvEhHXcRlSrb8CFTF6b01vyD4Zo5Y0EV X-Received: by 2002:a05:620a:4c9:: with SMTP id 9mr14726988qks.487.1589820650953; Mon, 18 May 2020 09:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589820650; cv=none; d=google.com; s=arc-20160816; b=EL/duuJv5xkQtnshh1VmtTHL3WrAu3W8K7P0tnm8FnvtTzugGqYmk5n02XTafHXzTR oP7/w2Zjde9LDKo+mIExTi2+U+jJJ11pacVEH/E2/BBGax75uOVKAWTuI46lfeK5az+L hyocQTyvavLSn4i5+e9j1UkEsTtCnfts774RkftL4CDRlftXj29NIktm6Sjac03nue+L KBC0KS4zabX5/5KnWTWS/V6n5to/4h26FTaLl8ncupBp5BoMZRBQ3LWOGuoE4PECfyok JB8at6IL45wIWW+djmMBnskjL+s8IeyWjlGxvqalXQuAqV7tc3wy2QlQZkd9VAA9i5Cc roRg== 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=PDxSs9xf1b7EFL4pA0grZqMFDbD8BMz/GvRTlqeyA2I=; b=EzIiZydRTp4HeajoljySuITVIXggon5bZ90hJsKBYbK50Y6onLJkLXb7sTY640Hu05 GRYchqkS9dF5TqQWi42gYVNOb6Kf/Kosc4zMG9v0faXJw5PBvsmZ0uRBHoFr+raSBeXO r2k2Fm/e4RU8I7zmBMLSdp8lC/qt/hnzNOLOKHdn3yCX04pKXYCthrWiQQ4CdyTSmmQl jOqATxJssm+MPh2fj/AHZCOJUk6zsDbugU4W1rpc3FjHl5DMqnIOUwtXjhac2hRhD1ND YWcH5VY7ZE0qSJgvFR+JAhNFyH31Z9gmozuNFETBknKPtltEVhnaxTBlmTuELSR+fop/ X7tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e2AxxJup; 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 r131si6214019qke.3.2020.05.18.09.50.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 09:50:50 -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=e2AxxJup; 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]:50518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaiyY-00085E-F8 for patch@linaro.org; Mon, 18 May 2020 12:50:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaip9-0002CR-SE for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:07 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:33996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaip8-0005s9-PQ for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:07 -0400 Received: by mail-pf1-x42f.google.com with SMTP id x15so5222551pfa.1 for ; Mon, 18 May 2020 09:41:06 -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=PDxSs9xf1b7EFL4pA0grZqMFDbD8BMz/GvRTlqeyA2I=; b=e2AxxJupJagi8K3bYFhRin1ja+XNx7qEOSklYn7bX3V3sasqPk3DKCZ7y4K6VoFE/l PAKSQlGoY4mJDxOTXf5daCf8qEmo/vQmJTxqljcHaAbTURf/cwidT9AvTUQdeP9NjEUK G0dRiJs0EvWeqi3ajkRobYvC8+oyFJ3+DVkI6j2SR7VReEnMXGlh9uNTkxewEQ0JghSt LlaqmccdYMeQwqDGO3sLFLvm8sc1S0pKfEHKc/NFSPAb2VABOgb8WQHqoobpfr0FJSAR 18yUyegB6NxX2vl4s63VPid8OXZfelZmswCxBkukTs6RqL5ZKr1WGvSaBF2Ublw5DcBo eXmw== 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=PDxSs9xf1b7EFL4pA0grZqMFDbD8BMz/GvRTlqeyA2I=; b=LeVMy7V4AOQkz8ny5dH+ozh3pv8jajEJfCgh4crH8+tYuGqFfU3q/+zbaZCXX2zsva rkFVlH/1zEmHApXEno9ntfov+Kyvx5oTJ4t9D7mpj0laelsxYzJ6Png/8RCQXbRyno42 Kq6a73gEEIUSPdzZUbf6ZpJc1rKCSgBrH4qw+XV77XcQRnOrhuTDitTeUhitKzeXdXHv jJStOUc78oIoZ+XJgRiwcRKW0qc7dDntYhez+OTXh0CKSCcN3ppaM/oJgBRVU+JOgROg s0E9bPhCbjP+4+NtXXyE0YWW/+bL+GMIae+0Hhgrv5RlbHRAJfUdUEtRwIlb/Cwgknl/ B9fA== X-Gm-Message-State: AOAM5318rGv5dCdvUKyr/UlFAKhTJ/UprEvh9uWqN7LgraG2x9IXhymR fCJ8qXc2PhLxUTIE/vTX/NHfDpBaxyQ= X-Received: by 2002:a62:cd4a:: with SMTP id o71mr17915345pfg.115.1589820064970; Mon, 18 May 2020 09:41:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 09:41:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 7/8] decodetree: Implement non-overlapping groups Date: Mon, 18 May 2020 09:40:51 -0700 Message-Id: <20200518164052.18689-8-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::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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" Intended to be nested within overlapping groups. Suggested-by: Peter Maydell Signed-off-by: Richard Henderson --- scripts/decodetree.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 0ba01e049c..a9739f671d 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -1021,21 +1021,22 @@ def parse_file(f, parent_pat): del toks[0] # End nesting? - if name == '}': + if name == '}' or name == ']': if len(toks) != 0: error(start_lineno, 'extra tokens after close brace') if len(parent_pat.pats) < 2: error(lineno, 'less than two patterns within braces') + # Make sure { } and [ ] nest properly. + if (name == '}') != isinstance(parent_pat, IncMultiPattern): + error(lineno, 'mismatched close brace') + try: parent_pat = nesting_pats.pop() except: - error(lineno, 'mismatched close brace') + error(lineno, 'extra close brace') nesting -= 2 - if indent != nesting: - error(lineno, 'indentation ', indent, ' != ', nesting) - toks = [] continue @@ -1044,11 +1045,14 @@ def parse_file(f, parent_pat): error(start_lineno, 'indentation ', indent, ' != ', nesting) # Start nesting? - if name == '{': + if name == '{' or name == '[': if len(toks) != 0: error(start_lineno, 'extra tokens after open brace') - nested_pat = IncMultiPattern(start_lineno) + if name == '{': + nested_pat = IncMultiPattern(start_lineno) + else: + nested_pat = ExcMultiPattern(start_lineno) parent_pat.pats.append(nested_pat) nesting_pats.append(parent_pat) parent_pat = nested_pat @@ -1067,6 +1071,9 @@ def parse_file(f, parent_pat): else: parse_generic(start_lineno, parent_pat, name, toks) toks = [] + + if nesting != 0: + error(lineno, 'missing close brace') # end parse_file From patchwork Mon May 18 16:40:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186893 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3053184ilb; Mon, 18 May 2020 09:41:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1cH2EqZIod3yTKK9t27l5xWkCSgzNUchOWqBg0zTaAi7gA5Etd9DolQGNHFVHDF5it0+w X-Received: by 2002:a0c:eb49:: with SMTP id c9mr17223472qvq.123.1589820080250; Mon, 18 May 2020 09:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589820080; cv=none; d=google.com; s=arc-20160816; b=kDX8sxP0dkdasKQo7YWtTj8zrxJxzrJs1a6M04dOe+XIgOPTUa8xPlqR+nj9lTb7Ki ouG1+S2ZZ/QHeRDT59K2jNMxYdXbHp08Top3ji41hnOLEZi2bvWS2SsgyceRBR+kHMsc AkuTu52BUntlfo0CM5cjNTW8lbuwWEsPW/DtZBy0MZD9U1PMu2Tomuzen739TYlxB0pN nEFb6NW0eE8qXLewH1qJsnbwaH66h6Qt8StNB+bgz76vqrMeVPvmNxGGDgBPJYVEmGYF kNPOADeJrvWBSvKArllr4m/Nbdt7NNnDTowUk30G8JnMjjxMX1gzW4MpmBjScaPPu2ha FNbw== 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=YR8AXhnmaa7YBf0c5Txz/pTDpNw3zZphMDFYyOMiCJ8=; b=CGt6lszypcI7QbJALS9SuxB8EqdvrxOWxa87XZZ6n58edFZ9FSCFPrSSDgTHIzDI5u w9Ib+2KcJZuEsSrcwy/vHWpIi2dcx24zR2PZeHn+kMUe/2ENEUvjsqTw13jKkwowBXR8 PA5IX8Py0/p3GbQgDZvsJiKixf224/2vLeCxO4CoV0Tb61i38RXoQfWez5kkc3BiUa33 a05/WHlYONKZ28oLonnC1P8gBEhg/xUecYpk4lIcJYDvAtvE6Z96nY/zWdTshPUO8p8V hCDzRpkTafhEzp+NXpZL3qM6YDIrh/zPsHAINx2cmgIQyTqpq/GaW5xNm5/H0sQ/FZf6 guAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m6TbyN5l; 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 203si5809343qkh.55.2020.05.18.09.41.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2020 09:41:20 -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=m6TbyN5l; 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]:45356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaipL-0002HM-Pc for patch@linaro.org; Mon, 18 May 2020 12:41:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaipB-0002Ev-5t for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:09 -0400 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]:38609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaipA-0005sT-Be for qemu-devel@nongnu.org; Mon, 18 May 2020 12:41:08 -0400 Received: by mail-pj1-x1041.google.com with SMTP id t40so72605pjb.3 for ; Mon, 18 May 2020 09:41:07 -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=YR8AXhnmaa7YBf0c5Txz/pTDpNw3zZphMDFYyOMiCJ8=; b=m6TbyN5laTTBvFTy6dbGCymQ8XGAHSt9MWDS9wOC1JRSL0jOjRlcPbDDX0LYFJQ54/ zuKCGzuYx5MDQ7UfFtnXtJCV2wq3Jakp0TGdhwWk5OTj6J8nr/07jBcjmtJ+ZzZH0uLN 63Q9xN98GjPEOntQYXBS+u/1vIfZ38F7mRp8NeBNXa87UGzZmw8KPnvjQy3hxOLhQsCK +e0cOd/3o98BsSuFdIZZ9hST7kKzFu12E36RrP3RCcQtbVRXVpjOUEFlNxGzyHKg2Gxw 3Z+U39QBEaWotqlkjt+aUlfnSxV6f9mpPROfVRTR0JJ0RnYFyEOp0hIyQI1LfDbyFClD euOA== 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=YR8AXhnmaa7YBf0c5Txz/pTDpNw3zZphMDFYyOMiCJ8=; b=N9oTc6RyYHawOlKNuAOJxwjPHtxqmR8qm9RMMpF23TWStFOWYU0J1bMOdkRUCWWrPr DUwD7jllyHAmS2oCCZ40ulG8qlvhzJ84rsaCb/9Ce1LIXnAliLLfoDi5BdwuM80Ek0Pg 7eDcQXp24VrAP+7aBD9kNNgg9BxU+mcv8iJxDGPeAjUJ8eEI1Nda5N8V8YIQQS2HQdrq v+bl50iTm1QrbqEVLDQ/im4CXX3R76jfIAI0XI8amrvtGOByDVeKVwybkUVUjDMqB4/W dYgn6pxokLZtYgtdjb7tKNlYZjf3WXSFp4nKdE5jEn4DT0CmBMZHqaoHOd1+YAvyCdzS juYQ== X-Gm-Message-State: AOAM532jpH3jqGoG4tQ+xUQl8AMxiuQ/0uB3UC5dNjtWtATPXrEqA4gY uX9n87j/bum4/IfDJZRvhliG+yvrH3A= X-Received: by 2002:a17:90a:589:: with SMTP id i9mr274327pji.156.1589820066767; Mon, 18 May 2020 09:41:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 09:41:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 8/8] target/arm: Use a non-overlapping group for misc control Date: Mon, 18 May 2020 09:40:52 -0700 Message-Id: <20200518164052.18689-9-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::1041; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1041.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 sub-group in the t32 deocode are mutually exclusive. Signed-off-by: Richard Henderson --- target/arm/t32.decode | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/arm/t32.decode b/target/arm/t32.decode index c63082fc9c..c21a988f97 100644 --- a/target/arm/t32.decode +++ b/target/arm/t32.decode @@ -312,13 +312,13 @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 .... @rdm &cps # Miscellaneous control - { + [ CLREX 1111 0011 1011 1111 1000 1111 0010 1111 DSB 1111 0011 1011 1111 1000 1111 0100 ---- DMB 1111 0011 1011 1111 1000 1111 0101 ---- ISB 1111 0011 1011 1111 1000 1111 0110 ---- SB 1111 0011 1011 1111 1000 1111 0111 0000 - } + ] # Note that the v7m insn overlaps both the normal and banked insn. {