LLVM  15.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 
21 namespace llvm {
22 
23 class GCNSubtarget;
24 class MachineFunction;
25 class TargetMachine;
26 
28  static char ID;
29 
30 public:
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 
74 private:
75  SIFunctionResourceInfo analyzeResourceUsage(const MachineFunction &MF,
76  const TargetMachine &TM) const;
77  void propagateIndirectCallRegisterUsage();
78 
80 };
81 } // namespace llvm
82 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURESOURCEUSAGEANALYSIS_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::ModulePass
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:248
llvm::Function
Definition: Function.h:60
llvm::GCNSubtarget
Definition: GCNSubtarget.h:31
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::HasDynamicallySizedStack
bool HasDynamicallySizedStack
Definition: AMDGPUResourceUsageAnalysis.h:41
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::AMDGPUResourceUsageAnalysis::getResourceInfo
const SIFunctionResourceInfo & getResourceInfo(const Function *F) const
Definition: AMDGPUResourceUsageAnalysis.h:67
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::HasRecursion
bool HasRecursion
Definition: AMDGPUResourceUsageAnalysis.h:42
uint64_t
llvm::MachineModuleInfoWrapperPass
Definition: MachineModuleInfo.h:215
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
llvm::DenseMap
Definition: DenseMap.h:716
llvm::AMDGPUResourceUsageAnalysis::runOnModule
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
Definition: AMDGPUResourceUsageAnalysis.cpp:99
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::NumAGPR
int32_t NumAGPR
Definition: AMDGPUResourceUsageAnalysis.h:36
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::getTotalNumVGPRs
int32_t getTotalNumVGPRs(const GCNSubtarget &ST, int32_t NumAGPR, int32_t NumVGPR) const
Definition: AMDGPUResourceUsageAnalysis.cpp:89
MachineModuleInfo.h
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MachineFunction
Definition: MachineFunction.h:241
llvm::Pass::doInitialization
virtual bool doInitialization(Module &)
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Definition: Pass.h:116
CallGraphSCCPass.h
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::UsesVCC
bool UsesVCC
Definition: AMDGPUResourceUsageAnalysis.h:39
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::NumExplicitSGPR
int32_t NumExplicitSGPR
Definition: AMDGPUResourceUsageAnalysis.h:37
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::AMDGPUResourceUsageAnalysis::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: AMDGPUResourceUsageAnalysis.h:62
llvm::AMDGPUResourceUsageAnalysis::AMDGPUResourceUsageAnalysis
AMDGPUResourceUsageAnalysis()
Definition: AMDGPUResourceUsageAnalysis.h:53
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::getTotalNumSGPRs
int32_t getTotalNumSGPRs(const GCNSubtarget &ST) const
Definition: AMDGPUResourceUsageAnalysis.cpp:82
llvm::AMDGPUResourceUsageAnalysis::doInitialization
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Definition: AMDGPUResourceUsageAnalysis.h:55
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::UsesFlatScratch
bool UsesFlatScratch
Definition: AMDGPUResourceUsageAnalysis.h:40
llvm::AMDGPUResourceUsageAnalysis
Definition: AMDGPUResourceUsageAnalysis.h:27
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::PrivateSegmentSize
uint64_t PrivateSegmentSize
Definition: AMDGPUResourceUsageAnalysis.h:38
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::NumVGPR
int32_t NumVGPR
Definition: AMDGPUResourceUsageAnalysis.h:35
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo
Definition: AMDGPUResourceUsageAnalysis.h:32
llvm::AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo::HasIndirectCall
bool HasIndirectCall
Definition: AMDGPUResourceUsageAnalysis.h:43
llvm::AMDGPUResourceUsageAnalysis::ID
static char ID
Definition: AMDGPUResourceUsageAnalysis.h:28