LLVM  13.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 
16 namespace llvm {
17 
18 class GCNSubtarget;
19 
21  /// A map to keep track of local memory objects and their offsets within the
22  /// local memory space.
24 
25 protected:
26  uint64_t ExplicitKernArgSize = 0; // Cache for this.
27  Align MaxKernArgAlign; // Cache for this.
28 
29  /// Number of bytes in the LDS that are being used.
30  unsigned LDSSize = 0;
31 
32  /// Number of bytes in the LDS allocated statically. This field is only used
33  /// in the instruction selector and not part of the machine function info.
34  unsigned StaticLDSSize = 0;
35 
36  /// Align for dynamic shared memory if any. Dynamic shared memory is
37  /// allocated directly after the static one, i.e., LDSSize. Need to pad
38  /// LDSSize to ensure that dynamic one is aligned accordingly.
39  /// The maximal alignment is updated during IR translation or lowering
40  /// stages.
42 
43  // State of MODE register, assumed FP mode.
45 
46  // Kernels + shaders. i.e. functions called by the hardware and not called
47  // by other functions.
48  bool IsEntryFunction = false;
49 
50  // Entry points called by other functions instead of directly by the hardware.
51  bool IsModuleEntryFunction = false;
52 
53  bool NoSignedZerosFPMath = false;
54 
55  // Function may be memory bound.
56  bool MemoryBound = false;
57 
58  // Kernel may need limited waves per EU for better performance.
59  bool WaveLimiter = false;
60 
61 public:
63 
64  uint64_t getExplicitKernArgSize() const {
65  return ExplicitKernArgSize;
66  }
67 
68  unsigned getMaxKernArgAlign() const { return MaxKernArgAlign.value(); }
69 
70  unsigned getLDSSize() const {
71  return LDSSize;
72  }
73 
75  return Mode;
76  }
77 
78  bool isEntryFunction() const {
79  return IsEntryFunction;
80  }
81 
83 
84  bool hasNoSignedZerosFPMath() const {
85  return NoSignedZerosFPMath;
86  }
87 
88  bool isMemoryBound() const {
89  return MemoryBound;
90  }
91 
92  bool needsWaveLimiter() const {
93  return WaveLimiter;
94  }
95 
96  unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV);
97  void allocateModuleLDSGlobal(const Module *M);
98 
99  Align getDynLDSAlign() const { return DynLDSAlign; }
100 
101  void setDynLDSAlign(const DataLayout &DL, const GlobalVariable &GV);
102 };
103 
104 }
105 #endif
llvm::AMDGPUMachineFunction::allocateLDSGlobal
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV)
Definition: AMDGPUMachineFunction.cpp:41
llvm
Definition: AllocatorList.h:23
llvm::AMDGPUMachineFunction::ExplicitKernArgSize
uint64_t ExplicitKernArgSize
Definition: AMDGPUMachineFunction.h:26
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::AMDGPUMachineFunction::getDynLDSAlign
Align getDynLDSAlign() const
Definition: AMDGPUMachineFunction.h:99
llvm::AMDGPUMachineFunction::AMDGPUMachineFunction
AMDGPUMachineFunction(const MachineFunction &MF)
Definition: AMDGPUMachineFunction.cpp:17
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::SmallDenseMap
Definition: DenseMap.h:880
DenseMap.h
llvm::AMDGPUMachineFunction::getLDSSize
unsigned getLDSSize() const
Definition: AMDGPUMachineFunction.h:70
llvm::AMDGPU::SIModeRegisterDefaults
Definition: AMDGPUBaseInfo.h:893
llvm::AMDGPUMachineFunction::LDSSize
unsigned LDSSize
Number of bytes in the LDS that are being used.
Definition: AMDGPUMachineFunction.h:30
llvm::AMDGPUMachineFunction::WaveLimiter
bool WaveLimiter
Definition: AMDGPUMachineFunction.h:59
llvm::AMDGPUMachineFunction::Mode
AMDGPU::SIModeRegisterDefaults Mode
Definition: AMDGPUMachineFunction.h:44
llvm::AMDGPUMachineFunction::needsWaveLimiter
bool needsWaveLimiter() const
Definition: AMDGPUMachineFunction.h:92
llvm::AMDGPUMachineFunction::NoSignedZerosFPMath
bool NoSignedZerosFPMath
Definition: AMDGPUMachineFunction.h:53
llvm::AMDGPUMachineFunction::StaticLDSSize
unsigned StaticLDSSize
Number of bytes in the LDS allocated statically.
Definition: AMDGPUMachineFunction.h:34
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:74
llvm::AMDGPUMachineFunction::MemoryBound
bool MemoryBound
Definition: AMDGPUMachineFunction.h:56
llvm::AMDGPUMachineFunction::allocateModuleLDSGlobal
void allocateModuleLDSGlobal(const Module *M)
Definition: AMDGPUMachineFunction.cpp:65
llvm::AMDGPUMachineFunction::isEntryFunction
bool isEntryFunction() const
Definition: AMDGPUMachineFunction.h:78
llvm::AMDGPUMachineFunction::IsModuleEntryFunction
bool IsModuleEntryFunction
Definition: AMDGPUMachineFunction.h:51
llvm::AMDGPUMachineFunction::getExplicitKernArgSize
uint64_t getExplicitKernArgSize() const
Definition: AMDGPUMachineFunction.h:64
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::AMDGPUMachineFunction::isMemoryBound
bool isMemoryBound() const
Definition: AMDGPUMachineFunction.h:88
llvm::MachineFunction
Definition: MachineFunction.h:230
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::AMDGPUMachineFunction::isModuleEntryFunction
bool isModuleEntryFunction() const
Definition: AMDGPUMachineFunction.h:82
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
llvm::AMDGPUMachineFunction::hasNoSignedZerosFPMath
bool hasNoSignedZerosFPMath() const
Definition: AMDGPUMachineFunction.h:84
llvm::AMDGPUMachineFunction::IsEntryFunction
bool IsEntryFunction
Definition: AMDGPUMachineFunction.h:48
MachineFunction.h
llvm::AMDGPUMachineFunction
Definition: AMDGPUMachineFunction.h:20
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:27
llvm::AMDGPUMachineFunction::DynLDSAlign
Align DynLDSAlign
Align for dynamic shared memory if any.
Definition: AMDGPUMachineFunction.h:41
llvm::AMDGPUMachineFunction::getMaxKernArgAlign
unsigned getMaxKernArgAlign() const
Definition: AMDGPUMachineFunction.h:68
AMDGPUBaseInfo.h
llvm::AMDGPUMachineFunction::setDynLDSAlign
void setDynLDSAlign(const DataLayout &DL, const GlobalVariable &GV)
Definition: AMDGPUMachineFunction.cpp:77