[yaml2obj][obj2yaml] - Do not create a symbol table by default.
[llvm-complete.git] / lib / Target / AMDGPU / AMDGPUMachineFunction.cpp
blob89ca702f577d3be4c30264fd6d804701b7bc65c0
1 //===-- AMDGPUMachineFunctionInfo.cpp ---------------------------------------=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "AMDGPUMachineFunction.h"
10 #include "AMDGPUSubtarget.h"
11 #include "AMDGPUPerfHintAnalysis.h"
12 #include "llvm/CodeGen/MachineModuleInfo.h"
14 using namespace llvm;
16 AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) :
17 MachineFunctionInfo(),
18 LocalMemoryObjects(),
19 ExplicitKernArgSize(0),
20 LDSSize(0),
21 IsEntryFunction(AMDGPU::isEntryFunctionCC(MF.getFunction().getCallingConv())),
22 NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath),
23 MemoryBound(false),
24 WaveLimiter(false) {
25 const AMDGPUSubtarget &ST = AMDGPUSubtarget::get(MF);
27 // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
28 // except reserved size is not correctly aligned.
29 const Function &F = MF.getFunction();
31 Attribute MemBoundAttr = F.getFnAttribute("amdgpu-memory-bound");
32 MemoryBound = MemBoundAttr.isStringAttribute() &&
33 MemBoundAttr.getValueAsString() == "true";
35 Attribute WaveLimitAttr = F.getFnAttribute("amdgpu-wave-limiter");
36 WaveLimiter = WaveLimitAttr.isStringAttribute() &&
37 WaveLimitAttr.getValueAsString() == "true";
39 CallingConv::ID CC = F.getCallingConv();
40 if (CC == CallingConv::AMDGPU_KERNEL || CC == CallingConv::SPIR_KERNEL)
41 ExplicitKernArgSize = ST.getExplicitKernArgSize(F, MaxKernArgAlign);
44 unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL,
45 const GlobalValue &GV) {
46 auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
47 if (!Entry.second)
48 return Entry.first->second;
50 unsigned Align = GV.getAlignment();
51 if (Align == 0)
52 Align = DL.getABITypeAlignment(GV.getValueType());
54 /// TODO: We should sort these to minimize wasted space due to alignment
55 /// padding. Currently the padding is decided by the first encountered use
56 /// during lowering.
57 unsigned Offset = LDSSize = alignTo(LDSSize, Align);
59 Entry.first->second = Offset;
60 LDSSize += DL.getTypeAllocSize(GV.getValueType());
62 return Offset;