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

Add IR utility that helps with return of multiple statements from Transform #4414

Merged
merged 9 commits into from
Feb 13, 2024

Conversation

vlstill
Copy link
Contributor

@vlstill vlstill commented Feb 12, 2024

@vlstill vlstill force-pushed the irutils-inline-block branch 2 times, most recently from dcb23a5 to de68fee Compare February 12, 2024 15:33
@vlstill vlstill marked this pull request as ready for review February 12, 2024 16:33
test/gtest/transforms.cpp Outdated Show resolved Hide resolved
ir/irutils.h Outdated Show resolved Hide resolved
ir/irutils.h Outdated Show resolved Hide resolved
ir/irutils.cpp Outdated Show resolved Hide resolved
@ChrisDodd
Copy link
Contributor

The way I've dealt with this in other passes is to just return a BlockStatement then use SimplifyControlFlow, but this is more efficient.

return new IR::IndexedVector<IR::StatOrDecl>(std::forward<Stmts>(stmts));
}
Util::SourceInfo srcInfo;
if (stmts.size() > 0) { // no .empty in initializer_list!
Copy link
Collaborator

Choose a reason for hiding this comment

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

std::empty? I guess that won't work for the other two...

Copy link
Contributor Author

@vlstill vlstill Feb 13, 2024

Choose a reason for hiding this comment

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

It should work for anything that has .empty or c-style array and on initializer_list. But I could not decide if it is nicer or uglier than size() > 0.

@vlstill vlstill enabled auto-merge (squash) February 13, 2024 16:03
@vlstill vlstill merged commit b0c1671 into p4lang:main Feb 13, 2024
16 checks passed
@vlstill vlstill deleted the irutils-inline-block branch February 13, 2024 16:39
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.

4 participants