Re: [PATCH v2 3/4] arm64/sysreg: Sort sysreg by encoding

From: Will Deacon
Date: Thu Mar 13 2025 - 17:58:52 EST


On Wed, Jan 15, 2025 at 04:25:57PM +0000, James Clark wrote:
> It's mostly been sorted by sysreg encoding, but not 100%. Sort it so
> new entries can be added without wondering where to put them.
>
> The following python script was used to sort, keeping the top level
> SysregFields and comments next to their current Sysreg entries by
> splitting on "EndSysreg":
>
> # cat arch/arm64/tools/sysreg | python3 sort.py > sorted-sysreg
> import sys, re
> def key(block):
> reg = r"\w+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)"
> match = re.search(reg, block)
> sort_val = ''.join(f"{int(n):02d}" for n in match.groups())
> return (sort_val, block)
> sysreg = sys.stdin.read().split("\nEndSysreg\n")[:-1]
> sysreg = sorted(sysreg, key=key)
> print("\nEndSysreg\n".join(sysreg) + "\nEndSysreg")
>
> Tested by diffing sorted outputs:
>
> $ diff <(sort arch/arm64/include/generated/asm/sysreg-defs.h) \
> <(sort before-sysreg-defs.h) -s
>
> Files /dev/fd/63 and /dev/fd/62 are identical
>
> Signed-off-by: James Clark <james.clark@xxxxxxxxxx>
> ---
> arch/arm64/tools/sysreg | 1006 +++++++++++++++++++--------------------
> 1 file changed, 503 insertions(+), 503 deletions(-)

This looks like unnecessary pain for backporting...

What do we gain from sorting this?

Will