diff options
Diffstat (limited to 'src/intel/genxml/gen_pack_header.py')
-rw-r--r-- | src/intel/genxml/gen_pack_header.py | 48 |
1 files changed, 42 insertions, 6 deletions
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() |