Problem
Symbol trait behavior is real MLIR semantics, but the generator currently handles it with scattered checks for the Symbol trait and the sym_name attribute. This creates special cases in member planning, property emission, and custom assembly rebuilding.
Trait-driven behavior should be represented in a centralized trait binding model.
Current Hotspots
src/MLIR.Generators/Emitters/Operations/OperationMemberPlanner.cs: maps sym_name to SymbolName
src/MLIR.Generators/Emitters/Operations/OperationMemberPlanner.cs: suppresses generic sym_name typing in some paths
src/MLIR.Generators/Emitters/Operations/OperationPropertyEmitter.cs: emits SymbolName
src/MLIR.Generators/Emitters/AssemblyFormat/BuildCustomAssemblySyntaxEmitter.cs: maps assembly variable sym_name back to SymbolName
Proposed Direction
Introduce trait binding metadata, for example:
public sealed class TraitBindingModel
{
public string TraitRecordName { get; }
public IReadOnlyList<GeneratedPropertyBinding> Properties { get; }
public IReadOnlyList<string> SuppressedAttributeProperties { get; }
public string? OperationBaseType { get; }
}
The Symbol trait binding would contribute:
SymbolName property
- backing attribute:
sym_name
- storage/public type: string via builtin
StringAttr
- suppression of generic
SymName
- assembly-format variable alias from
sym_name to SymbolName
Acceptance Criteria
Symbol trait behavior is described in one centralized trait binding location.
- Operation member planning consumes trait bindings instead of checking
Symbol directly.
- Operation property emission consumes generated property bindings instead of hardcoding
SymbolName.
- Custom assembly syntax rebuild resolves trait-provided aliases without ad hoc
sym_name logic.
- Existing symbol operations keep the
SymbolName API and avoid duplicate SymName properties.
Suggested Tests
- Generated symbol op exposes
SymbolName.
- Generated symbol op does not also expose generic
SymName.
SymbolName getter/setter round-trips through sym_name and builtin StringAttr.
- Custom assembly involving
$sym_name rebuilds from SymbolName.
- Non-symbol op with an attribute named
sym_name follows normal attribute behavior.
Notes
This issue intentionally keeps the Symbol special case semantically, but moves it out of emitter control flow and into trait metadata.
Problem
Symboltrait behavior is real MLIR semantics, but the generator currently handles it with scattered checks for theSymboltrait and thesym_nameattribute. This creates special cases in member planning, property emission, and custom assembly rebuilding.Trait-driven behavior should be represented in a centralized trait binding model.
Current Hotspots
src/MLIR.Generators/Emitters/Operations/OperationMemberPlanner.cs: mapssym_nametoSymbolNamesrc/MLIR.Generators/Emitters/Operations/OperationMemberPlanner.cs: suppresses genericsym_nametyping in some pathssrc/MLIR.Generators/Emitters/Operations/OperationPropertyEmitter.cs: emitsSymbolNamesrc/MLIR.Generators/Emitters/AssemblyFormat/BuildCustomAssemblySyntaxEmitter.cs: maps assembly variablesym_nameback toSymbolNameProposed Direction
Introduce trait binding metadata, for example:
The
Symboltrait binding would contribute:SymbolNamepropertysym_nameStringAttrSymNamesym_nametoSymbolNameAcceptance Criteria
Symboltrait behavior is described in one centralized trait binding location.Symboldirectly.SymbolName.sym_namelogic.SymbolNameAPI and avoid duplicateSymNameproperties.Suggested Tests
SymbolName.SymName.SymbolNamegetter/setter round-trips throughsym_nameand builtinStringAttr.$sym_namerebuilds fromSymbolName.sym_namefollows normal attribute behavior.Notes
This issue intentionally keeps the Symbol special case semantically, but moves it out of emitter control flow and into trait metadata.