Skip to content

inline_single_instance pass should maintain instance name #967

@rsetaluri

Description

@rsetaluri

See StanfordAHA/gemstone#43.

The inline_single_instances pass takes a module definition which contains only a single instance and instantiates that instance at the parent level. So if we have a hierarchy like:

- ModuleDef Top
  - Inst Son "son_inst"
  - Inst Daughter "daughter_inst"

- ModuleDef Son
  - Inst Grandchild "grandchild_inst"

We would want to transform that into

- ModuleDef Top
  - Inst Grandchild "son_inst"
  - Inst Daughter "daughter_inst"

since moduledef Grandchild only contains a single instance. Right now we name the lifted instance of Grandchild as son_inst$grandchild_inst since this is the naming logic generically used by inlining (infact it has to be so unless there is only a single instance inside).

At a high-level there are two ways to do this: one is to do the default naming and then rename the inlined instance. The other way to do this is to pass in a custom "namer" functor, which takes in the child and grandchild instances and returns a new name. The default value for this functor could be [](Instance* const child, Instance* const grandchild) { return child->name() + "$" + grandchild->name(); }. When inline single instances calls inlineInstance() the functor would be [](Instance* const child, Instance* const grandchild) { return child->name(); }.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions