Skip to content

Commit db2f85e

Browse files
committed
encapsulate regmask creation
1 parent 404f85a commit db2f85e

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

llvm/include/llvm/CodeGen/MachineFunction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,8 @@ class LLVM_ABI MachineFunction {
11681168
/// Allocate and initialize a register mask with @p NumRegister bits.
11691169
uint32_t *allocateRegMask();
11701170

1171+
MutableArrayRef<uint32_t> allocateRegMaskArray();
1172+
11711173
ArrayRef<int> allocateShuffleMask(ArrayRef<int> Mask);
11721174

11731175
/// Allocate and construct an extra info structure for a `MachineInstr`.

llvm/lib/CodeGen/MachineFunction.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,15 @@ const char *MachineFunction::createExternalSymbolName(StringRef Name) {
620620
}
621621

622622
uint32_t *MachineFunction::allocateRegMask() {
623+
return allocateRegMaskArray().data();
624+
}
625+
626+
MutableArrayRef<uint32_t> MachineFunction::allocateRegMaskArray() {
623627
unsigned NumRegs = getSubtarget().getRegisterInfo()->getNumRegs();
624628
unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
625629
uint32_t *Mask = Allocator.Allocate<uint32_t>(Size);
626630
memset(Mask, 0, Size * sizeof(Mask[0]));
627-
return Mask;
631+
return {Mask, Size};
628632
}
629633

630634
ArrayRef<int> MachineFunction::allocateShuffleMask(ArrayRef<int> Mask) {

llvm/lib/CodeGen/MachineOutliner.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,15 +1165,13 @@ bool MachineOutliner::outline(
11651165
CallInst->addOperand(
11661166
MachineOperand::CreateRegMask(*RegMasks.begin()));
11671167
} else {
1168-
uint32_t *RegMask = MF->allocateRegMask();
1169-
unsigned NumRegs =
1170-
MF->getSubtarget().getRegisterInfo()->getNumRegs();
1171-
unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
1172-
memset(RegMask, UINT32_MAX, Size * sizeof(RegMask[0]));
1168+
auto RegMask = MF->allocateRegMaskArray();
1169+
for (unsigned I = 0; I < RegMask.size(); ++I)
1170+
RegMask[I] = UINT32_MAX;
11731171
for (const uint32_t *Mask : RegMasks)
1174-
for (unsigned I = 0; I < Size; ++I)
1172+
for (unsigned I = 0; I < RegMask.size(); ++I)
11751173
RegMask[I] &= Mask[I];
1176-
CallInst->addOperand(MachineOperand::CreateRegMask(RegMask));
1174+
CallInst->addOperand(MachineOperand::CreateRegMask(RegMask.data()));
11771175
}
11781176
}
11791177

0 commit comments

Comments
 (0)