LLVM 23.0.0git
AMDGPUMachineFunction.h
Go to the documentation of this file.
1//===-- AMDGPUMachineFunctionInfo.h -------------------------------*- 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#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H
10#define LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H
11
13#include "llvm/ADT/DenseMap.h"
15#include "llvm/IR/DataLayout.h"
16#include "llvm/IR/Function.h"
17#include "llvm/IR/GlobalValue.h"
19
20namespace llvm {
21
22class AMDGPUSubtarget;
23
25 /// A map to keep track of local memory objects and their offsets within the
26 /// local memory space.
28
29protected:
30 uint64_t ExplicitKernArgSize = 0; // Cache for this.
31 Align MaxKernArgAlign; // Cache for this.
32
33 /// Number of bytes in the LDS that are being used.
36
37 /// Number of bytes in the LDS allocated statically. This field is only used
38 /// in the instruction selector and not part of the machine function info.
41
42 /// Align for dynamic shared memory if any. Dynamic shared memory is
43 /// allocated directly after the static one, i.e., LDSSize. Need to pad
44 /// LDSSize to ensure that dynamic one is aligned accordingly.
45 /// The maximal alignment is updated during IR translation or lowering
46 /// stages.
48
49 // Flag to check dynamic LDS usage by kernel.
50 bool UsesDynamicLDS = false;
51
53
54 // Kernels + shaders. i.e. functions called by the hardware and not called
55 // by other functions.
56 bool IsEntryFunction = false;
57
58 // Entry points called by other functions instead of directly by the hardware.
60
61 // Functions with the amdgpu_cs_chain or amdgpu_cs_chain_preserve CC.
62 bool IsChainFunction = false;
63
64 // Function may be memory bound.
65 bool MemoryBound = false;
66
67 // Kernel may need limited waves per EU for better performance.
68 bool WaveLimiter = false;
69
70 bool HasInitWholeWave = false;
71
72public:
74
78
80
82 return LDSSize;
83 }
84
86 return GDSSize;
87 }
88
89 void recordNumNamedBarriers(uint32_t GVAddr, unsigned BarCnt) {
91 std::max(NumNamedBarriers, ((GVAddr & 0x1ff) >> 4) + BarCnt - 1);
92 }
94
95 bool isEntryFunction() const {
96 return IsEntryFunction;
97 }
98
100
101 bool isChainFunction() const { return IsChainFunction; }
102
103 // The stack is empty upon entry to this function.
104 bool isBottomOfStack() const {
105 return isEntryFunction() || isChainFunction();
106 }
107
108 bool isMemoryBound() const {
109 return MemoryBound;
110 }
111
112 bool needsWaveLimiter() const {
113 return WaveLimiter;
114 }
115
116 bool hasInitWholeWave() const { return HasInitWholeWave; }
118
119 unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV) {
120 return allocateLDSGlobal(DL, GV, DynLDSAlign);
121 }
122
123 unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV,
124 Align Trailing);
125
126 static std::optional<uint32_t> getLDSKernelIdMetadata(const Function &F);
127 static std::optional<uint32_t> getLDSAbsoluteAddress(const GlobalValue &GV);
128
129 Align getDynLDSAlign() const { return DynLDSAlign; }
130
131 void setDynLDSAlign(const Function &F, const GlobalVariable &GV);
132
133 void setUsesDynamicLDS(bool DynLDS);
134
135 bool isDynamicLDSUsed() const;
136};
137
138}
139#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the DenseMap class.
#define F(x, y, z)
Definition MD5.cpp:54
AMDGPUMachineFunction(const Function &F, const AMDGPUSubtarget &ST)
static std::optional< uint32_t > getLDSKernelIdMetadata(const Function &F)
Align DynLDSAlign
Align for dynamic shared memory if any.
uint32_t LDSSize
Number of bytes in the LDS that are being used.
void setDynLDSAlign(const Function &F, const GlobalVariable &GV)
static std::optional< uint32_t > getLDSAbsoluteAddress(const GlobalValue &GV)
void recordNumNamedBarriers(uint32_t GVAddr, unsigned BarCnt)
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV)
uint32_t StaticLDSSize
Number of bytes in the LDS allocated statically.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...