From 3c60285cd9fa24e46301ef46b7df53c0a65009a0 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 22 Jan 2023 20:46:58 +0300 Subject: [PATCH] svp64_utf_8_validation.py: convert labels to addresses --- .../test/algorithms/svp64_utf_8_validation.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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) -- 2.30.2