freedreno/registers: Fix encoding fields in 64b registers

This was already broken for BINDLESS_BASE, but we didn't notice it
because we weren't using the builders. We have to cast fields that we OR
in, and we need to return uint64_t from the legacy field functions.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36590>
This commit is contained in:
Connor Abbott 2025-05-27 18:14:11 -04:00 committed by Marge Bot
parent ba427bc274
commit 3f70b05784

View file

@ -189,12 +189,13 @@ class Bitset(object):
print(" return (struct fd_reg_pair) {")
print(" .reg = (uint32_t)%s," % reg.reg_offset())
print(" .value =")
cast = "(uint64_t)" if reg.bit_size == 64 else ""
for f in self.fields:
if f.type in [ "address", "waddress" ]:
continue
else:
type, val = f.ctype("fields.%s" % field_name(reg, f))
print(" (%-40s << %2d) |" % (val, f.low))
print(" (%s%-40s << %2d) |" % (cast, val, f.low))
value_name = "dword"
if reg.bit_size == 64:
value_name = "qword"
@ -264,7 +265,9 @@ class Bitset(object):
(prefix, prefix, prefix, skip))
def dump(self, is_deprecated, prefix=None):
def dump(self, is_deprecated, prefix=None, reg=None):
if not reg:
return
if prefix is None:
prefix = self.name
if self.reg and self.reg.bit_size == 64:
@ -283,14 +286,16 @@ class Bitset(object):
elif f.type == "boolean" or (f.type is None and f.low == f.high):
tab_to("#define %s" % name, "0x%08x" % (1 << f.low))
else:
tab_to("#define %s__MASK" % name, "0x%08x" % mask(f.low, f.high))
tab_to("#define %s__MASK" % name, "0x%08xull" % mask(f.low, f.high))
tab_to("#define %s__SHIFT" % name, "%d" % f.low)
type, val = f.ctype("val")
ret_type = "uint64_t" if reg.bit_size == 64 else "uint32_t"
cast = "(uint64_t)" if reg.bit_size == 64 else ""
print("static inline uint32_t %s(%s val)\n{" % (name, type))
print("static inline %s %s(%s val)\n{" % (ret_type, name, type))
if f.shr > 0:
print("\tassert(!(val & 0x%x));" % mask(0, f.shr - 1))
print("\treturn ((%s) << %s__SHIFT) & %s__MASK;\n}" % (val, name, name))
print("\treturn (%s(%s) << %s__SHIFT) & %s__MASK;\n}" % (cast, val, name, name))
print()
class Array(object):
@ -437,7 +442,7 @@ class Reg(object):
print("static inline%s uint32_t REG_%s(%s) { return 0x%08x + %s; }" % (depcrstr, self.full_name, proto, offset, strides))
if self.bitset.inline:
self.bitset.dump(is_deprecated, self.full_name)
self.bitset.dump(is_deprecated, self.full_name, self)
print("")
def dump_pack_struct(self, is_deprecated):