Skip to content

Commit

Permalink
[FIRRTL] Re-implement old EmitOMIR ports logic in LowerClasses. (#7651)
Browse files Browse the repository at this point in the history
This transformation used to exist in EmitOMIR to detect the presence
of a specific field, and use it to add another specific field on the
fly. While we could do this through other means downstream, for full
compatibility we are re-implementing this logic.

Because we are already doing many expensive passes through the object
IR, this is implemented throughout the existing methods in
LowerClasses, rather than adding a new pass or a new traversal to an
existing pass.

One consequence of this choice is we do need to perform some global
mutation to collect objects that need to have this field added in a
multi-threaded context. To support this, a mutex is added to each
instance of the pass, and the collected objects are then processed
serially.

Otherwise, this is fairly straightforward. When we are declaring
classes, we check if we need to add the extra field. When we are
adding class bodies, we check if we need to add the extra block
argument. When we are converting object instances, we check if we need
to supply the extra argument. It is in this final case that we
actually make a list of objects. Now that we are off the JSON based
OMIR, this is the proper way to add a new field with the same type.
  • Loading branch information
mikeurbach authored Oct 2, 2024
1 parent 8c577d5 commit 9e3f863
Show file tree
Hide file tree
Showing 3 changed files with 284 additions and 20 deletions.
2 changes: 2 additions & 0 deletions include/circt/Dialect/FIRRTL/FIRRTLAnnotationHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ struct HierPathCache {
return FlatSymbolRefAttr::get(getSymFor(attr));
}

const SymbolTable &getSymbolTable() const { return symbolTable; }

private:
OpBuilder builder;
DenseMap<ArrayAttr, hw::HierPathOp> cache;
Expand Down
Loading

0 comments on commit 9e3f863

Please sign in to comment.