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/CodeGen/MachineFunction.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 22 class AMDGPUMachineFunction : public MachineFunctionInfo { 23 /// A map to keep track of local memory objects and their offsets within the 24 /// local memory space. 25 SmallDenseMap<const GlobalValue *, unsigned, 4> LocalMemoryObjects; 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. 32 uint32_t LDSSize = 0; 33 uint32_t GDSSize = 0; 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. 37 uint32_t StaticLDSSize = 0; 38 uint32_t StaticGDSSize = 0; 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. 45 Align DynLDSAlign; 46 47 // State of MODE register, assumed FP mode. 48 AMDGPU::SIModeRegisterDefaults 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: 66 AMDGPUMachineFunction(const MachineFunction &MF); 67 68 uint64_t getExplicitKernArgSize() const { 69 return ExplicitKernArgSize; 70 } 71 72 Align getMaxKernArgAlign() const { return MaxKernArgAlign; } 73 74 uint32_t getLDSSize() const { 75 return LDSSize; 76 } 77 78 uint32_t getGDSSize() const { 79 return GDSSize; 80 } 81 82 AMDGPU::SIModeRegisterDefaults getMode() const { 83 return Mode; 84 } 85 86 bool isEntryFunction() const { 87 return IsEntryFunction; 88 } 89 90 bool isModuleEntryFunction() const { return IsModuleEntryFunction; } 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 114