1 //===-- AMDGPUMachineFunctionInfo.h -------------------------------*- C++ -*-=// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H 11 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H 12 13 #include "llvm/ADT/DenseMap.h" 14 #include "llvm/CodeGen/MachineFunction.h" 15 16 namespace llvm { 17 18 class AMDGPUMachineFunction : public MachineFunctionInfo { 19 /// A map to keep track of local memory objects and their offsets within the 20 /// local memory space. 21 SmallDenseMap<const GlobalValue *, unsigned, 4> LocalMemoryObjects; 22 23 uint64_t KernArgSize; 24 unsigned MaxKernArgAlign; 25 26 /// Number of bytes in the LDS that are being used. 27 unsigned LDSSize; 28 29 // FIXME: This should probably be removed. 30 /// Start of implicit kernel args 31 unsigned ABIArgOffset; 32 33 // Kernels + shaders. i.e. functions called by the driver and not called 34 // by other functions. 35 bool IsEntryFunction; 36 37 bool NoSignedZerosFPMath; 38 39 // Function may be memory bound. 40 bool MemoryBound; 41 42 // Kernel may need limited waves per EU for better performance. 43 bool WaveLimiter; 44 45 public: 46 AMDGPUMachineFunction(const MachineFunction &MF); 47 48 uint64_t allocateKernArg(uint64_t Size, unsigned Align) { 49 assert(isPowerOf2_32(Align)); 50 KernArgSize = alignTo(KernArgSize, Align); 51 52 uint64_t Result = KernArgSize; 53 KernArgSize += Size; 54 55 MaxKernArgAlign = std::max(Align, MaxKernArgAlign); 56 return Result; 57 } 58 59 uint64_t getKernArgSize() const { 60 return KernArgSize; 61 } 62 63 unsigned getMaxKernArgAlign() const { 64 return MaxKernArgAlign; 65 } 66 67 void setABIArgOffset(unsigned NewOffset) { 68 ABIArgOffset = NewOffset; 69 } 70 71 unsigned getABIArgOffset() const { 72 return ABIArgOffset; 73 } 74 75 unsigned getLDSSize() const { 76 return LDSSize; 77 } 78 79 bool isEntryFunction() const { 80 return IsEntryFunction; 81 } 82 83 bool hasNoSignedZerosFPMath() const { 84 return NoSignedZerosFPMath; 85 } 86 87 bool isMemoryBound() const { 88 return MemoryBound; 89 } 90 91 bool needsWaveLimiter() const { 92 return WaveLimiter; 93 } 94 95 unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalValue &GV); 96 }; 97 98 } 99 #endif 100