AMDGPUMachineFunction.cpp revision 314564
1214152Sed//===-- AMDGPUMachineFunctionInfo.cpp ---------------------------------------=// 2214152Sed// 3214152Sed// The LLVM Compiler Infrastructure 4214152Sed// 5222656Sed// This file is distributed under the University of Illinois Open Source 6222656Sed// License. See LICENSE.TXT for details. 7214152Sed// 8214152Sed//===----------------------------------------------------------------------===// 9214152Sed 10214152Sed#include "AMDGPUMachineFunction.h" 11214152Sed#include "AMDGPUSubtarget.h" 12214152Sed 13214152Sedusing namespace llvm; 14214152Sed 15214152SedAMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) : 16214152Sed MachineFunctionInfo(), 17214152Sed LocalMemoryObjects(), 18214152Sed KernArgSize(0), 19214152Sed MaxKernArgAlign(0), 20214152Sed LDSSize(0), 21239138Sandrew ABIArgOffset(0), 22222656Sed IsKernel(MF.getFunction()->getCallingConv() == CallingConv::AMDGPU_KERNEL || 23222656Sed MF.getFunction()->getCallingConv() == CallingConv::SPIR_KERNEL) { 24214152Sed // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset, 25214152Sed // except reserved size is not correctly aligned. 26214152Sed} 27214152Sed 28214152Sedunsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL, 29214152Sed const GlobalValue &GV) { 30214152Sed auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0)); 31214152Sed if (!Entry.second) 32214152Sed return Entry.first->second; 33214152Sed 34214152Sed unsigned Align = GV.getAlignment(); 35214152Sed if (Align == 0) 36214152Sed Align = DL.getABITypeAlignment(GV.getValueType()); 37214152Sed 38214152Sed /// TODO: We should sort these to minimize wasted space due to alignment 39214152Sed /// padding. Currently the padding is decided by the first encountered use 40214152Sed /// during lowering. 41214152Sed unsigned Offset = LDSSize = alignTo(LDSSize, Align); 42214152Sed 43214152Sed Entry.first->second = Offset; 44 LDSSize += DL.getTypeAllocSize(GV.getValueType()); 45 46 return Offset; 47} 48