diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2021-05-28 10:00:36 +0200 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-09-21 20:25:31 +0000 |
commit | 1a8048954dcdc4257bff1cc9b6d6bc9b6b1cce1b (patch) | |
tree | ead0d48db0149b6945c9e0f72fcabb079933c515 | |
parent | a6b82d1c8c40a9aea5f3ae93327c0d72b78fb661 (diff) |
freedreno/isa: generate marcos used for printf(..)
Generate correct BITSET_FORMAT and BITSET_VALUE macros based
on the maximum needed ISA bits.
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11321>
-rw-r--r-- | src/freedreno/isa/decode.py | 3 | ||||
-rw-r--r-- | src/freedreno/isa/isa.py | 22 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/freedreno/isa/decode.py b/src/freedreno/isa/decode.py index 6bcc48bafc9..15580b25e42 100644 --- a/src/freedreno/isa/decode.py +++ b/src/freedreno/isa/decode.py @@ -226,6 +226,9 @@ typedef struct { } bitmask_t; +#define BITSET_FORMAT ${isa.format()} +#define BITSET_VALUE(v) ${isa.value()} + static inline uint64_t bitmask_to_uint64_t(bitmask_t mask) { diff --git a/src/freedreno/isa/isa.py b/src/freedreno/isa/isa.py index 87e0c6badaf..8f5dfe07dcf 100644 --- a/src/freedreno/isa/isa.py +++ b/src/freedreno/isa/isa.py @@ -492,3 +492,25 @@ class ISA(object): # TODO we should probably be able to look at the contexts where # an expression is evaluated and verify that it doesn't have any # {VARNAME} references that would be unresolved at evaluation time + + def format(self): + ''' Generate format string used by printf(..) and friends ''' + parts = [] + words = self.bitsize / 32 + + for i in range(int(words)): + parts.append('%08x') + + fmt = ''.join(parts) + + return f"\"{fmt[1:]}\"" + + def value(self): + ''' Generate format values used by printf(..) and friends ''' + parts = [] + words = self.bitsize / 32 + + for i in range(int(words) - 1, -1, -1): + parts.append('v[' + str(i) + ']') + + return ', '.join(parts) |