LLVM  15.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"
15 #include "llvm/IR/DataLayout.h"
16 #include "llvm/IR/GlobalValue.h"
17 #include "llvm/IR/GlobalVariable.h"
18 #include "llvm/IR/Function.h"
19 
20 namespace llvm {
21 
23  /// A map to keep track of local memory objects and their offsets within the
24  /// local memory space.
26 
27 protected:
28  uint64_t ExplicitKernArgSize = 0; // Cache for this.
29  Align MaxKernArgAlign; // Cache for this.
30 
31  /// Number of bytes in the LDS that are being used.
34 
35  /// Number of bytes in the LDS allocated statically. This field is only used
36  /// in the instruction selector and not part of the machine function info.
39 
40  /// Align for dynamic shared memory if any. Dynamic shared memory is
41  /// allocated directly after the static one, i.e., LDSSize. Need to pad
42  /// LDSSize to ensure that dynamic one is aligned accordingly.
43  /// The maximal alignment is updated during IR translation or lowering
44  /// stages.
46 
47  // State of MODE register, assumed FP mode.
49 
50  // Kernels + shaders. i.e. functions called by the hardware and not called
51  // by other functions.
52  bool IsEntryFunction = false;
53 
54  // Entry points called by other functions instead of directly by the hardware.
55  bool IsModuleEntryFunction = false;
56 
57  bool NoSignedZerosFPMath = false;
58 
59  // Function may be memory bound.
60  bool MemoryBound = false;
61 
62  // Kernel may need limited waves per EU for better performance.
63  bool WaveLimiter = false;
64 
65 public:
67 
69  return ExplicitKernArgSize;
70  }
71 
73 
74  uint32_t getLDSSize() const {
75  return LDSSize;
76  }
77 
78  uint32_t getGDSSize() const {
79  return GDSSize;
80  }
81 
83  return Mode;
84  }
85 
86  bool isEntryFunction() const {
87  return IsEntryFunction;
88  }
89 
91 
92  bool hasNoSignedZerosFPMath() const {
93  return NoSignedZerosFPMath;
94  }
95 
96  bool isMemoryBound() const {
97  return MemoryBound;
98  }
99 
100  bool needsWaveLimiter() const {
101  return WaveLimiter;
102  }
103 
104  unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV);
105  void allocateModuleLDSGlobal(const Function &F);
106 
107  Align getDynLDSAlign() const { return DynLDSAlign; }
108 
109  void setDynLDSAlign(const DataLayout &DL, const GlobalVariable &GV);
110 };
111 
112 }
113 #endif
llvm::AMDGPUMachineFunction::getMaxKernArgAlign
Align getMaxKernArgAlign() const
Definition: AMDGPUMachineFunction.h:72
llvm::AMDGPUMachineFunction::allocateLDSGlobal
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV)
Definition: AMDGPUMachineFunction.cpp:50
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::AMDGPUMachineFunction::ExplicitKernArgSize
uint64_t ExplicitKernArgSize
Definition: AMDGPUMachineFunction.h:28
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:107
llvm::AMDGPUMachineFunction::AMDGPUMachineFunction
AMDGPUMachineFunction(const MachineFunction &MF)
Definition: AMDGPUMachineFunction.cpp:18
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::SmallDenseMap
Definition: DenseMap.h:882
llvm::AMDGPUMachineFunction::LDSSize
uint32_t LDSSize
Number of bytes in the LDS that are being used.
Definition: AMDGPUMachineFunction.h:32
llvm::AMDGPUMachineFunction::getLDSSize
uint32_t getLDSSize() const
Definition: AMDGPUMachineFunction.h:74
DenseMap.h
llvm::AMDGPU::SIModeRegisterDefaults
Definition: AMDGPUBaseInfo.h:987
llvm::AMDGPUMachineFunction::WaveLimiter
bool WaveLimiter
Definition: AMDGPUMachineFunction.h:63
llvm::AMDGPUMachineFunction::Mode
AMDGPU::SIModeRegisterDefaults Mode
Definition: AMDGPUMachineFunction.h:48
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::AMDGPUMachineFunction::needsWaveLimiter
bool needsWaveLimiter() const
Definition: AMDGPUMachineFunction.h:100
GlobalValue.h
llvm::AMDGPUMachineFunction::NoSignedZerosFPMath
bool NoSignedZerosFPMath
Definition: AMDGPUMachineFunction.h:57
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::AMDGPUMachineFunction::getMode
AMDGPU::SIModeRegisterDefaults getMode() const
Definition: AMDGPUMachineFunction.h:82
llvm::AMDGPUMachineFunction::allocateModuleLDSGlobal
void allocateModuleLDSGlobal(const Function &F)
Definition: AMDGPUMachineFunction.cpp:91
llvm::AMDGPUMachineFunction::MemoryBound
bool MemoryBound
Definition: AMDGPUMachineFunction.h:60
uint64_t
llvm::AMDGPUMachineFunction::isEntryFunction
bool isEntryFunction() const
Definition: AMDGPUMachineFunction.h:86
llvm::AMDGPUMachineFunction::IsModuleEntryFunction
bool IsModuleEntryFunction
Definition: AMDGPUMachineFunction.h:55
llvm::AMDGPUMachineFunction::getExplicitKernArgSize
uint64_t getExplicitKernArgSize() const
Definition: AMDGPUMachineFunction.h:68
llvm::AMDGPUMachineFunction::getGDSSize
uint32_t getGDSSize() const
Definition: AMDGPUMachineFunction.h:78
llvm::AMDGPUMachineFunction::isMemoryBound
bool isMemoryBound() const
Definition: AMDGPUMachineFunction.h:96
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:37
llvm::AMDGPUMachineFunction::isModuleEntryFunction
bool isModuleEntryFunction() const
Definition: AMDGPUMachineFunction.h:90
GlobalVariable.h
Function.h
llvm::AMDGPUMachineFunction::hasNoSignedZerosFPMath
bool hasNoSignedZerosFPMath() const
Definition: AMDGPUMachineFunction.h:92
llvm::AMDGPUMachineFunction::IsEntryFunction
bool IsEntryFunction
Definition: AMDGPUMachineFunction.h:52
llvm::AMDGPUMachineFunction::StaticGDSSize
uint32_t StaticGDSSize
Definition: AMDGPUMachineFunction.h:38
MachineFunction.h
llvm::AMDGPUMachineFunction
Definition: AMDGPUMachineFunction.h:22
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:29
llvm::AMDGPUMachineFunction::GDSSize
uint32_t GDSSize
Definition: AMDGPUMachineFunction.h:33
llvm::AMDGPUMachineFunction::DynLDSAlign
Align DynLDSAlign
Align for dynamic shared memory if any.
Definition: AMDGPUMachineFunction.h:45
AMDGPUBaseInfo.h
llvm::AMDGPUMachineFunction::setDynLDSAlign
void setDynLDSAlign(const DataLayout &DL, const GlobalVariable &GV)
Definition: AMDGPUMachineFunction.cpp:104