LLVM 22.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#include "llvm/IR/PassManager.h"
21
22namespace llvm {
23
24class GCNSubtarget;
25class MachineFunction;
26class GCNTargetMachine;
27
29public:
30 static char ID;
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;
38 int32_t NumNamedBarrier = 0;
41 bool UsesVCC = false;
42 bool UsesFlatScratch = false;
44 bool HasRecursion = false;
45 bool HasIndirectCall = false;
47 };
48
51 uint32_t AssumedStackSizeForDynamicSizeObjects,
52 uint32_t AssumedStackSizeForExternalCall) const;
53};
54
59
60public:
61 static char ID;
63
64 bool runOnMachineFunction(MachineFunction &MF) override;
65
67
68 void getAnalysisUsage(AnalysisUsage &AU) const override {
69 AU.setPreservesAll();
71 }
72};
73
75 : public AnalysisInfoMixin<AMDGPUResourceUsageAnalysis> {
77 static AnalysisKey Key;
78
79 const GCNTargetMachine &TM;
80
81public:
84
86};
87
88} // namespace llvm
89#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURESOURCEUSAGEANALYSIS_H
This header defines various interfaces for pass management in LLVM.
This file defines the SmallVector class.
Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
AMDGPUResourceUsageAnalysis(const GCNTargetMachine &TM_)
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
SIFunctionResourceInfo analyzeResourceUsage(const MachineFunction &MF, uint32_t AssumedStackSizeForDynamicSizeObjects, uint32_t AssumedStackSizeForExternalCall) const
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const FunctionResourceInfo & getResourceInfo() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:93
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:29