jon.recoil.org

Module DSL.Validated_mem_offset

A validated memory offset that is guaranteed to be encodable in ARM64 load/store immediate addressing modes. The validation ensures:

type t
val create : scale:int -> offset:int -> t option

Validate an offset for use with load/store of the given scale (access size in bytes: 1, 2, 4, 8, or 16). Returns Some t if the offset can be encoded, None otherwise.

val to_operand : base:[ `GP of [< `X | `SP ] ] Reg.t -> t -> [ `Mem of [> `Offset_twelve_unsigned_scaled | `Offset_nine_signed_unscaled ] ] Operand.t

Convert to a memory operand. Never fails since the offset was validated at construction time.

val equal : t -> t -> bool

Equality comparison.

val offset : t -> int

The byte offset.

val scale : t -> int

The scale used for validation.

val is_valid : scale:int -> offset:int -> bool

Check if an offset can be encoded for the given scale.

val probe_semaphore_offset : t

Pre-validated offset for probe semaphore access (2-byte at offset 2).