From patchwork Fri Oct 26 18:19:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 149601 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1097870ljp; Fri, 26 Oct 2018 11:21:27 -0700 (PDT) X-Google-Smtp-Source: AJdET5eFVGZ/xXHmCvLwpO8HM8r4TxRXFlc0VVqiKWbkAObw6LhDujVfl2/JpmZt6f8fWdvnx/Ws X-Received: by 2002:a0c:87b7:: with SMTP id 52mr4287998qvj.8.1540578087303; Fri, 26 Oct 2018 11:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540578087; cv=none; d=google.com; s=arc-20160816; b=BQ0ae96yUc09vebPAsZ/fRU52+nJAL//aL2GKa4yJXVsEvlzVWiJsXJbe82CWy6JEX cow5fPZu59T9BEdr1zp1XrSGFrzMEx7cc+VOswxWD/axv17jl2rxL+Jq4pppmeA1LXZR IlA5fErnkpaZBFAT6Q11JOz8pe/ihGQnPTtdsdbSSDfpMhfQJ+niRCRNbYDhHnKuGCp3 X2lHG02EjUcXOkiNItuhXygGnjIRQxnq11RM6GS5Tl72+mmNrIKbc4+OVlLkuQBM3Ml1 xhT3NLUw2fGh4rK3geNG+H/az0RynIuH0Ic0YBg3c+Xrisjxic9nDJnr0cMZtokZRlLP vpTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:to:from :dkim-signature; bh=jGvP9n9GYCuSzlHJoE9+SsrV9IT7ZnYdfPNZZJgaW/4=; b=G5xmeaxGYmYeUO7J3meM1dvCAf3HjNH41BbGpkoVQWVxrguDOtLo/uTt8FJc6YBoSn DU3smyT5dv+9D9wOuJ5Bu8UJSAq+d/AdVtoNx56B3wkhWOOi9+Wcqkd6psByo6vH4jW/ ZnbG7T01+EWLVS3/cjR00LG+bJ0mGJDb2PgMC65Sy2TC52n4yqThLOrvJEw6BAIBhSTh dvKGCmeOdHOBjT/KZpTk2INhxn1VenWEF5hfEXx/z034la5b7MXbJitlPgSwL090PZGU XRbEG2rE7kOmZX8oZW9/ui6BU14Mp/hJhhOWLS8pdId0ExwFDRQqbYqXH1oUtXXuU/S8 otHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="A/V8WMBl"; 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 v1-v6si9358417qto.109.2018.10.26.11.21.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 26 Oct 2018 11:21:27 -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="A/V8WMBl"; 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]:33705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG6jc-0008Mp-Ol for patch@linaro.org; Fri, 26 Oct 2018 14:21:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG6iH-0007ia-HB for qemu-devel@nongnu.org; Fri, 26 Oct 2018 14:20:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gG6iE-0000Iu-By for qemu-devel@nongnu.org; Fri, 26 Oct 2018 14:20:01 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:41774) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gG6iD-0000H6-VH for qemu-devel@nongnu.org; Fri, 26 Oct 2018 14:19:58 -0400 Received: by mail-wr1-x443.google.com with SMTP id x12-v6so2254013wrw.8 for ; Fri, 26 Oct 2018 11:19: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; bh=jGvP9n9GYCuSzlHJoE9+SsrV9IT7ZnYdfPNZZJgaW/4=; b=A/V8WMBlNAoF5pRMaMmhtfrnl1qXjZzYfV4vq3Raki5l8fGbLqSbzA7g1EH2y9L+st Qi+tXwHywkFZhQ6QP72X19nekRVmQeZfWsj76Bks4LgPdYTfvlqmUla381RrI+G09NpK gjy6x1W7XcjM6i5wnABl6iPBSUXC2LKlxB2Zk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jGvP9n9GYCuSzlHJoE9+SsrV9IT7ZnYdfPNZZJgaW/4=; b=As2v1y7yJgWmWvITtRj1dN5ieAcYQi3vlCgAzK+ts3DvEjT9TjOUz5wWTkZNM0t+YG GUr/68IT/sxyciHndUCThn/9dRql2dQSADicBe+p+sbBz5vG2sEYMrYLWw/7hjd4NkjA SHt5ZttNmjgecvmQpGVfcFP3z1jad+SXuuBmIQdocGhR2sUQcn8Kal/1HIdc7NTETObb wXKWxzBML/Q+d46o0qUPOu9VsvO4HVw55++NTyBhxm/JpgpUk52grwxfBOu91kF3rpMO FJ9X9bS9QEJIVWAbY5lwlp2NwED1tiI/BN+HFmXz1xGOB67svsXyTxt2amfNIzm1oWI8 RYLQ== X-Gm-Message-State: AGRZ1gL2sS0rBjx2hAGKpPWznTwugpdLCBLdyxIAeysl8qjbCTeriDD4 FVnLnWxSWq7CX0CIfwjSAHoRP65x2l4= X-Received: by 2002:a5d:53d1:: with SMTP id a17-v6mr6255707wrw.41.1540577996297; Fri, 26 Oct 2018 11:19:56 -0700 (PDT) Received: from cloudburst.twiddle.net.ASUS (host86-153-40-62.range86-153.btcentralplus.com. [86.153.40.62]) by smtp.gmail.com with ESMTPSA id z4-v6sm6912222wmz.14.2018.10.26.11.19.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Oct 2018 11:19:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 26 Oct 2018 19:19:52 +0100 Message-Id: <20181026181952.8255-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH] 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 --- Bastian, I think this makes splitting the decode file even nicer. No temp file in the build tree, and better error messages. The makefile fragment now becomes e.g. target/riscv/decode_insn32.inc.c: $(decode32-y) $(DECODETREE) $(call quiet-command, \ $(PYTHON) $(DECODETREE) -o $@ --decode decode_insn32 $(decode32-y), \ "GEN", $(TARGET_DIR)$@) Also, I think that the rv64g insns should be in insn32-64.decode, mirroring insn16-64.decode, and leaving insn64.decode free for an actual 64-bit instruction word, as aluded to in the "Extending RISC-V" section of the manual. I've included this with the other two pending decodetree patches at https://github.com/rth7680/qemu.git decodetree r~ --- scripts/decodetree.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) -- 2.17.2 diff --git a/scripts/decodetree.py b/scripts/decodetree.py index c0bb447095..f60f1b0ab6 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -177,15 +177,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: @@ -197,6 +197,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 @@ -422,6 +424,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 @@ -474,7 +477,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(): @@ -922,8 +925,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 @@ -1014,10 +1018,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)