[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] decodetree: Allow multiple input files
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH] decodetree: Allow multiple input files |
Date: |
Fri, 26 Oct 2018 19:19:52 +0100 |
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 <address@hidden>
---
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)
--
2.17.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH] decodetree: Allow multiple input files,
Richard Henderson <=