Skip to main content

abi_alignment

Function abi_alignment 

Source
pub fn abi_alignment(
    ty: &AirType,
    types: &BTreeMap<TypeId, AirType>,
) -> Option<u64>
Expand description

Returns the ABI alignment in bytes for a type under System V AMD64 rules.

Uses a default pointer width of 8 bytes (64-bit). For target-aware layout, use abi_alignment_with_ptr.

Returns None for Opaque types or types that reference unknown TypeIds.

ยงAlignment rules

  • Pointer / Reference -> 8
  • Integer { bits } -> min(ceil(bits/8), 16).next_power_of_two() (at least 1)
  • Float { bits: 32 } -> 4
  • Float { bits: 64 } -> 8
  • Float { other } -> 8 (default for unusual float widths)
  • Vector { element, lanes } -> min(total_bytes.next_power_of_two(), 64)
  • Array { element, .. } -> alignment of element type
  • Struct { fields, .. } -> max of all field alignments
  • Void -> 1
  • Function { .. } -> 1 (function types have no meaningful alignment)
  • Opaque -> None