mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-21 01:06:46 +00:00
CodeGen: Cleanup regmask construction; NFC
- Avoid duplication of regmask size calculation. - Simplify allocateRegisterMask() call. - Rename allocateRegisterMask() to allocateRegMask() to be consistent with naming in MachineOperand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337986 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
12c27f5b53
commit
ee571f2b41
@ -709,13 +709,7 @@ public:
|
||||
}
|
||||
|
||||
/// Allocate and initialize a register mask with @p NumRegister bits.
|
||||
uint32_t *allocateRegisterMask(unsigned NumRegister) {
|
||||
unsigned Size = (NumRegister + 31) / 32;
|
||||
uint32_t *Mask = Allocator.Allocate<uint32_t>(Size);
|
||||
for (unsigned i = 0; i != Size; ++i)
|
||||
Mask[i] = 0;
|
||||
return Mask;
|
||||
}
|
||||
uint32_t *allocateRegMask();
|
||||
|
||||
/// allocateMemRefsArray - Allocate an array to hold MachineMemOperand
|
||||
/// pointers. This array is owned by the MachineFunction.
|
||||
|
@ -616,6 +616,11 @@ public:
|
||||
return Contents.RegMask;
|
||||
}
|
||||
|
||||
/// Returns number of elements needed for a regmask array.
|
||||
static unsigned getRegMaskSize(unsigned NumRegs) {
|
||||
return (NumRegs + 31) / 32;
|
||||
}
|
||||
|
||||
/// getRegLiveOut - Returns a bit mask of live-out registers.
|
||||
const uint32_t *getRegLiveOut() const {
|
||||
assert(isRegLiveOut() && "Wrong MachineOperand accessor");
|
||||
|
@ -1958,13 +1958,11 @@ bool MIParser::parseTargetIndexOperand(MachineOperand &Dest) {
|
||||
|
||||
bool MIParser::parseCustomRegisterMaskOperand(MachineOperand &Dest) {
|
||||
assert(Token.stringValue() == "CustomRegMask" && "Expected a custom RegMask");
|
||||
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
|
||||
assert(TRI && "Expected target register info");
|
||||
lex();
|
||||
if (expectAndConsume(MIToken::lparen))
|
||||
return true;
|
||||
|
||||
uint32_t *Mask = MF.allocateRegisterMask(TRI->getNumRegs());
|
||||
uint32_t *Mask = MF.allocateRegMask();
|
||||
while (true) {
|
||||
if (Token.isNot(MIToken::NamedRegister))
|
||||
return error("expected a named register");
|
||||
@ -1987,9 +1985,7 @@ bool MIParser::parseCustomRegisterMaskOperand(MachineOperand &Dest) {
|
||||
|
||||
bool MIParser::parseLiveoutRegisterMaskOperand(MachineOperand &Dest) {
|
||||
assert(Token.is(MIToken::kw_liveout));
|
||||
const auto *TRI = MF.getSubtarget().getRegisterInfo();
|
||||
assert(TRI && "Expected target register info");
|
||||
uint32_t *Mask = MF.allocateRegisterMask(TRI->getNumRegs());
|
||||
uint32_t *Mask = MF.allocateRegMask();
|
||||
lex();
|
||||
if (expectAndConsume(MIToken::lparen))
|
||||
return true;
|
||||
|
@ -486,6 +486,14 @@ const char *MachineFunction::createExternalSymbolName(StringRef Name) {
|
||||
return Dest;
|
||||
}
|
||||
|
||||
uint32_t *MachineFunction::allocateRegMask() {
|
||||
unsigned NumRegs = getSubtarget().getRegisterInfo()->getNumRegs();
|
||||
unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
|
||||
uint32_t *Mask = Allocator.Allocate<uint32_t>(Size);
|
||||
memset(Mask, 0, Size * sizeof(Mask[0]));
|
||||
return Mask;
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
||||
LLVM_DUMP_METHOD void MachineFunction::dump() const {
|
||||
print(dbgs());
|
||||
|
@ -96,7 +96,7 @@ bool RegUsageInfoCollector::runOnMachineFunction(MachineFunction &MF) {
|
||||
// Compute the size of the bit vector to represent all the registers.
|
||||
// The bit vector is broken into 32-bit chunks, thus takes the ceil of
|
||||
// the number of registers divided by 32 for the size.
|
||||
unsigned RegMaskSize = (TRI->getNumRegs() + 31) / 32;
|
||||
unsigned RegMaskSize = MachineOperand::getRegMaskSize(TRI->getNumRegs());
|
||||
RegMask.resize(RegMaskSize, 0xFFFFFFFF);
|
||||
|
||||
const Function &F = MF.getFunction();
|
||||
|
@ -160,7 +160,7 @@ void StackMapLiveness::addLiveOutSetToMI(MachineFunction &MF,
|
||||
/// register live set.
|
||||
uint32_t *StackMapLiveness::createRegisterMask(MachineFunction &MF) const {
|
||||
// The mask is owned and cleaned up by the Machine Function.
|
||||
uint32_t *Mask = MF.allocateRegisterMask(TRI->getNumRegs());
|
||||
uint32_t *Mask = MF.allocateRegMask();
|
||||
for (auto Reg : LiveRegs)
|
||||
Mask[Reg / 32] |= 1U << (Reg % 32);
|
||||
|
||||
|
@ -3909,9 +3909,9 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
||||
const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();
|
||||
|
||||
// Allocate a new Reg Mask and copy Mask.
|
||||
RegMask = MF.allocateRegisterMask(TRI->getNumRegs());
|
||||
unsigned RegMaskSize = (TRI->getNumRegs() + 31) / 32;
|
||||
memcpy(RegMask, Mask, sizeof(uint32_t) * RegMaskSize);
|
||||
RegMask = MF.allocateRegMask();
|
||||
unsigned RegMaskSize = MachineOperand::getRegMaskSize(TRI->getNumRegs());
|
||||
memcpy(RegMask, Mask, sizeof(RegMask[0]) * RegMaskSize);
|
||||
|
||||
// Make sure all sub registers of the argument registers are reset
|
||||
// in the RegMask.
|
||||
|
Loading…
x
Reference in New Issue
Block a user