Mesa (main): pan/gen_pack: Generalize the PREFIX() trick
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Aug 26 08:52:45 UTC 2021
Module: Mesa
Branch: main
Commit: 188a2d369188a616b9724e4865fe125053c417b1
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=188a2d369188a616b9724e4865fe125053c417b1
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Wed Jul 28 11:01:22 2021 +0200
pan/gen_pack: Generalize the PREFIX() trick
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12551>
---
src/panfrost/lib/gen_pack.py | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/src/panfrost/lib/gen_pack.py b/src/panfrost/lib/gen_pack.py
index f6a20fdcf74..d0b204e91bc 100644
--- a/src/panfrost/lib/gen_pack.py
+++ b/src/panfrost/lib/gen_pack.py
@@ -132,48 +132,50 @@ __gen_unpack_padded(const uint8_t *restrict cl, uint32_t start, uint32_t end)
return (2*odd + 1) << shift;
}
+#define PREFIX1(A) MALI_ ## A
+#define PREFIX2(A, B) MALI_ ## A ## _ ## B
+#define PREFIX4(A, B, C, D) MALI_ ## A ## _ ## B ## _ ## C ## _ ## D
+
#define pan_prepare(dst, T) \\
- *(dst) = (struct MALI_ ## T){ MALI_ ## T ## _header }
+ *(dst) = (struct PREFIX1(T)){ PREFIX2(T, header) }
#define pan_pack(dst, T, name) \\
- for (struct MALI_ ## T name = { MALI_ ## T ## _header }, \\
+ for (struct PREFIX1(T) name = { PREFIX2(T, header) }, \\
*_loop_terminate = (void *) (dst); \\
__builtin_expect(_loop_terminate != NULL, 1); \\
- ({ MALI_ ## T ## _pack((uint32_t *) (dst), &name); \\
+ ({ PREFIX2(T, pack)((uint32_t *) (dst), &name); \\
_loop_terminate = NULL; }))
#define pan_unpack(src, T, name) \\
- struct MALI_ ## T name; \\
- MALI_ ## T ## _unpack((uint8_t *)(src), &name)
+ struct PREFIX1(T) name; \\
+ PREFIX2(T, unpack)((uint8_t *)(src), &name)
#define pan_print(fp, T, var, indent) \\
- MALI_ ## T ## _print(fp, &(var), indent)
-
-#define PREFIX(A, B, C, D) MALI_ ## A ## _ ## B ## _ ## C ## _ ## D
+ PREFIX2(T, print)(fp, &(var), indent)
#define pan_section_offset(A, S) \\
- PREFIX(A, SECTION, S, OFFSET)
+ PREFIX4(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 (PREFIX(A, SECTION, S, TYPE) name = { PREFIX(A, SECTION, S, header) }, \\
+ for (PREFIX4(A, SECTION, S, TYPE) name = { PREFIX4(A, SECTION, S, header) }, \\
*_loop_terminate = (void *) (dst); \\
__builtin_expect(_loop_terminate != NULL, 1); \\
- ({ PREFIX(A, SECTION, S, pack) (pan_section_ptr(dst, A, S), &name); \\
+ ({ PREFIX4(A, SECTION, S, pack) (pan_section_ptr(dst, A, S), &name); \\
_loop_terminate = NULL; }))
#define pan_section_unpack(src, A, S, name) \\
- MALI_ ## A ## _SECTION_ ## S ## _TYPE name; \\
- MALI_ ## A ## _SECTION_ ## S ## _unpack(pan_section_ptr(src, A, S), &name)
+ PREFIX4(A, SECTION, S, TYPE) name; \\
+ PREFIX4(A, SECTION, S, unpack)(pan_section_ptr(src, A, S), &name)
#define pan_section_print(fp, A, S, var, indent) \\
- MALI_ ## A ## _SECTION_ ## S ## _print(fp, &(var), indent)
+ PREFIX4(A, SECTION, S, print)(fp, &(var), indent)
#define pan_merge(packed1, packed2, type) \
do { \
- for (unsigned i = 0; i < (MALI_ ## type ## _LENGTH / 4); ++i) \
+ for (unsigned i = 0; i < (PREFIX2(type, LENGTH) / 4); ++i) \
packed1.opaque[i] |= packed2.opaque[i]; \
} while(0)
More information about the mesa-commit
mailing list