Skip to content

Commit 292ee93

Browse files
authored
[CodeGen] Use Register in SwitchLoweringUtils. NFC (#109092)
Use an empty Register() instead of -1U.
1 parent 6b3c9e5 commit 292ee93

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

llvm/include/llvm/CodeGen/SwitchLoweringUtils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct CaseBlock {
170170
struct JumpTable {
171171
/// The virtual register containing the index of the jump table entry
172172
/// to jump to.
173-
unsigned Reg;
173+
Register Reg;
174174
/// The JumpTableIndex for this jump table in the function.
175175
unsigned JTI;
176176
/// The MBB into which to emit the code for the indirect jump.
@@ -182,7 +182,7 @@ struct JumpTable {
182182
/// The debug location of the instruction this JumpTable was produced from.
183183
std::optional<SDLoc> SL; // For SelectionDAG
184184

185-
JumpTable(unsigned R, unsigned J, MachineBasicBlock *M, MachineBasicBlock *D,
185+
JumpTable(Register R, unsigned J, MachineBasicBlock *M, MachineBasicBlock *D,
186186
std::optional<SDLoc> SL)
187187
: Reg(R), JTI(J), MBB(M), Default(D), SL(SL) {}
188188
};
@@ -218,7 +218,7 @@ struct BitTestBlock {
218218
APInt First;
219219
APInt Range;
220220
const Value *SValue;
221-
unsigned Reg;
221+
Register Reg;
222222
MVT RegVT;
223223
bool Emitted;
224224
bool ContiguousRange;
@@ -229,7 +229,7 @@ struct BitTestBlock {
229229
BranchProbability DefaultProb;
230230
bool FallthroughUnreachable = false;
231231

232-
BitTestBlock(APInt F, APInt R, const Value *SV, unsigned Rg, MVT RgVT, bool E,
232+
BitTestBlock(APInt F, APInt R, const Value *SV, Register Rg, MVT RgVT, bool E,
233233
bool CR, MachineBasicBlock *P, MachineBasicBlock *D,
234234
BitTestInfo C, BranchProbability Pr)
235235
: First(std::move(F)), Range(std::move(R)), SValue(SV), Reg(Rg),

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ void IRTranslator::splitWorkItem(SwitchCG::SwitchWorkList &WorkList,
838838
void IRTranslator::emitJumpTable(SwitchCG::JumpTable &JT,
839839
MachineBasicBlock *MBB) {
840840
// Emit the code for the jump table
841-
assert(JT.Reg != -1U && "Should lower JT Header first!");
841+
assert(JT.Reg && "Should lower JT Header first!");
842842
MachineIRBuilder MIB(*MBB->getParent());
843843
MIB.setMBB(*MBB);
844844
MIB.setDebugLoc(CurBuilder->getDebugLoc());

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,7 +2981,7 @@ void SelectionDAGBuilder::visitSwitchCase(CaseBlock &CB,
29812981
void SelectionDAGBuilder::visitJumpTable(SwitchCG::JumpTable &JT) {
29822982
// Emit the code for the jump table
29832983
assert(JT.SL && "Should set SDLoc for SelectionDAG!");
2984-
assert(JT.Reg != -1U && "Should lower JT Header first!");
2984+
assert(JT.Reg && "Should lower JT Header first!");
29852985
EVT PTy = DAG.getTargetLoweringInfo().getJumpTableRegTy(DAG.getDataLayout());
29862986
SDValue Index = DAG.getCopyFromReg(getControlRoot(), *JT.SL, JT.Reg, PTy);
29872987
SDValue Table = DAG.getJumpTable(JT.JTI, PTy);
@@ -3261,10 +3261,9 @@ void SelectionDAGBuilder::visitBitTestHeader(BitTestBlock &B,
32613261

32623262
/// visitBitTestCase - this function produces one "bit test"
32633263
void SelectionDAGBuilder::visitBitTestCase(BitTestBlock &BB,
3264-
MachineBasicBlock* NextMBB,
3264+
MachineBasicBlock *NextMBB,
32653265
BranchProbability BranchProbToNext,
3266-
unsigned Reg,
3267-
BitTestCase &B,
3266+
Register Reg, BitTestCase &B,
32683267
MachineBasicBlock *SwitchBB) {
32693268
SDLoc dl = getCurSDLoc();
32703269
MVT VT = BB.RegVT;

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ class SelectionDAGBuilder {
526526
void visitBitTestHeader(SwitchCG::BitTestBlock &B,
527527
MachineBasicBlock *SwitchBB);
528528
void visitBitTestCase(SwitchCG::BitTestBlock &BB, MachineBasicBlock *NextMBB,
529-
BranchProbability BranchProbToNext, unsigned Reg,
529+
BranchProbability BranchProbToNext, Register Reg,
530530
SwitchCG::BitTestCase &B, MachineBasicBlock *SwitchBB);
531531
void visitJumpTable(SwitchCG::JumpTable &JT);
532532
void visitJumpTableHeader(SwitchCG::JumpTable &JT,

llvm/lib/CodeGen/SwitchLoweringUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ bool SwitchCG::SwitchLowering::buildJumpTable(const CaseClusterVector &Clusters,
254254
->createJumpTableIndex(Table);
255255

256256
// Set up the jump table info.
257-
JumpTable JT(-1U, JTI, JumpTableMBB, nullptr, SL);
257+
JumpTable JT(Register(), JTI, JumpTableMBB, nullptr, SL);
258258
JumpTableHeader JTH(Clusters[First].Low->getValue(),
259259
Clusters[Last].High->getValue(), SI->getCondition(),
260260
nullptr, false);
@@ -455,7 +455,7 @@ bool SwitchCG::SwitchLowering::buildBitTests(CaseClusterVector &Clusters,
455455
BTI.push_back(BitTestCase(CB.Mask, BitTestBB, CB.BB, CB.ExtraProb));
456456
}
457457
BitTestCases.emplace_back(std::move(LowBound), std::move(CmpRange),
458-
SI->getCondition(), -1U, MVT::Other, false,
458+
SI->getCondition(), Register(), MVT::Other, false,
459459
ContiguousRange, nullptr, nullptr, std::move(BTI),
460460
TotalProb);
461461

0 commit comments

Comments
 (0)