26 auto GOCS = [FuncName, &OutContext](
StringRef Suffix) {
31 return GOCS(
".num_vgpr");
33 return GOCS(
".num_agpr");
35 return GOCS(
".numbered_sgpr");
37 return GOCS(
".private_seg_size");
39 return GOCS(
".uses_vcc");
41 return GOCS(
".uses_flat_scratch");
43 return GOCS(
".has_dyn_sized_stack");
45 return GOCS(
".has_recursion");
47 return GOCS(
".has_indirect_call");
58void MCResourceInfo::assignMaxRegs(
MCContext &OutContext) {
64 auto assignMaxRegSym = [&OutContext](
MCSymbol *
Sym, int32_t RegCount) {
66 Sym->setVariableValue(MaxExpr);
69 assignMaxRegSym(MaxVGPRSym, MaxVGPR);
70 assignMaxRegSym(MaxAGPRSym, MaxAGPR);
71 assignMaxRegSym(MaxSGPRSym, MaxSGPR);
77 assert(!Finalized &&
"Cannot finalize ResourceInfo again.");
79 assignMaxRegs(OutContext);
94void MCResourceInfo::assignResourceInfoExpr(
102 const MCExpr *SymVal = LocalConstExpr;
104 if (!Callees.
empty()) {
109 for (
const Function *Callee : Callees) {
110 if (!Seen.
insert(Callee).second)
113 MCSymbol *CalleeFnSym = TM.getSymbol(&Callee->getFunction());
144 if (ArgExprs.
size() > 1)
147 Sym->setVariableValue(SymVal);
168 auto SetMaxReg = [&](
MCSymbol *MaxSym, int32_t numRegs,
198 if (!Seen.
insert(Callee).second)
200 if (!Callee->isDeclaration()) {
201 MCSymbol *CalleeFnSym = TM.getSymbol(&Callee->getFunction());
214 const MCExpr *localConstExpr =
216 if (!ArgExprs.
empty()) {
222 Sym->setVariableValue(localConstExpr);
MC infrastructure to propagate the function level resource usage info.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
AMDGPU target specific MCExpr operations.
static const AMDGPUMCExpr * createMax(ArrayRef< const MCExpr * > Args, MCContext &Ctx)
static const AMDGPUMCExpr * createTotalNumVGPR(const MCExpr *NumAGPR, const MCExpr *NumVGPR, MCContext &Ctx)
static const AMDGPUMCExpr * create(VariantKind Kind, ArrayRef< const MCExpr * > Args, MCContext &Ctx)
static const AMDGPUMCExpr * createExtraSGPRs(const MCExpr *VCCUsed, const MCExpr *FlatScrUsed, bool XNACKUsed, MCContext &Ctx)
Allow delayed MCExpr resolve of ExtraSGPRs (in case VCCUsed or FlatScrUsed are unresolvable but neede...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
bool isSymbolUsedInExpression(const MCSymbol *Sym) const
Returns whether the given symbol is used anywhere in the expression or subexpressions.
void addMaxSGPRCandidate(int32_t candidate)
const MCExpr * getSymRefExpr(StringRef FuncName, ResourceInfoKind RIK, MCContext &Ctx)
void gatherResourceInfo(const MachineFunction &MF, const AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo &FRI, MCContext &OutContext)
AMDGPUResourceUsageAnalysis gathers resource usage on a per-function granularity.
MCSymbol * getMaxSGPRSymbol(MCContext &OutContext)
MCSymbol * getMaxAGPRSymbol(MCContext &OutContext)
const MCExpr * createTotalNumVGPRs(const MachineFunction &MF, MCContext &Ctx)
void finalize(MCContext &OutContext)
void addMaxAGPRCandidate(int32_t candidate)
MCSymbol * getMaxVGPRSymbol(MCContext &OutContext)
const MCExpr * createTotalNumSGPRs(const MachineFunction &MF, bool hasXnack, MCContext &Ctx)
MCSymbol * getSymbol(StringRef FuncName, ResourceInfoKind RIK, MCContext &OutContext)
void addMaxVGPRCandidate(int32_t candidate)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MCExpr * getVariableValue(bool SetUsed=true) const
getVariableValue - Get the value for variable symbols.
StringRef getName() const
getName - Get the symbol name.
bool isVariable() const
isVariable - Check if this is a variable symbol.
void setVariableValue(const MCExpr *Value)
Function & getFunction()
Return the LLVM function that this machine code represents.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isEntryFunctionCC(CallingConv::ID CC)
This is an optimization pass for GlobalISel generic memory operations.
bool HasDynamicallySizedStack
uint64_t PrivateSegmentSize
SmallVector< const Function *, 16 > Callees
uint64_t CalleeSegmentSize