Goal
Support typed arrays whose element constraint is a pure enum attribute constraint after pure enum wrappers have been removed.
Pure enum constraints inside typed arrays should decode from and encode to global::MLIR.IntegerAttr, not generated enum wrapper classes.
Depends On
- Pure enum constraints must already store/bind as
global::MLIR.IntegerAttr.
- Pure enum wrapper emission must already be removed.
Files To Inspect First
src/MLIR.Generators/AttributeConstraintCodeStrategy.cs
src/MLIR.Generators/Emitters/AssemblyFormat/AttributeAssemblyFormatEmitter.cs
src/MLIR.Generators/Emitters/AttributeConstraintEmitter.cs
src/MLIR.Generators/Emitters/Operations/OperationAttributeValueHelpers.cs
tests/MLIR.Generators.Tests/DialectGeneratorTypedAttributeTests.cs
tests/MLIR.Generators.Tests/DialectImporterTests.cs
Implementation Steps
-
Add a generated-source test for a typed array whose element is a pure enum.
Use an upstream-style shape if the importer already supports it. A representative example:
include "mlir/IR/EnumAttr.td"
def MINI_MODE_A : I32EnumAttrCase<"a", 0>;
def MINI_MODE_B : I32EnumAttrCase<"b", 1>;
def MiniEnum_Mode : I32EnumAttr<"Mode", "mode summary", [MINI_MODE_A, MINI_MODE_B]> {
let cppNamespace = "::mlir::minienum";
}
def MiniEnum_ModeArray : TypedArrayAttrBase<MiniEnum_Mode, "mode array">;
Then use MiniEnum_ModeArray in an operation argument.
If this exact TableGen shape is not supported yet, follow the existing typed-array test conventions in the repo and keep the test focused on enum element storage.
-
Update enum typed-array decode hooks.
In EnumAttributeConstraintCodeStrategy, implement or adjust typed-array element decoding so it:
- decodes each element syntax through the structured attribute decoder
- casts the decoded value to
global::MLIR.IntegerAttr
- converts the integer payload to the generated enum type using the enum info helper
- falls back consistently when the integer value is unknown
-
Update enum typed-array encode hooks.
Ensure generated code converts each enum element back to global::MLIR.IntegerAttr syntax using the enum bitwidth and integer type.
-
Remove any typed-array dependency on deleted wrapper classes.
Search generated source and generator source for assumptions like:
.TypedValue
AttrConstraintAttributeValue
Keep .TypedValue only for dedicated EnumAttr generated attribute classes where it still applies.
Acceptance Criteria
- Typed arrays of pure enum constraints generate code that compiles.
- Generated typed-array enum paths decode elements from
global::MLIR.IntegerAttr.
- Generated typed-array enum paths encode elements to
global::MLIR.IntegerAttr.
- Generated source does not reference deleted pure enum wrapper classes.
- Existing
EnumAttr AttrDef behavior remains unchanged.
Validation
dotnet test tests/MLIR.Generators.Tests/MLIR.Generators.Tests.csproj
If the change affects normal dialect generation:
dotnet build src/MLIR/MLIR.csproj -m:1 -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=obj/Generated
rg -n "AttrConstraintAttributeValue|TypedArray|IntegerAttr|public enum" src/MLIR/obj/Generated/MLIR.Generators/MLIR.Generators.DialectGenerator
Goal
Support typed arrays whose element constraint is a pure enum attribute constraint after pure enum wrappers have been removed.
Pure enum constraints inside typed arrays should decode from and encode to
global::MLIR.IntegerAttr, not generated enum wrapper classes.Depends On
global::MLIR.IntegerAttr.Files To Inspect First
src/MLIR.Generators/AttributeConstraintCodeStrategy.cssrc/MLIR.Generators/Emitters/AssemblyFormat/AttributeAssemblyFormatEmitter.cssrc/MLIR.Generators/Emitters/AttributeConstraintEmitter.cssrc/MLIR.Generators/Emitters/Operations/OperationAttributeValueHelpers.cstests/MLIR.Generators.Tests/DialectGeneratorTypedAttributeTests.cstests/MLIR.Generators.Tests/DialectImporterTests.csImplementation Steps
Add a generated-source test for a typed array whose element is a pure enum.
Use an upstream-style shape if the importer already supports it. A representative example:
Then use
MiniEnum_ModeArrayin an operation argument.If this exact TableGen shape is not supported yet, follow the existing typed-array test conventions in the repo and keep the test focused on enum element storage.
Update enum typed-array decode hooks.
In
EnumAttributeConstraintCodeStrategy, implement or adjust typed-array element decoding so it:global::MLIR.IntegerAttrUpdate enum typed-array encode hooks.
Ensure generated code converts each enum element back to
global::MLIR.IntegerAttrsyntax using the enum bitwidth and integer type.Remove any typed-array dependency on deleted wrapper classes.
Search generated source and generator source for assumptions like:
Keep
.TypedValueonly for dedicatedEnumAttrgenerated attribute classes where it still applies.Acceptance Criteria
global::MLIR.IntegerAttr.global::MLIR.IntegerAttr.EnumAttrAttrDef behavior remains unchanged.Validation
dotnet test tests/MLIR.Generators.Tests/MLIR.Generators.Tests.csprojIf the change affects normal dialect generation:
dotnet build src/MLIR/MLIR.csproj -m:1 -p:EmitCompilerGeneratedFiles=true -p:CompilerGeneratedFilesOutputPath=obj/Generated rg -n "AttrConstraintAttributeValue|TypedArray|IntegerAttr|public enum" src/MLIR/obj/Generated/MLIR.Generators/MLIR.Generators.DialectGenerator