Skip to content

Allow null syntax nodes in fully-bound MLIR.Semantics classes to support synthetic semantic nodes#17

Merged
jonathanvdc merged 6 commits intomainfrom
copilot/update-mlir-semantics-classes
Mar 31, 2026
Merged

Allow null syntax nodes in fully-bound MLIR.Semantics classes to support synthetic semantic nodes#17
jonathanvdc merged 6 commits intomainfrom
copilot/update-mlir-semantics-classes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

  • AttributeValue.Syntax → AttributeValueSyntax?
  • Block: two constructors; Label non-nullable
  • AssemblySyntaxBuilder: synthesize RegionSyntax/BlockSyntax when null
  • Block: synthetic constructor takes BlockReference; LabelReference non-nullable; Label computed
  • ValueReference: nullable Token; non-nullable data-holding Name; string constructor
  • BlockReference: nullable Token; non-nullable data-holding Label; string constructor
  • Operation.GetGenericBody() → nullable; move synthesis to AssemblySyntaxBuilder
  • AssemblySyntaxBuilder: use nullable Token from ValueReference/BlockReference when synthesizing
  • Update tests

Copilot AI changed the title [WIP] Update MLIR.Semantics classes for null wrapped nodes Allow null syntax nodes in fully-bound MLIR.Semantics classes to support synthetic semantic nodes Mar 31, 2026
Copilot AI requested a review from jonathanvdc March 31, 2026 00:41
Copy link
Copy Markdown
Owner

@jonathanvdc jonathanvdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving in the right direction. Some changes I'd like you to make:

  • Replace the RawSyntaxText Syntax in AttributeValue with an AttributeValueSyntax.
  • Split Block up into one constructor that grabs the label from the BlockSyntax and another constructor (for synthetic nodes) with a string label argument. Make BlockSyntax's Label property hold the data from either of those sources.
  • Synthesize RegionSyntax/BlockSyntax in AssemblySyntaxBuilder if the Region/Block Syntax property is null.

…structors, remove null label fallback

Agent-Logs-Url: https://github.com/jonathanvdc/MLIR.NET/sessions/1a5fa164-7732-4774-8ff6-f3625f3f0a17

Co-authored-by: jonathanvdc <9839946+jonathanvdc@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

Moving in the right direction. Some changes I'd like you to make:

  • Replace the RawSyntaxText Syntax in AttributeValue with an AttributeValueSyntax.
  • Split Block up into one constructor that grab...

Done in 48bdd53:

  • AttributeValue.Syntax is now AttributeValueSyntax?. AttributeValueConstructionContext.Syntax is also AttributeValueSyntax; the binder wraps RawSyntaxText in RawAttributeValueSyntax when creating construction contexts and UnknownAttributeValue instances.
  • Block now has two constructors: Block(BlockSyntax syntax, ...) (label taken from the syntax node) and Block(string label, ...) (for synthetic nodes). Label is now non-nullable string in both cases.
  • AssemblySyntaxBuilder was already synthesizing RegionSyntax/BlockSyntax for null-syntax nodes; the block case now uses block.Label directly (no ?? "^entry" fallback since Label is always non-null).

Copy link
Copy Markdown
Owner

@jonathanvdc jonathanvdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making good progress. See comments. Also, can you make the token in BlockReference and ValueReference nullable while making their string Name properties non-nullable and data-holding? If these tokens are null, synthesize them in AssemblySyntaxBuilder.

/// <param name="label">The block label, including the leading <c>^</c>.</param>
/// <param name="arguments">The semantic block arguments.</param>
/// <param name="operations">The operations contained in the block.</param>
public Block(string label, IReadOnlyList<BlockArgument> arguments, IReadOnlyList<Operation> operations)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you take a BlockReference here instead of a string, make Label a computed property from LabelReference, and make LabelReference non-nullable?

@@ -148,19 +148,28 @@ public NamedAttribute GetAttribute(string name)
/// </summary>
public GenericOperationBodySyntax GetGenericBody()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to AssemblySyntaxBuilder?

Agent-Logs-Url: https://github.com/jonathanvdc/MLIR.NET/sessions/b8741ebf-34a1-45a3-b6cf-be3beee8e913

Co-authored-by: jonathanvdc <9839946+jonathanvdc@users.noreply.github.com>
@jonathanvdc jonathanvdc marked this pull request as ready for review March 31, 2026 01:34
@jonathanvdc jonathanvdc merged commit a78dc16 into main Mar 31, 2026
1 check passed
@jonathanvdc jonathanvdc deleted the copilot/update-mlir-semantics-classes branch March 31, 2026 01:35
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.

2 participants