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

[ExportVerilog][Emit] Export emitted files #6728

Merged
merged 1 commit into from
Feb 24, 2024
Merged

Conversation

nandor
Copy link
Contributor

@nandor nandor commented Feb 21, 2024

No description provided.

Comment on lines 6076 to 6097
// 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;
}

Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

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

Agree.

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.

This looks good.

Please address @uenoku's comments about code duplication before merging.

lib/Conversion/ExportVerilog/ExportVerilog.cpp Outdated Show resolved Hide resolved
lib/Conversion/ExportVerilog/ExportVerilog.cpp Outdated Show resolved Hide resolved
lib/Conversion/ExportVerilog/ExportVerilog.cpp Outdated Show resolved Hide resolved
lib/Conversion/ExportVerilog/ExportVerilog.cpp Outdated Show resolved Hide resolved
Comment on lines 6076 to 6097
// 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;
}

Copy link
Member

Choose a reason for hiding this comment

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

Agree.

Base automatically changed from dev/nandor/emit-dialect to main February 24, 2024 08:09
@nandor
Copy link
Contributor Author

nandor commented Feb 24, 2024

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.

@nandor nandor merged commit cf931e1 into main Feb 24, 2024
4 checks passed
@nandor nandor deleted the dev/nandor/emit-emit branch February 24, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants