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