llvm.org GIT mirror llvm / ee571f2
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 Matthias Braun 2 years ago
7 changed file(s) with 21 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
708708 }
709709
710710 /// Allocate and initialize a register mask with @p NumRegister bits.
711 uint32_t *allocateRegisterMask(unsigned NumRegister) {
712 unsigned Size = (NumRegister + 31) / 32;
713 uint32_t *Mask = Allocator.Allocate(Size);
714 for (unsigned i = 0; i != Size; ++i)
715 Mask[i] = 0;
716 return Mask;
717 }
711 uint32_t *allocateRegMask();
718712
719713 /// allocateMemRefsArray - Allocate an array to hold MachineMemOperand
720714 /// pointers. This array is owned by the MachineFunction.
615615 return Contents.RegMask;
616616 }
617617
618 /// Returns number of elements needed for a regmask array.
619 static unsigned getRegMaskSize(unsigned NumRegs) {
620 return (NumRegs + 31) / 32;
621 }
622
618623 /// getRegLiveOut - Returns a bit mask of live-out registers.
619624 const uint32_t *getRegLiveOut() const {
620625 assert(isRegLiveOut() && "Wrong MachineOperand accessor");
19571957
19581958 bool MIParser::parseCustomRegisterMaskOperand(MachineOperand &Dest) {
19591959 assert(Token.stringValue() == "CustomRegMask" && "Expected a custom RegMask");
1960 const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
1961 assert(TRI && "Expected target register info");
19621960 lex();
19631961 if (expectAndConsume(MIToken::lparen))
19641962 return true;
19651963
1966 uint32_t *Mask = MF.allocateRegisterMask(TRI->getNumRegs());
1964 uint32_t *Mask = MF.allocateRegMask();
19671965 while (true) {
19681966 if (Token.isNot(MIToken::NamedRegister))
19691967 return error("expected a named register");
19861984
19871985 bool MIParser::parseLiveoutRegisterMaskOperand(MachineOperand &Dest) {
19881986 assert(Token.is(MIToken::kw_liveout));
1989 const auto *TRI = MF.getSubtarget().getRegisterInfo();
1990 assert(TRI && "Expected target register info");
1991 uint32_t *Mask = MF.allocateRegisterMask(TRI->getNumRegs());
1987 uint32_t *Mask = MF.allocateRegMask();
19921988 lex();
19931989 if (expectAndConsume(MIToken::lparen))
19941990 return true;
485485 return Dest;
486486 }
487487
488 uint32_t *MachineFunction::allocateRegMask() {
489 unsigned NumRegs = getSubtarget().getRegisterInfo()->getNumRegs();
490 unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
491 uint32_t *Mask = Allocator.Allocate(Size);
492 memset(Mask, 0, Size * sizeof(Mask[0]));
493 return Mask;
494 }
495
488496 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
489497 LLVM_DUMP_METHOD void MachineFunction::dump() const {
490498 print(dbgs());
9595 // Compute the size of the bit vector to represent all the registers.
9696 // The bit vector is broken into 32-bit chunks, thus takes the ceil of
9797 // the number of registers divided by 32 for the size.
98 unsigned RegMaskSize = (TRI->getNumRegs() + 31) / 32;
98 unsigned RegMaskSize = MachineOperand::getRegMaskSize(TRI->getNumRegs());
9999 RegMask.resize(RegMaskSize, 0xFFFFFFFF);
100100
101101 const Function &F = MF.getFunction();
159159 /// register live set.
160160 uint32_t *StackMapLiveness::createRegisterMask(MachineFunction &MF) const {
161161 // The mask is owned and cleaned up by the Machine Function.
162 uint32_t *Mask = MF.allocateRegisterMask(TRI->getNumRegs());
162 uint32_t *Mask = MF.allocateRegMask();
163163 for (auto Reg : LiveRegs)
164164 Mask[Reg / 32] |= 1U << (Reg % 32);
165165
39083908 const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();
39093909
39103910 // Allocate a new Reg Mask and copy Mask.
3911 RegMask = MF.allocateRegisterMask(TRI->getNumRegs());
3912 unsigned RegMaskSize = (TRI->getNumRegs() + 31) / 32;
3913 memcpy(RegMask, Mask, sizeof(uint32_t) * RegMaskSize);
3911 RegMask = MF.allocateRegMask();
3912 unsigned RegMaskSize = MachineOperand::getRegMaskSize(TRI->getNumRegs());
3913 memcpy(RegMask, Mask, sizeof(RegMask[0]) * RegMaskSize);
39143914
39153915 // Make sure all sub registers of the argument registers are reset
39163916 // in the RegMask.