-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[PowerPC][NFC] clean up if-else block in PPCRegisterInfo.cpp #140084
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
Conversation
|
@llvm/pr-subscribers-backend-powerpc Author: Lei Huang (lei137) ChangesMove all if-else conditions into a switch stmt for handling spills. Full diff: https://github.com/llvm/llvm-project/pull/140084.diff 1 Files Affected:
diff --git a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
index e1d9db0e3daa7..044bc2752d0f0 100644
--- a/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
@@ -1610,62 +1610,69 @@ PPCRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
// Get the instruction opcode.
unsigned OpC = MI.getOpcode();
- if ((OpC == PPC::DYNAREAOFFSET || OpC == PPC::DYNAREAOFFSET8)) {
+ switch (OpC) {
+ case PPC::DYNAREAOFFSET:
+ case PPC::DYNAREAOFFSET8:
lowerDynamicAreaOffset(II);
// lowerDynamicAreaOffset erases II
return true;
+ case PPC::DYNALLOC:
+ case PPC::DYNALLOC8: {
+ // Special case for dynamic alloca.
+ if (FPSI && FrameIndex == FPSI) {
+ lowerDynamicAlloc(II); // lowerDynamicAlloc erases II
+ return true;
+ }
+ break;
}
-
- // Special case for dynamic alloca.
- if (FPSI && FrameIndex == FPSI &&
- (OpC == PPC::DYNALLOC || OpC == PPC::DYNALLOC8)) {
- lowerDynamicAlloc(II);
- // lowerDynamicAlloc erases II
- return true;
- }
-
- if (FPSI && FrameIndex == FPSI &&
- (OpC == PPC::PREPARE_PROBED_ALLOCA_64 ||
- OpC == PPC::PREPARE_PROBED_ALLOCA_32 ||
- OpC == PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64 ||
- OpC == PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32)) {
- lowerPrepareProbedAlloca(II);
- // lowerPrepareProbedAlloca erases II
- return true;
+ case PPC::PREPARE_PROBED_ALLOCA_64:
+ case PPC::PREPARE_PROBED_ALLOCA_32:
+ case PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64:
+ case PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32: {
+ if (FPSI && FrameIndex == FPSI) {
+ lowerPrepareProbedAlloca(II); // lowerPrepareProbedAlloca erases II
+ return true;
+ }
+ break;
}
-
- // Special case for pseudo-ops SPILL_CR and RESTORE_CR, etc.
- if (OpC == PPC::SPILL_CR) {
+ case PPC::SPILL_CR:
+ // Special case for pseudo-ops SPILL_CR and RESTORE_CR, etc.
lowerCRSpilling(II, FrameIndex);
return true;
- } else if (OpC == PPC::RESTORE_CR) {
+ case PPC::RESTORE_CR:
lowerCRRestore(II, FrameIndex);
return true;
- } else if (OpC == PPC::SPILL_CRBIT) {
+ case PPC::SPILL_CRBIT:
lowerCRBitSpilling(II, FrameIndex);
return true;
- } else if (OpC == PPC::RESTORE_CRBIT) {
+ case PPC::RESTORE_CRBIT:
lowerCRBitRestore(II, FrameIndex);
return true;
- } else if (OpC == PPC::SPILL_ACC || OpC == PPC::SPILL_UACC) {
+ case PPC::SPILL_ACC:
+ case PPC::SPILL_UACC:
lowerACCSpilling(II, FrameIndex);
return true;
- } else if (OpC == PPC::RESTORE_ACC || OpC == PPC::RESTORE_UACC) {
+ case PPC::RESTORE_ACC:
+ case PPC::RESTORE_UACC:
lowerACCRestore(II, FrameIndex);
return true;
- } else if (OpC == PPC::STXVP && DisableAutoPairedVecSt) {
- lowerOctWordSpilling(II, FrameIndex);
- return true;
- } else if (OpC == PPC::SPILL_WACC) {
+ case PPC::STXVP: {
+ if (DisableAutoPairedVecSt) {
+ lowerOctWordSpilling(II, FrameIndex);
+ return true;
+ }
+ break;
+ }
+ case PPC::SPILL_WACC:
lowerWACCSpilling(II, FrameIndex);
return true;
- } else if (OpC == PPC::RESTORE_WACC) {
+ case PPC::RESTORE_WACC:
lowerWACCRestore(II, FrameIndex);
return true;
- } else if (OpC == PPC::SPILL_QUADWORD) {
+ case PPC::SPILL_QUADWORD:
lowerQuadwordSpilling(II, FrameIndex);
return true;
- } else if (OpC == PPC::RESTORE_QUADWORD) {
+ case PPC::RESTORE_QUADWORD:
lowerQuadwordRestore(II, FrameIndex);
return true;
}
|
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.
there is no default for the switch , is there a compile warning or error for it ?
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.
No, default handling is after the switch. Can add:
default: break;
diggerlin
left a comment
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.
LGTM
dd05a1f to
540af59
Compare
Move all if-else conditions into a switch stmt for handling spills.