panfrost: Add "hex" type to GenXML

Although known fields wouldn't be given the type "hex", it is useful as
the default type for unknown fields while reverse-engineering, and as
such is used in the Valhall XML.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14063>
This commit is contained in:
Alyssa Rosenzweig 2021-11-18 22:41:22 -05:00 committed by Marge Bot
parent 72b3f21cd4
commit 6eb0770be8

View file

@ -370,11 +370,11 @@ class Field(object):
type = 'bool'
elif self.type == 'float':
type = 'float'
elif self.type == 'uint' and self.end - self.start > 32:
elif self.type in ['uint', 'hex'] and self.end - self.start > 32:
type = 'uint64_t'
elif self.type == 'int':
type = 'int32_t'
elif self.type in ['uint', 'uint/float', 'padded', 'Pixel Format']:
elif self.type in ['uint', 'hex', 'uint/float', 'padded', 'Pixel Format']:
type = 'uint32_t'
elif self.type in self.parser.structs:
type = 'struct ' + self.parser.gen_prefix(safe_name(self.type.upper()))
@ -530,7 +530,7 @@ class Group(object):
elif field.modifier[0] == "log2":
value = "util_logbase2({})".format(value)
if field.type in ["uint", "uint/float", "address", "Pixel Format"]:
if field.type in ["uint", "hex", "uint/float", "address", "Pixel Format"]:
s = "__gen_uint(%s, %d, %d)" % \
(value, start, end)
elif field.type == "padded":
@ -604,7 +604,7 @@ class Group(object):
args.append(str(fieldref.start))
args.append(str(fieldref.end))
if field.type in set(["uint", "uint/float", "address", "Pixel Format"]):
if field.type in set(["uint", "hex", "uint/float", "address", "Pixel Format"]):
convert = "__gen_unpack_uint"
elif field.type in self.parser.enums:
convert = "(enum %s)__gen_unpack_uint" % enum_name(field.type)
@ -656,8 +656,10 @@ class Group(object):
print(' fprintf(fp, "%*s{}: %s\\n", indent, "", {} ? "true" : "false");'.format(name, val))
elif field.type == "float":
print(' fprintf(fp, "%*s{}: %f\\n", indent, "", {});'.format(name, val))
elif field.type == "uint" and (field.end - field.start) >= 32:
elif field.type in ["uint", "hex"] and (field.end - field.start) >= 32:
print(' fprintf(fp, "%*s{}: 0x%" PRIx64 "\\n", indent, "", {});'.format(name, val))
elif field.type == "hex":
print(' fprintf(fp, "%*s{}: 0x%x\\n", indent, "", {});'.format(name, val))
elif field.type == "uint/float":
print(' fprintf(fp, "%*s{}: 0x%X (%f)\\n", indent, "", {}, uif({}));'.format(name, val, val))
elif field.type == "Pixel Format":