Rewrote align_registers to accept any number of registers.

This commit is contained in:
Rhinemann 2023-06-27 17:49:03 +03:00
parent 32605e4b49
commit c20aef323d
1 changed files with 10 additions and 5 deletions

View File

@ -115,9 +115,14 @@ def align_registers(first_register: BasicRegister, second_register: BasicRegiste
first_size = len(first_register)
second_size = len(second_register)
required_size = max(first_size, second_size)
def align_registers(*args: BasicRegister) -> tuple[BasicRegister, ...]:
"""
Aligns registers by the length of the bigger one.
if first_size != second_size:
return first_register.adjusted_by_size(required_size), second_register.adjusted_by_size(required_size)
else:
return first_register, second_register
:param args: Basic registers to align.
:return: Aligned registers.
:rtype: tuple[BasicRegister, ...]
"""
required_size: int = max(map(len, args))
return tuple(reg.adjusted_by_size(required_size) for reg in args)