Skip to content

Fold typed-array attribute constraints into static definition emission - #130

Merged
jonathanvdc merged 4 commits into
mainfrom
copilot/fold-typed-array-attribute-constraints
Apr 14, 2026
Merged

jonathanvdc merged 4 commits into
mainfrom
copilot/fold-typed-array-attribute-constraints

Conversation

Copilot AI commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Typed-array attribute constraints were still emitted through a special generator path with per-constraint assembly-format shims. This changes them to the same static AttributeConstraintDefinition model used by other storage-backed constraints, backed by one reusable runtime typed-array assembly format.

  • Runtime assembly format unification

    • Replaced the generic TypedArrayAttributeAssemblyFormat<TElement> with a single reusable non-generic TypedArrayAttributeAssemblyFormat.
    • Kept behavior identical: parse [ ... ], bind via ArrayAttrConstraintHelpers.BindFromSyntax(...), print from reusable ArrayAttributeValueSyntax or rebuild from ArrayAttr.Value.
  • Generator strategy alignment

    • Updated TypedArrayConstraintCodeStrategy to emit a normal static constraint definition assembly-format expression:
      • new global::MLIR.Dialects.Attributes.Collections.TypedArrayAttributeAssemblyFormat()
    • Typed-array constraints now follow the same static-definition emission path as dictionary/type/unit/elements constraints.
  • Dead typed-array emission path removal

    • Removed AttributeConstraintEmissionKind.TypedArray.
    • Removed AttributeConstraintEmitter.EmitTypedArrayConstraint(...).
    • Removed AttributeConstraintEmitter.GetTypedArrayElementTypeName(...).
    • Eliminated generation of per-constraint ...AssemblyFormat : TypedArrayAttributeAssemblyFormat<TElement> classes.
  • Typed property overlays preserved

    • No changes to AttrModel overlay behavior for typed operation properties (csharpStorageType, csharpReturnType, csharpConvertFromStorage, csharpConstBuilderCall).
    • Typed arrays continue to project as strongly typed properties (e.g. IReadOnlyList<int>, IReadOnlyList<string>, etc.) via ArrayAttrConstraintHelpers.
  • Generator test strengthened

    • Extended TypedArrayAttrConstraintsAreGeneratedAsConstraintOnlyStaticClasses to assert reusable runtime typed-array format usage and absence of per-constraint typed-array assembly-format class emission.

Example emitted shape now used by typed-array constraints:

public static class I32ArrayAttrConstraintAttributeValue
{
    public static AttributeConstraintDefinition AttributeConstraintDefinition { get; } =
        new AttributeConstraintDefinition(
            "I32ArrayAttr",
            new global::MLIR.Dialects.Attributes.Collections.TypedArrayAttributeAssemblyFormat());
}

Copilot AI and others added 2 commits April 14, 2026 17:40
@jonathanvdc
jonathanvdc marked this pull request as ready for review April 14, 2026 17:44
Agent-Logs-Url: https://github.com/jonathanvdc/MLIR.NET/sessions/a5fb2e4a-caaa-4ef6-98d9-14cd6d56de09

Co-authored-by: jonathanvdc <9839946+jonathanvdc@users.noreply.github.com>
Copilot AI changed the title [WIP] Fold typed-array attribute constraints into static definition emission Fold typed-array attribute constraints into static definition emission Apr 14, 2026
Copilot AI requested a review from jonathanvdc April 14, 2026 17:46
@jonathanvdc
jonathanvdc merged commit 3a0a7b3 into main Apr 14, 2026
1 check passed
@jonathanvdc
jonathanvdc deleted the copilot/fold-typed-array-attribute-constraints branch April 14, 2026 17:57
@github-actions

Copy link
Copy Markdown

TableGen Interpreter Benchmarks

Commit: d71b0dabdd914fec045d98496fc8310627fb84da

Benchmark Baseline (ms) Candidate (ms) Delta Status
Evaluate.PathologicalDeepClassChain 0.030 0.027 -9.7% Improvement
Evaluate.PathologicalListPipeline 0.145 0.148 +2.5% Flat
Evaluate.PreludeArithOps 8.967 8.437 -5.9% Improvement
Evaluate.PreludeMiniDialect 3.302 3.381 +2.4% Flat
Evaluate.SimpleInheritanceLets 0.002 0.002 -1.0% Flat
Evaluate.UtilsTd 0.018 0.018 -1.5% Flat
ParseAndEvaluate.PreludeArithOps 20.332 20.412 +0.4% Flat
ParseAndEvaluate.PreludeMiniDialect 9.061 9.050 -0.1% Flat

Interpretation:

  • Regression means candidate mean time is more than 5% slower than baseline.
  • Improvement means candidate mean time is more than 5% faster than baseline.
  • Flat means the change stayed within a 5% noise band.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fold typed-array attribute constraints into static definition emission

2 participants