1 //===-- AMDGPUMachineFunctionInfo.cpp ---------------------------------------=// 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 #include "AMDGPUMachineFunction.h" 11 #include "AMDGPUSubtarget.h" 12 13 using namespace llvm; 14 15 AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) : 16 MachineFunctionInfo(), 17 LocalMemoryObjects(), 18 KernArgSize(0), 19 MaxKernArgAlign(0), 20 LDSSize(0), 21 ABIArgOffset(0), 22 IsKernel(MF.getFunction()->getCallingConv() == CallingConv::AMDGPU_KERNEL || 23 MF.getFunction()->getCallingConv() == CallingConv::SPIR_KERNEL), 24 NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath) { 25 // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset, 26 // except reserved size is not correctly aligned. 27 } 28 29 unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL, 30 const GlobalValue &GV) { 31 auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0)); 32 if (!Entry.second) 33 return Entry.first->second; 34 35 unsigned Align = GV.getAlignment(); 36 if (Align == 0) 37 Align = DL.getABITypeAlignment(GV.getValueType()); 38 39 /// TODO: We should sort these to minimize wasted space due to alignment 40 /// padding. Currently the padding is decided by the first encountered use 41 /// during lowering. 42 unsigned Offset = LDSSize = alignTo(LDSSize, Align); 43 44 Entry.first->second = Offset; 45 LDSSize += DL.getTypeAllocSize(GV.getValueType()); 46 47 return Offset; 48 } 49