From 39d8b56c4aeaee3bbf53613de1d78c06bb75f09e Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Wed, 8 Jan 2025 12:40:57 +0100 Subject: [PATCH] pan/genxml: Emit struct details before pack function We are going to use packed structs in [un]pack next so we need those to be emitted before them. Signed-off-by: Mary Guillemard Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/lib/genxml/gen_pack.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/panfrost/lib/genxml/gen_pack.py b/src/panfrost/lib/genxml/gen_pack.py index fa637487b14..0ae386a38d9 100644 --- a/src/panfrost/lib/genxml/gen_pack.py +++ b/src/panfrost/lib/genxml/gen_pack.py @@ -636,13 +636,8 @@ class Parser(object): print('#define {}_SECTION_{}_OFFSET {}'.format(aggregate.name.upper(), section.name.upper(), section.offset)) print("") - def emit_pack_function(self, name, group): - print("static ALWAYS_INLINE void\n%s_pack(uint32_t * restrict cl,\n%sconst struct %s * restrict values)\n{" % - (name, ' ' * (len(name) + 6), name)) - - group.emit_pack_function() - - print("}\n\n") + def emit_struct_detail(self, name, group): + group.get_length() # Should be a whole number of words assert((self.group.length % 4) == 0) @@ -652,6 +647,14 @@ class Parser(object): print('#define {} {}'.format (name + "_ALIGN", self.group.align)) print('struct {}_packed {{ uint32_t opaque[{}]; }};'.format(name.lower(), self.group.length // 4)) + def emit_pack_function(self, name, group): + print("static ALWAYS_INLINE void\n%s_pack(uint32_t * restrict cl,\n%sconst struct %s * restrict values)\n{" % + (name, ' ' * (len(name) + 6), name)) + + group.emit_pack_function() + + print("}\n\n") + def emit_unpack_function(self, name, group): print("static inline void") print("%s_unpack(const uint32_t * restrict cl,\n%sstruct %s * restrict values)\n{" % @@ -675,6 +678,7 @@ class Parser(object): self.emit_template_struct(self.struct, self.group) self.emit_header(name) if self.no_direct_packing == False: + self.emit_struct_detail(self.struct, self.group) self.emit_pack_function(self.struct, self.group) self.emit_unpack_function(self.struct, self.group) self.emit_print_function(self.struct, self.group)