From 14fe9fd3f7e39ccad316ef2be17fea0cc1aaad73 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Dec 2016 11:11:44 -0800 Subject: [PATCH] broadcom/genxml: Emit code for default headers for structs as well. In the vc5 NIR backend, I want to use the XML code-generation to set up pack/unpack of structs for the texture uniforms, and setting up the unpacked copy needs a default header. --- src/broadcom/cle/gen_pack_header.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/broadcom/cle/gen_pack_header.py b/src/broadcom/cle/gen_pack_header.py index 1ebeec7a794..3ec189895a3 100644 --- a/src/broadcom/cle/gen_pack_header.py +++ b/src/broadcom/cle/gen_pack_header.py @@ -478,13 +478,7 @@ class Parser(object): print("}\n#endif\n") - def emit_packet(self): - name = self.packet - - assert(self.group.fields[0].name == "opcode") - print('#define %-33s %6d' % - (name + "_opcode", self.group.fields[0].default)) - + def emit_header(self, name): default_fields = [] for field in self.group.fields: if not type(field) is Field: @@ -493,11 +487,18 @@ class Parser(object): continue default_fields.append(" .%-35s = %6d" % (field.name, field.default)) - if default_fields: - print('#define %-40s\\' % (name + '_header')) - print(", \\\n".join(default_fields)) - print('') + print('#define %-40s\\' % (name + '_header')) + print(", \\\n".join(default_fields)) + print('') + + def emit_packet(self): + name = self.packet + + assert(self.group.fields[0].name == "opcode") + print('#define %-33s %6d' % + (name + "_opcode", self.group.fields[0].default)) + self.emit_header(name) self.emit_template_struct(self.packet, self.group) self.emit_pack_function(self.packet, self.group) self.emit_unpack_function(self.packet, self.group) @@ -516,10 +517,8 @@ class Parser(object): def emit_struct(self): name = self.struct - # Emit an empty header define so that we can use the CL pack functions - # with structs. - print('#define ' + name + '_header') + self.emit_header(name) self.emit_template_struct(self.struct, self.group) self.emit_pack_function(self.struct, self.group) self.emit_unpack_function(self.struct, self.group) -- 2.30.2