32#define DEBUG_TYPE "ip-regalloc"
35 "Number of functions optimized for callee saved registers");
47 return "Register Usage Information Collector Pass";
67char RegUsageInfoCollector::ID = 0;
70 "Register Usage Information Collector",
false,
false)
106 <<
" -------------------- \nFunction Name : "
122 std::vector<uint32_t> RegMask;
128 RegMask.resize(RegMaskSize, ~((
uint32_t)0));
138 computeCalleeSavedRegs(SavedRegs, MF);
140 const BitVector &UsedPhysRegsMask =
MRI->getUsedPhysRegsMask();
141 auto SetRegAsDefined = [&RegMask] (
unsigned Reg) {
142 RegMask[
Reg / 32] &= ~(1u <<
Reg % 32);
150 for (
const MCPhysReg Reg :
TRI->getIntraCallClobberedRegs(&MF))
152 SetRegAsDefined(*AI);
157 for (
unsigned PReg = 1, PRegE =
TRI->getNumRegs(); PReg < PRegE; ++PReg) {
159 if (SavedRegs.
test(PReg))
163 if (!
MRI->def_empty(PReg)) {
165 if (!SavedRegs.
test(*AI))
166 SetRegAsDefined(*AI);
172 if (UsedPhysRegsMask.
test(PReg))
173 SetRegAsDefined(PReg);
180 <<
" function optimized for not having CSR.\n");
184 for (
unsigned PReg = 1, PRegE =
TRI->getNumRegs(); PReg < PRegE; ++PReg) {
185 if (MachineOperand::clobbersPhysReg(&(RegMask[0]), PReg))
186 dbgs() << printReg(PReg, TRI) <<
" ";
189 dbgs() <<
" \n----------------------------------------\n";
197void RegUsageInfoCollector::
205 if (SavedRegs.
none())
210 for (
unsigned i = 0; CSRegs[i]; ++i) {
212 if (SavedRegs.
test(Reg)) {
unsigned const MachineRegisterInfo * MRI
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Register Usage Information Collector
static bool isCallableFunction(const MachineFunction &MF)
This pass is required to take advantage of the interprocedural register allocation infrastructure.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
bool test(unsigned Idx) const
void clear()
clear - Removes all bits from the bitvector.
bool none() const
none - Returns true if none of the bits are set.
FunctionPass class - This class is used to implement most global optimizations.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
This class describes a target machine that is implemented with the LLVM target-independent code gener...
MCRegAliasIterator enumerates all registers aliasing Reg.
static constexpr unsigned NoRegister
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void storeUpdateRegUsageInfo(const Function &FP, ArrayRef< uint32_t > RegMask)
To store RegMask for given Function *.
void setTargetMachine(const LLVMTargetMachine &TM)
Set TargetMachine which is used to print analysis.
Wrapper class representing virtual and physical registers.
A global registry used in conjunction with static constructors to make pluggable components (like tar...
StringRef - Represent a constant reference to a string, i.e.
Information about stack frame layout on the target.
virtual void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs.
virtual bool isProfitableForNoCSROpt(const Function &F) const
Check if the no-CSR optimisation is profitable for the given function.
static bool isSafeForNoCSROpt(const Function &F)
Check if given function is safe for not having callee saved registers.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const TargetFrameLowering * getFrameLowering() const
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ AMDGPU_CS
Used for Mesa/AMDPAL compute shaders.
@ AMDGPU_VS
Used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (vertex shader if tess...
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ AMDGPU_HS
Used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
@ AMDGPU_GS
Used for Mesa/AMDPAL geometry shaders.
@ AMDGPU_PS
Used for Mesa/AMDPAL pixel shaders.
@ AMDGPU_ES
Used for AMDPAL shader stage before geometry shader if geometry is in use.
@ AMDGPU_LS
Used for AMDPAL vertex shader if tessellation is in use.
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createRegUsageInfoCollector()
This pass is executed POST-RA to collect which physical registers are preserved by given machine func...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void initializeRegUsageInfoCollectorPass(PassRegistry &)