diff options
author | Toni Lönnberg <[email protected]> | 2018-11-15 16:04:34 +0200 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-03-28 04:26:30 +0000 |
commit | b6f7b40d816356de2f9d19a1c9ebbdf8c000164e (patch) | |
tree | 579ad0bf455306aa634e0fbd54adca5d466a7592 /src | |
parent | ce6faa57ae9317e2017d9f1d74496f7fd3504a88 (diff) |
intel/genxml: Only handle instructions meant for render engine when generating
headers
v2: Fixed the check for engine
v3: Changed engine into an argument given to the scripts
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/genxml/gen_bits_header.py | 18 | ||||
-rw-r--r-- | src/intel/genxml/gen_pack_header.py | 48 |
2 files changed, 59 insertions, 7 deletions
diff --git a/src/intel/genxml/gen_bits_header.py b/src/intel/genxml/gen_bits_header.py index aac49fb49e2..8c87edb2e55 100644 --- a/src/intel/genxml/gen_bits_header.py +++ b/src/intel/genxml/gen_bits_header.py @@ -266,6 +266,10 @@ class XmlParser(object): if name == 'genxml': self.gen = Gen(attrs['gen']) elif name in ('instruction', 'struct', 'register'): + if name == 'instruction' and 'engine' in attrs: + engines = set(attrs['engine'].split('|')) + if not engines & self.engines: + return self.start_container(attrs) elif name == 'field': self.start_field(attrs) @@ -304,6 +308,8 @@ def parse_args(): help="If OUTPUT is unset or '-', then it defaults to '/dev/stdout'") p.add_argument('--cpp-guard', type=str, help='If unset, then CPP_GUARD is derived from OUTPUT.') + p.add_argument('--engines', nargs='?', type=str, default='render', + help="Comma-separated list of engines whose instructions should be parsed (default: %(default)s)") p.add_argument('xml_sources', metavar='XML_SOURCE', nargs='+') pargs = p.parse_args() @@ -319,11 +325,21 @@ def parse_args(): def main(): pargs = parse_args() + engines = pargs.engines.split(',') + valid_engines = [ 'render', 'blitter', 'video' ] + if set(engines) - set(valid_engines): + print("Invalid engine specified, valid engines are:\n") + for e in valid_engines: + print("\t%s" % e) + sys.exit(1) + # Maps name => Container containers = {} for source in pargs.xml_sources: - XmlParser(containers).parse(source) + p = XmlParser(containers) + p.engines = set(engines) + p.parse(source) with open(pargs.output, 'wb') as f: f.write(TEMPLATE.render(containers=containers, guard=pargs.cpp_guard)) diff --git a/src/intel/genxml/gen_pack_header.py b/src/intel/genxml/gen_pack_header.py index 9675b4b4d52..f76ad325f03 100644 --- a/src/intel/genxml/gen_pack_header.py +++ b/src/intel/genxml/gen_pack_header.py @@ -3,6 +3,7 @@ from __future__ import ( absolute_import, division, print_function, unicode_literals ) +import argparse import ast import xml.parsers.expat import re @@ -545,6 +546,13 @@ class Parser(object): if name == "instruction": self.instruction = safe_name(attrs["name"]) self.length_bias = int(attrs["bias"]) + if "engine" in attrs: + self.instruction_engines = set(attrs["engine"].split('|')) + else: + # When an instruction doesn't have the engine specified, + # it is considered to be for all engines, so 'None' is used + # to signify that the instruction belongs to all engines. + self.instruction_engines = None elif name == "struct": self.struct = safe_name(attrs["name"]) self.structs[attrs["name"]] = 1 @@ -628,6 +636,9 @@ class Parser(object): def emit_instruction(self): name = self.instruction + if self.instruction_engines and not self.instruction_engines & self.engines: + return + if not self.length is None: print('#define %-33s %6d' % (self.gen_prefix(name + "_length"), self.length)) @@ -688,11 +699,36 @@ class Parser(object): self.parser.ParseFile(file) file.close() -if len(sys.argv) < 2: - print("No input xml file specified") - sys.exit(1) +def parse_args(): + p = argparse.ArgumentParser() + p.add_argument('xml_source', metavar='XML_SOURCE', + help="Input xml file") + p.add_argument('--engines', nargs='?', type=str, default='render', + help="Comma-separated list of engines whose instructions should be parsed (default: %(default)s)") + + pargs = p.parse_args() + + if pargs.engines is None: + print("No engines specified") + sys.exit(1) + + return pargs + +def main(): + pargs = parse_args() + + input_file = pargs.xml_source + engines = pargs.engines.split(',') + valid_engines = [ 'render', 'blitter', 'video' ] + if set(engines) - set(valid_engines): + print("Invalid engine specified, valid engines are:\n") + for e in valid_engines: + print("\t%s" % e) + sys.exit(1) -input_file = sys.argv[1] + p = Parser() + p.engines = set(engines) + p.parse(input_file) -p = Parser() -p.parse(input_file) +if __name__ == '__main__': + main() |