Skip to content

buffer.pack

buffer dialect

Lay out simultaneously live physical byte ranges in one dense slab. Ranges retain operand order, begin at offsets satisfying their minimum alignments, and never alias. The total byte length is rounded up to the greatest range alignment so the result can be used as a repeatable record stride. Byte lengths may remain dynamic through specialization. Allocation lifetime packing is a separate compiler responsibility and must not be encoded with this operation.

Operation contract

Property Value
Semantic phase executable
Traits Pure

Signature

Kind Name Type Cardinality Description
Operand byte_lengths offset variadic Physical byte length of each range in slab order.
Result total_byte_length offset required Aligned physical byte length of the complete slab.
Result byte_offsets offset variadic Slab-relative byte offset of each range.
Attribute minimum_alignments i64_array required Positive power-of-two minimum byte alignment for each range.

Verification constraints

  • VariadicValuesMatch(byte_lengths, byte_offsets)
  • SameType(total_byte_length, byte_offsets)

Examples

%total, %header_offset, %payload_offset = buffer.pack [align(16) %header_bytes, align(256) %payload_bytes] : offset