Skip to content

Add optional niche layouts #30

Description

@itsfuad

Goal

Introduce optional niche layouts while preserving tagged fallback and unchanged source semantics.

Current state

LLVM currently uses tagged {present, value} layout for all ?T, including ?*T. Some design docs still describe pointer niches as delivered; correct those status claims before adding optimization.

Scope

  • Keep one canonical niche decision at type-layout or backend boundary.
  • Add a niche only when invalid representation is compiler-known, target-correct, and ABI-safe.
  • Evaluate owned and raw pointer-like carriers first; consider integers, floats, structs, and arrays only with proved invalid bit patterns.
  • Preserve tagged fallback for every type without valid niche.
  • Keep construction, presence checks, payload access, equality, cleanup, and ABI behavior representation-independent.

Relationships

Validation

  • Canonical layout tests for every accepted and rejected niche.
  • HIR, MIR, and LLVM tests proving identical behavior for niche and tagged layouts.
  • 32-bit and 64-bit ABI coverage.
  • Runtime fixtures for none, present values, equality, payload access, and cleanup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlanguage-modelPeeper language model, ownership, pointer, optional, array/slice workruntime-loweringHIR/MIR/backend runtime lowering work

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions