LLVM 20.0.0git
AMDGPUResourceUsageAnalysis.h
Go to the documentation of this file.
1//===- AMDGPUResourceUsageAnalysis.h ---- analysis of resources -*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10/// \brief Analyzes how many registers and other resources are used by
11/// functions.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPURESOURCEUSAGEANALYSIS_H
16#define LLVM_LIB_TARGET_AMDGPU_AMDGPURESOURCEUSAGEANALYSIS_H
17
20
21namespace llvm {
22
23class GCNSubtarget;
24class MachineFunction;
25class TargetMachine;
26
28 static char ID;
29
30public:
31 // Track resource usage for callee functions.
33 // Track the number of explicitly used VGPRs. Special registers reserved at
34 // the end are tracked separately.
35 int32_t NumVGPR = 0;
36 int32_t NumAGPR = 0;
37 int32_t NumExplicitSGPR = 0;
39 bool UsesVCC = false;
40 bool UsesFlatScratch = false;
42 bool HasRecursion = false;
43 bool HasIndirectCall = false;
44
45 int32_t getTotalNumSGPRs(const GCNSubtarget &ST) const;
46 // Total number of VGPRs is actually a combination of AGPR and VGPR
47 // depending on architecture - and some alignment constraints
48 int32_t getTotalNumVGPRs(const GCNSubtarget &ST) const;
49 };
50
52
53 bool doInitialization(Module &M) override {
54 CallGraphResourceInfo.clear();
56 }
57
58 bool runOnModule(Module &M) override;
59
60 void getAnalysisUsage(AnalysisUsage &AU) const override {
62 AU.setPreservesAll();
63 }
64
66 auto Info = CallGraphResourceInfo.find(F);
67 assert(Info != CallGraphResourceInfo.end() &&
68 "Failed to find resource info for function");
69 return Info->getSecond();
70 }
71
72private:
73 SIFunctionResourceInfo
74 analyzeResourceUsage(const MachineFunction &MF, const TargetMachine &TM,
75 uint32_t AssumedStackSizeForDynamicSizeObjects,
76 uint32_t AssumedStackSizeForExternalCall) const;
77 void propagateIndirectCallRegisterUsage();
78
80};
81} // namespace llvm
82#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURESOURCEUSAGEANALYSIS_H
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define F(x, y, z)
Definition: MD5.cpp:55
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:251
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
virtual bool doInitialization(Module &)
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Definition: Pass.h:119
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
const SIFunctionResourceInfo & getResourceInfo(const Function *F) const
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...