Lines Matching +full:max +full:- +full:functions
1 //===- AMDGPUResourceUsageAnalysis.h ---- analysis of resources -----------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 /// functions.
20 /// hardware-entrypoints. Therefore the register usage of functions with
21 /// indirect calls is estimated as the maximum of all non-entrypoint functions
24 //===----------------------------------------------------------------------===//
41 #define DEBUG_TYPE "amdgpu-resource-usage"
48 // only due to dynamic / non-entry block allocas.
50 "amdgpu-assume-external-call-stack-size",
55 "amdgpu-assume-dynamic-stack-object-size",
68 return cast<Function>(Op.getGlobal()->stripPointerCastsAndAliases()); in getCalleeFunction()
104 const TargetMachine &TM = TPC->getTM<TargetMachine>(); in runOnModule()
125 Function *F = IT->getFunction(); in runOnModule()
126 if (!F || F->isDeclaration()) in runOnModule()
134 SIFunctionResourceInfo &Info = CI.first->second; in runOnModule()
141 // It's possible we have unreachable functions in the module which weren't in runOnModule()
146 if (!F || F->isDeclaration()) in runOnModule()
151 if (!CI.second) // Skip already visited functions in runOnModule()
154 SIFunctionResourceInfo &Info = CI.first->second; in runOnModule()
180 const SIRegisterInfo &TRI = TII->getRegisterInfo(); in analyzeResourceUsage()
184 MRI.isLiveIn(MFI->getPreloadedReg( in analyzeResourceUsage()
193 if (Info.UsesFlatScratch && !MFI->getUserSGPRInfo().hasFlatScratchInit() && in analyzeResourceUsage()
207 if (MFI->isStackRealigned()) in analyzeResourceUsage()
258 int32_t MaxVGPR = -1; in analyzeResourceUsage()
259 int32_t MaxAGPR = -1; in analyzeResourceUsage()
260 int32_t MaxSGPR = -1; in analyzeResourceUsage()
502 int MaxUsed = HWReg + Width - 1; in analyzeResourceUsage()
517 TII->getNamedOperand(MI, AMDGPU::OpName::callee); in analyzeResourceUsage()
527 if (Callee && AMDGPU::isEntryFunctionCC(Callee->getCallingConv())) in analyzeResourceUsage()
530 bool IsIndirect = !Callee || Callee->isDeclaration(); in analyzeResourceUsage()
535 if (!Callee || !Callee->doesNotRecurse()) { in analyzeResourceUsage()
547 CalleeFrameSize = std::max( in analyzeResourceUsage()
555 std::max(CalleeFrameSize, in analyzeResourceUsage()
566 MaxSGPR = std::max(I->second.NumExplicitSGPR - 1, MaxSGPR); in analyzeResourceUsage()
567 MaxVGPR = std::max(I->second.NumVGPR - 1, MaxVGPR); in analyzeResourceUsage()
568 MaxAGPR = std::max(I->second.NumAGPR - 1, MaxAGPR); in analyzeResourceUsage()
570 std::max(I->second.PrivateSegmentSize, CalleeFrameSize); in analyzeResourceUsage()
571 Info.UsesVCC |= I->second.UsesVCC; in analyzeResourceUsage()
572 Info.UsesFlatScratch |= I->second.UsesFlatScratch; in analyzeResourceUsage()
573 Info.HasDynamicallySizedStack |= I->second.HasDynamicallySizedStack; in analyzeResourceUsage()
574 Info.HasRecursion |= I->second.HasRecursion; in analyzeResourceUsage()
575 Info.HasIndirectCall |= I->second.HasIndirectCall; in analyzeResourceUsage()
590 // Collect the maximum number of registers from non-hardware-entrypoints. in propagateIndirectCallRegisterUsage()
591 // All these functions are potential targets for indirect calls. in propagateIndirectCallRegisterUsage()
597 if (!AMDGPU::isEntryFunctionCC(I.getFirst()->getCallingConv())) { in propagateIndirectCallRegisterUsage()
599 NonKernelMaxSGPRs = std::max(NonKernelMaxSGPRs, Info.NumExplicitSGPR); in propagateIndirectCallRegisterUsage()
600 NonKernelMaxVGPRs = std::max(NonKernelMaxVGPRs, Info.NumVGPR); in propagateIndirectCallRegisterUsage()
601 NonKernelMaxAGPRs = std::max(NonKernelMaxAGPRs, Info.NumAGPR); in propagateIndirectCallRegisterUsage()
605 // Add register usage for functions with indirect calls. in propagateIndirectCallRegisterUsage()
606 // For calls to unknown functions, we assume the maximum register usage of in propagateIndirectCallRegisterUsage()
607 // all non-hardware-entrypoints in the current module. in propagateIndirectCallRegisterUsage()
611 Info.NumExplicitSGPR = std::max(Info.NumExplicitSGPR, NonKernelMaxSGPRs); in propagateIndirectCallRegisterUsage()
612 Info.NumVGPR = std::max(Info.NumVGPR, NonKernelMaxVGPRs); in propagateIndirectCallRegisterUsage()
613 Info.NumAGPR = std::max(Info.NumAGPR, NonKernelMaxAGPRs); in propagateIndirectCallRegisterUsage()