Skip to content

Commit a15ce9e

Browse files
committed
encapsulate regmask creation
1 parent e837f7e commit a15ce9e

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

llvm/include/llvm/CodeGen/MachineFunction.h

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

1151+
MutableArrayRef<uint32_t> allocateRegMaskArray();
1152+
11511153
ArrayRef<int> allocateShuffleMask(ArrayRef<int> Mask);
11521154

11531155
/// 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
@@ -623,11 +623,15 @@ const char *MachineFunction::createExternalSymbolName(StringRef Name) {
623623
}
624624

625625
uint32_t *MachineFunction::allocateRegMask() {
626+
return allocateRegMaskArray().data();
627+
}
628+
629+
MutableArrayRef<uint32_t> MachineFunction::allocateRegMaskArray() {
626630
unsigned NumRegs = getSubtarget().getRegisterInfo()->getNumRegs();
627631
unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
628632
uint32_t *Mask = Allocator.Allocate<uint32_t>(Size);
629633
memset(Mask, 0, Size * sizeof(Mask[0]));
630-
return Mask;
634+
return {Mask, Size};
631635
}
632636

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

llvm/lib/CodeGen/MachineOutliner.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "llvm/Support/SuffixTree.h"
7979
#include "llvm/Support/raw_ostream.h"
8080
#include "llvm/Transforms/Utils/ModuleUtils.h"
81+
#include <cstdint>
8182
#include <tuple>
8283
#include <vector>
8384

@@ -1165,15 +1166,13 @@ bool MachineOutliner::outline(
11651166
CallInst->addOperand(
11661167
MachineOperand::CreateRegMask(*RegMasks.begin()));
11671168
} 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]));
1169+
auto RegMask = MF->allocateRegMaskArray();
1170+
for (unsigned I = 0; I < RegMask.size(); ++I)
1171+
RegMask[I] = UINT32_MAX;
11731172
for (const uint32_t *Mask : RegMasks)
1174-
for (unsigned I = 0; I < Size; ++I)
1173+
for (unsigned I = 0; I < RegMask.size(); ++I)
11751174
RegMask[I] &= Mask[I];
1176-
CallInst->addOperand(MachineOperand::CreateRegMask(RegMask));
1175+
CallInst->addOperand(MachineOperand::CreateRegMask(RegMask.data()));
11771176
}
11781177
}
11791178

0 commit comments

Comments
 (0)