Skip to content

ArmPattern /d: decode B.cond, CBZ/CBNZ and the new load/store forms #11

Closed

Description

@scizzydo

get_result in Pattern.hpp only decodes B/BL, ADR/ADRP (+ ADD and LDR/LDRH/STR followers), lone LDR/LDRH/STR offsets, MOVZ and ADD/SUB. With X on anything else, find() throws std::logic_error("Failed to decode instruction with defined functions").

  • Branch targets: X B.EQ #?, X CBZ X0, #?, X CBNZ ... (imm19), and TBZ/TBNZ (imm14) once those are encoded.
  • ADRP followers: ADRP X8, ... + LDRB/LDRSW/STRB/STRH/LDUR [X8,#lo] (byte/flag globals are very common). Today only LDR/LDRH/STR end the ADRP chain with their offset.
  • Lone-offset values for the same forms.
  • While there: saved_offset += (offset < 0 ? -offset : offset) adds the absolute value of a negative (pre/post-index) offset; check whether that's intended.

Tests: deref_synthetic (everywhere) and deref_relocated (Apple arm64) in tests/test_arm.cpp.

🤖 Generated with Claude Code

Activity

  1. scizzydo commented on Oct 12, 2026

    @scizzydo
    OwnerAuthor

    Addressed in #12. Most of this had already landed in #4; this PR finishes it:

    • Branch targets: B.cond, CBZ/CBNZ and literal LDR were already decoded; TBZ/TBNZ (imm14) are added. The decoder is renamed a64_decode_branch_imm.
    • ADRP followers: LDRB/LDRSW/STRB/STRH/LDUR were already handled by a64_decode_load_store (covered in deref_synthetic). Added: FP/SIMD loads (LDR D0/Q1, LDUR S2 with Q scaled by 16), plus FP literal loads.
    • Lone-offset values: the same decoder, so it covers the same forms.
    • saved_offset: the code already adds the signed offset (saved_offset += offset), so negative pre-index offsets subtract; covered by the LDR X0, [X8,#-8]! follower test.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions