From nobody Thu Nov 6 08:24:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15405780722891018.7686283727983; Fri, 26 Oct 2018 11:21:12 -0700 (PDT) Received: from localhost ([::1]:33703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG6jB-000840-S7 for importer@patchew.org; Fri, 26 Oct 2018 14:20:57 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =3D 'decode' re_ident =3D '[a-zA-Z][a-zA-Z0-9_]*' =20 =20 -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 =20 if lineno: - r =3D '{0}:{1}: error:'.format(input_file, lineno) + r =3D '{0}:{1}: error:'.format(file, lineno) elif input_file: - r =3D '{0}: error:'.format(input_file) + r =3D '{0}: error:'.format(file) else: r =3D 'error:' for a in args: @@ -197,6 +197,8 @@ def error(lineno, *args): os.remove(output_file) exit(1) =20 +def error(lineno, *args): + error_with_file(input_file, lineno, args) =20 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 =3D name + self.file =3D input_file self.lineno =3D lineno self.base =3D base self.fixedbits =3D fixb @@ -474,7 +477,7 @@ class Pattern(General): global translate_prefix ind =3D str_indent(i) arg =3D 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 =3D=3D 0: pnames =3D [] 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) =20 fullmask =3D outermask | innermask =20 @@ -1014,10 +1018,11 @@ def main(): =20 if len(args) < 1: error(0, 'missing input file') - input_file =3D args[0] - f =3D open(input_file, 'r') - parse_file(f) - f.close() + for filename in args: + input_file =3D filename + f =3D open(filename, 'r') + parse_file(f) + f.close() =20 t =3D build_tree(patterns, 0, 0) prop_format(t) --=20 2.17.2