Commit 1a804895 authored by Christian Gmeiner's avatar Christian Gmeiner Committed by Marge Bot
Browse files

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's avatarChristian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Rob Clark's avatarRob Clark <robdclark@chromium.org>
Part-of: <mesa/mesa!11321>
parent a6b82d1c
......@@ -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)
{
......
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment