panfrost: Add a concatenation macro for genxml
authorAlyssa Rosenzweig <alyssa@collabora.com>
Tue, 13 Jul 2021 16:02:20 +0000 (12:02 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 23 Jul 2021 20:12:18 +0000 (20:12 +0000)
This is safer, since it allows the thing being concatenated to itself be
an expande macro, which we'll use as a stopgap to construct tiler jobs
with unified code. It's also a bit more readable, I think.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11851>

src/panfrost/lib/gen_pack.py

index 72cc644..f6a20fd 100644 (file)
@@ -149,17 +149,19 @@ __gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end)
 #define pan_print(fp, T, var, indent)                   \\
         MALI_ ## T ## _print(fp, &(var), indent)
 
+#define PREFIX(A, B, C, D) MALI_ ## A ## _ ## B ## _ ## C ## _ ## D
+
 #define pan_section_offset(A, S) \\
-        MALI_ ## A ## _SECTION_ ## S ## _OFFSET
+        PREFIX(A, SECTION, S, OFFSET)
 
 #define pan_section_ptr(base, A, S) \\
         ((void *)((uint8_t *)(base) + pan_section_offset(A, S)))
 
 #define pan_section_pack(dst, A, S, name)                                                         \\
-   for (MALI_ ## A ## _SECTION_ ## S ## _TYPE name = { MALI_ ## A ## _SECTION_ ## S ## _header }, \\
+   for (PREFIX(A, SECTION, S, TYPE) name = { PREFIX(A, SECTION, S, header) }, \\
         *_loop_terminate = (void *) (dst);                                                        \\
         __builtin_expect(_loop_terminate != NULL, 1);                                             \\
-        ({ MALI_ ## A ## _SECTION_ ## S ## _pack(pan_section_ptr(dst, A, S), &name);              \\
+        ({ PREFIX(A, SECTION, S, pack) (pan_section_ptr(dst, A, S), &name);              \\
            _loop_terminate = NULL; }))
 
 #define pan_section_unpack(src, A, S, name)                               \\