Skip to content

Conversation

fabianmcg
Copy link
Contributor

@fabianmcg fabianmcg commented Sep 3, 2025

Change enum attribute parsing to handle special characters and multi-word
identifiers. This allows enum attrs to use symbols like "+" and strings
with separators like "dash-separated-sentence" instead of being limited to
valid identifiers.

This also aligns enum attribute parsing with how enums are already handled
by the FieldParser:
https://github.com/llvm/llvm-project/blob/main/mlir/tools/mlir-tblgen/EnumsGen.cpp#L108

Signed-off-by: Fabian Mora <fabian.mora-cordero@amd.com>
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes enum attribute parsing in MLIR to handle special characters and multi-word identifiers by replacing parseKeyword with parseKeywordOrString. This change allows enum values to use symbols like "+" and strings with separators like "dash-separated-sentence" instead of being limited to valid identifiers, aligning with how enums are handled by the FieldParser.

Key changes:

  • Updated enum attribute parsing from parseKeyword to parseKeywordOrString
  • Added test coverage for enum values with special characters and multi-word identifiers
  • Enhanced existing test enums to include these new capabilities

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
mlir/include/mlir/IR/EnumAttr.td Updated parsing logic for IntEnumAttr and BitEnumAttr to use parseKeywordOrString
mlir/test/mlir-tblgen/attr-or-type-format.td Added new test enum with special character cases and updated existing enum
mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir Added roundtrip tests for special character enum values
mlir/test/lib/Dialect/Test/TestEnumDefs.td Extended TestSimpleEnum with special character cases
mlir/test/IR/array-of-attr.mlir Updated test to include special character enum value in array

@fabianmcg fabianmcg merged commit 913d44d into llvm:main Sep 3, 2025
10 checks passed
@fabianmcg fabianmcg deleted the fix-enum-attr branch September 3, 2025 13: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