LLVM  10.0.0svn
AMDGPUMachineFunction.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
8 
10 #include "AMDGPUSubtarget.h"
11 #include "AMDGPUPerfHintAnalysis.h"
13 
14 using namespace llvm;
15 
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) {
26 
27  // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
28  // except reserved size is not correctly aligned.
29  const Function &F = MF.getFunction();
30 
31  Attribute MemBoundAttr = F.getFnAttribute("amdgpu-memory-bound");
32  MemoryBound = MemBoundAttr.isStringAttribute() &&
33  MemBoundAttr.getValueAsString() == "true";
34 
35  Attribute WaveLimitAttr = F.getFnAttribute("amdgpu-wave-limiter");
36  WaveLimiter = WaveLimitAttr.isStringAttribute() &&
37  WaveLimitAttr.getValueAsString() == "true";
38 
42 }
43 
45  const GlobalValue &GV) {
46  auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
47  if (!Entry.second)
48  return Entry.first->second;
49 
50  unsigned Align = GV.getAlignment();
51  if (Align == 0)
52  Align = DL.getABITypeAlignment(GV.getValueType());
53 
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);
58 
59  Entry.first->second = Offset;
61 
62  return Offset;
63 }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalValue &GV)
AMDGPU specific subclass of TargetSubtarget.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
AMDGPUMachineFunction(const MachineFunction &MF)
F(f)
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
static const AMDGPUSubtarget & get(const MachineFunction &MF)
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
Definition: Attributes.cpp:191
unsigned getAlignment() const
Definition: Globals.cpp:97
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:258
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:486
bool isEntryFunctionCC(CallingConv::ID CC)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
unsigned LDSSize
Number of bytes in the LDS that are being used.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:212
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Definition: DataLayout.cpp:755
const Function & getFunction() const
Return the LLVM function that this machine code represents.
SPIR_KERNEL - Calling convention for SPIR kernel functions.
Definition: CallingConv.h:141
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:163
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:220
uint64_t getExplicitKernArgSize(const Function &F, Align &MaxAlign) const
Type * getValueType() const
Definition: GlobalValue.h:279
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:333
Calling convention for AMDGPU code object kernels.
Definition: CallingConv.h:205
Analyzes if a function potentially memory bound and if a kernel kernel may benefit from limiting numb...