Skip to content

Refactor MIR field/index access to projection places #32

Description

@itsfuad

Summary

MIR must keep storage projection separate from value access before arrays, slices, maps, and deeper addressable composite paths land.

First slice is implemented in #34:

  • replaces tactical FieldAddr with ProjectField
  • replaces StoreField with generic pointer Store
  • adds explicit Load for pointer-backed field reads
  • makes @box.field, box.field, and box.field = value share field projection logic

Problem

MIR used to mix place computation and value access:

  • Field was value-producing.
  • StoreField was a special write path.
  • Address-of field needed a one-off FieldAddr bridge to avoid LLVM pointer-to-copy temps.

That shape does not scale to arrays, slices, maps, nested fields, deref/index chains, or future addressability rules.

Direction

Continue pivoting MIR to projection/place form:

  • represent storage locations as projections, e.g. field, index, deref/local base
  • make reads explicit with Load(place)
  • make writes explicit with Store(place, value)
  • make address-of reuse place/projection computation instead of one-off address nodes

Current field slice spelling:

  • box.field through pointer -> Load(ProjectField(box, field))
  • @box.field -> ProjectField(box, field)
  • box.field = value -> Store(ProjectField(box, field), value)

Hard Line

Do not add future one-off address nodes:

  • no IndexAddr
  • no SliceAddr
  • no MapAddr

Arrays, slices, and maps must extend the projection/place path instead.

Remaining Acceptance Criteria

  • Add non-field projections needed by arrays/slices before indexing lands.
  • Keep backend GEP/load/store logic shared instead of duplicated by composite kind.
  • Make map element addressability policy explicit before map lowering lands.
  • Decide whether MIR keeps projection nodes directly or grows a fuller Place model.

PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions