LLVM 20.0.0git
AMDGPUMCResourceInfo.h
Go to the documentation of this file.
1//===- AMDGPUMCResourceInfo.h ----- MC Resource Info --------------*- 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 MC infrastructure to propagate the function level resource usage
11/// info.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMCRESOURCEINFO_H
16#define LLVM_LIB_TARGET_AMDGPU_AMDGPUMCRESOURCEINFO_H
17
20
21namespace llvm {
22
23class MCContext;
24class MCSymbol;
25class StringRef;
26class MachineFunction;
27
29public:
40 };
41
42private:
43 int32_t MaxVGPR = 0;
44 int32_t MaxAGPR = 0;
45 int32_t MaxSGPR = 0;
46
47 // Whether the MCResourceInfo has been finalized through finalize(MCContext
48 // &). Should only be called once, at the end of AsmPrinting to assign MaxXGPR
49 // symbols to their final value.
50 bool Finalized = false;
51
52 void assignResourceInfoExpr(int64_t localValue, ResourceInfoKind RIK,
54 const MachineFunction &MF,
56 MCContext &OutContext);
57
58 // Assigns expression for Max S/V/A-GPRs to the referenced symbols.
59 void assignMaxRegs(MCContext &OutContext);
60
61public:
62 MCResourceInfo() = default;
63 void addMaxVGPRCandidate(int32_t candidate) {
64 MaxVGPR = std::max(MaxVGPR, candidate);
65 }
66 void addMaxAGPRCandidate(int32_t candidate) {
67 MaxAGPR = std::max(MaxAGPR, candidate);
68 }
69 void addMaxSGPRCandidate(int32_t candidate) {
70 MaxSGPR = std::max(MaxSGPR, candidate);
71 }
72
74 MCContext &OutContext);
76 MCContext &Ctx);
77
78 void reset();
79
80 // Resolves the final symbols that requires the inter-function resource info
81 // to be resolved.
82 void finalize(MCContext &OutContext);
83
87
88 /// AMDGPUResourceUsageAnalysis gathers resource usage on a per-function
89 /// granularity. However, some resource info has to be assigned the call
90 /// transitive maximum or accumulative. For example, if A calls B and B's VGPR
91 /// usage exceeds A's, A should be assigned B's VGPR usage. Furthermore,
92 /// functions with indirect calls should be assigned the module level maximum.
94 const MachineFunction &MF,
96 MCContext &OutContext);
97
99 const MCExpr *createTotalNumSGPRs(const MachineFunction &MF, bool hasXnack,
100 MCContext &Ctx);
101};
102} // namespace llvm
103
104#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUMCRESOURCEINFO_H
Analyzes how many registers and other resources are used by functions.
arc branch finalize
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
MCResourceInfo()=default
void addMaxSGPRCandidate(int32_t candidate)
const MCExpr * getSymRefExpr(StringRef FuncName, ResourceInfoKind RIK, MCContext &Ctx)
void gatherResourceInfo(const MachineFunction &MF, const AMDGPUResourceUsageAnalysis::SIFunctionResourceInfo &FRI, MCContext &OutContext)
AMDGPUResourceUsageAnalysis gathers resource usage on a per-function granularity.
MCSymbol * getMaxSGPRSymbol(MCContext &OutContext)
MCSymbol * getMaxAGPRSymbol(MCContext &OutContext)
const MCExpr * createTotalNumVGPRs(const MachineFunction &MF, MCContext &Ctx)
void addMaxAGPRCandidate(int32_t candidate)
MCSymbol * getMaxVGPRSymbol(MCContext &OutContext)
const MCExpr * createTotalNumSGPRs(const MachineFunction &MF, bool hasXnack, MCContext &Ctx)
MCSymbol * getSymbol(StringRef FuncName, ResourceInfoKind RIK, MCContext &OutContext)
void addMaxVGPRCandidate(int32_t candidate)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18