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: 989718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="A/V8WMBl"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42hXNT3h4Jz9s9h for ; Sat, 27 Oct 2018 05:20:24 +1100 (AEDT) Received: from localhost ([::1]:33698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG6ia-0007in-Rc for incoming@patchwork.ozlabs.org; Fri, 26 Oct 2018 14:20:20 -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-Google-Smtp-Source: AJdET5fl+1MNrLKKewYXnR2mSAza9yKk+ZaI92rG5fSpnyQZCswWA4so1PwjfpQuaBPOl8YGMIyT6Q== 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+incoming=patchwork.ozlabs.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(-) 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)