-
Notifications
You must be signed in to change notification settings - Fork 299
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
[ExportVerilog][Emit] Export emitted files #6728
Conversation
ec530d0
to
11f5499
Compare
d615ef4
to
ef7ed09
Compare
11f5499
to
3086362
Compare
ef7ed09
to
28df435
Compare
// Drop an extraneous \n off the end of the string if present. | ||
StringRef string = op.getText(); | ||
if (string.ends_with("\n")) | ||
string = string.drop_back(); | ||
|
||
// Emit each \n separated piece of the string with each piece properly | ||
// indented. The convention is to not emit the \n so | ||
// emitLocationInfoAndNewLine can do that for the last line. | ||
bool isFirst = true; | ||
|
||
// Emit each line of the string at a time. | ||
while (!string.empty()) { | ||
auto lhsRhs = string.split('\n'); | ||
if (isFirst) | ||
isFirst = false; | ||
else { | ||
ps << PP::end << PP::newline << PP::neverbox; | ||
} | ||
ps << PPExtString(lhsRhs.first); | ||
string = lhsRhs.second; | ||
} | ||
|
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.
Can we avoid code duplication with SV verbatim op emission?
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.
Agree.
3086362
to
6e72558
Compare
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.
This looks good.
Please address @uenoku's comments about code duplication before merging.
// Drop an extraneous \n off the end of the string if present. | ||
StringRef string = op.getText(); | ||
if (string.ends_with("\n")) | ||
string = string.drop_back(); | ||
|
||
// Emit each \n separated piece of the string with each piece properly | ||
// indented. The convention is to not emit the \n so | ||
// emitLocationInfoAndNewLine can do that for the last line. | ||
bool isFirst = true; | ||
|
||
// Emit each line of the string at a time. | ||
while (!string.empty()) { | ||
auto lhsRhs = string.split('\n'); | ||
if (isFirst) | ||
isFirst = false; | ||
else { | ||
ps << PP::end << PP::newline << PP::neverbox; | ||
} | ||
ps << PPExtString(lhsRhs.first); | ||
string = lhsRhs.second; | ||
} | ||
|
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.
Agree.
6e72558
to
c13394f
Compare
28df435
to
4460d41
Compare
I didn't factor out the common functionality with verbatim since I wanted to avoid adding some rather complex helpers. Instead, I replaced the body in verbatim emission with a shorter implementation that works. |
No description provided.