Skip to content

Commit a40762c

Browse files
authored
[PowerPC][NFC] clean up if-else block in PPCRegisterInfo.cpp (llvm#140084)
Move all if-else conditions into a switch stmt for handling spills.
1 parent 8e3f44d commit a40762c

File tree

1 file changed

+42
-33
lines changed

1 file changed

+42
-33
lines changed

llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,62 +1610,71 @@ PPCRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
16101610
// Get the instruction opcode.
16111611
unsigned OpC = MI.getOpcode();
16121612

1613-
if ((OpC == PPC::DYNAREAOFFSET || OpC == PPC::DYNAREAOFFSET8)) {
1613+
switch (OpC) {
1614+
default:
1615+
break;
1616+
case PPC::DYNAREAOFFSET:
1617+
case PPC::DYNAREAOFFSET8:
16141618
lowerDynamicAreaOffset(II);
16151619
// lowerDynamicAreaOffset erases II
16161620
return true;
1621+
case PPC::DYNALLOC:
1622+
case PPC::DYNALLOC8: {
1623+
// Special case for dynamic alloca.
1624+
if (FPSI && FrameIndex == FPSI) {
1625+
lowerDynamicAlloc(II); // lowerDynamicAlloc erases II
1626+
return true;
1627+
}
1628+
break;
16171629
}
1618-
1619-
// Special case for dynamic alloca.
1620-
if (FPSI && FrameIndex == FPSI &&
1621-
(OpC == PPC::DYNALLOC || OpC == PPC::DYNALLOC8)) {
1622-
lowerDynamicAlloc(II);
1623-
// lowerDynamicAlloc erases II
1624-
return true;
1625-
}
1626-
1627-
if (FPSI && FrameIndex == FPSI &&
1628-
(OpC == PPC::PREPARE_PROBED_ALLOCA_64 ||
1629-
OpC == PPC::PREPARE_PROBED_ALLOCA_32 ||
1630-
OpC == PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64 ||
1631-
OpC == PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32)) {
1632-
lowerPrepareProbedAlloca(II);
1633-
// lowerPrepareProbedAlloca erases II
1634-
return true;
1630+
case PPC::PREPARE_PROBED_ALLOCA_64:
1631+
case PPC::PREPARE_PROBED_ALLOCA_32:
1632+
case PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64:
1633+
case PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32: {
1634+
if (FPSI && FrameIndex == FPSI) {
1635+
lowerPrepareProbedAlloca(II); // lowerPrepareProbedAlloca erases II
1636+
return true;
1637+
}
1638+
break;
16351639
}
1636-
1637-
// Special case for pseudo-ops SPILL_CR and RESTORE_CR, etc.
1638-
if (OpC == PPC::SPILL_CR) {
1640+
case PPC::SPILL_CR:
1641+
// Special case for pseudo-ops SPILL_CR and RESTORE_CR, etc.
16391642
lowerCRSpilling(II, FrameIndex);
16401643
return true;
1641-
} else if (OpC == PPC::RESTORE_CR) {
1644+
case PPC::RESTORE_CR:
16421645
lowerCRRestore(II, FrameIndex);
16431646
return true;
1644-
} else if (OpC == PPC::SPILL_CRBIT) {
1647+
case PPC::SPILL_CRBIT:
16451648
lowerCRBitSpilling(II, FrameIndex);
16461649
return true;
1647-
} else if (OpC == PPC::RESTORE_CRBIT) {
1650+
case PPC::RESTORE_CRBIT:
16481651
lowerCRBitRestore(II, FrameIndex);
16491652
return true;
1650-
} else if (OpC == PPC::SPILL_ACC || OpC == PPC::SPILL_UACC) {
1653+
case PPC::SPILL_ACC:
1654+
case PPC::SPILL_UACC:
16511655
lowerACCSpilling(II, FrameIndex);
16521656
return true;
1653-
} else if (OpC == PPC::RESTORE_ACC || OpC == PPC::RESTORE_UACC) {
1657+
case PPC::RESTORE_ACC:
1658+
case PPC::RESTORE_UACC:
16541659
lowerACCRestore(II, FrameIndex);
16551660
return true;
1656-
} else if (OpC == PPC::STXVP && DisableAutoPairedVecSt) {
1657-
lowerOctWordSpilling(II, FrameIndex);
1658-
return true;
1659-
} else if (OpC == PPC::SPILL_WACC) {
1661+
case PPC::STXVP: {
1662+
if (DisableAutoPairedVecSt) {
1663+
lowerOctWordSpilling(II, FrameIndex);
1664+
return true;
1665+
}
1666+
break;
1667+
}
1668+
case PPC::SPILL_WACC:
16601669
lowerWACCSpilling(II, FrameIndex);
16611670
return true;
1662-
} else if (OpC == PPC::RESTORE_WACC) {
1671+
case PPC::RESTORE_WACC:
16631672
lowerWACCRestore(II, FrameIndex);
16641673
return true;
1665-
} else if (OpC == PPC::SPILL_QUADWORD) {
1674+
case PPC::SPILL_QUADWORD:
16661675
lowerQuadwordSpilling(II, FrameIndex);
16671676
return true;
1668-
} else if (OpC == PPC::RESTORE_QUADWORD) {
1677+
case PPC::RESTORE_QUADWORD:
16691678
lowerQuadwordRestore(II, FrameIndex);
16701679
return true;
16711680
}

0 commit comments

Comments
 (0)