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());
104 const TargetMachine &TM = TPC->getTM<TargetMachine>();
125 Function *F = IT->getFunction();
126 if (!F || F->isDeclaration())
134 SIFunctionResourceInfo &Info = CI.first->second;
141 // It's possible we have unreachable functions in the module which weren't
146 if (!F || F->isDeclaration())
151 if (!CI.second) // Skip already visited functions
154 SIFunctionResourceInfo &Info = CI.first->second;
180 const SIRegisterInfo &TRI = TII->getRegisterInfo();
184 MRI.isLiveIn(MFI->getPreloadedReg(
193 if (Info.UsesFlatScratch && !MFI->getUserSGPRInfo().hasFlatScratchInit() &&
207 if (MFI->isStackRealigned())
258 int32_t MaxVGPR = -1;
259 int32_t MaxAGPR = -1;
260 int32_t MaxSGPR = -1;
502 int MaxUsed = HWReg + Width - 1;
517 TII->getNamedOperand(MI, AMDGPU::OpName::callee);
527 if (Callee && AMDGPU::isEntryFunctionCC(Callee->getCallingConv()))
530 bool IsIndirect = !Callee || Callee->isDeclaration();
535 if (!Callee || !Callee->doesNotRecurse()) {
547 CalleeFrameSize = std::max(
555 std::max(CalleeFrameSize,
566 MaxSGPR = std::max(I->second.NumExplicitSGPR - 1, MaxSGPR);
567 MaxVGPR = std::max(I->second.NumVGPR - 1, MaxVGPR);
568 MaxAGPR = std::max(I->second.NumAGPR - 1, MaxAGPR);
570 std::max(I->second.PrivateSegmentSize, CalleeFrameSize);
571 Info.UsesVCC |= I->second.UsesVCC;
572 Info.UsesFlatScratch |= I->second.UsesFlatScratch;
573 Info.HasDynamicallySizedStack |= I->second.HasDynamicallySizedStack;
574 Info.HasRecursion |= I->second.HasRecursion;
575 Info.HasIndirectCall |= I->second.HasIndirectCall;
590 // Collect the maximum number of registers from non-hardware-entrypoints.
591 // All these functions are potential targets for indirect calls.
597 if (!AMDGPU::isEntryFunctionCC(I.getFirst()->getCallingConv())) {
599 NonKernelMaxSGPRs = std::max(NonKernelMaxSGPRs, Info.NumExplicitSGPR);
600 NonKernelMaxVGPRs = std::max(NonKernelMaxVGPRs, Info.NumVGPR);
601 NonKernelMaxAGPRs = std::max(NonKernelMaxAGPRs, Info.NumAGPR);
605 // Add register usage for functions with indirect calls.
606 // For calls to unknown functions, we assume the maximum register usage of
607 // all non-hardware-entrypoints in the current module.
611 Info.NumExplicitSGPR = std::max(Info.NumExplicitSGPR, NonKernelMaxSGPRs);
612 Info.NumVGPR = std::max(Info.NumVGPR, NonKernelMaxVGPRs);
613 Info.NumAGPR = std::max(Info.NumAGPR, NonKernelMaxAGPRs);