Skip to content

Lower bare and nested array constants in MIR import #182

Closed

Description

@niklebedenko

Problem

The MIR importer can lower pointer-to-array constants such as &[T; N], but bare array value constants such as const TABLE: [T; N] can still fail when the whole array materializes as an operand before runtime indexing. Nested arrays such as [[T; M]; N] are also not handled by the flat array construction path.

Why this matters

Static lookup tables are common in device code. The importer should handle the array constant shape generally rather than only the pointer-to-array variant.

Expected behavior

Bare array constants and pointer-to-array constants should share the same array value construction logic. Nested arrays should be recursively decomposed when their leaves are supported primitive scalar constants.

Acceptance criteria

  • Bare [T; N] constants lower to MirConstructArrayOp values.
  • Pointer-to-array constants keep working by wrapping the shared array value in MirRefOp.
  • Nested arrays of primitive scalar leaves lower recursively.
  • Existing byte-backed constants with valid padding do not regress.
  • A focused example covers bare, nested, and pointer-to-array constants.

Activity

  1. added
    codegen
    enhancement
    on Jun 17, 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

    codegenenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions