Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIRRTL][LowerLayers] Clean up names of artifacts generated by layers #6733

Merged
merged 1 commit into from Feb 26, 2024

Conversation

rwy7
Copy link
Contributor

@rwy7 rwy7 commented Feb 21, 2024

  • Layer module name: move into helper.
  • Layer instance name:
    • don't put the parent module name in the instance name,
    • lowercase each part of the instance name, not just the first word.
  • Layer file name: move into helper.
  • Captured port names: don't prefix the port name with an underscore.

@rwy7 rwy7 added the FIRRTL Involving the `firrtl` dialect label Feb 21, 2024
@rwy7
Copy link
Contributor Author

rwy7 commented Feb 21, 2024

We need a verifier that bans layernames which are empty or include an underscore.

@seldridge
Copy link
Member

We need a verifier that bans layernames which are empty or include an underscore.

Good catch. If this is going to be a problem with the ABI, then we should put it in the spec.

Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

Output looks way better. It is totally reasonable to drop the leading _ and to simplify the naming of the instances.

Some comments about how to further simplify things in the review.

- Layer module name: move into helper.
- Layer instance name:
  - don't put the parent module name in the instance name,
  - lowercase each part of the instance name, not just the first word.
- Layer file name: move into helper.
- Captured port names: don't prefix the port name with an underscore.
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

LGTM

lib/Dialect/FIRRTL/Transforms/LowerLayers.cpp Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/LowerLayers.cpp Show resolved Hide resolved
lib/Dialect/FIRRTL/Transforms/LowerLayers.cpp Show resolved Hide resolved
Comment on lines -257 to +303
auto operandName = getFieldName(FieldRef(operand, 0), true);
const auto &[portName, _] = getFieldName(FieldRef(operand, 0), true);
Copy link
Member

Choose a reason for hiding this comment

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

Nice cleanup.

Comment on lines -479 to +525
auto moduleName = newModule.getModuleName();
auto instanceName =
(Twine((char)tolower(moduleName[0])) + moduleName.drop_front()).str();
auto instanceName = instanceNameForLayer(layerBlock.getLayerName());
Copy link
Member

Choose a reason for hiding this comment

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

This is so much cleaner. 💯

Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

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

LGTM, nice work!

lib/Dialect/FIRRTL/Transforms/LowerLayers.cpp Show resolved Hide resolved

/// For all layerblocks `@A::@B::@C` in a circuit called Circuit,
/// the output filename is `layers_Circuit_A_B_C.sv`.
static SmallString<32> fileNameForLayer(StringRef circuitName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this change for FIRRTL 4.0?

abi.md presently reads:

filename = "layers_" , module , "_", root , { "_" , nested } , ".sv" ;

(module not circuit)

Is this going to work for public modules that aren't the main module as-is?

Copy link
Member

Choose a reason for hiding this comment

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

I think this pass does not do the right thing for public modules. This happens to work now for the main module. The pass should be updated to emit the collateral for all public modules in a follow-on. Good catch, Will.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened an issue: #6748

@rwy7 rwy7 merged commit f5831fa into llvm:main Feb 26, 2024
4 checks passed
@rwy7 rwy7 deleted the lower-layers branch February 26, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIRRTL Involving the `firrtl` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants