Skip to content

[OM] Clean up ObjectOfieldOp: Move away from symbols, remove a field path and VerifyObjectFields pass#10303

Merged
uenoku merged 4 commits into
llvm:mainfrom
uenoku:dev/hidetou/om-clean-up
Apr 28, 2026
Merged

[OM] Clean up ObjectOfieldOp: Move away from symbols, remove a field path and VerifyObjectFields pass#10303
uenoku merged 4 commits into
llvm:mainfrom
uenoku:dev/hidetou/om-clean-up

Conversation

@uenoku
Copy link
Copy Markdown
Member

@uenoku uenoku commented Apr 23, 2026

This PR contains three refactoring/fix for ObjectOfieldOp. It may be better to split the PR but they are fairly coupled to each other so I found it's simpler to do it in a one PR.

  1. Replace FlatSymbolRefArrayAttr with StringAttr for field names, changing syntax from object, [@field] to object["field"]. Nested field access now requires chaining ObjectFieldOp instead of using an array path for the simplicity. FIRRTL has only used single field access, so it doesn't change anything for firtool pipeline.

  2. This replaces VerifyObjectFields pass with the ObjectFieldOp verifier itself by adding SymbolUserOpInterface. lower-classes.mlir test is updated since it created an IR that doesn't pass verifier. This will increase the verifier runtime for core dialects since we now verify symbol uses of object field op in a verifier for good or bad, so it may be controversial

  3. It also fixes Evaluator bug that didn't dereference ReferenceValue of object value as exposed by refactoring 1.

Close #7078. My primary motivation was to remove nested field access, since it makes IR mutation approach mentioned in #10265 (comment) way more simpler to implement.

Assisted-by: Augment: claude-sonnet-4.5

@uenoku uenoku requested a review from mikeurbach April 23, 2026 09:16
@uenoku uenoku force-pushed the dev/hidetou/om-clean-up branch from e0237fd to 7ced68b Compare April 23, 2026 09:19
%0 = om.object @ListCreateTest(%notpath, %basepath, %path) : (i1, !om.basepath, !om.path) -> !om.class.type<@ListCreateTest>

// CHECK: [[SUBFIELD:%.+]] = om.object.field [[OBJ]], [@nestedpath] : (!om.class.type<@PathTest>) -> !om.list<!om.list<!om.frozenpath>>
%1 = om.object.field %0, [@nestedpath] : (!om.class.type<@PathTest>) -> !om.list<!om.list<!om.path>>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This test was updated because @nestedath didn't exist in @PathTest.

@uenoku uenoku force-pushed the dev/hidetou/om-clean-up branch from 7ced68b to 9879c60 Compare April 23, 2026 09:29
}
firrtl.module private @WillBeReplaced(out %output: !firrtl.integer) {
%c = firrtl.integer 42
firrtl.propassign %output, %c : !firrtl.integer
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was added since otherwise it causes verification error after lowering.

let arguments = (ins
ClassType:$object,
FlatSymbolRefArrayAttr:$fieldPath
StrAttr:$field
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I considered to use an index instead of StringAttr in a similar way to HWStructExtractOp, but I didn't do that because OM class type doesn't contain field types (so it's not possible to lookup field type anyway).

@uenoku uenoku force-pushed the dev/hidetou/om-clean-up branch 2 times, most recently from 4cce16a to 97ba9f0 Compare April 23, 2026 09:59
Replace FlatSymbolRefArrayAttr with StringAttr for field names, changing
syntax from 'object, [@field]' to 'object["field"]'. Nested field access
now requires chaining ObjectFieldOp instead of using an array path.

This moves verification from the VerifyObjectFields pass into the
ObjectFieldOp verifier itself by adding SymbolUserOpInterface, eliminating
the need for a separate pass. The Evaluator is updated to handle StringAttr
and dereference ReferenceValue.
@uenoku uenoku force-pushed the dev/hidetou/om-clean-up branch from 97ba9f0 to 22db8d5 Compare April 23, 2026 10:21
@mikeurbach mikeurbach linked an issue Apr 28, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@mikeurbach mikeurbach left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for wrapping up this longstanding tech debt. @leonardt please take a look as well, since this is building off the work you did a long time back.

Comment thread include/circt/Dialect/OM/OMOps.td Outdated
@uenoku
Copy link
Copy Markdown
Member Author

uenoku commented Apr 28, 2026

Please let me merge this to unblock dependent work. @leonardt I'd appreciate post commit review!

@uenoku uenoku merged commit de851dc into llvm:main Apr 28, 2026
6 checks passed
@uenoku uenoku deleted the dev/hidetou/om-clean-up branch April 28, 2026 23:53
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.

[OM] om.object.field doesn't verify that field exists [OM] Rework Class and Object op to finish the move away from fields being symbols

2 participants