-
Notifications
You must be signed in to change notification settings - Fork 298
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] Export literal identifiers correctly #5502
[FIRRTL] Export literal identifiers correctly #5502
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't deeply vet but bouncing through LGTM! Few comments but mostly hooray, and thanks!
StringRef str = attr.getValue(); | ||
if (str.empty() || !isdigit(str.front())) | ||
return attr; | ||
return StringAttr::get(attr.getContext(), "`" + Twine(attr) + "`"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest letting PrettyPrinter's string storage handle this for you (the thing PPExtString
opts out of) instead of unique'ing into the context, but probably this is something already done as part of IR printing/etc., and also sufficiently rare to not matter.
addValueName(arguments[i], port.name); | ||
ps << PPExtString(port.name.getValue()) << " : "; | ||
addValueName(arguments[i], legalize(port.name)); | ||
ps << PPExtString(legalize(port.name)) << " : "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe not worth only calling legalize(port.name)
once, as done elsewhere/later? Works for me!)
|
||
// Test that literal identifiers work. | ||
// CHECK-LABEL: module `0Bar` : | ||
firrtl.module @"0Bar"( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome test, so thorough I love it!! Thank you! 🚀
Update the FIRRTL exporter to properly escape literal identifiers. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
b47d594
to
7505388
Compare
Update the FIRRTL exporter to properly escape literal identifiers.