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/CodeGen/MachineFunction.h" 14 #include "llvm/ADT/DenseMap.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 bool IsKernel; 34 35 public: 36 AMDGPUMachineFunction(const MachineFunction &MF); 37 38 uint64_t allocateKernArg(uint64_t Size, unsigned Align) { 39 assert(isPowerOf2_32(Align)); 40 KernArgSize = alignTo(KernArgSize, Align); 41 42 uint64_t Result = KernArgSize; 43 KernArgSize += Size; 44 45 MaxKernArgAlign = std::max(Align, MaxKernArgAlign); 46 return Result; 47 } 48 49 uint64_t getKernArgSize() const { 50 return KernArgSize; 51 } 52 53 void setABIArgOffset(unsigned NewOffset) { 54 ABIArgOffset = NewOffset; 55 } 56 57 unsigned getABIArgOffset() const { 58 return ABIArgOffset; 59 } 60 61 unsigned getLDSSize() const { 62 return LDSSize; 63 } 64 65 bool isKernel() const { 66 return IsKernel; 67 } 68 69 unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalValue &GV); 70 }; 71 72 } 73 #endif 74