From patchwork Wed Oct 31 12:14:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149779 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6713073ljp; Wed, 31 Oct 2018 05:15:23 -0700 (PDT) X-Google-Smtp-Source: AJdET5dIoOplEK/lyGzkJnNyAfEGWzwW5m60A8N3eh8RnIWskuKCygNy47X7Qb3ZwsOKZ+LUOts6 X-Received: by 2002:a37:27d2:: with SMTP id n201mr2318574qkn.18.1540988123801; Wed, 31 Oct 2018 05:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540988123; cv=none; d=google.com; s=arc-20160816; b=OguH8ndw43jWHXULHKLOy9TF6PLC6oBGGcBCf2vUutK/Tqg0cHFxExm6XAZdSsXixm BTlRMebZT6ZVZ4P94CSzmjy533o2QrHx9l9BYDpMD4O6QfzIa6sjVN+sdXieOwYNU5G3 /h0omrAT7ZqsVjQSOq62V1TUfpAk/HiHEu87rvu5iLHARMmaEUw6QsBdqOWj4BOZVKOY 6hAmok4zE9xvZLU3jyFXglFCaDgZWJfgZunEXJPfegsp4BKz+diPrP5gq/siP5fE4FBZ plqZpYtqudqT3sLgEbgQDwX0VysrOa1hyQGpIbpBHwJpmrY8BLmsCLXhjxxtr6Fta7t1 ms7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=zESlNWMkk7Fcwbo3x2MkGK4XqwPhUldV22MGkv8jLsw=; b=KNUa8FJQVm7CtkKW9siM2B05q5EuSyGROfJ+ii8cQwmpGtgBCo1oPiABGyqKO7HdC6 BKfHTAREw1Gtck4ucMkwO9ax00wmKpJVIFw4/NxVydx12ZpN8LMbrAd7qA08RLnc20UU UHCAw91WmZ8M1cDfCoUff+8xRKjz7BH4tHW7o5+gzXCs3PvRxF7BT7FRcUQfX8zZiwln lZLx77nDWamKVd6Ag7RN5oLqrVNztck5JVcfn9upR/bVJWqarGhOUDpxHpYFWGfZ6e5d 1xn8IFRuDBlME7DUEvlZYFSMtwVeKiNaoLwrwscAn9oL6JZABf3kVNFSyRKYiv97GXB5 5USg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d2pn3c+G; 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 b12si8996982qvd.178.2018.10.31.05.15.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 31 Oct 2018 05:15:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d2pn3c+G; 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]:59096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHpP8-00035d-ED for patch@linaro.org; Wed, 31 Oct 2018 08:15:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHpOn-00034H-93 for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:15:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHpOj-0002fV-5A for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:15:01 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:43413) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHpOf-0002Ri-Gn for qemu-devel@nongnu.org; Wed, 31 Oct 2018 08:14:55 -0400 Received: by mail-wr1-x42f.google.com with SMTP id t10-v6so16213054wrn.10 for ; Wed, 31 Oct 2018 05:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zESlNWMkk7Fcwbo3x2MkGK4XqwPhUldV22MGkv8jLsw=; b=d2pn3c+Gk2JTWpIqOK3opbS6NdhuauI7QQ8lqUc/sPOx62xFSOI+o9y9rzJhRCtXup Gou9OxMUBPRAP2SHaPkP+cQsAboL1+NNqe4gF0s5MT8o87z/GfDPQ+LJkBvzwhf5YrFu YXfIUF0NfF9GoMcCLUZizziQtIhADD/M602UI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zESlNWMkk7Fcwbo3x2MkGK4XqwPhUldV22MGkv8jLsw=; b=tOCuF9ncN5IJ+mYalqD8tZ3vz5d9hEkoWkS34mI36RaJg27Octc4TxfJXujZUsH0kU vAvWDRAUl1SUTIIqm94iaP5vCyPRyHATWu6418tAAwUiHXj0COdi7SU9eHTzo/bYgIY6 EROMWioF+Q1gSAln51dSfWzSE6FWjJGwALFF1WToHyH6j3h80gLPlxcbRg0LZZAkNZ+T BlwKZw7qqiWEsQpJwwRa5AdMFTQqELp4YgEdu7K6Crsq9PBvOKtEn0xVShp9nwefe/TV XiJBF0AxA5lco4XChdw+3TLAIigldhpuWJ/t9DSh2sntM4v1HTfxdVf1CYP865rDFjOm gDLw== X-Gm-Message-State: AGRZ1gJtSVALLwgiNMrBU22mUsgdHY2RBdaGXKXk+Q+H8hr8p4abgkzP zbLQ8MxhizRlO5mcY1ohAEF+MEPZUhQ= X-Received: by 2002:adf:ed8d:: with SMTP id c13-v6mr2502906wro.39.1540988088638; Wed, 31 Oct 2018 05:14:48 -0700 (PDT) Received: from cloudburst.twiddle.net.lan (79-69-241-110.dynamic.dsl.as9105.com. [79.69.241.110]) by smtp.gmail.com with ESMTPSA id l140-v6sm37008148wmb.24.2018.10.31.05.14.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 05:14:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Oct 2018 12:14:43 +0000 Message-Id: <20181031121443.605-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181031121443.605-1-richard.henderson@linaro.org> References: <20181031121443.605-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [PATCH v2 3/3] decodetree: Allow multiple input files 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: kbastian@mail.uni-paderborn.de Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" While it would be possible to concatenate input files with make, passing the original input files to decodetree.py allows us to generate error messages which allows compilation environments (read: emacs) to next-error to the correct input file. Signed-off-by: Richard Henderson --- scripts/decodetree.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) -- 2.17.2 Reviewed-by: Bastian Koppelmann diff --git a/scripts/decodetree.py b/scripts/decodetree.py index 6670d58cc1..4a3d46e4a7 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -175,15 +175,15 @@ decode_function = 'decode' re_ident = '[a-zA-Z][a-zA-Z0-9_]*' -def error(lineno, *args): +def error_with_file(file, lineno, *args): """Print an error message from file:line and args and exit.""" global output_file global output_fd if lineno: - r = '{0}:{1}: error:'.format(input_file, lineno) + r = '{0}:{1}: error:'.format(file, lineno) elif input_file: - r = '{0}: error:'.format(input_file) + r = '{0}: error:'.format(file) else: r = 'error:' for a in args: @@ -195,6 +195,8 @@ def error(lineno, *args): os.remove(output_file) exit(1) +def error(lineno, *args): + error_with_file(input_file, lineno, args) def output(*args): global output_fd @@ -420,6 +422,7 @@ class General: """Common code between instruction formats and instruction patterns""" def __init__(self, name, lineno, base, fixb, fixm, udfm, fldm, flds): self.name = name + self.file = input_file self.lineno = lineno self.base = base self.fixedbits = fixb @@ -472,7 +475,7 @@ class Pattern(General): global translate_prefix ind = str_indent(i) arg = self.base.base.name - output(ind, '/* line ', str(self.lineno), ' */\n') + output(ind, '/* ', self.file, ':', str(self.lineno), ' */\n') if not extracted: output(ind, self.base.extract_name(), '(&u.f_', arg, ', insn);\n') for n, f in self.fields.items(): @@ -920,8 +923,9 @@ def build_tree(pats, outerbits, outermask): if innermask == 0: pnames = [] for p in pats: - pnames.append(p.name + ':' + str(p.lineno)) - error(pats[0].lineno, 'overlapping patterns:', pnames) + pnames.append(p.name + ':' + p.file + ':' + str(p.lineno)) + error_with_file(pats[0].file, pats[0].lineno, + 'overlapping patterns:', pnames) fullmask = outermask | innermask @@ -1012,10 +1016,11 @@ def main(): if len(args) < 1: error(0, 'missing input file') - input_file = args[0] - f = open(input_file, 'r') - parse_file(f) - f.close() + for filename in args: + input_file = filename + f = open(filename, 'r') + parse_file(f) + f.close() t = build_tree(patterns, 0, 0) prop_format(t)