Go to the documentation of this file.
32 #define DEBUG_TYPE "ip-regalloc"
35 "Number of functions optimized for callee saved registers");
47 return "Register Usage Information Collector Pass";
70 "Register Usage Information Collector",
false,
false)
100 bool RegUsageInfoCollector::runOnMachineFunction(
MachineFunction &MF) {
106 <<
" -------------------- \nFunction Name : "
122 std::vector<uint32_t> RegMask;
128 RegMask.resize(RegMaskSize, ~((
uint32_t)0));
138 computeCalleeSavedRegs(SavedRegs, MF);
141 auto SetRegAsDefined = [&RegMask] (
unsigned Reg) {
142 RegMask[
Reg / 32] &= ~(1u <<
Reg % 32);
149 SetRegAsDefined(*AI);
154 for (
unsigned PReg = 1, PRegE =
TRI->
getNumRegs(); PReg < PRegE; ++PReg) {
156 if (SavedRegs.
test(PReg))
162 if (!SavedRegs.
test(*AI))
163 SetRegAsDefined(*AI);
169 if (UsedPhysRegsMask.
test(PReg))
170 SetRegAsDefined(PReg);
177 <<
" function optimized for not having CSR.\n");
181 for (
unsigned PReg = 1, PRegE =
TRI->
getNumRegs(); PReg < PRegE; ++PReg) {
182 if (MachineOperand::clobbersPhysReg(&(RegMask[0]), PReg))
183 dbgs() << printReg(PReg, TRI) <<
" ";
186 dbgs() <<
" \n----------------------------------------\n";
194 void RegUsageInfoCollector::
202 if (SavedRegs.
none())
207 for (
unsigned i = 0; CSRegs[
i]; ++
i) {
virtual void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs.
This is an optimization pass for GlobalISel generic memory operations.
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.
Information about stack frame layout on the target.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
void clear()
clear - Removes all bits from the bitvector.
bool none() const
none - Returns true if none of the bits are set.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
Reg
All possible values of the reg field in the ModR/M byte.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
@ AMDGPU_GS
Used for Mesa/AMDPAL geometry shaders.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
@ AMDGPU_LS
Used for AMDPAL vertex shader if tessellation is in use.
@ AMDGPU_VS
Used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (vertex shader if tess...
unsigned const TargetRegisterInfo * TRI
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Register Usage Information Collector
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
virtual const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const =0
Return a null-terminated list of all of the callee-saved registers on this target.
virtual bool isProfitableForNoCSROpt(const Function &F) const
Check if the no-CSR optimisation is profitable for the given function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
Represent the analysis usage information of a pass.
void storeUpdateRegUsageInfo(const Function &FP, ArrayRef< uint32_t > RegMask)
To store RegMask for given Function *.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
STATISTIC(NumFunctions, "Total number of functions")
@ AMDGPU_CS
Used for Mesa/AMDPAL compute shaders.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
bool def_empty(Register RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void initializeRegUsageInfoCollectorPass(PassRegistry &)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
static bool isCallableFunction(const MachineFunction &MF)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
static bool isSafeForNoCSROpt(const Function &F)
Check if given function is safe for not having callee saved registers.
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ AMDGPU_ES
Used for AMDPAL shader stage before geometry shader if geometry is in use.
StringRef - Represent a constant reference to a string, i.e.
unsigned const MachineRegisterInfo * MRI
Wrapper class representing virtual and physical registers.
const BitVector & getUsedPhysRegsMask() const
FunctionPass * createRegUsageInfoCollector()
This pass is executed POST-RA to collect which physical registers are preserved by given machine func...
INITIALIZE_PASS_BEGIN(RegUsageInfoCollector, "RegUsageInfoCollector", "Register Usage Information Collector", false, false) INITIALIZE_PASS_END(RegUsageInfoCollector
bool test(unsigned Idx) const
Function & getFunction()
Return the LLVM function that this machine code represents.
virtual const TargetFrameLowering * getFrameLowering() const
void setPreservesAll()
Set by analyses that do not transform their input at all.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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...
@ AMDGPU_HS
Used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
MCSubRegIterator enumerates all sub-registers of Reg.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
@ AMDGPU_PS
Used for Mesa/AMDPAL pixel shaders.
const char LLVMTargetMachineRef TM
FunctionPass class - This class is used to implement most global optimizations.
AnalysisUsage & addRequired()
MCRegAliasIterator enumerates all registers aliasing Reg.