From: Dmitry Selyutin Date: Sun, 22 Jan 2023 17:46:58 +0000 (+0300) Subject: svp64_utf_8_validation.py: convert labels to addresses X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b12a52421aa76c7ff33bce08c07932985dc14f64;p=openpower-isa.git svp64_utf_8_validation.py: convert labels to addresses --- diff --git a/src/openpower/test/algorithms/svp64_utf_8_validation.py b/src/openpower/test/algorithms/svp64_utf_8_validation.py index 933a9fd8..1a4247bb 100644 --- a/src/openpower/test/algorithms/svp64_utf_8_validation.py +++ b/src/openpower/test/algorithms/svp64_utf_8_validation.py @@ -302,9 +302,27 @@ def assemble(instructions, start_pc=0): pc += 8 else: pc += 4 - out_instructions.append(instr) + out_instructions.append((pc, instr)) + last_pc = pc + + for (idx, (pc, instr)) in enumerate(tuple(out_instructions)): + for (label, target) in labels.items(): + if label in instr: + if pc < target: + sign = "" + addr = (target - pc + 4) + else: + sign = "-" + addr = (pc - target - 4) + + origin = instr + instr = instr.replace(label, f"{sign}0x{addr:X}") + break + out_instructions[idx] = instr + for k, v in labels.items(): - out_instructions.append(f".set {k}, . - 0x{pc - v:X} # 0x{v:X}") + out_instructions.append(f".set {k}, . - 0x{last_pc - v:X} # 0x{v:X}") + return Program(list(SVP64Asm(out_instructions)), 0)