-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OM] Rework ClassOp to use fields terminator
This changes the OM dialect Class/ExternClass to use a terminator operation similar to hw.output. The ClassFields and ClassExternFields operations use a custom printer/parser to provide a syntax similar to hw.module where fields use the format `@name %val : !type` for non-extern fields and `@name : !type` for extern fields. Internally, the fields operations use attributes to store required information. Both fields operations store a list of fields to preserve definition order. Non-extern fields store a mapping from field name to operand index. Extern fields store a mapping from field name to type. The fields operations provide an API for getting the type of a field based on the name. The extern fields looks this up in the attribute dictionary, while the non-extern fields operation looks up the operand index and retrieves the type from the appropriate operand. This ensures that non-extern fields map to the latest type in cases where the operand type changes after construction. The Class/ExternClass operations provide a convenience API that lifts the fields API to avoid having to frequently request the underlying fields operation. The firrtl LowerClasses logic requires changes to use this API when constructing OM classes, as well as in the dialect conversion logic to handle the new operations. The OM evaluator similarly is updated for the new fields API. The OM linker is updated to skip constructing the field name to type map and instead using the getFieldType API provided by the classOp. The OM object field verifier also no longer needs to construct the field name to type maps and instead can just use the new API. Quite a few tests required updating for the new field syntax. Two TODOs left: * Is there a way to attach a note to a parser error? The old code used this when encountering duplicate fields (the note pointed to the previous definition). Because this check is now done at parse time, we are emitting parser errors instead of an InFlightDiagnostic. * Right now the getFieldType API uses a `std::optional` style for handling cases when the type of a field doesn't exist (i.e. the provided name is not field). Another option would be to expose a `hasField` API.
- Loading branch information
Showing
24 changed files
with
993 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.