diff options
author | Eric Anholt <[email protected]> | 2016-12-19 11:11:44 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2017-08-18 11:56:58 -0700 |
commit | 14fe9fd3f7e39ccad316ef2be17fea0cc1aaad73 (patch) | |
tree | 9c7146ca29f0ee3f7c92819364ddfe4516b91ffa /src | |
parent | 9caba0f16fc6a1a89effbeb36ec76d58ade58fe1 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/broadcom/cle/gen_pack_header.py | 27 |
1 files 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) |