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

[CIR[CIRGen][NFC] Refactor build switch op #552

Merged
merged 3 commits into from
Apr 25, 2024

Conversation

wenpen
Copy link
Contributor

@wenpen wenpen commented Apr 19, 2024

Make logic cleaner and more extensible.

Separate collecting SwitchStmt information and building op logic into different functions.
Add more UT to cover nested switch, which also worked before this pr.

This pr is split from #528.

@bcardosolopes bcardosolopes changed the title Refactor build switch op [CIR[CIRGen][NFC] Refactor build switch op Apr 19, 2024
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Thanks, more comments follow

assert(defaultStmt && "expected default stmt");
res = buildDefaultStmt(*defaultStmt, condV.getType(), caseAttrs,
os);
SmallVector<mlir::Attribute, 4> caseAttrs;
Copy link
Member

Choose a reason for hiding this comment

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

This block of logic here can be abstracted into its own helper function: all it does it building CaseOpKindAttr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added switchCondType in LexScope and moved these logic into helper function, thanks.

Copy link
Member

Choose a reason for hiding this comment

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

Passing params to functions is totally fine, things shouldn't be added to LexScope unless strictly needed. And if it's needed to fix a bug or support nested switches, should be added when time for that PR comes. Please don't add switchCondType into LexScope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, reverted the related changes, leave it to the future pr.

@wenpen wenpen force-pushed the refactor_build_switch_op branch from 65c8be7 to c495036 Compare April 20, 2024 03:14
@wenpen wenpen requested a review from bcardosolopes April 20, 2024 03:24
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@bcardosolopes bcardosolopes merged commit 0591e2a into llvm:main Apr 25, 2024
6 checks passed
lanza pushed a commit that referenced this pull request Apr 29, 2024
Make logic cleaner and more extensible.

Separate collecting `SwitchStmt` information and building op logic into
different functions.
Add more UT to cover nested switch, which also worked before this pr.

This pr is split from #528.
lanza pushed a commit that referenced this pull request Apr 29, 2024
Make logic cleaner and more extensible.

Separate collecting `SwitchStmt` information and building op logic into
different functions.
Add more UT to cover nested switch, which also worked before this pr.

This pr is split from #528.
lanza pushed a commit that referenced this pull request Apr 29, 2024
Make logic cleaner and more extensible.

Separate collecting `SwitchStmt` information and building op logic into
different functions.
Add more UT to cover nested switch, which also worked before this pr.

This pr is split from #528.
bruteforceboy pushed a commit to bruteforceboy/clangir that referenced this pull request Oct 2, 2024
Make logic cleaner and more extensible.

Separate collecting `SwitchStmt` information and building op logic into
different functions.
Add more UT to cover nested switch, which also worked before this pr.

This pr is split from llvm#528.
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
Make logic cleaner and more extensible.

Separate collecting `SwitchStmt` information and building op logic into
different functions.
Add more UT to cover nested switch, which also worked before this pr.

This pr is split from llvm#528.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
Make logic cleaner and more extensible.

Separate collecting `SwitchStmt` information and building op logic into
different functions.
Add more UT to cover nested switch, which also worked before this pr.

This pr is split from llvm#528.
lanza pushed a commit that referenced this pull request Nov 5, 2024
Make logic cleaner and more extensible.

Separate collecting `SwitchStmt` information and building op logic into
different functions.
Add more UT to cover nested switch, which also worked before this pr.

This pr is split from #528.
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.

2 participants