33 #define DEBUG_TYPE "ip-regalloc" 36 "Number of functions optimized for callee saved registers");
48 return "Register Usage Information Collector Pass";
71 "Register Usage Information Collector",
false,
false)
101 bool RegUsageInfoCollector::runOnMachineFunction(
MachineFunction &MF) {
107 <<
" -------------------- \nFunction Name : " 123 std::vector<uint32_t> RegMask;
129 RegMask.resize(RegMaskSize, ~((
uint32_t)0));
139 computeCalleeSavedRegs(SavedRegs, MF);
142 auto SetRegAsDefined = [&RegMask] (
unsigned Reg) {
143 RegMask[
Reg / 32] &= ~(1u <<
Reg % 32);
150 SetRegAsDefined(*AI);
155 for (
unsigned PReg = 1, PRegE = TRI->
getNumRegs(); PReg < PRegE; ++PReg) {
157 if (SavedRegs.
test(PReg))
163 if (!SavedRegs.
test(*AI))
164 SetRegAsDefined(*AI);
170 if (UsedPhysRegsMask.
test(PReg))
171 SetRegAsDefined(PReg);
178 <<
" function optimized for not having CSR.\n");
182 for (
unsigned PReg = 1, PRegE = TRI->
getNumRegs(); PReg < PRegE; ++PReg) {
187 dbgs() <<
" \n----------------------------------------\n";
195 void RegUsageInfoCollector::
203 if (SavedRegs.
none())
208 for (
unsigned i = 0; CSRegs[i]; ++i) {
210 if (SavedRegs.
test(Reg)) {
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
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
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Calling convention used for AMDPAL vertex shader if tessellation is in use.
Calling convention used for Mesa/AMDPAL geometry shaders.
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...
FunctionPass * createRegUsageInfoCollector()
This pass is executed POST-RA to collect which physical registers are preserved by given machine func...
virtual ArrayRef< MCPhysReg > getIntraCallClobberedRegs(const MachineFunction *MF) const
Return a list of all of the registers which are clobbered "inside" a call to the given function...
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...
Calling convention used for Mesa/AMDPAL compute shaders.
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
static bool isSafeForNoCSROpt(const Function &F)
Check if given function is safe for not having callee saved registers.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Calling convention used for Mesa/AMDPAL pixel shaders.
Information about stack frame layout on the target.
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.
bool none() const
none - Returns true if none of the bits are set.
virtual void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Calling convention used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (ve...
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...
static bool isCallableFunction(const MachineFunction &MF)
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
Calling convention for AMDGPU code object kernels.
Wrapper class representing virtual and physical registers.
Calling convention used for AMDPAL shader stage before geometry shader if geometry is in use...
virtual bool isProfitableForNoCSROpt(const Function &F) const
Check if the no-CSR optimisation is profitable for the given function.