34 #define DEBUG_TYPE "ip-regalloc" 37 "Number of functions optimized for callee saved registers");
49 return "Register Usage Information Collector Pass";
72 "Register Usage Information Collector",
false,
false)
87 <<
" -------------------- \n");
90 std::vector<uint32_t> RegMask;
96 RegMask.resize(RegMaskSize, ~((
uint32_t)0));
106 computeCalleeSavedRegs(SavedRegs, MF);
109 auto SetRegAsDefined = [&RegMask] (
unsigned Reg) {
110 RegMask[
Reg / 32] &= ~(1u <<
Reg % 32);
114 for (
unsigned PReg = 1, PRegE = TRI->
getNumRegs(); PReg < PRegE; ++PReg) {
116 if (SavedRegs.
test(PReg))
122 if (!SavedRegs.
test(*AI))
123 SetRegAsDefined(*AI);
129 if (UsedPhysRegsMask.
test(PReg))
130 SetRegAsDefined(PReg);
136 <<
" function optimized for not having CSR.\n");
139 for (
unsigned PReg = 1, PRegE = TRI->
getNumRegs(); PReg < PRegE; ++PReg)
143 LLVM_DEBUG(
dbgs() <<
" \n----------------------------------------\n");
150 void RegUsageInfoCollector::
161 for (
unsigned i = 0; CSRegs[i]; ++i) {
162 unsigned Reg = CSRegs[i];
163 if (SavedRegs.
test(Reg))
170 if (!RC->CoveredBySubRegs)
173 for (
unsigned PReg = 1, PRegE = TRI.
getNumRegs(); PReg < PRegE; ++PReg) {
174 if (SavedRegs.
test(PReg))
178 if (!RC->contains(PReg))
182 bool AllSubRegsSaved =
true;
184 if (!SavedRegs.
test(*SR)) {
185 AllSubRegsSaved =
false;
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
bool test(unsigned Idx) const
void initializeRegUsageInfoCollectorPass(PassRegistry &)
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
static bool isSafeForNoCSROpt(const Function &F)
Check if given function is safe for not having callee saved registers.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
iterator_range< regclass_iterator > regclasses() const
FunctionPass * createRegUsageInfoCollector()
This pass is executed POST-RA to collect which physical registers are preserved by given machine func...
virtual const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const =0
Return a null-terminated list of all of the callee-saved registers on this target.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void storeUpdateRegUsageInfo(const Function &FP, ArrayRef< uint32_t > RegMask)
To store RegMask for given Function *.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MCRegAliasIterator enumerates all registers aliasing Reg.
Represent the analysis usage information of a pass.
void setTargetMachine(const LLVMTargetMachine &TM)
Set TargetMachine which is used to print analysis.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
FunctionPass class - This class is used to implement most global optimizations.
bool def_empty(unsigned RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MCSubRegIterator enumerates all sub-registers of Reg.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
INITIALIZE_PASS_BEGIN(RegUsageInfoCollector, "RegUsageInfoCollector", "Register Usage Information Collector", false, false) INITIALIZE_PASS_END(RegUsageInfoCollector
Information about stack frame layout on the target.
Promote Memory to Register
const BitVector & getUsedPhysRegsMask() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
void setPreservesAll()
Set by analyses that do not transform their input at all.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
virtual const TargetFrameLowering * getFrameLowering() const
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
This pass is required to take advantage of the interprocedural register allocation infrastructure...
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Register Usage Information Collector