LLVM  16.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 
12 #include "Utils/AMDGPUBaseInfo.h"
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/Optional.h"
16 #include "llvm/IR/DataLayout.h"
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/GlobalValue.h"
19 #include "llvm/IR/GlobalVariable.h"
20 
21 namespace llvm {
22 
24  /// A map to keep track of local memory objects and their offsets within the
25  /// local memory space.
27 
28 protected:
29  uint64_t ExplicitKernArgSize = 0; // Cache for this.
30  Align MaxKernArgAlign; // Cache for this.
31 
32  /// Number of bytes in the LDS that are being used.
35 
36  /// Number of bytes in the LDS allocated statically. This field is only used
37  /// in the instruction selector and not part of the machine function info.
40 
41  /// Align for dynamic shared memory if any. Dynamic shared memory is
42  /// allocated directly after the static one, i.e., LDSSize. Need to pad
43  /// LDSSize to ensure that dynamic one is aligned accordingly.
44  /// The maximal alignment is updated during IR translation or lowering
45  /// stages.
47 
48  // Kernels + shaders. i.e. functions called by the hardware and not called
49  // by other functions.
50  bool IsEntryFunction = false;
51 
52  // Entry points called by other functions instead of directly by the hardware.
53  bool IsModuleEntryFunction = false;
54 
55  bool NoSignedZerosFPMath = false;
56 
57  // Function may be memory bound.
58  bool MemoryBound = false;
59 
60  // Kernel may need limited waves per EU for better performance.
61  bool WaveLimiter = false;
62 
63 public:
65 
67  return ExplicitKernArgSize;
68  }
69 
71 
72  uint32_t getLDSSize() const {
73  return LDSSize;
74  }
75 
76  uint32_t getGDSSize() const {
77  return GDSSize;
78  }
79 
80  bool isEntryFunction() const {
81  return IsEntryFunction;
82  }
83 
85 
86  bool hasNoSignedZerosFPMath() const {
87  return NoSignedZerosFPMath;
88  }
89 
90  bool isMemoryBound() const {
91  return MemoryBound;
92  }
93 
94  bool needsWaveLimiter() const {
95  return WaveLimiter;
96  }
97 
98  unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV) {
99  return allocateLDSGlobal(DL, GV, DynLDSAlign);
100  }
101  unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV,
102  Align Trailing);
103 
105 
106  // A kernel function may have an associated LDS allocation, and a kernel-scope
107  // LDS allocation must have an associated kernel function
108  static const GlobalVariable *
110 
112 
113  Align getDynLDSAlign() const { return DynLDSAlign; }
114 
115  void setDynLDSAlign(const DataLayout &DL, const GlobalVariable &GV);
116 };
117 
118 }
119 #endif
llvm::AMDGPUMachineFunction::getMaxKernArgAlign
Align getMaxKernArgAlign() const
Definition: AMDGPUMachineFunction.h:70
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::AMDGPUMachineFunction::ExplicitKernArgSize
uint64_t ExplicitKernArgSize
Definition: AMDGPUMachineFunction.h:29
Optional.h
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::Function
Definition: Function.h:60
llvm::AMDGPUMachineFunction::getDynLDSAlign
Align getDynLDSAlign() const
Definition: AMDGPUMachineFunction.h:113
llvm::AMDGPUMachineFunction::AMDGPUMachineFunction
AMDGPUMachineFunction(const MachineFunction &MF)
Definition: AMDGPUMachineFunction.cpp:19
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::SmallDenseMap
Definition: DenseMap.h:880
llvm::AMDGPUMachineFunction::LDSSize
uint32_t LDSSize
Number of bytes in the LDS that are being used.
Definition: AMDGPUMachineFunction.h:33
llvm::AMDGPUMachineFunction::getLDSSize
uint32_t getLDSSize() const
Definition: AMDGPUMachineFunction.h:72
DenseMap.h
llvm::Optional< uint32_t >
llvm::AMDGPUMachineFunction::WaveLimiter
bool WaveLimiter
Definition: AMDGPUMachineFunction.h:61
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::AMDGPUMachineFunction::getKernelLDSGlobalFromFunction
static const GlobalVariable * getKernelLDSGlobalFromFunction(const Function &F)
Definition: AMDGPUMachineFunction.cpp:88
llvm::AMDGPUMachineFunction::needsWaveLimiter
bool needsWaveLimiter() const
Definition: AMDGPUMachineFunction.h:94
GlobalValue.h
llvm::AMDGPUMachineFunction::NoSignedZerosFPMath
bool NoSignedZerosFPMath
Definition: AMDGPUMachineFunction.h:55
llvm::AMDGPUMachineFunction::allocateLDSGlobal
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV)
Definition: AMDGPUMachineFunction.h:98
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::AMDGPUMachineFunction::MemoryBound
bool MemoryBound
Definition: AMDGPUMachineFunction.h:58
llvm::AMDGPUMachineFunction::getLDSKernelIdMetadata
static Optional< uint32_t > getLDSKernelIdMetadata(const Function &F)
Definition: AMDGPUMachineFunction.cpp:147
llvm::AMDGPUMachineFunction::allocateKnownAddressLDSGlobal
void allocateKnownAddressLDSGlobal(const Function &F)
Definition: AMDGPUMachineFunction.cpp:101
uint64_t
llvm::AMDGPUMachineFunction::isEntryFunction
bool isEntryFunction() const
Definition: AMDGPUMachineFunction.h:80
llvm::AMDGPUMachineFunction::IsModuleEntryFunction
bool IsModuleEntryFunction
Definition: AMDGPUMachineFunction.h:53
llvm::AMDGPUMachineFunction::getExplicitKernArgSize
uint64_t getExplicitKernArgSize() const
Definition: AMDGPUMachineFunction.h:66
llvm::AMDGPUMachineFunction::getGDSSize
uint32_t getGDSSize() const
Definition: AMDGPUMachineFunction.h:76
llvm::AMDGPUMachineFunction::isMemoryBound
bool isMemoryBound() const
Definition: AMDGPUMachineFunction.h:90
llvm::MachineFunction
Definition: MachineFunction.h:257
DataLayout.h
uint32_t
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::AMDGPUMachineFunction::StaticLDSSize
uint32_t StaticLDSSize
Number of bytes in the LDS allocated statically.
Definition: AMDGPUMachineFunction.h:38
llvm::AMDGPUMachineFunction::isModuleEntryFunction
bool isModuleEntryFunction() const
Definition: AMDGPUMachineFunction.h:84
GlobalVariable.h
Function.h
llvm::AMDGPUMachineFunction::hasNoSignedZerosFPMath
bool hasNoSignedZerosFPMath() const
Definition: AMDGPUMachineFunction.h:86
llvm::AMDGPUMachineFunction::IsEntryFunction
bool IsEntryFunction
Definition: AMDGPUMachineFunction.h:50
llvm::AMDGPUMachineFunction::StaticGDSSize
uint32_t StaticGDSSize
Definition: AMDGPUMachineFunction.h:39
MachineFunction.h
llvm::AMDGPUMachineFunction
Definition: AMDGPUMachineFunction.h:23
llvm::MachineFunctionInfo
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
Definition: MachineFunction.h:95
llvm::AMDGPUMachineFunction::MaxKernArgAlign
Align MaxKernArgAlign
Definition: AMDGPUMachineFunction.h:30
llvm::AMDGPUMachineFunction::GDSSize
uint32_t GDSSize
Definition: AMDGPUMachineFunction.h:34
llvm::AMDGPUMachineFunction::DynLDSAlign
Align DynLDSAlign
Align for dynamic shared memory if any.
Definition: AMDGPUMachineFunction.h:46
AMDGPUBaseInfo.h
llvm::AMDGPUMachineFunction::setDynLDSAlign
void setDynLDSAlign(const DataLayout &DL, const GlobalVariable &GV)
Definition: AMDGPUMachineFunction.cpp:161