From 84842db4b2b2f30c0f0bb6b50113d13f05674c52 Mon Sep 17 00:00:00 2001 From: Benjamin Oldenburg Date: Sat, 21 Mar 2026 00:52:53 +0700 Subject: [PATCH] refactor: replace load instruction opcodes with symbolic constants (Phase 2.2 step 1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace hardcoded opcodes in arm64_ldrx(): - 0x39400000 → ARM64_LDR_B - 0x38400000 → ARM64_LDUR_B - 0x38206800 → ARM64_LDR_B_REG All tests pass. --- arm64-gen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arm64-gen.c b/arm64-gen.c index 7eda2f2d..ca4b0232 100644 --- a/arm64-gen.c +++ b/arm64-gen.c @@ -331,14 +331,14 @@ static void arm64_ldrx(int sg, int sz_, int dst, int bas, uint64_t off) if (sz >= 2) sg = 0; if (!(off & ~scaled_mask)) - o(0x39400000 | dst | bas << 5 | off << (10 - sz) | + o(ARM64_LDR_B | dst | bas << 5 | off << (10 - sz) | (uint32_t)!!sg << 23 | sz << 30); // ldr(*) x(dst),[x(bas),#(off)] else if (off < 256 || -off <= 256) - o(0x38400000 | dst | bas << 5 | (off & 511) << 12 | + o(ARM64_LDUR_B | dst | bas << 5 | (off & 511) << 12 | (uint32_t)!!sg << 23 | sz << 30); // ldur(*) x(dst),[x(bas),#(off)] else { arm64_movimm(30, off); // use x30 for offset - o(0x38206800 | dst | bas << 5 | (uint32_t)30 << 16 | + o(ARM64_LDR_B_REG | dst | bas << 5 | (uint32_t)30 << 16 | (uint32_t)(!!sg + 1) << 22 | sz << 30); // ldr(*) x(dst),[x(bas),x30] } }