LLVM  10.0.0svn
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 //===----------------------------------------------------------------------===//
10 #include "AMDGPUSubtarget.h"
11 #include "AMDGPUPerfHintAnalysis.h"
14 using namespace llvm;
18  LocalMemoryObjects(),
19  ExplicitKernArgSize(0),
20  MaxKernArgAlign(0),
21  LDSSize(0),
22  IsEntryFunction(AMDGPU::isEntryFunctionCC(MF.getFunction().getCallingConv())),
23  NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath),
24  MemoryBound(false),
25  WaveLimiter(false) {
28  // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset,
29  // except reserved size is not correctly aligned.
30  const Function &F = MF.getFunction();
32  Attribute MemBoundAttr = F.getFnAttribute("amdgpu-memory-bound");
33  MemoryBound = MemBoundAttr.isStringAttribute() &&
34  MemBoundAttr.getValueAsString() == "true";
36  Attribute WaveLimitAttr = F.getFnAttribute("amdgpu-wave-limiter");
37  WaveLimiter = WaveLimitAttr.isStringAttribute() &&
38  WaveLimitAttr.getValueAsString() == "true";
43 }
46  const GlobalValue &GV) {
47  auto Entry = LocalMemoryObjects.insert(std::make_pair(&GV, 0));
48  if (!Entry.second)
49  return Entry.first->second;
51  unsigned Align = GV.getAlignment();
52  if (Align == 0)
53  Align = DL.getABITypeAlignment(GV.getValueType());
55  /// TODO: We should sort these to minimize wasted space due to alignment
56  /// padding. Currently the padding is decided by the first encountered use
57  /// during lowering.
58  unsigned Offset = LDSSize = alignTo(LDSSize, Align);
60  Entry.first->second = Offset;
63  return Offset;
64 }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:112
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)
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:194
uint64_t getExplicitKernArgSize(const Function &F, unsigned &MaxAlign) const
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:487
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:133
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:223
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...