2016-07-27 00:45:58 +08:00
|
|
|
//===-- AMDGPUMachineFunctionInfo.cpp ---------------------------------------=//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-04-02 05:47:53 +08:00
|
|
|
#include "AMDGPUMachineFunction.h"
|
2016-07-27 00:45:58 +08:00
|
|
|
#include "AMDGPUSubtarget.h"
|
2016-06-18 13:15:53 +08:00
|
|
|
|
2013-07-17 08:31:35 +08:00
|
|
|
using namespace llvm;
|
2013-04-02 05:47:53 +08:00
|
|
|
|
|
|
|
AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) :
|
2014-07-13 11:06:39 +08:00
|
|
|
MachineFunctionInfo(),
|
2016-07-27 00:45:58 +08:00
|
|
|
LocalMemoryObjects(),
|
2016-06-18 13:15:53 +08:00
|
|
|
KernArgSize(0),
|
|
|
|
MaxKernArgAlign(0),
|
2014-09-15 23:41:53 +08:00
|
|
|
LDSSize(0),
|
2015-12-03 02:35:23 +08:00
|
|
|
ABIArgOffset(0),
|
2017-05-18 05:56:25 +08:00
|
|
|
IsEntryFunction(AMDGPU::isEntryFunctionCC(MF.getFunction()->getCallingConv())),
|
2017-02-28 03:35:42 +08:00
|
|
|
NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath) {
|
2016-07-27 00:45:58 +08:00
|
|
|
// FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
|
|
|
|
// except reserved size is not correctly aligned.
|
2016-07-01 18:00:58 +08:00
|
|
|
}
|
|
|
|
|
2016-07-27 00:45:58 +08:00
|
|
|
unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL,
|
|
|
|
const GlobalValue &GV) {
|
|
|
|
auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
|
|
|
|
if (!Entry.second)
|
|
|
|
return Entry.first->second;
|
|
|
|
|
|
|
|
unsigned Align = GV.getAlignment();
|
|
|
|
if (Align == 0)
|
|
|
|
Align = DL.getABITypeAlignment(GV.getValueType());
|
|
|
|
|
|
|
|
/// TODO: We should sort these to minimize wasted space due to alignment
|
|
|
|
/// padding. Currently the padding is decided by the first encountered use
|
|
|
|
/// during lowering.
|
|
|
|
unsigned Offset = LDSSize = alignTo(LDSSize, Align);
|
|
|
|
|
|
|
|
Entry.first->second = Offset;
|
|
|
|
LDSSize += DL.getTypeAllocSize(GV.getValueType());
|
|
|
|
|
|
|
|
return Offset;
|
2016-07-01 18:00:58 +08:00
|
|
|
}
|