Skip to content

Implement LLVM layout and lowering for payload variants #408

Closed

Description

@LunaStev

Tracked by #347. Depends on the typed HIR variant frontend merged in #374 and should build on the typed-HIR backend boundary.

Required contract

Lower each concrete variant instantiation to a deterministic tagged representation containing:

  • a discriminant;
  • storage aligned and sized for the largest payload case;
  • payload field access driven by typed HIR metadata;
  • no representation overlap with integer enum.

Implement constructor lowering, discriminant tests, payload extraction/binding, exhaustive match control flow, assignment, return, parameters, and nested variants.

ABI boundary

The representation is initially Wave-internal. Existing frontend guards that reject direct extern(c)/export(c) exposure must remain until a stable external ABI is designed. Generic specializations may have different layouts.

Completion criteria

  • Payload-free and payload-bearing constructors produce valid LLVM IR.
  • Match lowering reads the tag and binds payloads safely.
  • Generic, nested, pointer-recursive, copy/assignment, parameter, and return cases are tested.
  • Layout assertions cover size, alignment, and discriminant stability for x86_64, AArch64, and RV64.
  • LLVM verification passes and invalid programs fail in the frontend, not by backend panic.
  • The temporary “variant reached LLVM” guards are removed only for supported paths.

Activity

  1. added
    enhancement
    help wanted
    feature request
    needs testing
    on Aug 28, 2026
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

    enhancementfeature requesthelp wantedneeds testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions