LLVM 19.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, int32_t NumAGPR,
49 int32_t NumVGPR) const;
50 int32_t getTotalNumVGPRs(const GCNSubtarget &ST) const;
51 };
52
54
55 bool doInitialization(Module &M) override {
56 CallGraphResourceInfo.clear();
58 }
59
60 bool runOnModule(Module &M) override;
61
62 void getAnalysisUsage(AnalysisUsage &AU) const override {
64 AU.setPreservesAll();
65 }
66
68 auto Info = CallGraphResourceInfo.find(F);
69 assert(Info != CallGraphResourceInfo.end() &&
70 "Failed to find resource info for function");
71 return Info->getSecond();
72 }
73
74private:
75 SIFunctionResourceInfo
76 analyzeResourceUsage(const MachineFunction &MF, const TargetMachine &TM,
77 uint32_t AssumedStackSizeForDynamicSizeObjects,
78 uint32_t AssumedStackSizeForExternalCall) const;
79 void propagateIndirectCallRegisterUsage();
80
82};
83} // namespace llvm
84#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURESOURCEUSAGEANALYSIS_H
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define F(x, y, z)
Definition: MD5.cpp:55
const char LLVMTargetMachineRef TM
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:76
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
int32_t getTotalNumVGPRs(const GCNSubtarget &ST, int32_t NumAGPR, int32_t NumVGPR) const
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 ...